[HOpenGL] GLSL interface
Daniel Bergey
bergey at alum.mit.edu
Thu Feb 21 05:52:39 CET 2013
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 <claude at mathr.co.uk> wrote:
> 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
More information about the HOpenGL
mailing list