move uniform write into loop
This commit is contained in:
parent
c377d27cb2
commit
01b6134331
1 changed files with 19 additions and 4 deletions
23
src/Main.hs
23
src/Main.hs
|
@ -141,10 +141,14 @@ main = do
|
|||
|
||||
-- -- UNIFORMS
|
||||
|
||||
-- get the uniform's location out of the shader program
|
||||
uniLoc <- get $ GL.uniformLocation sp "u_color"
|
||||
-- write data to the uniform
|
||||
GL.uniform uniLoc $= (GL.Color4 1 0.5 0 1 :: GL.Color4 GL.GLfloat)
|
||||
-- -- get the uniform's location out of the shader program
|
||||
-- uniLoc <- get $ GL.uniformLocation sp "u_color"
|
||||
-- -- write data to the uniform
|
||||
-- GL.uniform uniLoc $= (GL.Color4 1 0.5 0 1 :: GL.Color4 GL.GLfloat)
|
||||
|
||||
-- create an MVar for pulsating red channel
|
||||
red <- newMVar 0
|
||||
increment <- newMVar 0.05
|
||||
|
||||
err <- get GL.errors
|
||||
print $ "pre-loop errors: " <> show err
|
||||
|
@ -171,6 +175,17 @@ main = do
|
|||
-- clear buffers before drawing
|
||||
GL.clear [GL.ColorBuffer]
|
||||
|
||||
-- throw away previous errors
|
||||
-- void $ get GL.errors
|
||||
|
||||
-- get the uniform's location out of the shader program
|
||||
uniLoc <- get $ GL.uniformLocation sp "u_color"
|
||||
-- write data to the uniform
|
||||
redValue <- takeMVar red
|
||||
incrementValue <- takeMVar increment
|
||||
let newRed = redValue + incrementValue
|
||||
GL.uniform uniLoc $= (GL.Color4 newRed 0.5 0 1 :: GL.Color4 GL.GLfloat)
|
||||
|
||||
-- the actual drawing happens here
|
||||
void $ get GL.errors
|
||||
GL.drawElements GL.Triangles 6 GL.UnsignedInt nullPtr
|
||||
|
|
Loading…
Reference in a new issue