Skip to main content
gamedev.net
🔒 Locked

Wrapping Textures Problem

Started by Jannes Jul 2, 2004 at 6:15 PM 4 replies 500+ views
Original Post
Jannes
Jannes
Hi, i cant figure out which Renderstates & SamplerStates i have to set to activate texture wrapping for texcoords < 0.0 & > 1.0 in tu and tv direction. Tutorial links welcome. Plz help.
wendigo23
wendigo23
In opengl it's
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_TRUE);glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_TRUE);

It affects the current texture.

There is probably something similar in DirectX.
RenderTarget
RenderTarget
pDevice->SetSamplerState( 0, D3DSAMP_ADDRESSU, D3DTADDRESS_WRAP );pDevice->SetSamplerState( 0, D3DSAMP_ADDRESSV, D3DTADDRESS_WRAP );
[sub]My spoon is too big.[/sub]
Jannes
Jannes
Actually i mean Textureadressing

I set these renderstates and samplerstates directly after creating the D3D-Device:

g_d3d_Device->SetRenderState(D3DRS_CULLMODE, D3DCULL_CCW);g_d3d_Device->SetRenderState(D3DRS_ZENABLE, TRUE);g_d3d_Device->SetRenderState(D3DRS_LIGHTING, TRUE);g_d3d_Device->SetRenderState(D3DRS_SPECULARENABLE, TRUE);g_d3d_Device->SetRenderState(D3DRS_DITHERENABLE, TRUE);g_d3d_Device->SetRenderState(D3DRS_WRAP0, 0);g_d3d_Device->SetSamplerState0,D3DSAMP_MINFILTER,D3DTEXF_LINEAR);g_d3d_Device->SetSamplerState(0,D3DSAMP_MAGFILTER,D3DTEXF_LINEAR);g_d3d_Device->SetSamplerState(1,D3DSAMP_MINFILTER,D3DTEXF_LINEAR);g_d3d_Device->SetSamplerState(1,D3DSAMP_MAGFILTER,D3DTEXF_LINEAR);g_d3d_Device->SetSamplerState(0,D3DSAMP_ADDRESSU,D3DTADDRESS_WRAP); g_d3d_Device->SetSamplerState(0,D3DSAMP_ADDRESSV,D3DTADDRESS_WRAP);g_d3d_Device->SetTextureStageState(0,D3DTSS_TEXCOORDINDEX,0);g_d3d_Device->SetTextureStageState(1,D3DTSS_TEXCOORDINDEX,0);g_d3d_Device->SetRenderState( D3DRS_AMBIENT, 0xffffffff );


i use a quad where i want the texture to be wrapped. My Renderfunction for this quad looks like this:

g_d3d_Device->SetRenderState(D3DRS_ZENABLE, FALSE);  g_d3d_Device->SetRenderState(D3DRS_LIGHTING, FALSE); g_d3d_Device->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);g_d3d_Device->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);g_d3d_Device->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);g_d3d_Device->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_MODULATE);	   g_d3d_Device->SetTexture(0,pTex->GetTexture());g_d3d_Device->SetStreamSource(0, SpriteVB, 0, sizeof(GUI_SCREENVERTEX));g_d3d_Device->SetFVF(D3DFVF_GUI_SCREENVERTEX);g_d3d_Device->DrawPrimitive(D3DPT_TRIANGLEFAN, 0, 2);  g_d3d_Device->SetTexture(0,NULL);g_d3d_Device->SetRenderState(D3DRS_LIGHTING, TRUE);g_d3d_Device->SetRenderState(D3DRS_ZENABLE, TRUE);


All works well for none wrapped textures (texcoords between 0.0 and 1.0). Setting the coords to different values, nothing is rendered (no error message too).
Jannes
Jannes
if anyone has a working codesnippet of texture wrapping plz post it here.
RenderTarget
RenderTarget
Have you tried setting those stage states after the SetTexture() call? I don't recall offhand whether those get reset by that call.
[sub]My spoon is too big.[/sub]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.