[cl-opengl-devel] Find out the current matrix-mode?
![](https://secure.gravatar.com/avatar/79ee60f3fedd5b858aa210b2cc606d6a.jpg?s=120&d=mm&r=g)
Hello everybody, I dug a little into CFFI now to solve my selection problem and I got it to work with %gl:selection-buffer. (thread "Is this project alive?") However now I am facing another problem: how do I find out the current matrix mode (I want to save it for later return)? gl:get-integer and cl-opengl-bindings::get-integer-v don't seem to return usable values: CL-USER> (mapcar (lambda (mode) (matrix-mode mode) (list mode (get-integer :matrix-mode))) '(:modelview :texture :projection)) ((:MODELVIEW 0) (:TEXTURE 0) (:PROJECTION 0)) CL-USER> (mapcar (lambda (mode) (matrix-mode mode) (list mode (get-integer :matrix-mode))) '(:modelview :texture :projection)) ((:MODELVIEW 0) (:TEXTURE 0) (:PROJECTION 0)) CL-USER> (with-foreign-object (mm :int) (mapcar (lambda (mode) (matrix-mode mode) (load-identity) (cl-opengl-bindings::get-integer-v #xBA0 mm) ; #xBA0 is :matrix-mode according to constants.lisp (list mode (mem-ref mm :int))) '(:modelview :texture :projection))) ((:MODELVIEW 690846) (:TEXTURE 690846) (:PROJECTION 690846)) CL-USER> (with-foreign-object (mm :int) (mapcar (lambda (mode) (matrix-mode mode) (load-identity) (cl-opengl-bindings::get-integer-v #xBA0 mm) (list mode (mem-ref mm :int))) '(:modelview :texture :projection))) ((:MODELVIEW 281840) (:TEXTURE 281840) (:PROJECTION 281840)) CL-USER> (with-foreign-object (mm :int) (mapcar (lambda (mode) (matrix-mode mode) (load-identity) (cl-opengl-bindings::get-integer-v #xBA0 mm) (list mode (mem-aref mm :int))) ; now with mem-aref instead of mem-ref '(:modelview :texture :projection))) ((:MODELVIEW 675676) (:TEXTURE 675676) (:PROJECTION 675676)) CL-USER> (with-foreign-object (mm :int) (mapcar (lambda (mode) (matrix-mode mode) (load-identity) (cl-opengl-bindings::get-integer-v #xBA0 mm) (list mode (mem-aref mm :int))) '(:modelview :texture :projection))) ((:MODELVIEW 671420) (:TEXTURE 671420) (:PROJECTION 671420)) CL-USER> Obviously there it is not the matrix mode which is returned, what am I doing wrong? Thank you in advance, best regards Jakob -- I would like E-Mails beeing encrypted with OpenPGP. You can find my public key here: http://jayk.resfarm.de/key.txt
![](https://secure.gravatar.com/avatar/326b108ffcc42f27628703b0c11ed239.jpg?s=120&d=mm&r=g)
On Mon, Jun 29, 2009 at 7:13 PM, Jakob Reschke <jakob@resfarm.de> wrote:
However now I am facing another problem: how do I find out the current matrix mode (I want to save it for later return)? gl:get-integer and cl-opengl-bindings::get-integer-v don't seem to return usable values:
You need an active GL context in order to experiment with these calls. Here's a quick and dirty way to do that: (glut:display-window (make-instance 'glut:window)) <abort the main loop with C-c> (gl:get-string :version) => "3.0.0 NVIDIA 180.44" It occurs to me that it'd be nice to use OSMesa for this sort of thing, namely for a test suite. I've attached some bindings to OSMesa if someone feels like playing with this as I don't have time right now. Here's an example: CL-USER> (gl:matrix-mode :projection) ; No value CL-USER> (gl:get-integer :matrix-mode) 5889 CL-USER> (cffi:foreign-enum-keyword '%gl:enum *) :PROJECTION CL-USER> (gl:get-string :version) "2.1 Mesa 7.4" HTH. -- Luís Oliveira http://student.dei.uc.pt/~lmoliv/
![](https://secure.gravatar.com/avatar/79ee60f3fedd5b858aa210b2cc606d6a.jpg?s=120&d=mm&r=g)
2009/6/30 Luís Oliveira <luismbo@gmail.com>:
You need an active GL context in order to experiment with these calls. Here's a quick and dirty way to do that:
(glut:display-window (make-instance 'glut:window)) <abort the main loop with C-c> (gl:get-string :version) => "3.0.0 NVIDIA 180.44"
Thank you very much, that did it.
participants (2)
-
Jakob Reschke
-
Luís Oliveira