add Renderer code
This commit is contained in:
parent
d21cc70759
commit
20b77a4068
1 changed files with 43 additions and 0 deletions
43
app/Renderer.hs
Normal file
43
app/Renderer.hs
Normal file
|
@ -0,0 +1,43 @@
|
|||
module Renderer where
|
||||
|
||||
import SDL (($=))
|
||||
|
||||
import qualified Graphics.Rendering.OpenGL as GL
|
||||
import qualified Graphics.GLUtil as GLU
|
||||
|
||||
import Foreign
|
||||
|
||||
initRenderData = do
|
||||
quadVAO <- GL.genObjectName
|
||||
quadVBO <- GL.genObjectname
|
||||
|
||||
GL.bindBuffer GL.ArrayBuffer $= Just quadVBO
|
||||
withArray rawVertices $ \ptr ->
|
||||
GL.bufferData Gl.ArrayBuffer $=
|
||||
( fromIntegral $ length rawVertices * sizeOf (0 :: Float)
|
||||
, ptr
|
||||
, GL.StaticDraw
|
||||
)
|
||||
|
||||
GL.bindVertexArrayObject $= Just quadVAO
|
||||
|
||||
Gl.VertexattribArray (GL.AttribLocation 0) $= GL.Enabled
|
||||
|
||||
Gl.vertexAttribPointer (GL.AttribLocation 0) $=
|
||||
( GL.ToFloat
|
||||
, GL.VertesArrayDescriptor 4 GL.Float 0 (plusPtr nullptr 0)
|
||||
)
|
||||
|
||||
GL.bindBuffer GL.ArrayBuffer $= Nothing
|
||||
GL.bindVertexArrayObject $= Nothing
|
||||
where
|
||||
rawVertices :: [Float]
|
||||
rawVertices =
|
||||
[ 0, 1, 0, 0
|
||||
, 1, 0, 1, 0
|
||||
, 0, 0, 0, 0
|
||||
|
||||
, 0, 1, 0, 1
|
||||
, 1, 1, 1, 1
|
||||
, 1, 0, 1, 0
|
||||
]
|
Loading…
Reference in a new issue