
What is the recommended way to create and use a Shader object? Graphics.Rendering.OpenGL.GL.Shaders.Shaders has a function createShader which looks good, but is not exported. Similar not-exported functions seem to exist for the Program type. If there's still work do be done on this part of the library, I can to test out some code and submit a pull request. Thanks, bergey

On 20/02/13 17:26, Daniel Bergey wrote:
What is the recommended way to create and use a Shader object?
Personally I tend to use OpenGLRaw package or OpenGLRaw21 package, as OpenGL package diverges from all the useful non-Haskell tutorials and documentation by a wide margin, and OpenGL package doesn't yet support such useful things as geometry shaders. Anyway, usage is mostly via the ObjectName/StateVar interface:
Graphics.Rendering.OpenGL.GL.Shaders.Shaders has a function createShader which looks good, but is not exported. Similar not-exported functions seem to exist for the Program type.
-- untested code do [vert] <- genObjectNames 1 [frag] <- genObjectNames 1 [prog] <- genObjectNames 1 shaderSource vert $= ["void main() { gl_Position = ftransform(); }"] shaderSource frag $= ["void main() { gl_FragColor = vec4(1.0); }"] compileShader vert compileShader frag attachedShaders prog $= ([vert], [frag]) linkProgram prog debugPrint =<< get (programInfoLog prog) currentProgram $= Just prog -- draw using shader here currentProgram $= Nothing
If there's still work do be done on this part of the library, I can to test out some code and submit a pull request.
Claude -- http://mathr.co.uk

Thank you. The example you gave was very helpful in understanding the
use of StateVars.
On 2013-02-20 at 12:49, Claude Heiland-Allen
On 20/02/13 17:26, Daniel Bergey wrote:
What is the recommended way to create and use a Shader object?
Personally I tend to use OpenGLRaw package or OpenGLRaw21 package, as OpenGL package diverges from all the useful non-Haskell tutorials and documentation by a wide margin, and OpenGL package doesn't yet support such useful things as geometry shaders. Anyway, usage is mostly via the ObjectName/StateVar interface:
Graphics.Rendering.OpenGL.GL.Shaders.Shaders has a function createShader which looks good, but is not exported. Similar not-exported functions seem to exist for the Program type.
-- untested code do [vert] <- genObjectNames 1 [frag] <- genObjectNames 1 [prog] <- genObjectNames 1 shaderSource vert $= ["void main() { gl_Position = ftransform(); }"] shaderSource frag $= ["void main() { gl_FragColor = vec4(1.0); }"] compileShader vert compileShader frag attachedShaders prog $= ([vert], [frag]) linkProgram prog debugPrint =<< get (programInfoLog prog) currentProgram $= Just prog -- draw using shader here currentProgram $= Nothing
participants (2)
-
Claude Heiland-Allen
-
Daniel Bergey