Hi all,

I'm trying to get some FFI bindings for FreeGlut
<http://freeglut.sourceforge.net/> to work. This is a C program that
works for me:


#include "GL/gl.h"
#include "GL/glut.h"

void
simple_render ()
{
  glClear (GL_COLOR_BUFFER_BIT);
  glFlush ();
}

int
main (int argc, char** argv)
{
  glutInitDisplayMode (GLUT_SINGLE|GLUT_RGB);
  glutCreateWindow ("Title.");
  glutDisplayFunc (simple_render);
  glutMainLoop ();
  return 1;
}


Here is a Lisp port that doesn't work:


(sys::load-object-file #p"/usr/lib/libGL.so")
(sys::load-object-file #p"/usr/lib/libglut.so")

(alien:def-alien-routine ("glFlush" gl-flush)
    c-call:void)

(alien:def-alien-routine ("glClear" gl-clear)
    c-call:void
  (mask bitfield :in))

(alien:def-alien-routine ("glutInitDisplayMode" glut-init-display-mode)
    c-call:void
  (mode c-call:unsigned-int :in))

(alien:def-alien-routine ("glutCreateWindow" glut-create-window)
    integer
  (title c-call:c-string :in))

(alien:def-alien-routine ("glutDisplayFunc" glut-display-func)
    c-call:void
  (callback :void-pointer :in))

(alien:def-alien-routine ("glutMainLoop" glut-main-loop)
    c-call:void)

(defconstant GL_COLOR_BUFFER_BIT #x00004000)
(defconstant GLUT_SINGLE #x0000)
(defconstant GLUT_RGB #x0000)

(alien:def-callback simple-render (c-call:void)
  (gl-clear GL_COLOR_BUFFER_BIT) 
  (gl-flush))

(defun simple-window ()
  (glut-init-display-mode (logior GLUT_SINGLE GLUT_RGB))
  (glut-create-window "Title.")
  (glut-display-func (alien:callback simple-render))
  (glut-main-loop))

;(simple-window)


I am getting failures in the call to `glut-create-window'. By adding
print statements to the freeglut library I have been able to trace the
problem into a call into the X server. This made me think that the
problem might be due to X not getting linked correctly so I tried
loading all of the libs listed by "ldd a.out" (where a.out is the C
program above).

(sys::load-object-file #p"/usr/lib/libGL.so.1")
(sys::load-object-file #p"/usr/lib/libglut.so.3")
(sys::load-object-file #p"/lib/libc.so.6")
(sys::load-object-file #p"/usr/lib/libGLcore.so.1")
(sys::load-object-file #p"/lib/libm.so.6")
(sys::load-object-file #p"/usr/X11R6/lib/libXext.so.6")
(sys::load-object-file #p"/usr/X11R6/lib/libX11.so.6")
(sys::load-object-file #p"/lib/libdl.so.2")
(sys::load-object-file #p"/usr/X11R6/lib/libGLU.so.1")
(sys::load-object-file #p"/lib/ld-linux.so.2")
(sys::load-object-file #p"/usr/lib/libstdc++.so.5")
(sys::load-object-file #p"/lib/libgcc_s.so.1")

But this didn't help either. I have also tried using `load-foreign'
and a static library without success.

I'm currently using 19a dated 2003-11-02.

--
jan


Reply via email to