[cl-opengl-devel] Vertex Arrays
Charlie McMackin
charliemac+cl-opengl at gmail.com
Tue Dec 26 01:46:29 UTC 2006
Hello,
Here is a patch done with your requested method. In addition, should
Bart's changes be merged, I also have a patch working for that (not
attached with this email).
Again, I'm not strong on macros yet so my changes gl/util.lisp's
with-opengl-sequence need extra scrutiny. Vertex array functions need
to be able to send variable type information but the current
with-opengl-sequence is coded assuming constant types.
If you wonder why I removed the flet section of the macro, I kept
getting errors that I concluded were due to the various lexical scopes
happening with flet, once-only, and gensyms
I'd like to hear what kind of results it produces for others as I only
have a ati 9600 mobility to test on.
Charlie Mac
-------------- next part --------------
New patches:
[vertex array addition
charliemac+cl-opengl at gmail.com**20061226010622
Added mostly working functionality for vertex arrays.
"with-opengl-sequence" macro modified (hopefully correctly) in gl/util.lisp, possible danger of code
breakage.
] {
hunk ./examples/examples.lisp 11
- rb-double rb-hello #|rb-varray|# rb-lines rb-polys rb-cube rb-model
+ rb-double rb-hello rb-varray rb-lines rb-polys rb-cube rb-model
hunk ./examples/redbook/varray.lisp 14
- (deref-method :accessor deref-method :initform 'draw-array)))
+ (deref-method :accessor deref-method :initform 'draw-array))
+ (:default-initargs :width 350 :height 350 :title "varray.lisp"
+ :mode '(:single :rgb)))
hunk ./examples/redbook/varray.lisp 19
- ;; XXX TODO
-#||
- static GLint vertices[] = {25, 25,
- 100, 325,
- 175, 25,
- 175, 325,
- 250, 25,
- 325, 325};
- static GLfloat colors[] = {1.0, 0.2, 0.2,
- 0.2, 0.2, 1.0,
- 0.8, 1.0, 0.2,
- 0.75, 0.75, 0.75,
- 0.35, 0.35, 0.35,
- 0.5, 0.5, 0.5};
+ (let ((vertices '(25 25
+ 100 325
+ 175 25
+ 175 325
+ 250 25
+ 325 325))
+ (colors '(1.0 0.2 0.2
+ 0.2 0.2 1.0
+ 0.8 1.0 0.2
+ 0.75 0.75 0.75
+ 0.35 0.35 0.35
+ 0.5 0.5 0.5)))
hunk ./examples/redbook/varray.lisp 32
- glEnableClientState (GL_VERTEX_ARRAY);
- glEnableClientState (GL_COLOR_ARRAY);
-
- glVertexPointer (2, GL_INT, 0, vertices);
- glColorPointer (3, GL_FLOAT, 0, colors);
-||# )
+ (gl:enable-client-state :vertex-array)
+ (gl:enable-client-state :color-array)
+
+ (gl:vertex-pointer 2 :int 0 vertices)
+ (gl:color-pointer 3 :float 0 colors)))
+
hunk ./examples/redbook/varray.lisp 39
-(defun setup-interlave ()
-#|| static GLfloat intertwined[] =
- {1.0, 0.2, 1.0, 100.0, 100.0, 0.0,
- 1.0, 0.2, 0.2, 0.0, 200.0, 0.0,
- 1.0, 1.0, 0.2, 100.0, 300.0, 0.0,
- 0.2, 1.0, 0.2, 200.0, 300.0, 0.0,
- 0.2, 1.0, 1.0, 300.0, 200.0, 0.0,
- 0.2, 0.2, 1.0, 200.0, 100.0, 0.0};
-
- glInterleavedArrays (GL_C3F_V3F, 0, intertwined);
- ||#)
+(defun setup-interleave ()
+ (let ((intertwined '(1.0 0.2 1.0 100.0 100.0 0.0
+ 1.0 0.2 0.2 0.0 200.0 0.0
+ 1.0 1.0 0.2 100.0 300.0 0.0
+ 0.2 1.0 0.2 200.0 300.0 0.0
+ 0.2 1.0 1.0 300.0 200.0 0.0
+ 0.2 0.2 1.0 200.0 100.0 0.0)))
+
+ (gl:interleaved-arrays :c3f-v3f 0 intertwined)))
hunk ./examples/redbook/varray.lisp 49
-(defmethod initialize-instance :after ((w varray-window) &key)
+(defmethod glut:display-window :before ((w varray-window))
hunk ./examples/redbook/varray.lisp 56
- (ecase deref-method
+ (ecase (deref-method w)
hunk ./examples/redbook/varray.lisp 79
- (case (setup-method varray-window)
+ (case (setup-method w)
hunk ./examples/redbook/varray.lisp 81
- (setf (setup-method varray-window) 'interleaved)
+ (setf (setup-method w) 'interleaved)
hunk ./examples/redbook/varray.lisp 83
- (interlaved
- (setf (setup-method varray-window) 'pointer)
+ (interleaved
+ (setf (setup-method w) 'pointer)
hunk ./examples/redbook/varray.lisp 89
- (setf (deref-method varray-window)
- (case (deref-method varray-window)
+ (setf (deref-method w)
+ (ecase (deref-method w)
hunk ./examples/redbook/varray.lisp 98
- (case key
+ (case (code-char key)
hunk ./examples/redbook/varray.lisp 104
-
- (glut:init-display-mode :single :rgb)
- (make-instance 'varray-window
- :width 350 :height 350
- :pos-x 100 :pos-y 100
- :title "varray.lisp"
- :events '(:display :reshape :mouse :keyboard))
- (glut:main-loop))
+ (glut:display-window (make-instance 'varray-window)))
+
+
+
+
+
+
+
hunk ./gl/funcs.lisp 55
+(defglfun ("glArrayElement" %glArrayElement) :void
+ (i int))
+
hunk ./gl/funcs.lisp 170
+(defglfun ("glClientActiveTexture" %glClientActiveTexture) :void
+ (texture enum))
+
hunk ./gl/funcs.lisp 198
+(defglfun ("glColorPointer" %glColorPointer) :void
+ (size int)
+ (type enum)
+ (stride sizei)
+ (pointer :pointer))
+
hunk ./gl/funcs.lisp 329
+(defglfun ("glDisableClientState" %glDisableClientState) :void
+ (array enum))
+
+(defglfun ("glDisableVertexAttribArray" %glDisableVertexAttribArray) :void
+ (index uint))
+
+(defglfun ("glDrawArrays" %glDrawArrays) :void
+ (mode enum)
+ (first int)
+ (count sizei))
+
hunk ./gl/funcs.lisp 347
+(defglfun ("glDrawElements" %glDrawElements) :void
+ (mode enum)
+ (count sizei)
+ (type enum)
+ (indices :pointer))
+
hunk ./gl/funcs.lisp 358
+(defglfun ("glEdgeFlagPointer" %glEdgeFlagPointer) :void
+ (stride sizei)
+ (pointer :pointer))
+
hunk ./gl/funcs.lisp 365
+(defglfun ("glEnableClientState" %glEnableClientState) :void
+ (array enum))
+
+(defglfun ("glEnableVertexAttribArray" %glEnableVertexAttribArray) :void
+ (index uint))
+
hunk ./gl/funcs.lisp 418
+(defglfun ("glFogCoordPointer" %glFogCoordPointer) :void
+ (type enum)
+ (stride sizei)
+ (pointer :pointer))
+
hunk ./gl/funcs.lisp 580
+(defglfun ("glIndexPointer" %glIndexPointer) :void
+ (type enum)
+ (stride sizei)
+ (pointer :pointer))
+
hunk ./gl/funcs.lisp 587
+(defglfun ("glInterleavedArrays" %glInterleavedArrays) :void
+ (frmat enum)
+ (stride sizei)
+ (pointer :pointer))
+
hunk ./gl/funcs.lisp 738
+(defglfun ("glNormalPointer" %glNormalPointer) :void
+ (type enum)
+ (stride sizei)
+ (pointer :pointer))
+
hunk ./gl/funcs.lisp 898
+(defglfun ("glSecondaryColorPointer" %glSecondaryColorPointer) :void
+ (size int)
+ (type enum)
+ (stride sizei)
+ (pointer :pointer))
+
hunk ./gl/funcs.lisp 966
+(defglfun ("glTexCoordPointer" %glTexCoordPointer) :void
+ (size int)
+ (type enum)
+ (stride sizei)
+ (pointer :pointer))
+
hunk ./gl/funcs.lisp 1190
+(defglfun ("glVertexAttribPointer" %glVertexAttribPointer) :void
+ (index uint)
+ (size int)
+ (type enum)
+ (normalized boolean)
+ (stride sizei)
+ (pointer :pointer))
+
+(defglfun ("glVertexPointer" %glVertexPointer) :void
+ (size int)
+ (type enum)
+ (stride sizei)
+ (pointer :pointer))
+
hunk ./gl/opengl.lisp 125
+;;;
+;;; 2.8 Vertex Arrays
+;;;
+
+(defun vertex-pointer (size type stride lisp-array)
+ (with-opengl-sequence (array type lisp-array)
+ (%glVertexPointer size type stride array)))
+
+(defun normal-pointer (type stride lisp-array)
+ (with-opengl-sequence (array type lisp-array)
+ (%glNormalPointer type stride array)))
+
+(defun color-pointer (size type stride lisp-array)
+ (with-opengl-sequence (array type lisp-array)
+ (%glColorPointer size type stride array)))
+
+(defun secondary-color-pointer (size type stride lisp-array)
+ (with-opengl-sequence (array type lisp-array)
+ (%glSecondaryColorPointer size type stride array)))
+
+(defun index-pointer (type stride lisp-array)
+ (with-opengl-sequence (array type lisp-array)
+ (%glIndexPointer type stride array)))
+
+(defun edge-flag-pointer (stride lisp-array)
+ (with-opengl-sequence (array 'boolean lisp-array)
+ (%glEdgeFlagPointer stride array)))
+
+(defun fog-coord-pointer (type stride lisp-array)
+ (with-opengl-sequence (array type lisp-array)
+ (%glFogCoordPointer type stride array)))
+
+(defun tex-coord-pointer (size type stride lisp-array)
+ (with-opengl-sequence (array type lisp-array)
+ (%glTexCoordPointer size type stride array)))
+
+(defun vertex-attrib-pointer (index size type normalized stride lisp-array)
+ (with-opengl-sequence (array type lisp-array)
+ (%glVertexAttribPointer index size type normalized stride array)))
+
+(declaim (inline enable-client-state))
+(defun enable-client-state (state)
+ (%glEnableClientState state))
+
+(declaim (inline disable-client-state))
+(defun disable-client-state (state)
+ (%glDisableClientState state))
+
+(declaim (inline client-active-texture))
+(defun client-active-texture (enum)
+ (%glClientActiveTexture enum))
+
+(declaim (inline array-element))
+(defun array-element (i)
+ (%glArrayElement i))
+
+(declaim (inline draw-arrays))
+(defun draw-arrays (mode first count)
+ (%glDrawArrays mode first count))
+
+;; (defun multi-draw-arrays ())
+
+(defun draw-elements (mode count type lisp-indices)
+ (with-opengl-sequence (indices type lisp-indices)
+ (%glDrawElements mode count type indices)))
+
+;; (defun draw-range-elements ())
+
+(defun interleaved-arrays (format stride lisp-array)
+ ;;array type needs more logic I think
+ ;;float is quick hack to get working with redbook varray example
+ (with-opengl-sequence (array 'float lisp-array)
+ (%glInterleavedArrays format stride array)))
+
hunk ./gl/package.lisp 65
+ ;; 2.8 Vertex Arrays
+ #:vertex-pointer
+ #:normal-pointer
+ #:color-pointer
+ #:secondary-color-pointer
+ #:index-pointer
+ #:edge-flag-pointer
+ #:fog-coord-pointer
+ #:tex-coord-pointer
+ #:vertex-attrib-pointer
+ #:enable-client-state
+ #:disable-client-state
+ #:client-active-texture
+ #:array-element
+ #:draw-arrays
+;; #:multi-draw-arrays
+ #:draw-elements
+;; #:multi-draw-elements
+;; #:draw-range-elements
+ #:interleaved-arrays
hunk ./gl/util.lisp 111
+
+(defun convert-seq (type lisp-sequence)
+ (case type
+ ((float :float) (mapcar #'float lisp-sequence))
+ ((double :double) (mapcar #'(lambda (x) (float x 1.0d0))
+ lisp-sequence))
+ (t lisp-sequence)))
+
hunk ./gl/util.lisp 121
- (flet ((converting (form) ; um, assuming type is constant
- (case (eval type) ; silly hack.. FIXME
- (float `(float ,form))
- (double `(float ,form 1.0d0))
- (t form))))
- (let ((count (gensym "COUNT")))
- (once-only (type lisp-sequence)
- `(let ((,count (length ,lisp-sequence)))
- (with-foreign-object (,var ,type ,count)
- (loop for i below ,count
- do (setf (mem-aref ,var ,type i)
- ,(converting `(elt ,lisp-sequence i))))
- , at body))))))
+ (let ((count (gensym "COUNT"))
+ (typed-seq (convert-seq type lisp-sequence)))
+ (once-only (type typed-seq)
+ `(let ((,count (length ,typed-seq)))
+ (with-foreign-object (,var ,type ,count)
+ (loop for i below ,count
+ do (setf (mem-aref ,var ,type i)
+ (elt ,typed-seq i)))
+ , at body)))))
}
Context:
[Misc patch
Luis Oliveira <loliveira at common-lisp.net>**20061117024105
Patch courtesy of Bart Botta.
]
[Applied patch from Bart Botta
Oliver Markovic <entrox at entrox.org>**20061112111533]
[Pushed wrong version of render-to-texture.lisp; fixed
Oliver Markovic <entrox at entrox.org>**20061111152828]
[Add render-to-texture example
Oliver Markovic <entrox at entrox.org>**20061111151241
- Add new example in examples/misc/ illustrating the use of FBOs
]
[Add support for buffer objects
Oliver Markovic <entrox at entrox.org>**20061111151103
- Add vertex and pixel buffer objects
- Add support for the EXT_framebuffer_object extension
]
[Fix downcasing issues with enum generation.
James Bielman <jamesjb at jamesjb.com>**20060830200239]
[Implement GLU projection functions.
James Bielman <jamesjb at jamesjb.com>**20060828054332
- New exported functions: GLU:PROJECT, GLU:UN-PROJECT, GLU:UN-PROJECT4.
- New utility macro: WITH-OPENGL-ARRAYS for binding multiple arrays.
]
[Implement numeric OpenGL state querying functions.
James Bielman <jamesjb at jamesjb.com>**20060828054131
- New exported functions: GET-BOOLEAN, GET-DOUBLE, GET-FLOAT,
GET-INTEGER, and GET-ENUM. These functions are able to automatically
return the correct number of return values when the query enum is
in the *QUERY-ENUM-SIZES* table.
]
[Replace separate enum types with generated GL:ENUM.
James Bielman <jamesjb at jamesjb.com>**20060828052308]
[Add a script to generate OpenGL constants from the specifiction.
James Bielman <jamesjb at jamesjb.com>**20060828051427]
[Add OpenGL specification data files for enum values.
James Bielman <jamesjb at jamesjb.com>**20060828051348]
[Define foreign functions inline via DEFGLFUN helper macro.
James Bielman <jamesjb at jamesjb.com>**20060828045747]
[Move GL function DEFCFUNs into funcs.lisp.
James Bielman <jamesjb at jamesjb.com>**20060828045514]
[More 64-bit-cleanliness fixes, use ints instead of longs.
James Bielman <jamesjb at jamesjb.com>**20060828044816]
[Fix bug in WITH-OPENGL-ARRAY when VAR and LISP-ARRAY are the same.
James Bielman <jamesjb at jamesjb.com>**20060823210517]
[Use :INT as the base type for GL:INT and GL:SIZEI.
James Bielman <jamesjb at jamesjb.com>**20060823171453
- Using :LONG broke on 64-bit Linux. According to the GL header on my
Linux system, GLint and GLsizei are of C type 'int'.
]
[Minor fix to glut/interface.lisp
Luis Oliveira <loliveira at common-lisp.net>**20060703224124]
[CL-GLUT update
Luis Oliveira <loliveira at common-lisp.net>**20060624235928
- Fix foreign-symbol-pointer usage in glut/fonts.lisp.
- Move enums next to the DEFCFUNs where they're used.
- Rework the CL-GLUT CLOS interface.
- Reorganize examples and rewrite them using the updated CLOS interface.
]
[s/windows/cffi-features:windows
Luis Oliveira <loliveira at common-lisp.net>**20060425212810]
[Convert array contents to floats in MAP1 and MAP2.
James Bielman <jamesjb at jamesjb.com>**20060412015458]
[Add evaluator constants to the ENABLE-CAP enum.
James Bielman <jamesjb at jamesjb.com>**20060412015045]
[New example: glut-teapot.lisp
Luis Oliveira <loliveira at common-lisp.net>**20060326211537
Also, fixed a typo in the README and added a README for the examples.
]
[GLUT: add missing event and fix typo
Luis Oliveira <loliveira at common-lisp.net>**20060221054305
- Missing event: passive-motion.
- fullscreen -> full-screen
- move the (setf title) magic to a :before method.
]
[Minor fixes to the examples
Luis Oliveira <loliveira at common-lisp.net>**20060221054151
- add ignore declarations to unused arguments.
- use MOD!
]
[Oops. Forgot to darcs add examples/mesademos/package.lisp
Luis Oliveira <loliveira at common-lisp.net>**20060219211853]
[More examples
Luis Oliveira <loliveira at common-lisp.net>**20060218054241
- New examples: rb{6,7,8,9,10,11,12,13}.
- Use with-new-list in mesademos/gears.lisp.
- Add copyright notices to examples.
- Fix example 4 which was drawing *halftone* twice.
]
[with-new-list, with-primitive and call-lists
Luis Oliveira <loliveira at common-lisp.net>**20060218051830]
[GLUT: use gl:ensure-double
Luis Oliveira <loliveira at common-lisp.net>**20060217231013]
[Small change to with-opengl-sequence
Luis Oliveira <loliveira at common-lisp.net>**20060217224915
- Make it convert the sequence's elements to float or double
when the type is gl:float or gl:double respectively. Breaks
when type isn't constant, oops.
]
[Tiny update to GLU
Luis Oliveira <loliveira at common-lisp.net>**20060217222227
- Mostly move files around. (remind not to create stub files again, ugh)
- Added some new functions.
]
[New types: gl:ensure-double and gl:ensure-float
Luis Oliveira <loliveira at common-lisp.net>**20060217221729
- Define and export ensure-double and ensure-float. (these need a recent
CFFI)
- Also export some types that'll be needed for GLU. Maybe a gl-types
package would be a good idea?
]
[Oops. Forgot darcs add.
Luis Oliveira <loliveira at common-lisp.net>**20060207034827]
[New examples
Luis Oliveira <loliveira at common-lisp.net>**20060207032245
- New 5 examples from the redbook.
- 2 GLU functions needed for the examples.
- Added gl:polygon-stipple needed for one of the examples.
- Fixed silly bugs in cl-glut's ascii-to-char type and
the base-window initialize-instance.
- Moved window's title initform to a special.
]
[Preliminary CLOS interface to GLUT
Luis Oliveira <loliveira at common-lisp.net>**20060206182638
- Removed a german 'ss' from rasterization.lisp which was upsetting SBCL.
- New macro WITH-PUSHED-MATRIX. WITH-MATRIX might be a better name?
- New experimental CLOS-based interface to GLUT.
- New example using the new CLOS interface. Moved old gears exmample
to gears-raw.lisp.
]
[Optimizations (needs recent CFFI again)
Luis Oliveira <loliveira at common-lisp.net>**20060203014020
- Add declarations in gears.lisp
- Define the gl:* types to have no translation
]
[Use internal-time-units-per-second
Luis Oliveira <loliveira at common-lisp.net>**20060202200413]
[Add fps counter to examples/mesademos/gears.lisp
Luis Oliveira <loliveira at common-lisp.net>**20060202195354]
[Texturing functions added.
Oliver Markovic <entrox at entrox.org>**20060202185907
- Added preliminary support for glTexImage and glTexSubImage. I'm still not sure
on how to handle the data.
- Added glCopyTexImage and glCopyTexSubImage
- Added glAreTexturesResident and glPrioritizeTextures along with TEXTURE-RESIDENT-P
and PRIORITIZE-TEXTURE, which are hopefully less awkward to use than the direct
translations.
- Added glTexEnv.
]
[Oops. Missing glut/main.lisp file.
Luis Oliveira <loliveira at common-lisp.net>**20060202190632]
[GLUT update, less straw.
Luis Oliveira <loliveira at common-lisp.net>**20060202124342
(requires recent cffi patches fixing defcenum issue and
implementing defbitfield)
- add missing depends-on to funcs in cl-opengl.asd
- complete glut bindings. next step: high level interface.
]
[Add glutSetOption.
Alexey Dvoychenkov <keriax at gmail.com>**20060202031904]
[Big patch, lots of straw again.
Luis Oliveira <loliveira at common-lisp.net>**20060201164339
- GLU: added asd file and stub .lisp files.
- Examples:
- added cl-glut-examples.asd
- new example: gears.lisp
- GLUT: added asd file and implemented a few routines. (mostly those
needed by the gears.lisp example)
- Add my name to HEADER too.
- 3 separate manuals is probably overkill? Use only one for now.
- GL:
- fixed enums, these should canonicalize to GLenum, not int.
- renamed gl types from GLfoo to gl:foo (and exported them)
- fixed erroneus check-type.
- look for libGL.so.N if libGL.so isn't found.
- removed some tabs from the files.
- added missing space between ":constant-attenuation" and
"linear-attenuation".
- added missing (declare (ignore ..)) to avoid warnings.
- fixed a small bug/typo where a foreign array was being accessed
as if it were Lisp array.
- change ;;;-comments to ;;-comments in package.lisp in order to
indent well.
]
[Add documentation structure.
Luis Oliveira <loliveira at common-lisp.net>**20060201013908
Just straw, no content. Taken from cffi mostly.
]
[Minor changes
Luis Oliveira <loliveira at common-lisp.net>**20060131190956
- added HEADER file.
- changed library.lisp to use BSD license.
- removed tabs from state.lisp
]
[Added examples directory.
Oliver Markovic <entrox at entrox.org>**20060131120521]
[Initial revision.
Oliver Markovic <entrox at entrox.org>**20060131115438]
Patch bundle hash:
841fe3384f34b042a1df602d779c59cf4e8f3f71
More information about the cl-opengl-devel
mailing list