KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Ok so I'm still struggling to get this to work. The important parts of my code are: def __init__(self, vertices, normals, triangles): self.bufferVertices = glGenBuffersARB(1) glBindBufferARB(GL_ARRAY_BUFFER_ARB, self.bufferVertices) glBufferDataARB(GL_ARRAY_BUFFER_ARB, ADT.arrayByteCount(vertices), ADT.voidDataPointer(vertices), GL_STATIC_DRAW_ARB) self.vertices = vertices self.bufferNormals = glGenBuffersARB(1) glBindBufferARB(GL_ARRAY_BUFFER_ARB, self.bufferNormals) glBufferDataARB(GL_ARRAY_BUFFER_ARB, ADT.arrayByteCount(normals), ADT.voidDataPointer(normals), GL_STATIC_DRAW_ARB) self.normals = normals self.bufferTriangles = glGenBuffersARB(1) glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, self.bufferTriangles) glBufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, ADT.arrayByteCount(triangles), ADT.voidDataPointer(triangles), GL_STATIC_DRAW_ARB) self.triangles = triangles glDisableClientState(GL_VERTEX_ARRAY) **(Not sure if any of the following influence in any way)** glDisableClientState(GL_NORMAL_ARRAY) glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0) glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0) I don't think there is anything wrong here from what I've read so far about VBO's. So now I have my vertex, normals(not used yet) and triangle indices buffers. Now for the actual draw: def draw(self, type): glDisableClientState(GL_VERTEX_ARRAY) glDisableClientState(GL_NORMAL_ARRAY) glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0) glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0) **Again above line not sure if they have any use.** glEnableClientState(GL_VERTEX_ARRAY) glBindBufferARB(GL_ARRAY_BUFFER_ARB, self.bufferVertices) glVertexPointer(3, GL_FLOAT, 0, None) glEnableClientState(GL_NORMAL_ARRAY); glBindBufferARB(GL_ARRAY_BUFFER_ARB, self.bufferNormals) glNormalPointer(GL_FLOAT, 0, None) if type == GL_POINTS:
Tags (comma-separated)
Save Edits
Cancel