Jump to content
  • Advertisement
Sign in to follow this  
subflood

OpenGL Textures are blurry

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

Here is how I load each of the textures:
            glGenTextures(1, &brTex[idx]);
            
            glBindTexture(GL_TEXTURE_2D, brTex[idx]);
            
            glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);
            glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR_MIPMAP_NEAREST);
            
            gluBuild2DMipmaps(GL_TEXTURE_2D, 3, btextures[idx]->w, btextures[idx]->h, GL_BGR, 
                              GL_UNSIGNED_BYTE, btextures[idx]->pixels );



Each texture is 80 x 20 pixels and thats also the size I make each rectangle, (2d game using ortho2d()) which I apply the texture too. Also I have blending enabled which I initialized with this code: glColor4f(1.0f, 1.0f, 1.0f, 1.0f); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); That's about it. The only problem I'm having is that the textures appear blurry, I also used another library besides OpenGl for the game and they looked just fine.

Share this post


Link to post
Share on other sites
Advertisement
yea mipmaps blurred my images as well. The exact reason I forget right now, but it has something to do with just making a resized copy of the image I think.
Anywho, use
glTexImage2D();

Share this post


Link to post
Share on other sites
OpenGL can only do power-of-two texture sizes (128x32, 64x64 etc.) unless you use extensions. gluBuild2dmipmaps will automagically resize your texture to the nearest valid size and rescale your image to fit (which introduces the blurring).

Either:
- use correctly sized textures in the first place
- create textures larger than needed and mess with the texture coords to get the correct subregion
- use an extension to load oddly sized textures

Share this post


Link to post
Share on other sites
I wan't to go with the extension option but I don't know anything about extensions. Can anyone give me a link or explain how to use an extension?

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
You dont have to enable any extensions to use non power of 2 textures. Yes it is an extension, but if the extension exists it simply works. Now, the thing is, hardly any video cards support non-power-of-2 textures. Stick with power-of-2 textures and never, ever let gluBuild2DMipmaps resize a non-power-of-2 texture (its buggy as hell and only results in data loss).

Share this post


Link to post
Share on other sites
gluBuild2DMipmaps is going to stretch an 80x20 texture to 128x32. That's probably the source of most of your blurring. The rest is the choice of filtering, since it's going to apply a box filter to the texels. For 2D you're going to adjust your textures offline to be power of two and use GL_NEAREST filtering.

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!