我试图将我的vert、指数和正文点定在VBO:并用我的手提方法加以提炼,在TAO/OpenGL TK framwork下的C#中。 但我的屏幕只显示一个黑色屏幕。 我在没有VBO的情况下进行了检测,然后运行。 但是,凭借我的vert、指数和正文,我可以取得成功。
我的法典:
private float[] vertices;
private byte[] indices;
private float[] texture;
private int[] mVertexBuffer;
private int[] mIndicesBuffer;
private int[] mTextureBuffer;
//...Constructor start
vertices = new float[] {
-1.0f, -1.0f, 1.0f,
1.0f, -1.0f, 1.0f,
-1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f,
1.0f, -1.0f, 1.0f,
1.0f, -1.0f, -1.0f,
1.0f, 1.0f, 1.0f,
1.0f, 1.0f, -1.0f,
1.0f, -1.0f, -1.0f,
-1.0f, -1.0f, -1.0f,
1.0f, 1.0f, -1.0f,
-1.0f, 1.0f, -1.0f,
-1.0f, -1.0f, -1.0f,
-1.0f, -1.0f, 1.0f,
-1.0f, 1.0f, -1.0f,
-1.0f, 1.0f, 1.0f,
-1.0f, -1.0f, -1.0f,
1.0f, -1.0f, -1.0f,
-1.0f, -1.0f, 1.0f,
1.0f, -1.0f, 1.0f,
-1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f,
-1.0f, 1.0f, -1.0f,
1.0f, 1.0f, -1.0f,
};
texture = new float[] {
0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f,
0.0f, 1.0f,
1.0f, 1.0f,
0.0f, 0.0f,
1.0f, 0.0f,
0.0f, 1.0f,
1.0f, 1.0f,
0.0f, 0.0f,
1.0f, 0.0f,
0.0f, 1.0f,
1.0f, 1.0f,
0.0f, 0.0f,
1.0f, 0.0f,
0.0f, 1.0f,
1.0f, 1.0f,
0.0f, 0.0f,
1.0f, 0.0f,
0.0f, 1.0f,
1.0f, 1.0f,
0.0f, 0.0f,
1.0f, 0.0f,
};
indices = new byte[] {
0, 1, 3, 0, 3, 2, 4, 5, 7, 4, 7, 6,
8, 9, 11, 8, 11, 10,
12, 13, 15, 12, 15, 14,
16, 17, 19, 16, 19, 18,
20, 21, 23, 20, 23, 22,
};
mVertexBuffer = new int[1];
mIndicesBuffer = new int[1];
mTextureBuffer = new int[1];
//...Constructor end
public void setBuffers() {
gl.glGenBuffersARB(1, mVertexBuffer);
gl.glBindBufferARB(GL.GL_ARRAY_BUFFER_ARB, mVertexBuffer[0]);
gl.glBufferDataARB(GL.GL_ARRAY_BUFFER_ARB,
(IntPtr)(vertices.Length * sizeof(float)),
vertices, GL.GL_STATIC_DRAW_ARB);
gl.glGenBuffersARB(1, mIndicesBuffer);
gl.glBindBufferARB(GL.GL_ELEMENT_ARRAY_BUFFER_ARB, mIndicesBuffer[0]);
gl.glBufferDataARB(GL.GL_ELEMENT_ARRAY_BUFFER_ARB,
(IntPtr)(indices.Length * sizeof(float)),
indices, GL.GL_DYNAMIC_DRAW_ARB);
gl.glGenBuffersARB(1, mTextureBuffer);
gl.glBindBufferARB(GL.GL_ARRAY_BUFFER_ARB, mTextureBuffer[0]);
gl.glBufferDataARB(GL.GL_ARRAY_BUFFER_ARB,
(IntPtr)(texture.Length * sizeof(float)),
texture, GL.GL_STATIC_DRAW_ARB);
}
public void draw()
{
gl.glBegin(gl.GL_TRIANGLES);
gl.glEnableClientState(GL.GL_VERTEX_ARRAY);
gl.glEnableClientState(GL.GL_TEXTURE_COORD_ARRAY);
gl.glBindBufferARB(GL.GL_ARRAY_BUFFER_ARB, mVertexBuffer[0]);
gl.glVertexPointer(3, GL.GL_FLOAT, 0, mVertexBuffer);
gl.glBindBufferARB(GL.GL_ARRAY_BUFFER_ARB, mTextureBuffer[0]);
gl.glTexCoordPointer(2, GL.GL_FLOAT, 0, mTextureBuffer);
gl.glBindBufferARB(GL.GL_ELEMENT_ARRAY_BUFFER_ARB, mIndicesBuffer[0]);
gl.glDrawElements(GL.GL_TRIANGLES, indices.Length,
gl.GL_UNSIGNED_BYTE, mIndicesBuffer);
gl.glDisableClientState(GL.GL_VERTEX_ARRAY);
gl.glDisableClientState(GL.GL_TEXTURE_COORD_ARRAY);
gl.glEnd();
}
斜角/图象/图形点在我的C++ VBO中发挥作用,但并非在这里。 因此,我猜测我错过了装束的 st。