开发者

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, f开发者_JS百科ilterMode);
    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


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

However, there are workarounds.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜