[HOpenGL] problems running SmoothOpenGL3

Michael [Plouj] Ploujnikov ploujj at gmail.com
Sat Aug 1 19:08:29 EDT 2009


On Sat, Aug 1, 2009 at 10:54 AM, Sven Panne<Sven.Panne at aedion.de> wrote:
> 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/


More information about the HOpenGL mailing list