Re: GLSL interface
Daniel Bergey <[email protected]> Wed, 20 Feb 2013 23:52:39 -0500
| Newsgroups | gmane.comp.lang.haskell.hopengl |
|---|---|
| Message-ID | <[email protected]> |
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 <[email protected]> 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