Hello, I've implemented some of the functions in section 6.1.14 Shader and Program Queries. This also led to the FIXMEs in get-active-attrib and get-active-uniform being fixed (they relied on fixed buffer-sizes which are now queried).
Sincerely, Mikael Lax
New patches: [Implement some shader/program queries. Clear two FIXMEs. Mikael Lax <[EMAIL PROTECTED]>**20070912144020] { hunk ./gl/opengl.lisp 556 - ;; FIXME: query size of character buffer - (with-foreign-objects ((characters-written '%gl:sizei) - (size '%gl:int) - (type :long) - (name '%gl:char 1024)) - (%gl:get-active-attrib program index 1024 characters-written size type name) - (when (< 0 (mem-ref characters-written '%gl:sizei)) - (values (mem-ref size '%gl:int) - (foreign-enum-keyword '%gl:enum (mem-ref type :long)) - (foreign-string-to-lisp name))))) + (let ((attrib-max-length (get-program program :active-attribute-max-length))) + (with-foreign-objects ((characters-written '%gl:sizei) + (size '%gl:int) + (type :long) + (name '%gl:char attrib-max-length)) + (%gl:get-active-attrib program index attrib-max-length + characters-written size type name) + (when (< 0 (mem-ref characters-written '%gl:sizei)) + (values (mem-ref size '%gl:int) + (foreign-enum-keyword '%gl:enum (mem-ref type :long)) + (foreign-string-to-lisp name)))))) hunk ./gl/opengl.lisp 585 - ;; FIXME: query size of character buffer - (with-foreign-objects ((characters-written '%gl:sizei) - (size '%gl:int) - (type :long) - (name '%gl:char 1024)) - (%gl:get-active-uniform program index 1024 characters-written size type name) - (when (< 0 (mem-ref characters-written '%gl:sizei)) - (values (mem-ref size '%gl:int) - (foreign-enum-keyword '%gl:enum (mem-ref type :long)) - (foreign-string-to-lisp name))))) + (let ((uniform-max-length (get-program program :active-uniform-max-length))) + (with-foreign-objects ((characters-written '%gl:sizei) + (size '%gl:int) + (type :long) + (name '%gl:char uniform-max-length)) + (%gl:get-active-uniform program index uniform-max-length + characters-written size type name) + (when (< 0 (mem-ref characters-written '%gl:sizei)) + (values (mem-ref size '%gl:int) + (foreign-enum-keyword '%gl:enum (mem-ref type :long)) + (foreign-string-to-lisp name)))))) hunk ./gl/package.lisp 296 + ;; 6.1.14 Shader and Program Queries + #:is-shader + #:get-shader + #:is-program + #:get-program + #:get-attached-shaders + #:get-shader-info-log + #:get-program-info-log + #:get-shader-source hunk ./gl/state.lisp 424 + +;;; 6.1.14 Shader and Program Queries + +(import-export %gl:is-shader) + +(define-get-function get-shader-aux (shader pname) + (%gl:get-shader-iv :int int)) + +(defun get-shader (shader pname) + (case pname + ((:delete-status :compile-status) + ;; Return a boolean for these. + (plusp (get-shader-aux shader pname :int))) + (otherwise + (get-shader-aux shader pname :int)))) + +(import-export %gl:is-program) + +(define-get-function get-program-aux (program pname) + (%gl:get-program-iv :int int)) + +(defun get-program (program pname) + (case pname + ((:delete-status :link-status :validate-status) + ;; Return a boolean for these. + (plusp (get-program-aux program pname :int))) + (otherwise + (get-program-aux program pname :int)))) + +(defun get-attached-shaders (program) + "Returns a list of the shaders attached to PROGRAM" + (let ((max-shaders (get-program program :attached-shaders))) + (with-foreign-object (shaders '%gl:uint max-shaders) + (%gl:get-attached-shaders program max-shaders (null-pointer) shaders) + (loop for i below max-shaders + collecting (mem-aref shaders '%gl:uint i))))) + +(defun get-shader-info-log (shader) + "Returns as a string the entire info log for SHADER" + (let ((info-log-length (get-shader shader :info-log-length))) + (with-foreign-object (info-log '%gl:char info-log-length) + (%gl:get-shader-info-log shader info-log-length (null-pointer) info-log) + (foreign-string-to-lisp info-log)))) + +(defun get-program-info-log (program) + "Returns as a string the entire info log for PROGRAM" + (let ((info-log-length (get-program program :info-log-length))) + (with-foreign-object (info-log '%gl:char info-log-length) + (%gl:get-program-info-log program info-log-length (null-pointer) info-log) + (foreign-string-to-lisp info-log)))) + +(defun get-shader-source (shader) + "Returns as a string the entire source of SHADER" + (let ((source-length (get-shader shader :shader-source-length))) + (with-foreign-object (source '%gl:char source-length) + (%gl:get-shader-source shader source-length (null-pointer) source) + (foreign-string-to-lisp source)))) } Context: [Compressed textures and draw/read-pixels Mikael Lax <[EMAIL PROTECTED]>**20070510115014] [glut package: fix spelling of solid-icosahedron Luis Oliveira <[EMAIL PROTECTED]>**20070502184621] [glut/interface.lisp: fix bug re the ascii-to-char type Luis Oliveira <[EMAIL PROTECTED]>**20070502182307] [sbcl/x86-64: disable floating point traps Luis Oliveira <[EMAIL PROTECTED]>**20070403222155] [Fix the ensure-float type to work with doubles Luis Oliveira <[EMAIL PROTECTED]>**20070323045220 Bug reported by alastair37. ] [with-foreign-matrix: use %gl:float instead of :float Luis Oliveira <[EMAIL PROTECTED]>**20070323040609] [Preliminary support for vertex arrays and VBOs courtesy of Thomas Weidner. Luis Oliveira <[EMAIL PROTECTED]>**20070314221152 ] [Remove useless cl-glut-examples-system package Luis Oliveira <[EMAIL PROTECTED]>**20070311011401] [Small change to generate-gl-function Luis Oliveira <[EMAIL PROTECTED]>**20070311002941 - test with pointerp and null-pointer-p ] [Fix name mangling Luis Oliveira <[EMAIL PROTECTED]>**20070309070443 Patch courtesy of Bart Botta. - fixes lispification of a bunch of the new function names. - more type info for array of pointer args (:pointer (:pointer type)) instead of (:pointer :pointer). ] [More simplification. Luis Oliveira <[EMAIL PROTECTED]>**20070307214020 - Use definline and import-export throughout the rest of the bindings. ] [Fix some function names, simplify lispifications Luis Oliveira <[EMAIL PROTECTED]>**20070307191242 - Fixed regex in generate-funcs.lisp and regenerated funcs.lisp. - New macros import-export and definline. - Used them in opengl.lisp. ] [Fix type names in gl/util.lisp Luis Oliveira <[EMAIL PROTECTED]>**20070307011242] [New DEFGLEXTFUN and other minor changes Luis Oliveira <[EMAIL PROTECTED]>**20070307010114 - New DEFGLEXTFUN macro courtesy of Thomas Weidner. - GLUT: set %gl:*gl-get-proc-address* to glut:get-proc-address. ] [Change :color-buffer-bit to :color-buffer, etc, in the examples Luis Oliveira <[EMAIL PROTECTED]>**20070306043408] [Fix typo in gl/opengl.lisp Luis Oliveira <[EMAIL PROTECTED]>**20070306040804] [Add missing gl/bindings.lisp Luis Oliveira <[EMAIL PROTECTED]>**20070306034316] [Fix glu, glut and gl/opengl.lisp with new names Luis Oliveira <[EMAIL PROTECTED]>**20070306033727] [Mega patch from Bart Botta Luis Oliveira <[EMAIL PROTECTED]>**20070306024546 - Merged Bart Botta's stuff for generating gl/funcs.lisp from the .spec files. Also adds new cl-opengl-bindings package with low-level functions. Fixed some parsing bugs. - Updated for OpenGL 2.1. (enums, too) ] [GL enum changes Luis Oliveira <[EMAIL PROTECTED]>**20070305153651 - Updated .spec files for OpenGL 2.1. - Two changes to generate-enums.lisp: * print the symbols lower-cased; * generates some aliases for symbols ending in -bits and -bit. e.g.: :color-buffer-bit and :color-buffer. - Regenerated gl/constants.lisp. ] [Add Lispy abstraction for GLUT's TIMER event. Luis Oliveira <[EMAIL PROTECTED]>**20070304220421] [Make foreign types work with CFFI's new type system. Luis Oliveira <[EMAIL PROTECTED]>**20070304220240] [Some old changes to the manual.. Luis Oliveira <[EMAIL PROTECTED]>**20070304220205] [vertex array addition [EMAIL PROTECTED] Added mostly working functionality for vertex arrays. "with-opengl-sequence" macro modified (hopefully correctly) in gl/util.lisp, possible danger of code breakage. ] [Misc patch Luis Oliveira <[EMAIL PROTECTED]>**20061117024105 Patch courtesy of Bart Botta. ] [Applied patch from Bart Botta Oliver Markovic <[EMAIL PROTECTED]>**20061112111533] [Pushed wrong version of render-to-texture.lisp; fixed Oliver Markovic <[EMAIL PROTECTED]>**20061111152828] [Add render-to-texture example Oliver Markovic <[EMAIL PROTECTED]>**20061111151241 - Add new example in examples/misc/ illustrating the use of FBOs ] [Add support for buffer objects Oliver Markovic <[EMAIL PROTECTED]>**20061111151103 - Add vertex and pixel buffer objects - Add support for the EXT_framebuffer_object extension ] [Fix downcasing issues with enum generation. James Bielman <[EMAIL PROTECTED]>**20060830200239] [Implement GLU projection functions. James Bielman <[EMAIL PROTECTED]>**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 <[EMAIL PROTECTED]>**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 <[EMAIL PROTECTED]>**20060828052308] [Add a script to generate OpenGL constants from the specifiction. James Bielman <[EMAIL PROTECTED]>**20060828051427] [Add OpenGL specification data files for enum values. James Bielman <[EMAIL PROTECTED]>**20060828051348] [Define foreign functions inline via DEFGLFUN helper macro. James Bielman <[EMAIL PROTECTED]>**20060828045747] [Move GL function DEFCFUNs into funcs.lisp. James Bielman <[EMAIL PROTECTED]>**20060828045514] [More 64-bit-cleanliness fixes, use ints instead of longs. James Bielman <[EMAIL PROTECTED]>**20060828044816] [Fix bug in WITH-OPENGL-ARRAY when VAR and LISP-ARRAY are the same. James Bielman <[EMAIL PROTECTED]>**20060823210517] [Use :INT as the base type for GL:INT and GL:SIZEI. James Bielman <[EMAIL PROTECTED]>**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 <[EMAIL PROTECTED]>**20060703224124] [CL-GLUT update Luis Oliveira <[EMAIL PROTECTED]>**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 <[EMAIL PROTECTED]>**20060425212810] [Convert array contents to floats in MAP1 and MAP2. James Bielman <[EMAIL PROTECTED]>**20060412015458] [Add evaluator constants to the ENABLE-CAP enum. James Bielman <[EMAIL PROTECTED]>**20060412015045] [New example: glut-teapot.lisp Luis Oliveira <[EMAIL PROTECTED]>**20060326211537 Also, fixed a typo in the README and added a README for the examples. ] [GLUT: add missing event and fix typo Luis Oliveira <[EMAIL PROTECTED]>**20060221054305 - Missing event: passive-motion. - fullscreen -> full-screen - move the (setf title) magic to a :before method. ] [Minor fixes to the examples Luis Oliveira <[EMAIL PROTECTED]>**20060221054151 - add ignore declarations to unused arguments. - use MOD! ] [Oops. Forgot to darcs add examples/mesademos/package.lisp Luis Oliveira <[EMAIL PROTECTED]>**20060219211853] [More examples Luis Oliveira <[EMAIL PROTECTED]>**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 <[EMAIL PROTECTED]>**20060218051830] [GLUT: use gl:ensure-double Luis Oliveira <[EMAIL PROTECTED]>**20060217231013] [Small change to with-opengl-sequence Luis Oliveira <[EMAIL PROTECTED]>**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 <[EMAIL PROTECTED]>**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 <[EMAIL PROTECTED]>**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 <[EMAIL PROTECTED]>**20060207034827] [New examples Luis Oliveira <[EMAIL PROTECTED]>**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 <[EMAIL PROTECTED]>**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. ] [Texturing functions added. Oliver Markovic <[EMAIL PROTECTED]>**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. ] [Optimizations (needs recent CFFI again) Luis Oliveira <[EMAIL PROTECTED]>**20060203014020 - Add declarations in gears.lisp - Define the gl:* types to have no translation ] [Use internal-time-units-per-second Luis Oliveira <[EMAIL PROTECTED]>**20060202200413] [Add fps counter to examples/mesademos/gears.lisp Luis Oliveira <[EMAIL PROTECTED]>**20060202195354] [Oops. Missing glut/main.lisp file. Luis Oliveira <[EMAIL PROTECTED]>**20060202190632] [GLUT update, less straw. Luis Oliveira <[EMAIL PROTECTED]>**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 <[EMAIL PROTECTED]>**20060202031904] [Big patch, lots of straw again. Luis Oliveira <[EMAIL PROTECTED]>**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 <[EMAIL PROTECTED]>**20060201013908 Just straw, no content. Taken from cffi mostly. ] [Minor changes Luis Oliveira <[EMAIL PROTECTED]>**20060131190956 - added HEADER file. - changed library.lisp to use BSD license. - removed tabs from state.lisp ] [Added examples directory. Oliver Markovic <[EMAIL PROTECTED]>**20060131120521] [Initial revision. Oliver Markovic <[EMAIL PROTECTED]>**20060131115438] Patch bundle hash: 8eb98b9bfb5c4054fd3803c1fc069a476962f799
_______________________________________________ cl-opengl-devel mailing list cl-opengl-devel@common-lisp.net http://common-lisp.net/cgi-bin/mailman/listinfo/cl-opengl-devel