Skip to main content
GameDev.net gamedev.net
🔒 Locked

Textures with frames

Started by _Flecko Jul 11, 2004 at 8:10 PM 0 replies 700+ views
Original Post
_Flecko
_Flecko
I've written a 2D graphics class library using textured quads with position/colored vertices and an orthoganal view, and I'm having some trouble with small errors in rendering. Because all textures have to be powers of two, I have a texture wrapper class that accepts input about the size of the sprite within the texture and the number of frames (for example, in a walk cycle for a 32x32 sprite, you could just have the 4 frames in one 64x64 image), and can provide the texture coordinates for the four corners of a given frame. Unfortunately, there's a bit of error, since this isn't exactly what DX was made to do. The only way I can think of to fix this would be to use a transparent buffer of a couple pixels around each frame, which could probably be done only by modifying the texture class, but it would also end up wasting a good deal of memory, and it would only half-solve the problem. Anyone have any other ideas how I can get this thing pixel perfect without giving up untransformed vertices?
--------------Trans2D - 2D library for C# / Managed DirectX
Jiia
Jiia
You mean the problem is color bleeding through the edges? That's texture filtering. If you're using D3DXSprite, you have to turn it off every single frame, after Sprite->Begin(). Pretty crappy, really.

I think it may be better to waste the extra memory and padd the color. Anyways, to turn off filtering..

Device->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_NONE);
Device->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_NONE);
Device->SetSamplerState(0, D3DSAMP_MIPFILTER, D3DTEXF_NONE);

Topic Locked

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

Sign in to reply to this topic.