[Haskell-beginners] OpenGLRaw Tutorial

Michael Baker michaeltbaker at gmail.com
Mon Mar 11 19:19:50 CET 2013

Excellent Isaac, thanks!

On Mon, Mar 11, 2013 at 12:37 PM, Isaac Dupree <
ml at isaac.cedarswampstudios.org> wrote:

> On 03/11/2013 11:41 AM, Michael Baker wrote:
>> The concern that lead me to try OpenGLRaw
>> instead is that drawing every vertex/color/etc with a separate function
>> call seems incredibly inefficient. I imagine I'm going to have to learn
>> to use buffers at some point.
> You are correct.  Partly for that reason, glBegin()/glEnd()/glVertex*()
> don't even exist in OpenGL ES and are deprecated since OpenGL 3.0.  It's a
> shame that so many OpenGL tutorials still teach them.
> Note to others: your program depends on glfw-b (or anyway, Hackage
> 'glfw-b' works and Hackage 'glfw' doesn't).
> glEnableVertexAttribArray/**glVertexAttribPointer are for passing data to
> shader programs, I believe.  Everyone should use shader programs (GLSL).
>  GL without shader programs uses the "fixed-function pipeline" which is
> deprecated.  But I haven't used shaders yet, so I've attached how to do it
> with VBOs and the fixed-function pipeline.  I used glInterleavedArrays and
> glDrawArrays.  (That's probably not the only way to do it; OpenGL has lots
> of legacy and semi-redundant functions.)
> As jean verdier noted, your byte count argument to glBufferData was wrong;
> "fromIntegral $ length verticies * sizeOf (head verticies)" fixes it.
> Four coordinates per vertex is (as far as I know) not very useful for
> two-dimensional or three-dimensional shapes.
> Doing glGenBuffers every frame without glDeleteBuffers leaks buffers.
> Either save them or delete them.  I didn't fix this. Control.Exception's
> bracket or bracket_ can be useful for this sort of thing.
> I also attached a version that can attach a color to each vertex. Haskell
> FFI peeps, is there a better way to do this than writing a Storable
> instance for each GL buffer data layout?
> -Isaac (who has been learning modern OpenGL for http://www.lasercake.net/)
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://www.haskell.org/mailman/listinfo/beginners
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20130311/022c20e3/attachment.htm>

More information about the Beginners mailing list