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
That code looks like it ought to work, and I assume if you're using VBOs that you know how to make sure your frustum is setup so that you're object's visible. Are you running this in Windows or in Linux or ? and what version of GHC are you using? There is also a specific HOpenGL mailinglist, just called HOpenGL that you can join by searching for it on the http://haskell.org site. On Mon, Aug 25, 2008 at 1:43 PM, Twinside <twinside@gmail.com> 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
-- I try to take things like a crow; war and chaos don't always ruin a picnic, they just mean you have to be careful what you swallow. -- Jessica Edwards
Oh, and you might try this using Vertex Arrays instead of VBOs. I'll also assume you're checking for the appropriate ARB extensions to make sure VBOs are available on your hardware... If this displays correctly using Vertex Arrays (which can still be interleaved), then I would check your hardware if I were you. On Mon, Aug 25, 2008 at 2:35 PM, Jefferson Heard <jefferson.r.heard@gmail.com> wrote:
That code looks like it ought to work, and I assume if you're using VBOs that you know how to make sure your frustum is setup so that you're object's visible. Are you running this in Windows or in Linux or ? and what version of GHC are you using?
There is also a specific HOpenGL mailinglist, just called HOpenGL that you can join by searching for it on the http://haskell.org site.
On Mon, Aug 25, 2008 at 1:43 PM, Twinside <twinside@gmail.com> 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
-- I try to take things like a crow; war and chaos don't always ruin a picnic, they just mean you have to be careful what you swallow.
-- Jessica Edwards
-- I try to take things like a crow; war and chaos don't always ruin a picnic, they just mean you have to be careful what you swallow. -- Jessica Edwards
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 <twinside@gmail.com> 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
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 +
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 : mutantlemon@gmail.com [mailto:mutantlemon@gmail.com] 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 <twinside@gmail.com> wrote: 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
participants (3)
-
Bit Connor -
Jefferson Heard -
Twinside