1

hello i want to use a texture on a cube (created by glutsolidcube()), how can i define where the texture is pictured at? (for example on the "frontside" of a cube)

glEnable(GL_TEXTURE_2D);
    glBindTexture(GL_TEXTURE_2D, texture[0]);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filterMode);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filterMode);

    glColor4f(0.8,0.7,0.11,1.0);
    glPushMatrix();
        glScalef(4, 1.2, 1.5);
        glTranslatef( 0, 0.025, 0);
        glutSolidCube(0.1);
    glPopMatrix();
  glDisable(GL_TEXTURE_2D);

thanks

Tyzak
  • 2,430
  • 8
  • 38
  • 52
  • 1
    possible duplicate of http://stackoverflow.com/questions/327043/how-to-apply-texture-to-glutsolidcube – Bahbar Apr 13 '10 at 15:11

2 Answers2

1

Not possible, since glutSolidCube() only generates vertexes and normals, not texture coordinates.

However, there are workarounds.

Community
  • 1
  • 1
genpfault
  • 51,148
  • 11
  • 85
  • 139
0

Unfortunately, using glutSolidCube is impossible, as it doesn't support texturing. What I'd suggest is a tutorial that explains the process that may help you. It's a bit outdated, but NeHe's texturing tutorial has some code that explains how to draw a cube, and the code is commented to explain which side is which for you.

Andrei Krotkov
  • 5,556
  • 3
  • 33
  • 36