Sign in to follow this  
Folke

OpenGL How do I remove the "smoothing out" effect when I render?

Recommended Posts

Hi Gamedev, I'm switching to OpenGL from DirectX, so wish me good luck, will you? Overall everything is working out fine. Except from this one detail. But it's a really important detail, so I just have to make it work. I'm making an old-school 2D game. So it naturally has to be in low resolution. And I know that I could just change the screen resolution and be done with it. But I don't want to do that, some laptops can't enter low resolutions. And changing screen-resolution can take several seconds. Resizing every texture as I draw them is a much better solution, in my opinion. But it doesn't work. OpenGL draws my sprite-textures all fuzzy when I resize them. First look at this screen. That is what it looks like. Then look at this screen. That is what I would like it to look like. (I'm not actually making my game THAT low res. Only almost) To sum it up I want to make a low-resolution (2D) game without changing the screen resolution. So. What should I do? It worked fine in Direct3D, so there has to be a way to do it in OpenGL, right? Here is the code I use to render, in case that's any help:
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glBindTexture(GL_TEXTURE_2D, texture[0]);
glBegin(GL_QUADS);
float x      = 100.0f;
float y      = 100.0f;
float z      = 0.0f;
float width  = 32.0f;
float height = 32.0f;
float f      = 9.0f;  // resizing factor
glTexCoord2f(0.0f, 0.0f); glVertex3f( x,           y+(height*f), z );
glTexCoord2f(0.0f, 1.0f); glVertex3f( x,           y,            z );
glTexCoord2f(1.0f, 1.0f); glVertex3f( x+(width*f), y,            z );
glTexCoord2f(1.0f, 0.0f); glVertex3f( x+(width*f), y+(height*f), z );
glEnd();




Thank you for your time // Folke

Share this post


Link to post
Share on other sites
Your images won't load, but I'll try and suggest this:

If you want your images pixelated, MAKE pixelated images. If you try and resize an otherwise normal image to make it pixelated, OpenGL will do everything it can to smooth the image and make it look normal (unless you change the texture filtering parameters).

If you want pixel art, make pixel art. There was an article posted on Gamedev's front page just a few days ago about creating pixel art.

Share this post


Link to post
Share on other sites
Quote:
Original post by deadstar
If you want your images pixelated, MAKE pixelated images. If you try and resize an otherwise normal image to make it pixelated, OpenGL will do everything it can to smooth the image and make it look normal (unless you change the texture filtering parameters).

Given that changing texture filtering parameters is so easy and that (ostensibly) the art is already done, I'd give it a shot. Particularly, pay attention to your glTexParameteri calls when you load and set up your textures. You'll want to use GL_NEAREST for your min/mag filters.

Share this post


Link to post
Share on other sites
Sorry about the images, I think they are OK now though. Yeah, you are right I definitely want to make pixel art. But, well that one is actually OK right now. The problem is how to keep my pixel art low res.

The texture filtering parameters you were talking about is probably exactly what I'm looking for though. Any idea about what kind of parameters that would be?

Share this post


Link to post
Share on other sites
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this