Archived

This topic is now archived and is closed to further replies.

Texture problems - Help please

This topic is 5654 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello and thanks for reading this, I''m currently working on a basic 2D rectangular engine ( yes, i know how to do isometric and i''ll switch to it later ) and i''m having really annoying problems with textures. ---- What i do ---- Currently, i read a .TGA file, put it in a HDC and use GetPixel. It all sounds to work great, and it does. Then i put it in a texture ( 256x256, 32x32 tiles ). So far, so good. The problem comes when i render it. I use a static VB where with 256 vertices ( (256x256) / ( 32x32 ) * 4 ) I ( hopefully, hehe ) correcly use increments of 0.125 in tu and tv. Then i finally render it ( using matrices to position the tile ) and, well, err... it doesn''t work very well. ---- The problem ---- There are random horizontal and vertical lines ( of another color, naturally, else i wouldn''t see it ) on the screen! And when i scroll, some go away and new ones come! It looks *really* bad. My guess is that either i do something wrong with the tu and tv OR i am having problems with matrices. Or maybe it''s render states... Stupid DX! Okay, so here''s the render states i use ( didn''t use the code command because it''s not SO long ) g_pd3dDevice->SetRenderState (D3DRS_AMBIENT,RGB(255,255,255)); g_pd3dDevice->SetRenderState ( D3DRS_CULLMODE, D3DCULL_NONE); g_pd3dDevice->SetRenderState ( D3DRS_LIGHTING, FALSE); g_pd3dDevice->SetRenderState ( D3DRS_ZENABLE, FALSE); g_pd3dDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, TRUE ); g_pd3dDevice->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_SRCALPHA ); g_pd3dDevice->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA ); g_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_MODULATE); g_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE); g_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_TFACTOR); g_pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE); g_pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG2, D3DTA_TFACTOR); g_pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1); g_pd3dDevice->SetTextureStageState( 0, D3DTSS_MAGFILTER ,D3DTEXF_POINT ); g_pd3dDevice->SetTextureStageState( 0, D3DTSS_MINFILTER ,D3DTEXF_POINT );

Share this post


Link to post
Share on other sites
Since you are doing 2D in 3D make sure that you have offset all of you vertices by -0.5 in the x and y directions. More information on this can be found by searching the forums or at this location in the DirectX SDK help: mk:@MSITStore:C:\MSSDK\doc\DirectX8\directx8_c.chm::/directx_cpp/Graphics/ProgrammersGuide/UsingDirect3D/Textures/Filtering/NearestPointSampling.htm

Hope that helps,

Scott

Share this post


Link to post
Share on other sites
Thanks a lot, it works now!

But by offseting the tu and tv even by very little, won''t i evantually lose a pixel?

Anyway, i''m satisfied with that solution. Thanks!


Uttar

Share this post


Link to post
Share on other sites