Jump to content
  • Advertisement
Sign in to follow this  
bobenko

OpenGL OpenGL 2D texture drawing problem

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

Hi all, I have a problem: I use OpenGL for rendering and SOIL for loading textures.

On screenshot in attachment you can see that image that I get when render on the screen differs from original one. I think that it can be texture filtering problems or some camera wrong parameters.

Or maybe it is a problem of loading image( some compression parameters etc), if so should I use libpng or can solve this problem using some SOIL settings.




here is some code of my OpenGL settings. When I enable openGl in pixel format I set color depth to 32 bits



InitWindow( Caption, _width, _height, _isWindowed );
EnableOpenGL( hWnd, &hDC, &hRC );

//
//OPENGL PARAMETERS
//
//parameters
glEnable(GL_TEXTURE_2D);
glEnable(GL_DEPTH_TEST);
glEnable(GL_CULL_FACE);
glEnable(GL_BLEND);
glDisable( GL_DEPTH_TEST );
glDisable( GL_LIGHTING );
//camera
glViewport(0, 0, Width(), Height());
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho ( 0, Width(), Height(), 0, 0, 1 );
glMatrixMode (GL_MODELVIEW);
glLoadIdentity();
//blending
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
//textures
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST_MIPMAP_NEAREST);
glShadeModel(GL_SMOOTH);

glClearDepth(1.0f);


glDepthFunc(GL_LEQUAL);
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);



If you need some additional code I can give.
Thanks in advance.

Share this post


Link to post
Share on other sites
Advertisement
[s]Maybe post your Opengl context creation code? It almost looks like you don't have enough color depth, but that looks pretty bad, I think it would have to be pretty low to look like that.
[/s]

Bah, sorry I just saw you already said 32 bit color.

Is it just this particular texture that looks like that, or your whole program? If you draw like a quad with gradient, does it look smooth or have lots of color bands?

Share this post


Link to post
Share on other sites
All gradient textures have such glitch, but other are not with color they supposed to be. Green for example is not so green as it should. In the attachment 2 above you can see.

Share this post


Link to post
Share on other sites
I had similar problem, actually(the texture looked like a low-bit texture). But it went away when I use shader. I dunno how that happenned though...

Share this post


Link to post
Share on other sites
Something seems to be dropping your textures back to 16-bit internally. Could you maybe check your glTexImage2D calls and change the internalformat param from GL_RGB (or GL_RGBA (or 3, or 4)) to GL_RGB8 (or GL_RGBA8); OpenGL isn't actually obliged to give you a full precision internal format if you don't explicitly ask for one.

Share this post


Link to post
Share on other sites

OpenGL isn't actually obliged to give you a full precision internal format if you don't explicitly ask for one.

There are, strictly speaking, no guarantees even with explicit formats. The post-3.0 (I think) contexts have some stricter rules than pre-3.0 contexts regarding the bit depths in that post-3.0 will give not give you less than the requested number of bits, but can give you more. The requested color components and component type are enforced both pre- and post-3.0, but the number of bits does not have to be enforced in pre-3.0 even with an explicit format.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!