[Haskell-beginners] OpenGLRaw Tutorial
es at ertes.de
Mon Mar 11 12:43:25 CET 2013
Michael Baker <michaeltbaker at gmail.com> wrote:
> However, I'm struggling a bit because I haven't used Haskell's foreign
> interface before. Here is an attempt which is expected to draw a
> triangle, but instead draws nothing: http://hpaste.org/83837
The first thing I notice is that you never set a vertex color, which is
black by default in all cases I've encountered. So it may be drawing,
but you may simply not see it. =)
Before you begin drawing put this somewhere:
glColor3f 1 0 0
That should draw a red shape. Another option is to set a different
glClearColor 1 0 0 1
That sets a red background.
> Does anyone know of a tutorial for OpenGLRaw or the foreign interface
> that might help me understand how to marshall data around? It seems
> like many people turn to OpenGLRaw when they're learning OpenGL so
> that they can follow the tutorials. I imagine it would be useful to
> have a guide out there that covers how to actually use it.
My recommendation is to go with the higher level OpenGL library. The
main difference is that the `gl` prefix is dropped and the numerous
similar functions (`color2f`, `color3f`, `color4f`, etc.) are collapsed
into a single polymorphic function `color`:
import qualified Graphics.Rendering.OpenGL as GL
GL.color (GL.Color3 1 0 (0 :: GL.GLfloat))
This looks more complicated, but it makes other things a lot easier, so
in the end you win.
Not to be or to be and (not to be or to be and (not to be or to be and
(not to be or to be and ... that is the list monad.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 836 bytes
Desc: not available
More information about the Beginners