Oversmoothing?

Member
Posts: 67
Joined: 2006.07
Post: #1
It seems like OpenGL is smoothing everything a bit too much for my 2D tile-based game. So much that some of the small text in my game gets a little hard to read at times (and it messes with the alpha in some places -- one image doesn't fade into the background like it's supposed to). I was wondering if I am drawing things in the correct way or if, perhaps, the problem is in my loading code.

Since there's a lot of code, I've put it on pastebin instead of posting it here:

Drawing code:
http://disaster_area.pastebin.org/797

AGL context setup code, basically copied from OneSadCookie's code in "Creating Mac Games":
http://disaster_area.pastebin.org/798

And here is the image loading code (mostly ripped from Apple's "OpenGL Programming Guide for Mac OS X"):
http://disaster_area.pastebin.org/800

Sorry if that was too much code, but I'm not sure where the problem is (and what code would be relevant). Thanks for any help you guys can give.
Quote this message in a reply
Sage
Posts: 1,482
Joined: 2002.09
Post: #2
Image examples would be helpful.

Scott Lembcke - Howling Moon Software
Author of Chipmunk Physics - A fast and simple rigid body physics library in C.
Quote this message in a reply
Sage
Posts: 1,066
Joined: 2004.07
Post: #3
With no images to tell what's going wrong, I can't say for sure. My guess is possibly how you are loading it. If you are using mipmaps you can sometimes get smoothed or blurred images.
Quote this message in a reply
Member
Posts: 67
Joined: 2006.07
Post: #4
I would post images, but I have no server to post them to. Any suggestions for a quick, free image hosting service I can utilize?

I'm not sure if I am using mipmaps or not, seeing as I am kind of unfamiliar with OpenGL...
Quote this message in a reply
Sage
Posts: 1,066
Joined: 2004.07
Post: #5
Quote this message in a reply
Oldtimer
Posts: 834
Joined: 2002.09
Post: #6
Try to throw a glTranslatef (0.375, 0.375, 0); at the start of your drawing code.
Quote this message in a reply
Member
Posts: 67
Joined: 2006.07
Post: #7
Well, it seems as if I have found the problem. First of all, the Quartz loading was doing some funky recalculation of the alpha layers and darkening the image, so I replaced it with libpng. The oversmoothing, however, was caused by these two lines:

Code:
glTexParameteri(GL_TEXTURE_RECTANGLE_EXT, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_RECTANGLE_EXT, GL_TEXTURE_MIN_FILTER, GL_LINEAR);

Apparently, switching GL_LINEAR to GL_NEAREST got rid of the problem. Oh well. But thanks for the help anyways.

And as for the glTranslatef (0.375, 0.375, 0) bit, if that is the 0.375 unit offset, then what does glOrtho(-0.375, 640.0 - 0.375, 480.0 - 0.375, -0.375, -1.0, 1.0) do? I assume the subtraction of 0.375 is unnecesary, or does it go along with the glTranslate call?
Quote this message in a reply
Sage
Posts: 1,482
Joined: 2002.09
Post: #8
To the first problem, Quartz loads images as premultiplied I hear.

To the second, if you aren't quite matching the texels to the pixels they are displayed in, the slight filtering will make the texture look blurry. You might want to check on that.

Scott Lembcke - Howling Moon Software
Author of Chipmunk Physics - A fast and simple rigid body physics library in C.
Quote this message in a reply
Member
Posts: 67
Joined: 2006.07
Post: #9
Ah, I seemed to be getting some slightly blurred textures here and there for no apparent reason. That's probably why. Thanks guys! Grin
Quote this message in a reply
Post Reply