Jump to content
  • Advertisement
Sign in to follow this  
GameCheetz

IDirectTexture8

This topic is 4914 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

I'm drawing textures to the screen 1 to 1 for a 2D game. I want it to not perform ANY antialiasing whatsoever. The result is currently blurry with boxes around each sprite being drawn. Each sprite is drawn to the backbuffer using 2 triangles. Since blurring seems to be the default, how do I turn it off? Also, I tried using IDirectSuface8 instead. Since copyRects doesn't support alpha, I have to check each pixel for transparency, then send it a lot of 1x1 rectangles. This looks the way I want it, but lags horribly. Is there any way to have my cake & eat it too?

Share this post


Link to post
Share on other sites
Advertisement
Simply disable mapmap-generation for the textures, (aka) 1 mipmap-level when loading... otherwise D3D might get a little too happy with the mipmapping.

Share this post


Link to post
Share on other sites
Here's my call to the constructor for the textures:

D3DXCreateTextureFromResourceEx(m_pD3DDevice, NULL, MAKEINTRESOURCE(resource), width, height, 1, 0, D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, X_DEFAULT, D3DX_DEFAULT, D3DRGBA(0,0,1,0),NULL, NULL, &loadedSprites[numSprites]);

I already have a 1 for the number of mipmap levels.

Share this post


Link to post
Share on other sites
There's tucked-away DX documentation about how texels need to be mapped to pixel locations. Stuff in there about .5 offsetting due to the way pixels and texels are addressed. I don't recall the details immediately.

Share this post


Link to post
Share on other sites
double sourceX=(tileNum%numCols)*(1.0/numCols)+(0.5/(width*numCols));
double sourceY=(tileNum/numCols)*(1.0/numRows)+(0.5/(height*numRows));

The +(0.5/(width*... is to adjust by half a pixel to deal with the pixel-texel offset thing. Without that, the sprite just displays offset, but just as blurry.

EDIT: Your link went to the main page of DirectX9's MSDN documentation. I've searched through the documentation there for information already... I assume you meant a more specific link.

Share this post


Link to post
Share on other sites
Oops. My bad: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/directx9_c/directx/graphics/ProgrammingGuide/GettingStarted/Direct3DTextures/coordinates/MappingTexelsToPixels.asp

You should be offsetting your vertices' x and y by .5. Not .5 / some number. Unless I'm reading you wrong. Also, the accurate thing is to subtract .5, not add.

Share this post


Link to post
Share on other sites
The texture goes from 0 to 1, so subtracting .5 isn't .5 pixels, it's half the width. That's why I divide it by the conversion from pixels to texture height/width... I looked at your link & it does seem to be that type of artifact, so my math must be wrong somewhere... I've more than quadruple checked it, but I'll check it again.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!