VBO pointer issues

BlitzMax Forums/BlitzMax OpenGL Programming/VBO pointer issues

I made a test mesh and the issues lies in Method New()
Strict 
Type QuickTestMesh

	Field intVertexBuffer
	Field fltVertex:Float[]
	
	Field intElementBuffer
	Field shtElements:Short[]
	
	Method New()
	'			    ---------1--------, ---------2--------,  ---------3-------,  ----------4------
		fltVertex =[ 1.0 , -1.0 , 0.0 ,   1.0 , 1.0,  0.0 ,   -1.0, -1.0, 0.0 ,   1.0, -1.0, 0.0 ]
		shtElements = [ 1:Short,  2:Short, 3:Short,   2:Short, 4:Short, 3:Short ] 
		
	
	
		glGenBuffers 1, Varptr(intVertexBuffer)
		glBindBuffer(GL_ARRAY_BUFFER, intVertexBuffer)
		glBufferData(GL_ARRAY_BUFFER, 3 * fltVertex.length * SizeOf(fltVertex[0]), .. 
			Varptr(fltVertex[0]), GL_STATIC_DRAW)
		glBindBuffer(GL_ARRAY_BUFFER, 0 )
		
		
		glGenBuffers(1,  Varptr(intElementBuffer) )
		glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, intElementBuffer)
		glBufferData(GL_ELEMENT_ARRAY_BUFFER, shtElements.length * SizeOf(shtElements[0]), ..
			Varptr(shtElements[0]), GL_STATIC_DRAW)
		glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0 )
		
	
	
	End Method
	
	Method Delete()
	
		glDeleteBuffers(1, Varptr(intElementBuffer))
		glDeleteBuffers(1, Varptr(intVertexbuffer))
	
	End Method
	
	Method Render()
	
		glEnableClientState(GL_Vertex_Array)
	

		glBindBuffer(GL_ARRAY_BUFFER, intVertexBuffer)
		glVertexPointer(3, GL_FLOAT , 0, Null)
		
		glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, intVertexBuffer)
		glDrawElements(GL_TRIANGLES, shtElements.length , GL_UNSIGNED_SHORT, Null)
		
		glBindBuffer(GL_ARRAY_BUFFER, 0)
		glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0)
		
		glDisableClientState(GL_Vertex_Array)


	End Method 

	

End Type


glGenBuffers 1, Varptr(intVertexBuffer)

I keep gettin an unhandle memory exception here. I don't understand why exactlly.

Same happens with glGenBuffersARB too.

im not sure how blitz handles extensions and such, but are you sure the functions are loaded properly?

Before i can use these in C#, I have to make sure that 'glGenBuffersARB' and 'glGenBuffers' and such actually contain the proper pointer to the function you need.

try it with
glGenBuffersARB
glBindBufferARB
and the use of GlewInit

If you want to render these buffers, you have to call glDrawElements. Also you need to save the vertexcount and emelentcount.

cu olli

i've tried ARBs

GlewInit?

I got the arraylist working. I want to get VBOs to work as well though.

GlewInit must be called before you can use any glew functionality (like the ones you want to use. Everything beside OpenGL 1.2 is glew)

ok, thanks :).