Hello,

OpenGL allows you to get the current modelview matrix via the function 'glGetDoublev'.

Here's that procedure from 'gl.ss' that comes with Ikarus:

  ;; void glGetDoublev( GLenum pname, GLdouble *params )
  (define-function void glGetDoublev (int byte*))

So, you pass in a bytevector.

Included below is a test program for getting and printing the modelview matrix. This is the portion of the code that gets and prints the matrix:

    (let ((bv (make-bytevector (* 16 8) 0)))
      (glGetDoublev GL_MODELVIEW_MATRIX bv)
      (display bv)
      (newline))

It should be the identity matrix.

This is the output I get from Ypsilon:

Ypsilon 0.9.6-trunk/r413 Copyright (c) 2009 Y.Fujita, LittleWing Company Limited.
>
#vu8(0 0 0 0 0 0 240 63 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 240 63 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 240 63 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 240 63)

And from Ikarus:

Ikarus Scheme version 0.0.4-rc1+ (revision 1747, build 2009-04-02)
Copyright (c) 2006-2008 Abdulaziz Ghuloum

> #vu8(0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0)

Ed

(import (gl) (glut))

(glutInit (vector 0) (vector ""))

(define display-func
  (lambda ()

    (glMatrixMode GL_MODELVIEW)
    (glLoadIdentity)

    (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)

    (let ((bv (make-bytevector (* 16 8) 0)))
      (glGetDoublev GL_MODELVIEW_MATRIX bv)
      (display bv)
      (newline))

    (glFlush)))

(define reshape-func
  (lambda (w h)
    (glViewport 0 0 w h)
    (glMatrixMode GL_PROJECTION)
    (glLoadIdentity)
    (glOrtho 0.0 (+ w 0.0) 0.0 (+ h 0.0) -10.0 10.0)))

(glutInitWindowPosition 100 100)
(glutInitWindowSize 500 500)

(glutCreateWindow "Hello GLUT")

(glutDisplayFunc display-func)

(glutReshapeFunc reshape-func)

(glutMainLoop)

Reply via email to