aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeanne-Kamikaze <jeannekamikaze@gmail.com>2013-03-12 15:58:10 +0100
committerJeanne-Kamikaze <jeannekamikaze@gmail.com>2013-03-12 15:58:10 +0100
commitcad366d3319aad9f448db1d16445dea7e9dcb599 (patch)
tree68ff6143bb9dcdf82d928078430c83ecdd3f9adc
parent67bcdd1e3acfb40ec3fde31740416ed1ebf755db (diff)
Added unbind functions
-rw-r--r--Spear/GL.hs22
1 files changed, 20 insertions, 2 deletions
diff --git a/Spear/GL.hs b/Spear/GL.hs
index 65f985b..aa3e930 100644
--- a/Spear/GL.hs
+++ b/Spear/GL.hs
@@ -5,6 +5,7 @@ module Spear.GL
5, newProgram 5, newProgram
6, linkProgram 6, linkProgram
7, useProgram 7, useProgram
8, unuseProgram
8, withGLSLProgram 9, withGLSLProgram
9 -- ** Locations 10 -- ** Locations
10, attribLocation 11, attribLocation
@@ -36,6 +37,7 @@ module Spear.GL
36, VAO 37, VAO
37, newVAO 38, newVAO
38, bindVAO 39, bindVAO
40, unbindVAO
39, enableVAOAttrib 41, enableVAOAttrib
40, attribVAOPointer 42, attribVAOPointer
41 -- ** Rendering 43 -- ** Rendering
@@ -47,6 +49,7 @@ module Spear.GL
47, BufferUsage(..) 49, BufferUsage(..)
48, newBuffer 50, newBuffer
49, bindBuffer 51, bindBuffer
52, unbindBuffer
50, BufferData(..) 53, BufferData(..)
51, bufferData' 54, bufferData'
52, withGLBuffer 55, withGLBuffer
@@ -59,6 +62,7 @@ module Spear.GL
59, loadTextureImage 62, loadTextureImage
60 -- ** Manipulation 63 -- ** Manipulation
61, bindTexture 64, bindTexture
65, unbindTexture
62, loadTextureData 66, loadTextureData
63, texParami 67, texParami
64, texParamf 68, texParamf
@@ -162,10 +166,8 @@ newProgram shaders = do
162 when (h == 0) $ gameError "glCreateProgram failed" 166 when (h == 0) $ gameError "glCreateProgram failed"
163 rkey <- register $ deleteProgram h 167 rkey <- register $ deleteProgram h
164 let program = GLSLProgram h rkey 168 let program = GLSLProgram h rkey
165
166 mapM_ (gameIO . attachShader program) shaders 169 mapM_ (gameIO . attachShader program) shaders
167 linkProgram program 170 linkProgram program
168
169 return program 171 return program
170 172
171-- | Delete the program. 173-- | Delete the program.
@@ -196,6 +198,10 @@ linkProgram prog = do
196useProgram :: GLSLProgram -> IO () 198useProgram :: GLSLProgram -> IO ()
197useProgram prog = glUseProgram $ getProgram prog 199useProgram prog = glUseProgram $ getProgram prog
198 200
201-- | Deactivate the active program.
202unuseProgram :: IO ()
203unuseProgram = glUseProgram 0
204
199-- | Attach the given shader to the given program. 205-- | Attach the given shader to the given program.
200attachShader :: GLSLProgram -> GLSLShader -> IO () 206attachShader :: GLSLProgram -> GLSLShader -> IO ()
201attachShader prog shader = glAttachShader (getProgram prog) (getShader shader) 207attachShader prog shader = glAttachShader (getProgram prog) (getShader shader)
@@ -411,6 +417,10 @@ deleteVAO vao = Foreign.with vao $ glDeleteVertexArrays 1
411bindVAO :: VAO -> IO () 417bindVAO :: VAO -> IO ()
412bindVAO = glBindVertexArray . getVAO 418bindVAO = glBindVertexArray . getVAO
413 419
420-- | Unbind the bound vao.
421unbindVAO :: IO ()
422unbindVAO = glBindVertexArray 0
423
414-- | Enable the given vertex attribute of the bound vao. 424-- | Enable the given vertex attribute of the bound vao.
415-- 425--
416-- See also 'bindVAO'. 426-- See also 'bindVAO'.
@@ -516,6 +526,10 @@ deleteBuffer buf = Foreign.with buf $ glDeleteBuffers 1
516bindBuffer :: GLBuffer -> TargetBuffer -> IO () 526bindBuffer :: GLBuffer -> TargetBuffer -> IO ()
517bindBuffer buf target = glBindBuffer (fromTarget target) $ getBuffer buf 527bindBuffer buf target = glBindBuffer (fromTarget target) $ getBuffer buf
518 528
529-- | Unbind the bound buffer.
530unbindBuffer :: TargetBuffer -> IO ()
531unbindBuffer target = glBindBuffer (fromTarget target) 0
532
519class Storable a => BufferData a where 533class Storable a => BufferData a where
520 -- | Set the buffer's data. 534 -- | Set the buffer's data.
521 bufferData :: TargetBuffer -> [a] -> BufferUsage -> IO () 535 bufferData :: TargetBuffer -> [a] -> BufferUsage -> IO ()
@@ -616,6 +630,10 @@ loadTextureImage file minFilter magFilter = do
616bindTexture :: Texture -> IO () 630bindTexture :: Texture -> IO ()
617bindTexture = glBindTexture gl_TEXTURE_2D . getTex 631bindTexture = glBindTexture gl_TEXTURE_2D . getTex
618 632
633-- | Unbind the bound texture.
634unbindTexture :: IO ()
635unbindTexture = glBindTexture gl_TEXTURE_2D 0
636
619-- | Load data onto the bound texture. 637-- | Load data onto the bound texture.
620-- 638--
621-- See also 'bindTexture'. 639-- See also 'bindTexture'.