Archived

This topic is now archived and is closed to further replies.

Dunge

Weird textures

Recommended Posts

Anyone know how can my texture appear so strange? It''s the best looking one I saw.. testing with other gave even weirder results.. and applying it on quaratics/other objects do the same thing.. This is how I create it: glGenTextures(1, &BallTex.texID); glBindTexture(GL_TEXTURE_2D, BallTex.texID); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGB, BallTex.width, BallTex.height, GL_RGB, GL_UNSIGNED_BYTE, BallTex.data);

Share this post


Link to post
Share on other sites
are you sure that the bitmap''s format is RGB?

Is it square size (even with gluBuildMipmaps it''s good to have a square 2^n size image) ?



[ My Site ]
''I wish life was not so short,'' he thought. ''Languages take such a time, and so do all the things one wants to know about.'' - J.R.R Tolkien
Founding member of "Un-Ban nes8bit" association (UNA) (to join put this in your sig) (Welcome back to JesperT)
/*ilici*/

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
I''ve seen that type of artifact often when the bitmap is not read in correctly. Make sure you are reading the file properly. It will be easier if it is a power of 2, which it should be anyway before you send the data to the video card.

Share this post


Link to post
Share on other sites
Well I use the code of the OpenGL Game Programming book to loadd the BMP and set it as a texture... and I use a texture from the source cd too... 512*512.. dunno what could go wrong!

Share this post


Link to post
Share on other sites
glGenTextures(1, &BallTex.texID);
glBindTexture(GL_TEXTURE_2D, BallTex.texID);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGB, BallTex.width, BallTex.height, GL_RGB, GL_UNSIGNED_BYTE, BallTex.data);

You need to use different texture parameters when you use mipmaps.

Use this

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);

Share this post


Link to post
Share on other sites
Hi dunge. when you can see the different channels like that in the texture, it is probably incorrect format. I think I can see an alpha channel there too (look at the bands, red, green, blue, grey). Have you tried GL_RGBA instead of GL_RGB?

Share this post


Link to post
Share on other sites