
Hi Haskell list, Today I'm turning to you for the use of VBO (Vertex Buffer Object) in Haskell. I seem to be able to create one without any problem using the following code : ------------------------------------------------------ vboOfList :: Int -> [Float] -> IO BufferObject vboOfList size elems = let ptrsize = toEnum $ size * 4 arrayType = ElementArrayBuffer in do [array] <- genObjectNames 1 bindBuffer arrayType $= Just array arr <- newListArray (0, size - 1) elems withStorableArray arr (\ptr -> bufferData arrayType $= (ptrsize, ptr, StaticDraw)) bindBuffer ArrayBuffer $= Nothing reportErrors return array ------------------------------------------------------ However the problem arise when I try to draw primitives using this vbo : ------------------------------------------------------ displayVbo buff size = do let stride = toEnum sizeOfVertexInfo vxDesc = VertexArrayDescriptor 3 Float stride $ offset 0 colors = VertexArrayDescriptor 4 Float stride $ offset 12 texCoo = VertexArrayDescriptor 2 Float stride $ offset (12 + 16) filt = VertexArrayDescriptor 4 Float stride $ offset (12 + 16 + 8) bindBuffer ArrayBuffer $= Just buff arrayPointer VertexArray $= vxDesc arrayPointer ColorArray $= colors arrayPointer TextureCoordArray $= texCoo arrayPointer SecondaryColorArray $= filt drawArrays Quads 0 size bindBuffer ArrayBuffer $= Nothing ------------------------------------------------------ Nothing is displayed on screen. As you can see, my VBO contain interleaved data : - 3 float for the vertex - 4 for the color - 2 for the texture coordinate - 4 for the secondary color) The 'offset' function has type Int -> Ptr Float, and is used to forge a pointer from an Int, to mimic the C way of using VBO. As far as I've checked, the values in my list for VBO generation are valid and well displayed using other techniques. So is there a workaround other method for my solution, preferably by keeping my data interleaved? Secondly, is there any sample for advanced features like VBOs in Haskell? Regards, Vincent