First thanks you two for the reply. Now for the solution, I'm a bit ashamed of myself, because I simply forgot to put a clientState VertexArray $= Enabled
The rest of the code is valid beside this 'little' miss -----Message d'origine----- De : [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] De la part de Bit Connor Envoyé : lundi 25 août 2008 23:44 À : Twinside Cc : haskell-cafe@haskell.org Objet : Re: [Haskell-cafe] OpenGL's VBO with Haskell Hi, I used VBO with haskell and I remember it being pretty straightforward, pretty much the same as in C. This was a while ago and I don't really remember how things work so I can't really comment on your code. But I'll see if I can find my old haskell VBO code. On Mon, Aug 25, 2008 at 8:43 PM, Twinside <[EMAIL PROTECTED]> wrote: > 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 > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe