Daniel Herring | 14 Jan 03:45 2014

small patch


The attached patch fixes an apparent copy/paste typo in cl-opengl.

I tested the %gl:sampler-parameter-i path.  From a quick inspection, the 
others look correct.

- Daniel
From 2679ee47f7f4c1bb979e9667274e3b6f42927c7f Mon Sep 17 00:00:00 2001
From: D Herring <dherring <at> at.tentpost.dot.com>
Date: Mon, 13 Jan 2014 21:41:41 -0500
Subject: [PATCH] sampler-parameter bugfix

 gl/rasterization.lisp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gl/rasterization.lisp b/gl/rasterization.lisp
index 650d57a..67c2ad5 100644
--- a/gl/rasterization.lisp
+++ b/gl/rasterization.lisp
 <at>  <at>  -294,7 +294,7  <at>  <at> 
   (defun sampler-parameter (sampler pname param)
     (body sampler
-          %gl:tex-parameter-i %gl:tex-parameter-f %gl:tex-parameter-fv)))
+          %gl:sampler-parameter-i %gl:sampler-parameter-f %gl:sampler-parameter-fv)))
 ;;; 3.8.12 Texture Objects
(Continue reading)

Greg Bennett | 16 Nov 19:49 2013

Blending (Redbook Ch6)

;; I am trying to learn to use cl-opengl by translating some of those
;; examples from the redbook which are not in the distributed code
;; under ../examples/redbook.

;; In particular, I should like to understand some of Ch6 of the Redbook
;; dealing with blending and antialiasing. I began with blending.

;; While I seem to have pieces working, the code below, and its author,
;; are obviously missing one or more essential ideas. I would be happy
;; to learn what they are, so that I can discover how I might had found
;; them out without bothering the list about possibly trivial matters.

;; (lisp-implementation-version) returns
;; Version 1.9-r15972M (linuxX8664) for ccl.
;; I use 2-pane emacs with C-c C-c to move forms from source
;; buffer to *slime-repl ccl* buffer
;; all under Linux Mint 14 (64 bit).

;; Thanks for any and all assistance
;; Cheers /Greg Bennett

;;+ Code and comments on its execution follow.

;; This is blender.lisp
;; An attempt to adapt the code in the
;; OpenGL Programming Guide P230/1
;; to cl-opengl
;; borrowing from redbook/examples/lines.lisp for basic windowing code,
;; and with helpful hints from Bart Botta about how to convert the C
;; code to opengl's forms.
(Continue reading)

Greg Bennett | 11 Nov 20:43 2013


I am trying to use some of the ideas of Ch6 Blending, etc. of the OpenGL
Programming Guide. Specifically I am interested in the use of the A
attribute of glColor for erasing points, lines, etc..

The beginning of Ch6 talks about blending and its first example
emphasizes the need to call glEnable and glBlendFunc before actually
drawing anything, although I can get somewhere without these.

I have found the definitions of the cl-opengl versions in 
funcs-gl-gles1-gles2.lisp (in the gl subdirectory of cl-opengl), so
I assume they are callable. I'm stuck one the appropriate arguments.

P230 0f the Guide, Example 6-1 starts with
   glColorClear(1.0, 1.0, 1.0, 0.0);
   glBlendFunc(GL_ONE, GL_ONE);

and GL_ONE is defined on P228 as (1,1,1).

I would be grateful for information about the calling sequences of the
above 3 lines in cl-opengl. Perhaps there are examples/sources I should
be aware of which would save me posting to the list.

Thanks for any and all assistance.
Cheers /Greg Bennett

Greg Bennett | 11 Nov 21:05 2013


Hello there .. 
I am trying to experiment with the 4th, A, attribute of glColor to erase
lines, points, etc. 
Looking at Chapter 6 of the OpenGL Programming Guide, I see mention of
blending and its activation when using that attribute.
Specifically, Example 6-1 on P230 begins with
    glClearColor(1.0, 10., 1.0, 0.0);
    glBlendFunc(GL_ONE, GL_ONE);

I can see the definitions of glBlendFunc and glEnable in the file
so I presume they are callable. It is the arguments which have me

GL_ONE is defined as (1, 1, 1) on P228, GL_BLEND gets no mention that I
can find.

I would appreciate pointers to the calling sequences under cl-opengl of
the above 3 lines. I have to say that I can do some erasing without
calling glBlendFunc or glEnable, although what happens is a bit odd.

Perhaps there are examples/resources of which I am unaware which would
have saved me posting what may be a simple query to the list.

Thanks for any and all assistance, and for you patience.
Cheers /Greg Bennett

Greg Bennett | 6 Nov 19:40 2013


Running ccl 1.9-r15968M under linux mint 14, I assume that the easiest
way to get cl-opengl is via quicklisp.

On its release pages I see three projects which mention cl-opengl in some way:
cl-glfw-20130615git <- lots of stuff
cl-opengl-20131003git <- the core pieces, I believe.

Should I install them all, I wonder ?

Cheers /Greg Bennett
Chris Bagley | 24 Oct 11:31 2013

OSX and (gl:get-integer :num-extensions)

I have two users for whom a call to (gl:get-integer :num-extensions) errors with:
OpenGL signaled (1280 . iNVLID-ENUM) from GET-INTGER-V

The only thing they both have in common it seems is OSX
Here is copied from one of their slime error buffers.

OpenGL signalled (1280 . INVALID-ENUM) from GET-INTEGER-V.
   [Condition of type CL-OPENGL-BINDINGS:OPENGL-

 0: [CONTINUE] Continue
 1: [RETRY] Retry SLIME REPL evaluation request.
 2: [*ABORT] Return to SLIME's top level.
 3: [ABORT] Abort thread (#<THREAD "repl-thread" RUNNING {1003448023}>)

  0: (CL-OPENGL-BINDINGS:CHECK-ERROR #<unavailable argument>)
  4: (CEPL:REPL 640 480)
  7: (SWANK::EVAL-REGION "(cepl:repl) ..)

It seems from here https://developer.apple.com/library/mac/releasenotes/general/macosxlionapidiffs/OpenGL.html that this enum was only added in OsX 10.7 (Lion) but at least one of these folks is using mavericks which has 4.2 support (so I'm told :))

Any idea what would be causing this?

Chris Bagley | 16 Oct 13:42 2013

Confused as to how generate-gl-function works

It seems to be compiling a new lambda on every call. I'll walk through my logic below:

So I am looking at how (gen-buffers) is implemented.

(defun gen-buffers (count)
  (with-foreign-object (buffer-array '%gl:uint count)
    (%gl:gen-buffers count buffer-array)
    (loop for i below count
          collecting (mem-aref buffer-array '%gl:uint i))))

%gl:gen-buffers is deifned as
(defglextfun ("glGenBuffers" gen-buffers) :void
  (n sizei)
  (buffers (:pointer uint)))

which expands to:
 (declaim (notinline gen-buffers))
 (defun gen-buffers (n buffers)
   (generate-gl-function "glgenbuffers" 'gen-buffers ':void
                         '((n sizei) (buffers (:pointer uint))) n buffers))
 (setf (get 'gen-buffers 'proc-address-dummy) #'gen-buffers)

and generate-gl-function
(defun generate-gl-function (foreign-name lisp-name result-type body &rest args)
  (let ((address (gl-get-proc-address foreign-name))
        (arg-list (mapcar #'first body)))
    (when (or (not (pointerp address)) (null-pointer-p address))
      (error "Couldn't find function ~A" foreign-name))
    (compile lisp-name
             `(lambda ,arg-list
                     (:library opengl)
                     , <at> (loop for i in body
                          collect (second i)
                          collect (first i))
                  (check-error ',lisp-name))))
    (apply lisp-name args)))

What is going on here? I don't believe that it is recompiling the wrapper function on every call, but I'm having issues working out how else this works.
Hope someone can help me out here.

Rujia Liu | 4 Oct 11:26 2013

glClearColor not found on some machine, some CL system


I'm new to cl-opengl and was reading this tutorial:


I've downloaded tut02.lisp, but have trouble running it.

On my machine, ccl 1.6 (windows XP, 32 bit, OpenGL 1.5) gives:

; Warning: Don't know how to setup a hook before saving cores on this Lisp.
; While executing: #<Anonymous Function #xCE06D0E>, in process listener(1).
> Error: Couldn't find function glClearColor
> While executing: CL-OPENGL-BINDINGS::GENERATE-GL-FUNCTION, in process listener
> Type :GO to continue, :POP to abort, :R for a list of available restarts.
> If continued: Skip loading "tut02.lisp"
> Type :? for other options.

But SBCL 1.1.4 (win32-thread fork) runs perfectly.

On another machine (windows 7, 64 bit, OpenGL 4.3), both ccl 1.6 and SBCL (both 32-bit) gave the error message before.

Could anyone give me some suggestions? Thanks in advance

- Rujia

Andreas Thiele | 10 Sep 11:17 2013

cl-opengl and current Clozure Lisp 1.9 (32 and 64-bit) on Windows 7



I have problems running cl-opengl. I used quicklisp and loaded cl-opengl.


Here a probably simple error:


After trying


(gl:get* :version)


I get:


NIL is not of type (OR SYMBOL

                       FUNCTION), and can't be FUNCALLed or APPLYed

   [Condition of type TYPE-ERROR]



0: [RETRY] Retry SLIME REPL evaluation request.

1: [*ABORT] Return to SLIME's top level.

2: [ABORT-BREAK] Reset this thread

3: [ABORT] Kill this thread






  3: (SWANK::EVAL-REGION "(gl:get* :version)\n")


I obtain exactly the same error on CCL 1.9 32-bit and 64-bit. Looks like something small or simple.


Any advice appreciated.


Best Regards

Andreas Thiele






markb | 28 Apr 00:32 2013

Sample code for vertex arrays

Can anyone provide sample code using vertex arrays?

The program varray.lisp in the redbook examples uses these but things like gl:vertex-pointer do not
appear to be exported into the cl-opengl package.

cage | 10 Mar 14:35 2013

slow interpolation issues


I have written an MD2 3d mesh loader, everything works fine except for
the animations.

Because  the model  save only  the key  frame for  each  animation the
loader  must interpolate  the vertex  position of  the mesh  to  get a
smooth animation.

My solution was to save the  triangles vertices in a gl-array for each
frame an then doing linear interpolation, something like that:

(defun lerp-gl-array (a b c count interpolation-factor)
  (dotimes (i count) 
    (setf (gl:glaref c i) 
      (alexandria:lerp interpolation-factor (gl:glaref a i) (gl:glaref b i)))))

but it seem to be too slow as shown by the SBCL profiler

  seconds  |     gc     |     consed    | calls |  sec/call  |  name  
   264.554 |      8.189 | 8,307,049,792 | 2,870 |   0.092179 | CL-GL-UTILS:LERP-GL-ARRAY
   264.554 |      8.189 | 8,307,049,792 | 2,870 |            | Total

is this my fault? Any idea how can I improve performance?

Thank you.


source code published is licensed under the "Simplified BSD License"