   SOLVED: Pixel Perfect Textures (OpenGL)
  Hello,I want to render pixel perfect textures in a 2D environment via OpenGL, OpenIL and C++.I have set up my window and created an glOrtho view successfully. But now I encountered a strange bug which only occurs in windowed mode. Below is my test texture:For some reason, this 32x32 texture is not rendered as it should on a 32x32 quad. It rather looks like this:A bigger view of both textures (how it should look and how it is rendered):When I render my scene in fullscreen mode, everything works perfect. But in windowed mode it looks like above.Does anybody know what I am doing wrong?regards,Phex[Edited by - Phex on June 6, 2006 4:28:00 PM]
  What does your call to glOrtho look like _exactly_?   ;  Texture gets resized in windowed mode. Your window in windowed mode has different resolution than it has in fullscreen mode.   ;  ivarbug - That doesn't necessarily matter. It is possible to create pixel perfect graphics in Windowed mode.If, say, you've got an 800 by 600 window(fullscreen or not), your glOrtho call should look something like this:glOrtho(0, 800, 0, 600, 0.0f, 100.0f);With that, you can use an OpenGL unit as a pixel, and you will get pixel-perfect graphics.Oh, and it looks like you're using GL_NEAREST for texture filtering, you might want to try GL_LINEAR or use mipmaps, it will make non-pixel perfect textures look better.;  Maybe it's my eyes but it looks like he/she is already using GL_LINEAR filtering. You don't need GL_LINEAR for pixel PERFECT.glOrtho call should look like "glOrtho(0, WINDOW_SIZE_X, 0, WINDOW_SIZE_Y, 0.0f, 100.0f);" if you want pixel perfect textures.   ;Quote:What does your call to glOrtho look like _exactly_?my Ortho View looks like this:glOrtho( 0, APP->Window->Width, 0, APP->Window->Height, 0, 100.0f );where APP->Window->Width = 640 andAPP->Window->Height = 480for example (which is the size of my window, not included the window frame). I checked these values at runtime, they dont change.Quote:Oh, and it looks like you're using GL_NEAREST for texture filtering, you might want to try GL_LINEAR or use mipmaps, it will make non-pixel perfect textures look better.I use Texture = ilutGLBindTexImage() to create textures. I havent found a way to change the filtering settings in OpenIL so far.   ;  Make sure the size of you window isn't also including the title bar and stuff, because you want the size of the drawable area to be 640x480 or whatever.tj963   ;  What are the exact texture coordinates you're using? I can see more lines in the texture than how it's rendered...   ;Quote:Make sure the size of you window isn't also including the title bar and stuff, because you want the size of the drawable area to be 640x480 or whatever.Yeah, I am checking this right now.Quote:What are the exact texture coordinates you're using? I can see more lines in the texture than how it's rendered...Actually I just render a simple 32 x 32 quad in this test:glBegin(GL_QUADS);  glTexCoord2f( 0.0f, 1.0f );  glVertex2d( 0, 0 );  glTexCoord2f( 1.0f, 1.0f );  glVertex2d( 32, 0 );  glTexCoord2f( 1.0f, 0.0f );  glVertex2d( 32, 32 );  glTexCoord2f( 0.0f, 0.0f );  glVertex2d( 0, 32 );glEnd();;Quote:Original post by PhexQuote:What does your call to glOrtho look like _exactly_?my Ortho View looks like this:glOrtho( 0, APP->Window->Width, 0, APP->Window->Height, 0, 100.0f );where APP->Window->Width = 640 andAPP->Window->Height = 480for example (which is the size of my window, not included the window frame). I checked these values at runtime, they dont change.Quote:Oh, and it looks like you're using GL_NEAREST for texture filtering, you might want to try GL_LINEAR or use mipmaps, it will make non-pixel perfect textures look better.I use Texture = ilutGLBindTexImage() to create textures. I havent found a way to change the filtering settings in OpenIL so far.Could you try changing it to:glOrtho( 0-0.5, APP->Window->Width-0.5, 0-0.5, APP->Window->Height-0.5, 0, 100.0f );