Weird textures
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);
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*/
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*/
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.
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!
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);
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);
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?
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
Change GL_LINEAR_MIPMAP_LINEAR to GL_LINEAR and run that see what happens
Change GL_LINEAR_MIPMAP_LINEAR to GL_LINEAR and run that see what happens
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement