Created
November 2, 2012 22:41
-
-
Save scan/4004808 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment