Jump to content
  • Advertisement
Sign in to follow this  
BennettSteele

OpenGL OpenGL Draw 64x64 Textures Like "Minecraft"

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

So i want to make my game without the (what i think is) ugly color averaging between pixels when the image is spread out really far. So instead of sky1, id rather have it so that there are clean, cut edges. how would i do this? The picture is what it is now and do not want, the gradual shift from white to transparent.

Share this post


Link to post
Share on other sites
Advertisement
But im also using a library to load my images: SOIl. This is how i load them:


GLuint GetTexture(std::string Filename)
{
GLuint tex_ID =0;
tex_ID= SOIL_load_OGL_texture
(
Filename.c_str(),
SOIL_LOAD_AUTO,
SOIL_CREATE_NEW_ID,
SOIL_FLAG_MIPMAPS | SOIL_FLAG_NTSC_SAFE_RGB | SOIL_FLAG_COMPRESS_TO_DXT
);
return tex_ID;
}



where would i place the

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);



in there?

Share this post


Link to post
Share on other sites
Find your glTexParameter function and change it to GL_NEAREST, instead of GL_LINEAR or whatever u have.

It is a sad time when almost all new posts I see on gamedev nowadays are about making graphics as shitty as minecraft. Lets get back to making cool shit as soon as possible people.

Share this post


Link to post
Share on other sites
after you have the GLuint variable, call glBindTexture() and then right after set the glTexParameter. GL operates on the current bound texture.

Share this post


Link to post
Share on other sites
XD i just am using it for close up textures, otherwise i dont care what it looks like because the rest of the game looks really good.
HOLY BLOCKY PIXELS BATMAN! IT WORKED! :D Thank you so much!
Want to see what it looks like now? Too bad, you have too behold the blockyness.

Share this post


Link to post
Share on other sites
You will notice at far distances that you will get a lot of shimmering pixels other wise. If your cube draws to a square portion of the screen 10x10, it will pick 10x10 of those 64x64 to draw. Next frame it might render to 9x10 pixels, and will pick a whole different set of pixels out of the 64x64. It has 10 pixels to fill and 64 to choose from, so each frame they will be random.

using mip mapping it will just render the 8x8 or 16x16 downscaled size of the texture in which it will pick the same pixels for both those cases so you wont see a pixel flicker each frame from white to blue to white to blue because of random sampling.Instead for both cases it will be choosing roughly the same pixels as it has 8 pixels to render and 8 to choose from, or 9 pixels to render and 8 to choose from. It is a lot less random and flickering.

Share this post


Link to post
Share on other sites
As dpadam450 suggested, you will get rendering artefacts when you are trying to squeeze textures into a comparatively low resolution screen area. One way to reduce such problems is by using a technique known as mip-mapping. The difference can be striking under certain situations, an extreme example is shown below:

Mipmapping_example.png

To enable mip-mapping in OpenGL, use this filter parameter:

glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);

Also, don't forget to generate your mip-maps (needs OpenGL 3.0 or greater):

glGenerateMipmap(GL_TEXTURE_2D);

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!