Tyzak
Tyzak

Reputation: 2438

texture on cube-side with opengl

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

Upvotes: 1

Views: 2591

Answers (2)

Andrei Krotkov
Andrei Krotkov

Reputation: 5684

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.

Upvotes: 0

genpfault
genpfault

Reputation: 52084

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

However, there are workarounds.

Upvotes: 1

Related Questions