小编wil*_*iGo的帖子

如何在 OpenGL 中使用三角形带创建圆柱体的纹理?

这是我创建的圆柱体:

void drawCylinder(float r, float g, float b) {
    setMaterialColors(r, g, b);
    glColor4f(r, g, b, 1.0);
    /* top triangle */
    double i, resolution  = 0.1;
    double height = 1, radius = 0.5;
    glPushMatrix();
    glTranslatef(0, -0.5, 0);
    glBegin(GL_TRIANGLE_FAN);
        glVertex3f(0, height, 0);  /* center */
        for (i = 0; i <= 2 * PI; i += resolution)
            glVertex3f(radius * cos(i), height, radius * sin(i));
    glEnd();

    /* bottom triangle: note: for is in reverse order */
    glBegin(GL_TRIANGLE_FAN);
        glVertex3f(0, 0, 0);  /* center */ …
Run Code Online (Sandbox Code Playgroud)

c++ opengl opengl-es texture-mapping

5
推荐指数
1
解决办法
9727
查看次数

标签 统计

c++ ×1

opengl ×1

opengl-es ×1

texture-mapping ×1