Mick Charles Beaver | 4 Jun 19:25 2014
Picon

trouble running on ms windows

Hi,

I was poking around with the arcsynthesis GL tutorials and wanted to try coding them up in Lisp with SDL2. I was able to get the first tutorial running on Linux, but when I try to run it on Windows, I get an error when calling gl:create-shader. Specifically, SLIME breaks into:

NIL is not of type (OR SYMBOL
                       FUNCTION), and can't be FUNCALLed or APPLYed
   [Condition of type TYPE-ERROR]

Is there something special that needs to be done for loading extensions on Windows? The shader-vao sample runs for me, but I can't determine if GLUT is doing something special or not. I can't wholly rule out that I've done something silly, so I've attached the source.

-Mick
Attachment (gltut01.lisp): application/octet-stream, 3890 bytes
_______________________________________________
Cl-opengl-devel mailing list
Cl-opengl-devel <at> common-lisp.net
http://common-lisp.net/cgi-bin/mailman/listinfo/cl-opengl-devel
Daniel Herring | 14 Jan 03:45 2014

small patch

Hi,

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

Greg Bennett | 16 Nov 19:49 2013
Picon

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.

;; Comparing the Guide with the examples files, I infer that
;; the contents of void inint(void) go to (defmethod
(glut:display-window ()))
;; while void display(void) -> (defmethod (glut:display( )))

;; *Typically executing the forms below down to and including
;; (defun (gb-blend( ..))
;; and then running (gb-blend) produces a solid yellow
;; window. The x in its top right does indeed kill it.

;; Adding the (defmethod keyboard ...) form and running
;; (gb-blend) produces that yellow window, the keys a,s,r,m,x
;; have no effect on it at all.

;; The x in its top right kills it. Esc kills it too and
;; leads to this in the message
;; window of what was the repl:
;+ Lisp connection closed unexpectedly: connection broken
;+ by remote peer

;+ alt-x slime asks whether I want to start another lisp
;+ answer no -> (presumably) the lisp with which contact
;+ had been severed. This repl knows about nothing which
;+ preceded its interruption.

;; I said Typically, because just ONCE the code without
;; the keyboard method produced a yellow pane with a white
;; square in its centre.

;; Adding the keyboard method to this -> that same pair
;; which reacted to the keys as described on P230 in respect
;; of the white square:
;; a no change
;; s white -> blue
;; r blue -> yellow
;; m yellow -> black
;; x black -> white
;; Esc graceful fold.

;; Having closed the window,
;; immediately re-doing (gb-blend) -> that same collection
;; of responses to keys.

;; Closing lisp, redoing the whole exercise from
;; the same, unchanged, source file -> only the
;; solid yellow pane, unchanged by key presses, save Esc which
;; produces the train wreck described earlier.

;; A package
(defpackage :zot
  (:use :cl))

;; Use it
(in-package :zot)

;; Class for windows in which blending actions should occur
(defclass blender-window (glut:window)
  ()
  (:default-initargs
   :width 400 :height 400 :pos-x 50 :pos-y 50
   :mode '(:single :rgb) :title "Blender Window"))

;; Set up some attributes
;; Described as in void init(void) on P230
(defmethod glut:display-window ((w blender-window))
  (gl:clear-color 1.0 1.0 0.0 0.0)
  (gl:blend-func :one :one)
  (gl:enable :blend)
)

;; We seem to need this reshape method
;; in order that anything show on the screen
(defmethod glut:reshape ((w blender-window) width height)
  (gl:viewport 0 0 width height)
  (gl:matrix-mode :projection)
  (gl:load-identity)
  (glu:ortho-2d 0 width 0 height))

;; A method on display to get what seems
;; to be a rectangle to be modified by blending actions
;; code in void display(void) on P230
(defmethod glut:display ((w blender-window))
  (gl:clear :color-buffer-bit)
  (gl:color 0.0 0.0 1.0)
  (gl:rect -0.5 -0.5 0.5 0.5)
  (gl:flush))

(defun gb-blend ()
  (glut:display-window (make-instance 'blender-window)))

;; If I have translated correctly, that's all I need.
;; Let's make a blender-window

;; There is it in the top left of the screen
;; correct title, solid yellow background.
;; (? Should there have been a yellow square in the middle ?)
;; On to blending through the keyboard.

;; The keyboard method to drive the blender options
;; in the OpenGL P G P231
(defmethod glut:keyboard ((w blender-window) key x y)
  (declare (ignore x y))
  (case key
    ((#\a) (gl:blend-equation :func-add))
    ((#\s) (gl:blend-equation :func-subtract))
    ((#\r) (gl:blend-equation :func-reverse-subtract))
    ((#\m) (gl:blend-equation :min))
    ((#\x) (gl:blend-equation :max))
    ((#\Esc) (glut:destroy-current-window))
    )
  (glut:post-redisplay)
)

;; Assuming correct translation, run (gb-blend) and press 'a'
;; The story is at the top of the file.

Greg Bennett | 11 Nov 20:43 2013
Picon

Blending

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);
   glEnable(GL_BLEND);

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
Picon

Blending

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);
    glEnable(GL_BLEND);

I can see the definitions of glBlendFunc and glEnable in the file
  funcs-gl-gles1-gles2.lisp
so I presume they are callable. It is the arguments which have me
tricked.

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
Picon

Packages

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-glfw3
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
Picon

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-
ERROR]

Restarts:
 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}>)

Backtrace:
  0: (CL-OPENGL-BINDINGS:CHECK-ERROR #<unavailable argument>)
  1: (CL-OPENGL:GET-INTEGER :NUM-EXTENSIONS 1)
  2: (CEPL::GET-GL-EXTENSIONS)
  3: (CEPL::CEPL-POST-CONTEXT-INITIALIZE)
  4: (CEPL:REPL 640 480)
  5: (SB-INT:SIMPLE-EVAL-IN-LEXENV (CEPL:REPL) #<NULL-LEXENV>)
  6: (EVAL (CEPL:REPL))
  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?

Baggers
Chris Bagley | 16 Oct 13:42 2013
Picon

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:
(progn
 (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)
 '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
                (multiple-value-prog1
                    (foreign-funcall-pointer
                     ,address
                     (:library opengl)
                     , <at> (loop for i in body
                          collect (second i)
                          collect (first i))
                     ,result-type)
                  #-cl-opengl-no-check-error
                  (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.
Cheers
Baggers

Rujia Liu | 4 Oct 11:26 2013
Picon

glClearColor not found on some machine, some CL system

Hi!

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

http://nklein.com/2010/06/nehe-tutorial-02-drawing-triangles-and-quadrilaterals/

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
(1).
> 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
Picon

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

Hi,

 

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]

 

Restarts:

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

 

Backtrace:

  0: (CL-OPENGL-BINDINGS::GL-GET-PROC-ADDRESS "glGetString")

  1: (CCL::CALL-CHECK-REGS CL-OPENGL:GET* :VERSION)

  2: (CCL::CHEAP-EVAL (CL-OPENGL:GET* :VERSION))

  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
Picon

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.


Gmane