where did i do wrong?

BlitzMax Forums/BlitzMax OpenGL Programming/where did i do wrong?

where did i do wrong here?

Strict
'global
Global vertices:Float[] = [1.0,-1.0,0.0,-1.0,-1.0,0.0,0.0,1.0,0.0]

Global colors:Int[] = [255,50,160,180,255,70,90,10,255]
Global triangleBuffer:Int[1]

Init()
setupProjection()

While Not KeyHit(key_escape)
	render()
	Flip
Wend
End

Function Init()
	glEnableClientState GL_VERTEX_ARRAY
	glEnableClientState GL_COLOR_ARRAY
	
	glGenBuffers 1,Varptr triangleBuffer[0]
	glBindBuffer GL_ARRAY_BUFFER,triangleBuffer[0]
	glBufferData GL_ARRAY_BUFFER,9*(SizeOf(32) + SizeOf(8)),Null,GL_STATIC_DRAW
	glBufferSubData GL_ARRAY_BUFFER,0,9*SizeOf(32),vertices
	glBufferSubData GL_ARRAY_BUFFER,9*SizeOf(32),9*SizeOf(8),colors
	
	glVertexPointer 3,GL_FLOAT,0,vertices
	glColorPointer 3,GL_UNSIGNED_BYTE,0,colors
EndFunction

Function setupProjection()
	'glViewport 0,0,640,480
	GLGraphics 640,480
	glMatrixMode GL_PROJECTION
	glLoadIdentity
	gluPerspective 45.0,Float(GraphicsWidth())/Float(GraphicsHeight()),1.0,1000.0
EndFunction

Function render()
	glClear GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT
	glMatrixMode GL_MODELVIEW
	glLoadIdentity
	gluLookAt 0.0,0.0,10.0,0.0,0.0,0.0,0.0,0.1,0.0
	glDrawArrays GL_TRIANGLES,0,3
EndFunction


anyone can run this?

You need to call glewInit() before using OpenGL extensions, such as glGenBuffers. Additionally you need to initialize your gl context before starting to bind anything. So use this:
setupProjection()
glewInit()
Init()