H
Funktioniert (WinXP, Geforce 8800 GTS, ForceWare 175.19):
struct Vector
{
float x,y,z;
};
struct Vertex
{
Vector position;
Vector normal;
float u,v;
};
unsigned int vertexBuffer;
// vertexbuffer anlegen
glGenBuffersARB(1, &vertexBuffer);
glBindBufferARB(GL_ARRAY_BUFFER_ARB, vertexBuffer);
glBufferDataARB(GL_ARRAY_BUFFER_ARB, numTriangles*3*sizeof(Vertex), NULL, GL_STATIC_DRAW_ARB);
// vertexbuffer fuellen
glBindBufferARB(GL_ARRAY_BUFFER_ARB, vertexBuffer);
volatile Vertex *vtx= glMapBufferARB(GL_ARRAY_BUFFER_ARB, GL_WRITE_ONLY);
// vtx[...]= ...
glUnmapBufferARB(GL_ARRAY_BUFFER_ARB );
// rendern
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_NORMAL_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glBindBufferARB(GL_ARRAY_BUFFER_ARB, vertexBuffer);
glVertexPointer(3, GL_FLOAT, sizeof(Vertex), NULL);
glBindBufferARB(GL_ARRAY_BUFFER_ARB, vertexBuffer);
glNormalPointer(GL_FLOAT, sizeof(Vertex), (GLvoid*)sizeof(Vector));
glBindBufferARB(GL_ARRAY_BUFFER_ARB, vertexBuffer);
glTexCoordPointer(2, GL_FLOAT, sizeof(Vertex), (GLvoid*)(2*sizeof(Vector)));
glDrawArrays(GL_TRIANGLES, 0, numTriangles*3);
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_NORMAL_ARRAY);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);