I am getting unexplainable crashes when using VBO commands.
Declare the functions:
Global glGenBuffersARB(a,b:Byte Ptr) "Win32"
Global glBindBufferARB(a,b) "Win32"
Global glBufferDataARB(a,b,c:Byte Ptr,d) "Win32"
Get the function pointers:
SUPPORT_VERTEXBUFFEROBJECT=True
'glGenBuffersARB
pointer=wglGetProcAddress("glGenBuffersARB")
If pointer
glGenBuffersARB=Byte Ptr(pointer)
Else
SUPPORT_VERTEXBUFFEROBJECT=False
EndIf
'glBindBufferARB
pointer=wglGetProcAddress("glBindBufferARB")
If pointer
glBindBufferARB=Byte Ptr(pointer)
Else
SUPPORT_VERTEXBUFFEROBJECT=False
EndIf
'glBufferDataARB
pointer=wglGetProcAddress("glBufferDataARB")
If pointer
glBufferDataARB=Byte Ptr(pointer)
Else
SUPPORT_VERTEXBUFFEROBJECT=False
EndIf
Create the buffer:
If Not limb.rendersurface.staticvertexarray
glenableclientstate GL_VERTEX_ARRAY
glGenBuffersARB 1,Varptr(limb.rendersurface.staticvertexarray)
glBindBufferARB GL_ARRAY_BUFFER_ARB,limb.rendersurface.staticvertexarray
glBufferDataARB GL_ARRAY_BUFFER_ARB,limb.rendersurface.vertexarray.size(),limb.rendersurface.vertexarray.buf(),GL_STATIC_DRAW_ARB
EndIf
Draw using a VBO vertex array:
glenableclientstate GL_VERTEX_ARRAY
If staticvertexarray
glBindBuffer GL_ARRAY_BUFFER_ARB,staticvertexarray
glVertexPointer 3,GL_FLOAT,0,Int Ptr(0)
Else
glVertexPointer 3,GL_FLOAT,0,BankBuf(vertexarray)
EndIf
When I call glBindBuffer() in the last block of code, the program crashes.
|