Jump to content
  • Advertisement
Sign in to follow this  
nprz

Loaded texture is blurred?

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

What I did is loaded a tga file and make it as a texture and then use that texture to be drawn on the screen. The problem I'm having is as if antialiasing was on and it doesn't look crisp. Anyway, I uploaded the files here I don't think there is a problem with loading the TGA file because I used one of the examples on gamdev and I figured if there was a problem, it wouldn't be reported already. This is a comparison of what it looks like and what I was expecting it to look like.

Share this post


Link to post
Share on other sites
Advertisement
Probably you are using an interpolation filter. Try to remove it


glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER , GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER , GL_NEAREST);



Another tip: your mapped quads (the card) should be of the same dimension of the (sub)image you use.

Share this post


Link to post
Share on other sites
Your textures are not powers of two (in dimension). Who knows what opengl is doing to them in order to make them so.

I found this here:
Quote:

Initially, the width and height of data are checked to see if they are a power of two. If not, a copy of data (not data), is scaled up or down to the nearest power of two. This copy will be used for subsequent mipmapping operations described below. (If width or height is exactly between powers of 2, then the copy of data will scale upwards.) For example, if width is 57 and height is 23 then a copy of data will scale up to 64 in width and down to 16 in depth, before mipmapping takes place.

Given that your card texture is 71x96, it is probably being scaled to 64x64, losing lots of detail in the process. Either don't use gluBuild2dMipmaps, or manually scale your images UP to 128x128.

Share this post


Link to post
Share on other sites
Well, all the cards are in one file, so I have to resize the whole file to a power of 2. I guess this is improving the quality of the card. I guess I miss read multiple of 2 before instead of power of 2.

Thanks

Share this post


Link to post
Share on other sites
Still doesn't look like it should.
The tga file is 512x2048 which are powers of 2.

Share this post


Link to post
Share on other sites
Quote:
Original post by nprz
Still doesn't look like it should.
The tga file is 512x2048 which are powers of 2.


The dimensions must be equal in size and a power of 2. (Eg. 512x512, 256x256, etc)

I'm sure that I can already hear the resounding groan of agony coming from over there. :)

Share this post


Link to post
Share on other sites
You bet I'm groaning. It makes me want to use an engine that does all this for me. Oh well, I think I can fix that problem fairly easily, thank you.

-edit- It looks more blurry as 2048x2048. Any other suggestions? :)

Share this post


Link to post
Share on other sites
errm, no.
OpenGL textures can be any power of two in any direction, so his texture sizes are valid.

the problem is mapping the texels to the screen, which is whats causing the bluring, try offseting your texture coords by 0.5 (or 0.05.. some small number with a 5 in anyways) in each direction (cant recall off hand if its positive or negative either) and that should help line up texel centers with pixel centers

Share this post


Link to post
Share on other sites
offsetting the TexCoord by 0.05 or any amount will just move what part of the texture is displayed. and changing the Vertex will just move where it is displayed.

Can anyone recommend any files to load BMP as a texture, so I can at least try that?

Share this post


Link to post
Share on other sites
Quote:
Original post by _the_phantom_
errm, no.
OpenGL textures can be any power of two in any direction, so his texture sizes are valid.


Gah, are you serious? I've been misinformed then. Many apologies nprz for this unintentionally misleading information. :/

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!