跳到主要内容
← Vertex Transformations

Vertex Transformations

Index Buffer

在opengl层定义了Index Buffer: [0, 1, 2, 2, 3, 0].

实时渲染 · 网格 GLSL

第 4 课:Index Buffer

我的解:在opengl层定义了Index Buffer: [0, 1, 2, 2, 3, 0].

我的解

attribute int index;

void main() {
  const float dx[4] = float[](-0.5,0.5, 0.5, -0.5);
  const float dy[4] = float[](-0.5,-0.5, 0.5, 0.5);

  gl_Position = vec4(dx[index], dy[index], 0.0, 1.0);
}

复盘笔记

  • 在opengl层定义了Index Buffer: [0, 1, 2, 2, 3, 0].
  • 这样四个顶点就能实现两个三角形