hey guys, i'm designing a satellite for my project....the thing is its looks kinda plain...so i read abt texture coor....but i'm not sure how to use it....could you help me out with this....

glColor3f(0.5f, 0.0f, 1.0f);
    glTranslatef(0.0f,0.0f,0.0f);
    gluCylinder(pObj,5.0f, 5.0f, 10.0f, 24, 24);    //drawing cylinder(but got holes...=(,must cover them up)
    glColor3f(0.5f, 0.0f, 1.0f);
    glTranslatef(0.0f,0.0f,10.0f);
    //gluSphere(pObj,5.0f,24,24);
    gluDisk(pObj,0.0f,5.0f,24,10);  
    glColor3f(0.5f, 0.0f, 1.0f);
    glTranslatef(0.0f,0.0f,-10.0f);
    //gluSphere(pObj,5.0f,24,24);

    gluDisk(pObj,0.0f,5.0f,24,10);  

    glTranslatef(0.0f,0.0f,10.0f);
    glColor3f(0.0f, 0.0f, 0.0f);
    gluCylinder(pObj,4.5f, 1.0f, 5.0f, 24, 24);
    glTranslatef(0.0f,0.0f,5.0f);
    glColor3f(0.5f, 0.0f, 1.0f);
    gluDisk(pObj,0.0f,1.0f,24,10);
    glRotatef(90,0.0f,10.0f,0.0f);
    glTranslatef(10.0f,0.0f,0.0f);
    glColor3f(0.5f, 0.0f, 1.0f);
    gluSphere(pObj,5.5f,24,24);
    gluCylinder(pObj,0.3f, 0.3f, 7.0f, 24, 24);
    glRotatef(270,0.0f,1.0f,0.0f);
    glTranslatef(6.0f,-5.8f,0.0f);
    glRectf(0.0f, 10.0f,35.0f, 2.0f);

    glRotatef(270,0.0f,1.0f,0.0f);
    glTranslatef(0.0f,5.5f,6.2f);
    gluCylinder(pObj,0.3f, 0.3f, 7.0f, 24, 24);
    glRotatef(270,0.0f,1.0f,0.0f);
    glTranslatef(6.0f,-5.8f,0.0f);
    glRectf(0.0f, 10.0f,35.0f, 2.0f);

thank you in advance guys....

When you are drawing a square you can add a texture to it like this:

glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, myTexure->textureID);
glBegin(GL_QUADS);
	glNormal3f( 0.0f, 0.0f, 0.0f); //Normals are needed for things like light reflection
	glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f,  0.0f);
	glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, -1.0f,  0.0f);
	glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f,  1.0f,  0.0f);
	glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f,  1.0f,  0.0f);
glEnd();
glDisable(GL_TEXTURE_2D);

glTexCoord2f(0.0f, 0.0f); maps the top left corner of the texture to this particular vertex. And so on.

Now, if you instead use a drawing function, let's say gluCylinder(pObj,5.0f, 5.0f, 10.0f, 24, 24); I'm pretty sure it automatically maps all texure coordinates on the cylinder for you. So try:

glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, myTexure->textureID);
gluCylinder(pObj,5.0f, 5.0f, 10.0f, 24, 24); 
glDisable(GL_TEXTURE_2D);
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.