VBO and glGenBuffers
BlitzMax Forums/OpenGL Module/VBO and glGenBuffers
| ||
Hello, Can someone tell me if this is correct for the VBOs Type tmesh Field varray:Float[] field vbuffer:Int Method Init:tmesh(v:Float[]) varray = v[..] glGenBuffers(1, VarPtr(vbuffer)) glBindBuffer(GL_ARRAY_BUFFER, vbuffer) glBufferData(GL_ARRAY_BUFFER, SizeOf(varray), varray, GL_DYNAMIC_DRAW) End Method Method Draw:tMesh() glBindBuffer(GL_VERTEX_ARRAY, vbuffer) glVertexPointer(3, GL_FLOAT, 0, Int Ptr 0) glEnableClientState(GL_VERTEX_ARRAY) glDrawAarrays(GL_TRIANGLES, 0, 3) glDisableClientState(GL_VERTEX_ARRAY) glFlush() End Method End Type Function CreateMesh:tMesh(vertex:Float[], mesh:tMesh=Null) If mesh = null then mesh = New tMesh.Init(vertex[..]) Return mesh End Function SetGraphicsDriver GLGraphicsDriver() Graphics 800,600 arraytest:Float[] = [1.0,1.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0] Global meshtest:tMesh = CreateMesh(arraytest) While Not KeyHit(KEY_ESCAPE) glClear GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT meshtest.Draw() Flip Wend End This is the link I used: Vertex Buffer Object Thanks, FBEpyon |
| ||
This seems to work |
| ||
Interesting stuff makes me want to have a crack at max again :) |
| ||
Thanks, I wasn't sure if anyone else was having luck with it, I will work on cranking out more things in the next few weeks.. I wanted to work with pure OpenGl now instead of using the mods out there. I noticed you added in the glewinit() that would explain my issues.. I also wrote a Martix and Vector Class.. so I will be adding in the rotation here soon.. just need to figure that out, most people use shaders when you are working with opengl 3.0 and higher you have to. |