[Haskell-beginners] Performance problem with Haskell/OpenGL/GLFW

Jesper Särnesjö sarnesjo at gmail.com
Sun Mar 10 10:38:07 CET 2013

On Sun, Mar 10, 2013 at 4:46 PM, Jesper Särnesjö <sarnesjo at gmail.com> wrote:
> I've figured out what the problem is: the Haskell program is using a
> software implementation of OpenGL, so rendering *does* in fact happen
> on the CPU.
> It would appear that there is in fact some relevant difference between
> the Haskell and C versions of my program, or possibly some way
> in which the bindings from the GLFW-b package are different from the C
> library.

To remove any possibility of the problem being in GLFW-b or OpenGLRaw,
I created two new programs, one in Haskell [1] and one in C [2], that
don't import or include anything related to OpenGL, and that simply
create a context, check if it is hardware accelerated, and then exit.
That is all. And still, the Haskell program receives a software
renderer, while the C program receives a hardware one:

    $ ghc -O2 Test2.hs -lglfw -framework OpenGL -fforce-recomp && ./Test2
    [1 of 1] Compiling Main             ( Test2.hs, Test2.o )
    Linking Test2 ...
    $ gcc -O2 test2.c -lglfw -framework OpenGL && ./a.out

I haven't had the chance to run these programs on any OS other than
Mac OS X 10.8.2, so I don't know if this problem is Mac-specific.
Still, it's really weird that the system would differentiate between
Haskell and C programs in this way.

If anyone has any ideas about what's going on here, I'd very much like
to hear them.

Jesper Särnesjö

[1] https://gist.github.com/sarnesjo/5116084#file-test2-hs
[2] https://gist.github.com/sarnesjo/5116084#file-test2-c

More information about the Beginners mailing list