gles11 : Vertexbuffer

Monkey Forums/Monkey Programming/gles11 : Vertexbuffer

bruZard(Posted 2011) [#1]
why the vertexbuffer takes only two coordinates (x, y)? is gles11 just for 2d? :D

Method Rethink:Void(indizies:Int[])
        Local vList:List<Float> = new List<Float>		
	For Local v:Vertex = EachIn self.vertices
		vList.AddLast(v.vertexdata.x)
		vList.AddLast(v.vertexdata.y)
		'vList.AddLast(v.vertexdata.z)
	Next
		
	Local vArray:Float[]	= vList.ToArray()	; vList = Null		
	Self.vertexBuffer	= DataBuffer.Create(vArray.Length * 4)
	Self.indexBuffer	= DataBuffer.Create(indizies.Length * 2)
		
	For Local i:Int = 0 To vArray.Length - 1
		Self.vertexBuffer.PokeFloat(i * 4, vArray[i])
	Next
		
	For Local i:Int = 0 To indizies.Length - 1
		Self.indexBuffer.PokeShort(i * 2, indizies[i])
	Next
		
	glBindBuffer(GL_ARRAY_BUFFER, Self.vbo)
	glBufferData(GL_ARRAY_BUFFER, Self.vertexBuffer.Size(), Self.vertexBuffer, GL_STATIC_DRAW)
	glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, Self.ibo)
	glBufferData(GL_ELEMENT_ARRAY_BUFFER, Self.indexBuffer.Size(), Self.indexBuffer, GL_STATIC_DRAW)
		
End



marksibly(Posted 2011) [#2]
Hi,

You'll have to change the 'size' param of glVertexPointer to 3...see:

http://www.khronos.org/opengles/sdk/1.1/docs/man/

You may also have to change the 'stride' and 'pointer' params depending on how your vertices are laid out in memory - for simple vertices with no texcoord, normal or color data, using 0 for both should work.


bruZard(Posted 2011) [#3]
ah, thank you!