From jocelyn_frechot at yahoo.fr Fri Mar 16 21:39:59 2012 From: jocelyn_frechot at yahoo.fr (=?UTF-8?B?Sm9jZWx5biBGcsOpY2hvdA==?=) Date: Fri, 16 Mar 2012 22:39:59 +0100 Subject: [cl-opengl-devel] Extension functions re-defining themselves Message-ID: <4F63B32F.7030306@yahoo.fr> Hello, I?d like to report the folling issue I bumped into: in the cl-opengl-bindings package, extension functions defined with defglextfun will re-define themselves the first time they are called. This is somewhat an unexpected and potentially undesirable behavior: if you store one of those function objects before calling it, it will compile a new object every time it is funcalled. Thanks -- Jocelyn From luismbo at gmail.com Sat Mar 17 10:01:49 2012 From: luismbo at gmail.com (=?ISO-8859-1?Q?Lu=EDs_Oliveira?=) Date: Sat, 17 Mar 2012 10:01:49 +0000 Subject: [cl-opengl-devel] Extension functions re-defining themselves In-Reply-To: <4F63B32F.7030306@yahoo.fr> References: <4F63B32F.7030306@yahoo.fr> Message-ID: On Fri, Mar 16, 2012 at 9:39 PM, Jocelyn Fr?chot wrote: > I?d like to report the folling issue I bumped into: in > the cl-opengl-bindings package, extension functions defined with > defglextfun will re-define themselves the first time they are called. > This is somewhat an unexpected and potentially undesirable behavior: > if you store one of those function objects before calling it, it will > compile a new object every time it is funcalled. At the end of gl/bindings.lisp there's an alternative implementation of DEFGLEXTFUN that doesn't call compile or redefine anything. Does that work better for you? -- Lu?s Oliveira http://r42.eu/~luis/ From jocelyn_frechot at yahoo.fr Sat Mar 17 11:28:32 2012 From: jocelyn_frechot at yahoo.fr (=?UTF-8?B?Sm9jZWx5biBGcsOpY2hvdA==?=) Date: Sat, 17 Mar 2012 12:28:32 +0100 Subject: [cl-opengl-devel] Extension functions re-defining themselves In-Reply-To: References: <4F63B32F.7030306@yahoo.fr> Message-ID: <4F647560.1070306@yahoo.fr> On 17/03/2012 11:01, Lu?s Oliveira wrote: > At the end of gl/bindings.lisp there's an alternative implementation > of DEFGLEXTFUN that doesn't call compile or redefine anything. Does > that work better for you? I tried this version: (defmacro defglextfun ((cname lname) return-type &body args) (alexandria:with-unique-names (pointer) `(let ((,pointer (null-pointer))) (defun ,lname ,(mapcar #'car args) (when (null-pointer-p ,pointer) (setf ,pointer (gl-get-proc-address ,cname)) (assert (not (null-pointer-p ,pointer)) () "Couldn't load symbol ~A~%" ,cname) (format t "Loaded function pointer for ~A: ~A~%" ,cname ,pointer) (push (lambda () (setf ,pointer (null-pointer))) *gl-extension-resetter-list*)) (foreign-funcall-pointer ,pointer (:library opengl) ,@(loop for arg in args collect (second arg) collect (first arg)) ,return-type))))) However, compilation of gl/funcs.lisp fails due to heap exhaustion (using SBCL 1.0.55). -- Jocelyn From dmsurti at gmail.com Fri Mar 30 08:51:52 2012 From: dmsurti at gmail.com (Deepak Surti) Date: Fri, 30 Mar 2012 14:21:52 +0530 Subject: [cl-opengl-devel] Texture coordinates using vertex array Message-ID: Hi, I have written a small library using cl-opengl to do skeletal animation which works great. I use vertex arrays in the process. As outlined in opengl-array.lisp under examples, I have a gl array of vertices. To the vertex object in the gl array I added texture coordinates: (gl:tex-coord :type float :components (u v)) In my code, (just like enable vertex and color array); I enable tex coord array ; all texture loading code and creating gl vertices/indices code (gl:enable-client-state :texture-coord-array) ....... (gl:bind-gl-vertex-array gl-vertices) (gl:draw-elements :triangles gl-indices) ........ (gl:enable-client-state :texture-coord-array) However it leads to a memory segment address error. If I go the primitive route, rendering the triangle vertices and texture coordinates, things work fine. Obviously, as for texture coordinates with draw elements; I am missing something. I tried looking up into the source/examples but could not find. [PS: i am no C expert, so am stuck here] Any help appreciated, Let me know in case of any questions, Thanks and Regards, Deepak -- To see a miracle, be the miracle. -------------- next part -------------- An HTML attachment was scrubbed... URL: From luismbo at gmail.com Sat Mar 31 15:42:00 2012 From: luismbo at gmail.com (=?ISO-8859-1?Q?Lu=EDs_Oliveira?=) Date: Sat, 31 Mar 2012 16:42:00 +0100 Subject: [cl-opengl-devel] Extension functions re-defining themselves In-Reply-To: <4F647560.1070306@yahoo.fr> References: <4F63B32F.7030306@yahoo.fr> <4F647560.1070306@yahoo.fr> Message-ID: Hello Jocelyn, I tried it out as well and got similar results. I also tried using load-time-value for the pointer cache in the hopes that making the DEFUN a top-level form would appease SBCL but that help too much. Have you tried using a less smart compiler such as CCL ou CLISP? -- Lu?s Oliveira http://r42.eu/~luis On Mar 17, 2012 11:28 AM, "Jocelyn Fr?chot" wrote: > On 17/03/2012 11:01, Lu?s Oliveira wrote: > > At the end of gl/bindings.lisp there's an alternative implementation >> of DEFGLEXTFUN that doesn't call compile or redefine anything. Does >> that work better for you? >> > > I tried this version: > > (defmacro defglextfun ((cname lname) return-type &body args) > (alexandria:with-unique-names (pointer) > `(let ((,pointer (null-pointer))) > (defun ,lname ,(mapcar #'car args) > (when (null-pointer-p ,pointer) > (setf ,pointer (gl-get-proc-address ,cname)) > (assert (not (null-pointer-p ,pointer)) () > "Couldn't load symbol ~A~%" ,cname) > (format t "Loaded function pointer for ~A: ~A~%" ,cname ,pointer) > (push (lambda () (setf ,pointer (null-pointer))) > *gl-extension-resetter-list*)) > (foreign-funcall-pointer > ,pointer > (:library opengl) > ,@(loop for arg in args collect (second arg) collect (first arg)) > ,return-type))))) > > However, compilation of gl/funcs.lisp fails due to heap exhaustion > (using SBCL 1.0.55). > > -- > Jocelyn > -------------- next part -------------- An HTML attachment was scrubbed... URL: From nikodemus at random-state.net Sat Mar 31 16:02:52 2012 From: nikodemus at random-state.net (Nikodemus Siivola) Date: Sat, 31 Mar 2012 19:02:52 +0300 Subject: [cl-opengl-devel] Extension functions re-defining themselves In-Reply-To: References: <4F63B32F.7030306@yahoo.fr> <4F647560.1070306@yahoo.fr> Message-ID: On 31 March 2012 18:42, Lu?s Oliveira wrote: > I tried it out as well and got similar results. I also tried using > load-time-value for the pointer cache in the hopes that making the DEFUN a > top-level form would appease SBCL but that help too much. > > Have you tried using a less smart compiler such as CCL ou CLISP? Can you point me at right spot in cl-opengl sources, and provide a test-case. I think I have an idea... Cheers, -- nikodemus From jocelyn_frechot at yahoo.fr Sat Mar 31 16:46:35 2012 From: jocelyn_frechot at yahoo.fr (=?UTF-8?B?Sm9jZWx5biBGcsOpY2hvdA==?=) Date: Sat, 31 Mar 2012 18:46:35 +0200 Subject: [cl-opengl-devel] Extension functions re-defining themselves In-Reply-To: References: <4F63B32F.7030306@yahoo.fr> <4F647560.1070306@yahoo.fr> Message-ID: <4F7734EB.8090809@yahoo.fr> On 31/03/2012 17:42, Lu?s Oliveira wrote: > I tried it out as well and got similar results. I also tried using > load-time-value for the pointer cache in the hopes that making the DEFUN a > top-level form would appease SBCL but that help too much. > > Have you tried using a less smart compiler such as CCL ou CLISP? No I haven?t. For now I store function symbols rather than objects. I guess the overhead of funcall-ing them is negligible in my context. -- Jocelyn From luismbo at gmail.com Sat Mar 31 23:11:53 2012 From: luismbo at gmail.com (=?ISO-8859-1?Q?Lu=EDs_Oliveira?=) Date: Sun, 1 Apr 2012 00:11:53 +0100 Subject: [cl-opengl-devel] Extension functions re-defining themselves In-Reply-To: References: <4F63B32F.7030306@yahoo.fr> <4F647560.1070306@yahoo.fr> Message-ID: On Sat, Mar 31, 2012 at 5:02 PM, Nikodemus Siivola wrote: > Can you point me at right spot in cl-opengl sources, and provide a > test-case. I think I have an idea... The code is at: The test-case is simply compiling cl-opengl. SBCL will exhaust the heap while attempting to compile gl/funcs.lisp which contains about 2000 usages of DEFGLEXTFUN. Cheers, -- Lu?s Oliveira http://r42.eu/~luis/