finish episode 12
This commit is contained in:
parent
f5ae496256
commit
8c58ec6d81
2 changed files with 21 additions and 2 deletions
|
@ -4,12 +4,16 @@ This softwre aims to be an OpenGL renderer written in Haskell following the
|
|||
OpenGL tutorial by The Cherno
|
||||
(<https://www.youtube.com/playlist?list=PLlrATfBNZ98foTJPJ_Ev03o2oq3-GGOS2>).
|
||||
|
||||
## Important notes
|
||||
|
||||
There are some major deviations from the tutorial setup here as follows:
|
||||
|
||||
* Code base is entirely written in Haskell, not C++
|
||||
* Instead of GLFW with GLEW I use SDL2 out of familiarity
|
||||
* Shaders are actually split into files per type, since IÄmnot willing to
|
||||
unleash Haskell list magic
|
||||
* Since I am using the OpenGL core profile from the start there is also a
|
||||
vertex array creation call present from the start.
|
||||
|
||||
I leave as many helpful comments as possible throughout the code, so feel free
|
||||
to peruse it.
|
||||
|
|
19
src/Main.hs
19
src/Main.hs
|
@ -67,8 +67,8 @@ main = do
|
|||
-- -- VERTICES
|
||||
|
||||
-- first, create and bind a vertex array object
|
||||
bo <- GL.genObjectName
|
||||
GL.bindVertexArrayObject $= Just bo
|
||||
vao <- GL.genObjectName
|
||||
GL.bindVertexArrayObject $= Just vao
|
||||
|
||||
-- define vertices (positions of the triangle corners) as List of Floats
|
||||
let vertexPositions =
|
||||
|
@ -155,6 +155,15 @@ main = do
|
|||
|
||||
-- -- EVENTING AND DRAWING
|
||||
|
||||
-- -- UNBINDING ALL BUFFERS AND VERTEX ARRAYS
|
||||
|
||||
GL.bindVertexArrayObject $= Nothing
|
||||
GL.bindBuffer GL.ArrayBuffer $= Nothing
|
||||
GL.bindBuffer GL.ElementArrayBuffer $= Nothing
|
||||
GL.currentProgram $= Nothing
|
||||
|
||||
-- -- LOOPING
|
||||
|
||||
-- initial poll for events
|
||||
evs <- newMVar =<< SDL.pollEvents
|
||||
|
||||
|
@ -175,6 +184,12 @@ main = do
|
|||
-- clear buffers before drawing
|
||||
GL.clear [GL.ColorBuffer]
|
||||
|
||||
-- rebind everything neccessary for draw call
|
||||
GL.bindVertexArrayObject $= Just vao
|
||||
-- (note the missing bindings to the vertex buffer and the attrib pointer)
|
||||
GL.bindBuffer GL.ElementArrayBuffer $= Just ibo
|
||||
GL.currentProgram $= Just sp
|
||||
|
||||
-- throw away previous errors
|
||||
-- void $ get GL.errors
|
||||
|
||||
|
|
Loading…
Reference in a new issue