PDA

View Full Version : Texture problem



IulianBa
05-16-2011, 06:29 AM
I`m new to OpenGL, i found some tutorials about texturing, but i got some problems...


GLUquadric *name;
GLuint nameTexture;

void test (void) {
glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
glEnable ( GL_TEXTURE_2D );
glBindTexture ( GL_TEXTURE_2D, nameTexture);

glBegin(GL_QUADS);
// Test!
glVertex3f(-1,-1,-1);
glVertex3f(1,-1,-1);
glVertex3f(1,-1,1);
glVertex3f(-1,-1,1);
glEnd();
glDisable ( GL_TEXTURE_2D );
}
void init (void)
{
name = gluNewQuadric();
gluQuadricTexture( name, GL_TRUE);
pereteTexture = LoadBitmap("name.bmp");
}


Right now, i can`t see the texture but only the main color that`s in it. That`s really strange, because if i add for example a sphere, will show correct texture.

Any ideas will be appreciated.

Thanks

ZbuffeR
05-16-2011, 07:58 AM
You need to set a different texture coordinate for each vertex. By default it should be something like 0,0
For the sphere, I guess you use something that already generates both texcoords and vertex positions.

IulianBa
05-16-2011, 08:23 AM
I fixed it, thanks.