Re: OpenGL/GLUT examples crashing: known problem?

Tim Smith <[email protected]>
Newsgroups gmane.comp.lang.haskell.hopengl
Message-ID <[email protected]>
On 2005 Apr 12, Claus Reinke <[email protected]> wrote:

> there are some opengl debuggers and tracers around - I'm googling for a
> free windows one, mac users seem to have such support provided by apple, 
> other platforms have their own.

Claus,

Thank you for the response.  I haven't found one yet for XFree86 on
FreeBSD.

But I did do a number of more experiments.  I have a couple of odd
results that maybe someone can help with.

Here is the strangest one (from my perspective).  I've commented which
objects can be drawn, and which ones crash.  I can't find *any* reason
for this behavior, by looking at the code.

E.g., Sphere' crashes but Cone draws fine.  Looking at the
.../GLUT/Objects.hs, the foreign import statements are basically
identical for the two functions (Cone takes one extra argument).  If
anyone can imagine a way that Cone would succeed but Sphere' would fail,
I'm all ears. :-)

A C program can call glutSolidSphere just fine.  Also, I trimmed out
every unneeded OpenGL-related call; if I put in the usual boilerplate of
setting the projection matrix, etc., it still has the same behavior.

-- cut -----------------------------------------------
import Graphics.UI.GLUT
import qualified System.Environment as Env

main :: IO ()
main = do
    objIndex <- getObjIndex
    createWindow "test"
    displayCallback $= display objIndex
    mainLoop

display :: Int -> DisplayCallback
display objIndex = do
    renderObject Solid (objects !! objIndex)
    flush       -- comment this out, and it still crashes on 5-6,8-11

-- This is sloppy, sorry...
getObjIndex :: IO Int
getObjIndex = do
    args <- Env.getArgs
    return (intOfFirstArg args)
    where
        intOfFirstArg [] = 0
        intOfFirstArg (a:_) = read a

objects :: [Object]
objects = [
        Cube 1,                 -- 0:  OK
        Dodecahedron,           -- 1:  OK
        Icosahedron,            -- 2:  OK
        Octahedron,             -- 3:  OK
        Tetrahedron,            -- 4:  OK
        RhombicDodecahedron,    -- 5:  Crash / user error (freeglut)
        Sphere' 1 5 5,          -- 6:  Crash
        Cone 1 1 5 5,           -- 7:  OK
        Cylinder' 1 1 5 5,      -- 8:  Crash / user error (freeglut)
        Torus 0.75 1 5 5,       -- 9:  Crash
        Teapot 1,               -- 10: Crash
        SierpinskiSponge 1      -- 11: Crash / user error (freeglut)
    ]
-- cut -----------------------------------------------


The "Crash / user error (freeglut)" comment means that those three
objects crash with the current GLUT code, but return this error when I
"#define GLUT_GET_PROC_ADDRESS_IS_BROKEN 1" in GLUT/cbits/HsGLUT.c:

objs: user error (unknown GLUT call glutSolidRhombicDodecahedron, check
for freeglut)

There's no configure tests which define that - it's not mentioned
anywhere else besides HsGLUT.c - so I don't know if that's meaningful,
but I thought I would explain it.


There's another class of crashes related to lighting & display lists,
but this is way too long as it is.  I'll stop here, and hope that
someone might be able to suggest a reason for the strange behavior.


Thanks a lot for reading this far!

Tim
-- 
If you're not part of the solution, you're part of the precipitate.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.