File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed
src/Graphics/Rendering/OpenGL/GL/Shaders Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -157,6 +157,33 @@ makeUniformVar setter location = makeStateVar getter (setter location)
157
157
getUniform program location buf
158
158
peek buf
159
159
160
+ getSimpleUniform :: Storable a => Program -> UniformLocation -> Ptr a -> IO ()
161
+ getSimpleUniform (Program p) (UniformLocation ul) = glGetUniformfv p ul . castPtr
162
+
163
+ makeSimpleUniformVar :: (UniformComponent a )
164
+ => UniformLocation -> StateVar a
165
+ makeSimpleUniformVar location = makeStateVar getter (uniform1 location)
166
+ where getter = do program <- fmap fromJust $ get currentProgram
167
+ allocaBytes maxUniformBufferSize $ \ buf -> do
168
+ getSimpleUniform program location buf
169
+ peek buf
170
+
171
+ instance Uniform GLfloat where
172
+ uniform = makeSimpleUniformVar
173
+ uniformv = uniform1v
174
+
175
+ instance Uniform GLint where
176
+ uniform = makeSimpleUniformVar
177
+ uniformv = uniform1v
178
+
179
+ instance Uniform GLuint where
180
+ uniform = makeSimpleUniformVar
181
+ uniformv = uniform1v
182
+
183
+ instance Uniform GLdouble where
184
+ uniform = makeSimpleUniformVar
185
+ uniformv = uniform1v
186
+
160
187
instance UniformComponent a => Uniform (Vertex2 a ) where
161
188
uniform = makeUniformVar $ \ location (Vertex2 x y) -> uniform2 location x y
162
189
uniformv location count = uniform2v location count . (castPtr :: Ptr (Vertex2 b ) -> Ptr b )
You can’t perform that action at this time.
0 commit comments