----- Original Message -----
From: "Eduardo Cavazos" <[email protected]>
To: <[email protected]>
Sent: Wednesday, February 11, 2009 5:45 AM
Subject: [ikarus-users] glut test case
Hello,
As I mentioned in a previous email, I was unable to run the opengl demos
which come with Ikarus.
I narrowed down the problem to 'glutReshapeFunc'.
Here's a test case which works:
----------------------------------------------------------------------
(import (glut))
(import (gl))
(define display-func
(lambda ()
(glViewport 0 0 500 500)
(glMatrixMode GL_PROJECTION)
(glLoadIdentity)
(glOrtho 0.0 500.0 0.0 500.0 -10.0 10.0)
(glMatrixMode GL_MODELVIEW)
(glClearColor 0.0 0.0 0.0 1.0)
(glClear GL_COLOR_BUFFER_BIT)
(glColor4d 1.0 1.0 1.0 1.0)
(glBegin GL_LINES)
(glVertex2d 10.0 10.0)
(glVertex2d 90.0 90.0)
(glEnd)
(glFlush)))
(glutInitWindowPosition 100 100)
(glutInitWindowSize 500 500)
(glutInit (vector 0) (vector ""))
(glutCreateWindow "Hello GLUT")
(glutDisplayFunc display-func)
(glutMainLoop)
----------------------------------------------------------------------
Now here's a code which results in a segmentation fault:
----------------------------------------------------------------------
(import (glut))
(import (gl))
(define display-func
(lambda ()
(glViewport 0 0 500 500)
(glMatrixMode GL_PROJECTION)
(glLoadIdentity)
(glOrtho 0.0 500.0 0.0 500.0 -10.0 10.0)
(glMatrixMode GL_MODELVIEW)
(glClearColor 0.0 0.0 0.0 1.0)
(glClear GL_COLOR_BUFFER_BIT)
(glColor4d 1.0 1.0 1.0 1.0)
(glBegin GL_LINES)
(glVertex2d 10.0 10.0)
(glVertex2d 90.0 90.0)
(glEnd)
(glFlush)))
(define reshape-func
(lambda (w h)
(display h)
))
(glutInitWindowPosition 100 100)
(glutInitWindowSize 500 500)
(glutInit (vector 0) (vector ""))
(glutCreateWindow "Hello GLUT")
(glutDisplayFunc display-func)
(glutReshapeFunc reshape-func)
(glutMainLoop)
----------------------------------------------------------------------
Note that I'm simply calling 'display' on the 'h' argument of
'reshape-func'. That's what triggers the segmentation fault.
Perhaps the ffi to 'glutReshapeFunc' is getting hosed.
Ed
From the docs of the reshape function:
This default callback will simply call glViewport(0,0,width,height) on the
normal plane (and on the over-lay if one exists).
I assume you need to at least do the call to glViewport in your reshape
callback (and possibly remove the call inside your display callback).
Cheers
leppie