Help showing textures?

Started by
4 comments, last by Ozelo 12 years, 5 months ago
As I am a complete beginner, I would like to show textures (In particula, 16x16) like I could see a "clear" distinction between texture pixels. I couldn't find it yet, hope someone can help me out.

I am using this code:


Init:

mytexdata := LoadBMP('tst.bmp');
glGenTextures(1, mytex);
glBindTexture(GL_TEXTURE_2D, mytex);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);
gluBuild2DMipmaps(GL_TEXTURE_2D, 3, mytexdata.sizeX, mytexdata.sizeY, GL_RGB, GL_UNSIGNED_BYTE, mytexdata.data);
[/quote]

Show:

glEnable(GL_LIGHTING);

glEnable(GL_TEXTURE_2D);
glColor4f(1.0, 1.0, 1.0, 1.0);
glBindTexture(GL_TEXTURE_2D, mytex);
glBegin(GL_QUADS);
glNormal3f( 0.0, 0.0, 1.0);
glTexCoord2f(0.0, 0.0); glVertex3f(-0.5, 19.5, 0.5);
glTexCoord2f(1.0, 0.0); glVertex3f( 0.5, 19.5, 0.5);
glTexCoord2f(1.0, 1.0); glVertex3f( 0.5, 20.5, 0.5);
glTexCoord2f(0.0, 1.0); glVertex3f(-0.5, 20.5, 0.5);
glEnd();
[/quote]



Iv'e attached the results: The picture on left is what I got, the picture on the right side is what I would like to see. Pls, advice. Why it seem so "blur"?
Advertisement
(warning I don't use open GL)

You may want to look at the specifics behind your glTexParameteri()

edited for your edit of clarity!
I'm still confused. Even a texture size of 2x2 pixels seems to "merge" pixel colors and I would like to see four clearly distinct squares, each one at a discrete color corresponding to that texture pixel.. :( You mean I need to place and apply a specific parameter to get the expected result?
Try GL_NEAREST instead of GL_LINEAR
Change GL_LINEAR to GL_NEAREST

EDIT: Beaten!
YES, Thank you very much! Now I got it! It was kinda giving me a bite on my feets! lol ty ty ty ty

This topic is closed to new replies.

Advertisement