Loaded texture is blurred?

Started by
12 comments, last by wendigo23 19 years, 3 months ago
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.
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.
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.
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
Still doesn't look like it should.
The tga file is 512x2048 which are powers of 2.

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. :)
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? :)
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
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?

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. :/

This topic is closed to new replies.

Advertisement