Cube using single GL_TRIANGLE_STRIP

后端 未结 4 837
滥情空心
滥情空心 2021-02-07 04:03

Is it possible to draw a whole cube using just a single GL_TRIANGLE_STRIP?

Obviously it\'s just the cube combinatorics I\'m concerned about here, it might a

4条回答
  •  难免孤独
    2021-02-07 05:01

    For those of you who are lazy (like me), here's a copy-paste version of rob mayoff's answer ;)

    static const GLfloat cube_strip[] = {
        -1.f, 1.f, 1.f,     // Front-top-left
        1.f, 1.f, 1.f,      // Front-top-right
        -1.f, -1.f, 1.f,    // Front-bottom-left
        1.f, -1.f, 1.f,     // Front-bottom-right
        1.f, -1.f, -1.f,    // Back-bottom-right
        1.f, 1.f, 1.f,      // Front-top-right
        1.f, 1.f, -1.f,     // Back-top-right
        -1.f, 1.f, 1.f,     // Front-top-left
        -1.f, 1.f, -1.f,    // Back-top-left
        -1.f, -1.f, 1.f,    // Front-bottom-left
        -1.f, -1.f, -1.f,   // Back-bottom-left
        1.f, -1.f, -1.f,    // Back-bottom-right
        -1.f, 1.f, -1.f,    // Back-top-left
        1.f, 1.f, -1.f      // Back-top-right
    };
    

提交回复
热议问题