[HOpenGL] GLSL interface
Claude Heiland-Allen
claude at mathr.co.uk
Wed Feb 20 18:49:43 CET 2013
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
More information about the HOpenGL
mailing list