简体   繁体   English

使用GLUT在立方体上进行OpenGL多重纹理映射

[英]OpenGL multiple texture mapping on a cube using GLUT

Have been trying to figure out how to put a different texture on each side of a cube using OpenGL and GLUT. 一直在尝试找出如何使用OpenGL和GLUT在立方体的每一侧上放置不同的纹理。 I can get it to be a simple texture but multiple texture won't. 我可以使它成为简单的纹理,但不会有多个纹理。 I would put up my code but it is ugly and cluttered right now. 我会放上我的代码,但是它现在很丑陋且混乱。 If this is pretty easy to do please post some code for me to follow. 如果这样做很容易,请发布一些代码供我遵循。 Thanks! 谢谢!

its NEHE openGL lesson #22 http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=22 , then if you want to have different texture for each face, you can modify the cube rendering part for each face by switching glClientActiveTextureARB(GL_TEXTURE0_ARB); 它的NEHE openGL第22课http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=22 ,那么如果您希望每个面都有不同的纹理,则可以修改每个面的立方体渲染部分通过切换glClientActiveTextureARB(GL_TEXTURE0_ARB); ,or glClientActiveTextureARB(GL_TEXTURE1_ARB); glClientActiveTextureARB(GL_TEXTURE1_ARB); depend on the number of texture you have. 取决于您拥有的纹理数量。

for example: ` 例如:

 // Back Face
    glClientActiveTextureARB(GL_TEXTURE0_ARB);
    glNormal3f( 0.0f, 0.0f,-1.0f);
    for (i=4; i<8; i++) {
        glTexCoord2f(data[5*i],data[5*i+1]);
        glVertex3f(data[5*i+2],data[5*i+3],data[5*i+4]);
    }
    // Top Face  
    glClientActiveTextureARB(GL_TEXTURE1_ARB);
    glNormal3f( 0.0f, 1.0f, 0.0f);
    for (i=8; i<12; i++) {
        glTexCoord2f(data[5*i],data[5*i+1]);
        glVertex3f(data[5*i+2],data[5*i+3],data[5*i+4]);
    }

` `

disclaimer: i never test those codes, its based on my memory, you should check ii'am in doubt whether it was glClientActiveTexture() or glActiveTexture() 免责声明:我从不测试那些代码,它基于我的内存,您应该检查ii'am是否是glClientActiveTexture()或glActiveTexture()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM