problems running SmoothOpenGL3

Hi, I wanted to give the new SmoothOpenGL3.hs example a try, but I ran into a strange problem with it. Prior to trying this example, I unregistered the old OpenGL and GLUT packages and installed new ones with cabal. Below is a list of all the Haskell packages on my system: $ ghc-pkg list /usr/lib64/ghc-6.10.3/./package.conf: Cabal-1.6.0.3, HUnit-1.2.0.3, QuickCheck-1.2.0.0, X11-1.4.5, array-0.2.0.0, base-3.0.3.1, base-4.1.0.0, bytestring-0.9.1.4, containers-0.2.0.1, directory-1.0.0.3, (dph-base-0.3), (dph-par-0.3), (dph-prim-interface-0.3), (dph-prim-par-0.3), (dph-prim-seq-0.3), (dph-seq-0.3), extensible-exceptions-0.1.1.0, filepath-1.1.0.2, (ghc-6.10.3), ghc-prim-0.1.0.0, haddock-2.4.2, haskell-src-1.0.1.3, haskell98-1.0.1.0, hpc-0.5.0.3, html-1.0.1.2, integer-0.1.0.1, mtl-1.1.0.2, network-2.2.1, old-locale-1.0.0.1, old-time-1.0.0.2, packedstring-0.1.0.1, parallel-1.1.0.1, parsec-2.1.0.1, pretty-1.0.1.0, process-1.0.1.1, random-1.0.0.1, regex-base-0.72.0.2, regex-compat-0.71.0.1, regex-posix-0.72.0.3, rts-1.0, stm-2.1.1.2, syb-0.1.0.1, template-haskell-2.3.0.1, time-1.1.3, unix-2.3.2.0, xhtml-3000.2.0.1, xmonad-0.8.1 /home/plouj/.ghc/x86_64-linux-6.10.3/package.conf: GLURaw-1.0.0.0, GLUT-2.2.0.0, ObjectName-1.0.0.0, OpenGL-2.3.0.0, OpenGLRaw-1.0.1.0, SDL-0.5.5, StateVar-1.0.0.0, Tensor-1.0.0.1, X11-xft-0.3, hinotify-0.2, utf8-string-0.3.5, xmonad-contrib-0.8.1 I copied SmoothOpenGL3.hs from the GLUT-2.2.0.0.tar.gz tarball into the current directory and here is what happened when I tried running it with runghc: $ runghc SmoothOpenGL3.hs SmoothOpenGL3.hs: /home/plouj/.cabal/lib/GLUT-2.2.0.0/ghc-6.10.3/HSGLUT-2.2.0.0.o: unknown symbol `glutGet' SmoothOpenGL3.hs: SmoothOpenGL3.hs: unable to load package `GLUT-2.2.0.0' $ ghc-pkg list|grep GLUT GLURaw-1.0.0.0, GLUT-2.2.0.0, ObjectName-1.0.0.0, OpenGL-2.3.0.0, $ nm /home/plouj/.cabal/lib/GLUT-2.2.0.0/ghc-6.10.3/HSGLUT-2.2.0.0.o|grep glutGet 0000000000007720 D GLUTzm2zi2zi0zi0_GraphicsziUIziGLUTziState_ptrzuglutGetModeValues_closure 0000000000045060 T GLUTzm2zi2zi0zi0_GraphicsziUIziGLUTziState_ptrzuglutGetModeValues_info U glutGet U glutGetColor U glutGetMenu U glutGetModifiers U glutGetProcAddress U glutGetWindow I get a similar problem in ghci: $ ghci GHCi, version 6.10.3: http://www.haskell.org/ghc/ :? for help Loading package ghc-prim ... linking ... done. Loading package integer ... linking ... done. Loading package base ... linking ... done. Prelude> :l SmoothOpenGL3.hs [1 of 1] Compiling Main ( SmoothOpenGL3.hs, interpreted ) Ok, modules loaded: Main. *Main> main Loading package syb ... linking ... done. Loading package base-3.0.3.1 ... linking ... done. Loading package array-0.2.0.0 ... linking ... done. Loading package containers-0.2.0.1 ... linking ... done. Loading package OpenGLRaw-1.0.1.0 ... linking ... done. Loading package GLURaw-1.0.0.0 ... linking ... done. Loading package ObjectName-1.0.0.0 ... linking ... done. Loading package StateVar-1.0.0.0 ... linking ... done. Loading package Tensor-1.0.0.1 ... linking ... done. Loading package OpenGL-2.3.0.0 ... linking ... done. Loading package GLUT-2.2.0.0 ... linking ... <interactive>: /home/plouj/.cabal/lib/GLUT-2.2.0.0/ghc-6.10.3/HSGLUT-2.2.0.0.o: unknown symbol `glutGet' ghc: unable to load package `GLUT-2.2.0.0' Finally, this is what I get if I try to compile with 'ghc --make': $ ghc --make -lglut SmoothOpenGL3.hs # the linker fails without -lglut similar to this: http://www.haskell.org/pipermail/hopengl/2008-September/000756.html [1 of 1] Compiling Main ( SmoothOpenGL3.hs, SmoothOpenGL3.o ) Linking SmoothOpenGL3 ... $ ./SmoothOpenGL3 SmoothOpenGL3: user error (unknown GLUT call glutInitContextVersion, check for freeglut) $ ldd ./SmoothOpenGL3 linux-vdso.so.1 => (0x00007fffd25ff000) libglut.so.3 => /usr/lib64/libglut.so.3 (0x000000323c000000) libGLU.so.1 => /usr/lib64/libGLU.so.1 (0x0000003242000000) libGL.so.1 => /usr/lib64/libGL.so.1 (0x0000003241c00000) libm.so.6 => /lib64/libm.so.6 (0x0000003239400000) libgmp.so.3 => /usr/lib64/libgmp.so.3 (0x000000323bc00000) libdl.so.2 => /lib64/libdl.so.2 (0x0000003239800000) librt.so.1 => /lib64/librt.so.1 (0x000000323a400000) libc.so.6 => /lib64/libc.so.6 (0x0000003239000000) libXext.so.6 => /usr/lib64/libXext.so.6 (0x000000323b400000) libX11.so.6 => /usr/lib64/libX11.so.6 (0x000000323a800000) libXxf86vm.so.1 => /usr/lib64/libXxf86vm.so.1 (0x0000003248a00000) libstdc++.so.6 => /usr/lib64/libstdc++.so.6 (0x0000003243e00000) libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x0000003241000000) libXdamage.so.1 => /usr/lib64/libXdamage.so.1 (0x000000323ec00000) libXfixes.so.3 => /usr/lib64/libXfixes.so.3 (0x000000323cc00000) libdrm.so.2 => /usr/lib64/libdrm.so.2 (0x0000003242400000) libpthread.so.0 => /lib64/libpthread.so.0 (0x0000003239c00000) /lib64/ld-linux-x86-64.so.2 (0x0000003238c00000) libXau.so.6 => /usr/lib64/libXau.so.6 (0x000000323ac00000) libxcb.so.1 => /usr/lib64/libxcb.so.1 (0x000000323b000000) I'm not sure if this problem is specific to my setup or if it's a bug in the new GLUT/OpenGL packages. I would appreciate any help either way. -- http://plouj.com/

Am Freitag, 31. Juli 2009 17:25:45 schrieb Michael [Plouj] Ploujnikov:
[...] Finally, this is what I get if I try to compile with 'ghc --make':
$ ghc --make -lglut SmoothOpenGL3.hs # the linker fails without -lglut similar to this: http://www.haskell.org/pipermail/hopengl/2008-September/000756.html
I don't know what's going on here, things work for me without -lglut on openSUSE 11.1. Which OS/distro are you using? It is hard to debug without actually seeing it fail for oneself. Anyway, I am in the process of changing the GLUT package to use dynamic linking internally, too, and the autoconf dependency will be removed as well. If you like, you could give the code on http://darcs.haskell.org/packages/GLUT/ a try and tell us about your results. Hopefully such linking issues will be a thing of the past... (famous last words ;-)
[1 of 1] Compiling Main ( SmoothOpenGL3.hs, SmoothOpenGL3.o ) Linking SmoothOpenGL3 ... $ ./SmoothOpenGL3 SmoothOpenGL3: user error (unknown GLUT call glutInitContextVersion, check for freeglut)
That's OK: To create an OpenGL 3.x context, you need a recent version of freeglut. Classic GLUT and older versions of freeglut simply do not have the API entries glutInitContextVersion and glutInitContextFlags. I really, really hope that the freeglut project admins make a release soon. I am active in this project, but I can't make releases. There are a few GL/GLX extensions I'd like to add to freeglut, too, but only after a release. Depending on your OpenGL driver, you can make things work by using ./SmoothOpenGL3 classic This will create a "normal" (i.e. legacy) context, which might work, too. Perhaps you have to change the GLSL "#version 140" to "#version 130", your mileage may vary, but this is a driver issue, and OpenGL 3.1 is really still on the bleeding edge. NVIDIA's 190.18 drivers work fine for me on openSUSE x86_64. Note that SmoothOpenGL3 is perhaps not the most elegant way to use OpenGL 3.x, it is my first shot at a "pure" OpenGL 3.1 program which does not use any deprecated functionality, only shaders, vertex arrays in buffer objects, hand-calculated matrices, etc. From this example one can see that the OpenGL package misses a Haskell representation of the various GLSL matrix types, but that is a topic for a different mail thread. :-) Cheers, S.

On Sat, Aug 1, 2009 at 10:54 AM, Sven Panne
Am Freitag, 31. Juli 2009 17:25:45 schrieb Michael [Plouj] Ploujnikov:
[...] Finally, this is what I get if I try to compile with 'ghc --make':
$ ghc --make -lglut SmoothOpenGL3.hs # the linker fails without -lglut similar to this: http://www.haskell.org/pipermail/hopengl/2008-September/000756.html
I don't know what's going on here, things work for me without -lglut on openSUSE 11.1. Which OS/distro are you using?
Fedora 11 x86_64
It is hard to debug without actually seeing it fail for oneself. Anyway, I am in the process of changing the GLUT package to use dynamic linking internally, too, and the autoconf dependency will be removed as well. If you like, you could give the code on http://darcs.haskell.org/packages/GLUT/ a try and tell us about your results. Hopefully such linking issues will be a thing of the past... (famous last words ;-)
I actually don't know how to install a package from source like this. I'm only familiar with the 'cabal install ...' way. Anyways, I deleted ~/.ghc/ and ~/.cabal/ and reinstalled all of my packages (GLUT, SDL and xmonad-contrib). After this, I'm able to run 'ghc --make SmoothOpenGL3.hs' successfully on my Fedora11 desktop, but not the Fedora11 laptop (I'll continue to investigate it).
[1 of 1] Compiling Main ( SmoothOpenGL3.hs, SmoothOpenGL3.o ) Linking SmoothOpenGL3 ... $ ./SmoothOpenGL3 SmoothOpenGL3: user error (unknown GLUT call glutInitContextVersion, check for freeglut)
That's OK: To create an OpenGL 3.x context, you need a recent version of freeglut.
I'm using: freeglut-2.4.0-16.fc11.x86_64 freeglut-devel-2.4.0-16.fc11.x86_64 from Fedora.
Classic GLUT and older versions of freeglut simply do not have the API entries glutInitContextVersion and glutInitContextFlags. I really, really hope that the freeglut project admins make a release soon.
Yup. Five years is a long time with no update :)
I am active in this project, but I can't make releases. There are a few GL/GLX extensions I'd like to add to freeglut, too, but only after a release.
Depending on your OpenGL driver, you can make things work by using
./SmoothOpenGL3 classic
I tried this on my desktop without modifying the code and got this: $ ghc --make SmoothOpenGL3.hs [1 of 1] Compiling Main ( SmoothOpenGL3.hs, SmoothOpenGL3.o ) Linking SmoothOpenGL3 ... $ ./SmoothOpenGL3 classic Vendor: NVIDIA Corporation Renderer: GeForce 8600 GTS/PCI/SSE2 Version: 3.0.0 NVIDIA 185.18.14 GLSL: 1.30 NVIDIA via Cg compiler compile log: 0(1) : error C0201: unsupported version 140 0(2) : warning C7532: global type mat4 requires "#version 100" or later 0(3) : warning C7532: global type vec4 requires "#version 100" or later 0(5) : warning C7022: unrecognized profile specifier "smooth" 0(5) : error C0502: syntax error at token "smooth" 0(5) : error C5060: out can't be used with non-varying fg_SmoothColor 0(9) : warning C7532: global variable gl_Position requires "#version 100" or later compile log: 0(1) : error C0201: unsupported version 140 0(2) : warning C7532: global type vec4 requires "#version 100" or later 0(2) : warning C7022: unrecognized profile specifier "smooth" 0(2) : error C0502: syntax error at token "smooth" 0(3) : error C5060: out can't be used with non-varying fg_FragColor link log: Vertex info ----------- 0(1) : error C0201: unsupported version 140 0(2) : warning C7532: global type mat4 requires "#version 100" or later 0(3) : warning C7532: global type vec4 requires "#version 100" or later 0(5) : warning C7022: unrecognized profile specifier "smooth" 0(5) : error C0502: syntax error at token "smooth" 0(5) : error C5060: out can't be used with non-varying fg_SmoothColor 0(9) : warning C7532: global variable gl_Position requires "#version 100" or later Fragment info ------------- 0(1) : error C0201: unsupported version 140 0(2) : warning C7532: global type vec4 requires "#version 100" or later 0(2) : warning C7022: unrecognized profile specifier "smooth" 0(2) : error C0502: syntax error at token "smooth" 0(3) : error C5060: out can't be used with non-varying fg_FragColor GL errorInvalidOperation (invalid operation) detected in initShader GL errorInvalidOperation (invalid operation) detected in triangle GL errorInvalidOperation (invalid operation) detected in triangle Strangely, runghc on the same source fails: $ runghc SmoothOpenGL3.hs classic freeglut (SmoothOpenGL3.hs): ERROR: Internal error <Visual with necessary capabilities not found> in function fgOpenWindow X Error of failed request: BadWindow (invalid Window parameter) Major opcode of failed request: 4 (X_DestroyWindow) Resource id in failed request: 0x0 Serial number of failed request: 22 Current serial number in output stream: 22 Not surprisingly, the shaders failed to compile on my laptop's X4500: $ ghc --make -lglut SmoothOpenGL3.hs Linking SmoothOpenGL3 ... $ ./SmoothOpenGL3 classic Vendor: Tungsten Graphics, Inc Renderer: Mesa DRI Mobile Intel® GM45 Express Chipset GEM 20090114 Version: 2.1 Mesa 7.6-devel GLSL: 1.20 compile log: Error: Preprocessor error Error: failed to preprocess the source. compile log: Error: Preprocessor error Error: failed to preprocess the source. link log: linking with uncompiled shader GL errorInvalidOperation (invalid operation) detected in initShader GL errorInvalidOperation (invalid operation) detected in triangle GL errorInvalidOperation (invalid operation) detected in triangle GL errorInvalidOperation (invalid operation) detected in triangle GL errorInvalidOperation (invalid operation) detected in triangle GL errorInvalidOperation (invalid operation) detected in triangle Then I changed the shader versions to 130 and got this: $ ghc --make SmoothOpenGL3.hs [1 of 1] Compiling Main ( SmoothOpenGL3.hs, SmoothOpenGL3.o ) Linking SmoothOpenGL3 ... $ ./SmoothOpenGL3 classic Vendor: NVIDIA Corporation Renderer: GeForce 8600 GTS/PCI/SSE2 Version: 3.0.0 NVIDIA 185.18.14 GLSL: 1.30 NVIDIA via Cg compiler and I finally saw a red/blue/green triangle! runghc failed with this code again.
This will create a "normal" (i.e. legacy) context, which might work, too. Perhaps you have to change the GLSL "#version 140" to "#version 130", your mileage may vary, but this is a driver issue, and OpenGL 3.1 is really still on the bleeding edge. NVIDIA's 190.18 drivers work fine for me on openSUSE x86_64.
I'll have to wait for this driver to appear in rpmfusion for Fedora. Version 185.18.14 appears to be the latest stable available at the moment.
Note that SmoothOpenGL3 is perhaps not the most elegant way to use OpenGL 3.x, it is my first shot at a "pure" OpenGL 3.1 program which does not use any deprecated functionality, only shaders, vertex arrays in buffer objects, hand-calculated matrices, etc. From this example one can see that the OpenGL package misses a Haskell representation of the various GLSL matrix types, but that is a topic for a different mail thread. :-)
Thanks for answering me and working on OpenGL support in Haskell! -- http://plouj.com/
participants (2)
-
Michael [Plouj] Ploujnikov
-
Sven Panne