More work on webgl

This commit is contained in:
David Botton 2022-08-14 14:21:54 -04:00
parent 00446e4f83
commit 67ceca8c18

View file

@ -12,46 +12,74 @@
(cl:in-package :clog-webgl) (cl:in-package :clog-webgl)
;; Use clog-canvas to create the html element and then use
;; clog-webgl:create-webgl to obtain the WebGL2 context
(defsection @clog-webgl (:title "CLOG WebGL Objects") (defsection @clog-webgl (:title "CLOG WebGL Objects")
"CLOG-WebGL - Class for CLOG WebGL objects" "CLOG-WebGL - Class for CLOG WebGL objects"
(clog-webgl class) (clog-webgl class)
(create-webgl generic-function) (create-webgl generic-function)
(drawing-buffer-width generic-function) (drawing-buffer-width generic-function)
(drawing-buffer-height generic-function) (drawing-buffer-height generic-function)
(buffer-parameter generic-function)
(context-attributes generic-function)
(webgl-error generic-function)
(frame-buffer-attachment-parameter generic-function)
(parameter generic-function)
(render-buffer-parameter generic-function)
(texture-paramenter generic-function)
(vertex-attribute generic-function)
(active-texture generic-function) (active-texture generic-function)
(blend-color generic-function) (blend-color generic-function)
(blend-equation generic-function) (blend-equation generic-function)
(blend-equation-seperate generic-function) (blend-equation-seperate generic-function)
(blend-function generic-function) (blend-function generic-function)
(blend-function-seperate generic-function) (blend-function-seperate generic-function)
(check-frame-buffer-status generic-function) (check-frame-buffer-status generic-function)
(clear-color generic-function) (clear-color generic-function)
(clear-depth generic-function) (clear-depth generic-function)
(clear-webgl generic-function) (clear-webgl generic-function)
(clear-stencil generic-function) (clear-stencil generic-function)
(color-mask generic-function) (color-mask generic-function)
(depth-function generic-function) (depth-function generic-function)
(depth-mask generic-function) (depth-mask generic-function)
(depth-range generic-function) (depth-range generic-function)
(disable generic-function) (disable-capability generic-function)
(disable-vertex-attribute-array generic-function) (disable-vertex-attribute-array generic-function)
(draw-arrays generic-function) (draw-arrays generic-function)
(draw-elements generic-function) (draw-elements generic-function)
(enable generic-function) (enable-capability generic-function)
(enable-vertex-attribute-array generic-function) (enable-vertex-attribute-array generic-function)
(finish generic-function) (finish generic-function)
(flush generic-function) (flush generic-function)
(frame-buffer-render-buffer generic-function) (frame-buffer-render-buffer generic-function)
(frame-buffer-texture-2d generic-function) (frame-buffer-texture-2d generic-function)
(front-face generic-function) (front-face generic-function)
(generate-mipmap generic-function) (generate-mipmap generic-function)
(viewport generic-function) (hint generic-function)
(vertex-attribute-pointer generic-function) (is-capability-enabled generic-function)
(is-context-lost generic-function)
(pixel-store-integer generic-function)
(polygon-offset generic-function)
(render-buffer-storage generic-function)
(sample-coverage generic-function)
(scissor generic-function)
(stencil-function generic-function)
(stencil-function-seperate generic-function)
(stencil-mask generic-function)
(stencil-mask-seperate generic-function)
(stencil-operation generic-function)
(stencil-operation-seperate generic-function)
(texture-parameter-float generic-function)
(texture-parameter-integer generic-function)
(viewport generic-function)
(vertex-attribute-pointer generic-function)
(compile-shader-source generic-function) (compile-shader-source generic-function)
(compile-webgl-program generic-function) (compile-webgl-program generic-function)
"CLOG-WebGL-Active-Info - Class for CLOG WebGL Active Info objects" "CLOG-WebGL-Active-Info - Class for CLOG WebGL Active Info objects"
(clog-webgl-active-info class) (clog-webgl-active-info class)
@ -62,6 +90,7 @@
"CLOG-WebGL-Shader - Class for CLOG WebGL-Shader objects" "CLOG-WebGL-Shader - Class for CLOG WebGL-Shader objects"
(clog-webgl-shader class) (clog-webgl-shader class)
(create-shader generic-function) (create-shader generic-function)
(is-shader generic-function)
(shader-source generic-function) (shader-source generic-function)
(shader-parameter generic-function) (shader-parameter generic-function)
@ -72,6 +101,7 @@
"CLOG-WebGL-Program - Class for CLOG WebGL-Program objects" "CLOG-WebGL-Program - Class for CLOG WebGL-Program objects"
(clog-webgl-program class) (clog-webgl-program class)
(create-program generic-function) (create-program generic-function)
(is-program generic-function)
(attach-shader generic-function) (attach-shader generic-function)
(detach-shader generic-function) (detach-shader generic-function)
@ -81,6 +111,7 @@
(uniform-location generic-function) (uniform-location generic-function)
(active-attribute generic-function) (active-attribute generic-function)
(active-uniform generic-function) (active-uniform generic-function)
(uniform generic-function)
(program-info-log generic-function) (program-info-log generic-function)
(link-program generic-function) (link-program generic-function)
(use-program generic-function) (use-program generic-function)
@ -89,6 +120,8 @@
"CLOG-WebGL-Buffer - Class for CLOG WebGL-Buffer objects" "CLOG-WebGL-Buffer - Class for CLOG WebGL-Buffer objects"
(clog-webgl-buffer class) (clog-webgl-buffer class)
(create-webgl-buffer generic-function) (create-webgl-buffer generic-function)
(is-buffer generic-function)
(bind-buffer generic-function) (bind-buffer generic-function)
(buffer-data generic-function) (buffer-data generic-function)
(buffer-sub-data generic-function) (buffer-sub-data generic-function)
@ -103,24 +136,27 @@
"CLOG-WebGL-Frame-Buffer - Class for CLOG WebGL-Frame-Buffer objects" "CLOG-WebGL-Frame-Buffer - Class for CLOG WebGL-Frame-Buffer objects"
(clog-webgl-frame-buffer class) (clog-webgl-frame-buffer class)
(create-webgl-frame-buffer generic-function) (create-webgl-frame-buffer generic-function)
(is-frame-buffer generic-function)
(bind-frame-buffer generic-function) (bind-frame-buffer generic-function)
(delete-frame-buffer generic-function) (delete-frame-buffer generic-function)
"CLOG-WebGL-Render-Buffer - Class for CLOG WebGL-Render-Buffer objects" "CLOG-WebGL-Render-Buffer - Class for CLOG WebGL-Render-Buffer objects"
(clog-webgl-render-buffer class) (clog-webgl-render-buffer class)
(create-webgl-render-buffer generic-function) (create-webgl-render-buffer generic-function)
(is-render-buffer generic-function)
(bind-render-buffer generic-function) (bind-render-buffer generic-function)
(delete-render-buffer generic-function) (delete-render-buffer generic-function)
"CLOG-WebGL-Texture - Class for CLOG WebGL-Texture objects" "CLOG-WebGL-Texture - Class for CLOG WebGL-Texture objects"
(clog-webgl-texture class) (clog-webgl-texture class)
(create-webgl-texture generic-function) (create-webgl-texture generic-function)
(is-texture generic-function)
(bind-texture generic-function) (bind-texture generic-function)
(delete-texture generic-function)) (delete-texture generic-function))
;; Use clog-canvas to create the html element and then use clog-webgl
;; to obtain the WebGL2 context
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Implementation - clog-webgl ;; Implementation - clog-webgl
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -161,6 +197,150 @@ can be webgl (version 1) or webgl2 (default)"))
(defmethod drawing-buffer-height ((obj clog-webgl)) (defmethod drawing-buffer-height ((obj clog-webgl))
(parse-float (query obj "drawingBufferHeight"))) (parse-float (query obj "drawingBufferHeight")))
(defgeneric buffer-parameter (clog-webgl glenum-target glenum-pname)
(:documentation "Returns information about the buffer.
target
------
A GLenum specifying the target buffer object. Possible values:
:ARRAY_BUFFER
Buffer containing vertex attributes, such as vertex coordinates, texture coordinate data, or vertex color data.
:ELEMENT_ARRAY_BUFFER
Buffer used for element indices.
When using a WebGL 2 context, the following values are available additionally:
:COPY_READ_BUFFER
Buffer for copying from one buffer object to another.
:COPY_WRITE_BUFFER
Buffer for copying from one buffer object to another.
:TRANSFORM_FEEDBACK_BUFFER
Buffer for transform feedback operations.
:UNIFORM_BUFFER
Buffer used for storing uniform blocks.
:PIXEL_PACK_BUFFER
Buffer used for pixel transfer operations.
:PIXEL_UNPACK_BUFFER
Buffer used for pixel transfer operations.
pname
-----
A GLenum specifying information to query. Possible values:
:BUFFER_SIZE
Returns a GLint indicating the size of the buffer in bytes.
:BUFFER_USAGE
Returns a GLenum indicating the usage pattern of the buffer. One of the followings:
:STATIC_DRAW
:DYNAMIC_DRAW
:STREAM_DRAW
When using a WebGL 2 context, the following values are available additionally:
:STATIC_READ
:DYNAMIC_READ
:STREAM_READ
:STATIC_COPY
:DYNAMIC_COPY
:STREAM_COPY"))
(defmethod buffer-parameter ((obj clog-webgl) glenum-target glenum-pname)
(query obj (format nil "getBufferParameter(~A.~A,~A.~A)"
(script-id obj) glenum-target
(script-id obj) glenum-pname)))
(defmethod context-attributes ((obj clog-webgl))
(query obj "getContextAttributes()"))
(defmethod webgl-error ((obj clog-webgl))
(parse-integer (query obj "getError()")))
;; WebGLRenderingContext.getExtension()
(defmethod frame-buffer-attachment-parameter ((obj clog-webgl) glenum-target
glenum-attachment
glenum-pname)
(query obj (format nil "getFramebufferAttachmentParameter(~A.~A,~A.~A,~A.~A)"
(script-id obj) glenum-target
(script-id obj) glenum-attachment
(script-id obj) glenum-pname)))
(defmethod parameter ((obj clog-webgl) glenum-pname)
(query obj (format nil "getParameter(~A.~A)"
(script-id obj) glenum-pname)))
(defmethod render-buffer-parameter ((obj clog-webgl) glenum-target glenum-pname)
(query obj (format nil "getRenderbufferParameter(~A.~A,~A.~A)"
(script-id obj) glenum-target
(script-id obj) glenum-pname)))
;; WebGLRenderingContext.getShaderPrecisionFormat()
;; WebGLRenderingContext.getShaderSource()
;; WebGLRenderingContext.getSupportedExtensions()
(defmethod texture-parameter ((obj clog-webgl) glenum-target glenum-pname)
(query obj (format nil "getTexParameter(~A.~A,~A.~A)"
(script-id obj) glenum-target
(script-id obj) glenum-pname)))
(defgeneric vertex-attribute (clog-webgl index glenum-pname)
(:documentation "Information about a vertex attribute at a given position.
pname
-----
A GLenum specifying the information to query. Possible values:
:VERTEX_ATTRIB_ARRAY_BUFFER_BINDING
Returns the currently bound WebGLBuffer.
:VERTEX_ATTRIB_ARRAY_ENABLED
Returns a GLboolean that is true if the vertex attribute is enabled at this index. Otherwise false.
:VERTEX_ATTRIB_ARRAY_SIZE
Returns a GLint indicating the size of an element of the vertex array.
:VERTEX_ATTRIB_ARRAY_STRIDE
Returns a GLint indicating the number of bytes between successive elements in the array. 0 means that the elements are sequential.
:VERTEX_ATTRIB_ARRAY_TYPE
Returns a GLenum representing the array type. One of
:BYTE
:UNSIGNED_BYTE
:SHORT,
:UNSIGNED_SHORT
:FLOAT
:VERTEX_ATTRIB_ARRAY_NORMALIZED
Returns a GLboolean that is true if fixed-point data types are normalized for the vertex attribute array at the given index.
:CURRENT_VERTEX_ATTRIB
Returns a Float32Array (with 4 elements) representing the current value of the vertex attribute at the given index.
When using a WebGL 2 context, the following values are available additionally:
:VERTEX_ATTRIB_ARRAY_INTEGER
Returns a GLboolean indicating whether an integer data type is in the vertex attribute array at the given index.
:VERTEX_ATTRIB_ARRAY_DIVISOR
Returns a GLint describing the frequency divisor used for instanced rendering."))
(defmethod vertex-attribute ((obj clog-webgl) index glenum-pname)
(query obj (format nil "getVertexAttrib(~A,~A.~A)"
index
(script-id obj) glenum-pname)))
;; WebGLRenderingContext.getVertexAttribOffset()
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Methdods - clog-webgl ;; Methdods - clog-webgl
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -361,6 +541,22 @@ https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/disable")
(execute obj (format nil "disable(~A.~A)" (execute obj (format nil "disable(~A.~A)"
(script-id obj) glenum-capability))) (script-id obj) glenum-capability)))
(defgeneric is-capability-enabled (clog-webgl glenum-capability)
(:documentation "Return true if glenum-capability is enabled.
https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/isEnabled"))
(defmethod is-capability-enabled ((obj clog-webgl) glenum-capability)
(js-true-p (query obj (format nil "isEnabled(~A.~A)"
(script-id obj) glenum-capability))))
(defgeneric disable-vertex-attribute-array (clog-webgl attribute-location)
(:documentation "Turns the generic vertex attribute array off at a given index
position."))
(defmethod disable-vertex-attribute-array ((obj clog-webgl) attribute-location)
(execute obj (format nil "desableVertexAttribArray(~A)"
attribute-location)))
(defgeneric draw-arrays (clog-webgl mode offset count) (defgeneric draw-arrays (clog-webgl mode offset count)
(:documentation "Renders primitives from array data. MODE can be: (:documentation "Renders primitives from array data. MODE can be:
:POINTS Draws a single dot. :POINTS Draws a single dot.
@ -470,13 +666,125 @@ When using a WebGL 2 context, the following values are available additionally:
(execute obj (format nil "generateMipmap(~A.~A)" (execute obj (format nil "generateMipmap(~A.~A)"
(script-id obj) glenum-target))) (script-id obj) glenum-target)))
(defgeneric disable-vertex-attribute-array (clog-webgl attribute-location) (defgeneric hint (clog-webgl glenum-target glenum-mode)
(:documentation "Turns the generic vertex attribute array off at a given index (:documentation "Hints for certain behaviors. The interpretation of these
position.")) hints depend on the implementation.
(defmethod disable-vertex-attribute-array ((obj clog-webgl) attribute-location) target
(execute obj (format nil "desableVertexAttribArray(~A)" ------
attribute-location))) Sets which behavior to be controlled. Possible values:
:GENERATE_MIPMAP_HINT
Quality of filtering when generating mipmap images with WebGLRenderingContext.generateMipmap().
When using the OES_standard_derivatives extension:
ext.FRAGMENT_SHADER_DERIVATIVE_HINT_OES
Accuracy of the derivative calculation for the GLSL built-in functions: dFdx, dFdy, and fwidth.
When using a WebGL 2 context, the following values are available additionally:
:FRAGMENT_SHADER_DERIVATIVE_HINT
Same as ext.FRAGMENT_SHADER_DERIVATIVE_HINT_OES
mode
----
Sets the behavior. The default value is :DONT_CARE. The possible values are:
:FASTEST : The most efficient behavior should be used.
:NICEST : The most correct or the highest quality option should be used.
:DONT_CARE : There is no preference for this behavior."))
(defmethod hint ((obj clog-webgl) glenum-target glenum-mode)
(execute obj (format nil "hint(~A.~A,~A.~A)"
(script-id obj) glenum-target
(script-id obj) glenum-mode)))
(defgeneric is-context-lost (clog-webgl)
(:documentation "Return true if context was lost and needs to be re-established"))
(defmethod is-context-lost ((obj clog-webgl))
(js-true-p (query obj "isContextLost()")))
;; WebGLRenderingContext.lineWidth() - lineWidth only 1.0 works, so has no effect anymore since 2017
(defmethod pixel-store-integer ((obj clog-webgl) glenum-pname value)
(execute obj (format nil "pixelStorei(~A.~A,~A)"
(script-id obj) glenum-pname
value)))
(defmethod polygon-offset ((obj clog-webgl) factor units)
(execute obj (format nil "polygonOffset(~A,~A)"
factor units)))
;; WebGLRenderingContext.readPixels()
(defmethod render-buffer-storage ((obj clog-webgl) glenum-target
glenum-internal-format
width height)
(execute obj (format nil "renderbufferStorage(~A.~A,~A.~A,~A,~A)"
(script-id obj) glenum-target
(script-id obj) glenum-internal-format
width height)))
(defmethod sample-coverage ((obj clog-webgl) value invertp)
(execute obj (format nil "sampleCoverage(~A,~A)"
value (p-true-js invertp))))
(defmethod scissor ((obj clog-webgl) x y width height)
(execute obj (format nil "scissor(~A,~A,~A,~A)"
x y width height)))
(defmethod stencil-function ((obj clog-webgl) glenum-func ref mask)
(execute obj (format nil "stencilFunc(~A.~A,~A,~A)"
(script-id obj) glenum-func
ref mask)))
(defmethod stencil-function-seperate ((obj clog-webgl) glenum-face
glenum-func ref mask)
(execute obj (format nil "stencilFuncSeperate(~A.~A,~A.~A,~A,~A)"
(script-id obj) glenum-face
(script-id obj) glenum-func
ref mask)))
(defmethod stencil-mask ((obj clog-webgl) mask)
(execute obj (format nil "stencilMask(~A)" mask)))
(defmethod stencil-mask-seperate ((obj clog-webgl) glenum-face mask)
(execute obj (format nil "stencilFuncSeperate(~A.~A,~A)"
(script-id obj) glenum-face
mask)))
(defmethod stencil-operation ((obj clog-webgl) fail zfail zpass)
(execute obj (format nil "stencilOp(~A,~A,~A)"
fail zfail zpass)))
(defmethod stencil-operation-seperate ((obj clog-webgl) glenum-face
fail zfail zpass)
(execute obj (format nil "stencilOpSeperate(~A.~A,~A,~A,~A)"
(script-id obj) glenum-face
fail zfail zpass)))
;; WebGLRenderingContext.texImage2D()
(defmethod texture-parameter-integer ((obj clog-webgl) glenum-target
glenum-pname value)
(execute obj (format nil "textParameteri(~A.~A,~A.~A,~A)"
(script-id obj) glenum-target
(script-id obj) glenum-pname
value)))
(defmethod texture-parameter-float ((obj clog-webgl) glenum-target
glenum-pname value)
(execute obj (format nil "textParameterf(~A.~A,~A.~A,~A)"
(script-id obj) glenum-target
(script-id obj) glenum-pname
value)))
;; WebGLRenderingContext.texSubImage2D()
;; WebGL2RenderingContext.uniform[1234][uif][v]()
;; WebGLRenderingContext.uniformMatrix[234]fv()
;; WebGLRenderingContext.vertexAttrib[1234]f[v]()
(defmethod viewport ((obj clog-webgl) x y width height) (defmethod viewport ((obj clog-webgl) x y width height)
(execute obj (format nil "viewport(~A,~A,~A,~A)" (execute obj (format nil "viewport(~A,~A,~A,~A)"
@ -562,6 +870,12 @@ For :GLENUM values"))
:html-id web-id :html-id web-id
:clog-webgl obj))) :clog-webgl obj)))
(defgeneric is-shader (clog-webgl-shader)
(:documentation "Return true if is valid"))
(defmethod is-shader ((obj clog-webgl-shader))
(js-true-p (query (gl obj) (format nil "isShader(~A)" (script-id obj)))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Properties - clog-webgl-shader ;; Properties - clog-webgl-shader
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -572,11 +886,26 @@ For :GLENUM values"))
(escape-string source))) (escape-string source)))
source) source)
(defgeneric shader-parameter (clog-webgl-shader glenum-param)
(:documentation "Returns information about the given shader.
:DELETE_STATUS
Returns a GLboolean indicating whether or not the shader is flagged for deletion.
:COMPILE_STATUS
Returns a GLboolean indicating whether or not the last shader compilation was successful.
:SHADER_TYPE
Returns a GLenum indicating whether the shader is a vertex shader (gl.VERTEX_SHADER) or fragment shader (gl.FRAGMENT_SHADER) object.
"))
(defmethod shader-parameter ((obj clog-webgl-shader) glenum-param) (defmethod shader-parameter ((obj clog-webgl-shader) glenum-param)
(query (gl obj) (format nil "getShaderParameter(~A, ~A.~A)" (query (gl obj) (format nil "getShaderParameter(~A, ~A.~A)"
(script-id obj) (script-id obj)
(script-id (gl obj)) glenum-param))) (script-id (gl obj)) glenum-param)))
(defgeneric shader-info-log (clog-webgl-shader)
(:documentation "It contains warnings, debugging and compile information."))
(defmethod shader-info-log ((obj clog-webgl-shader)) (defmethod shader-info-log ((obj clog-webgl-shader))
(query (gl obj) (format nil "getShaderInfoLog(~A)" (query (gl obj) (format nil "getShaderInfoLog(~A)"
(script-id obj)))) (script-id obj))))
@ -613,29 +942,77 @@ For :GLENUM values"))
:html-id web-id :html-id web-id
:clog-webgl obj))) :clog-webgl obj)))
(defgeneric is-program (clog-webgl-program)
(:documentation "Return true if is valid"))
(defmethod is-program ((obj clog-webgl-program))
(js-true-p (query (gl obj) (format nil "isProgram(~A)" (script-id obj)))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Parameters - clog-webgl-program ;; Parameters - clog-webgl-program
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defgeneric program-parameter (clog-webgl-program glenum-param)
(:documentation "Information about the given program.
:DELETE_STATUS
Returns a GLboolean indicating whether or not the program is flagged for deletion.
:LINK_STATUS
Returns a GLboolean indicating whether or not the last link operation was successful.
:VALIDATE_STATUS
Returns a GLboolean indicating whether or not the last validation operation was successful.
:ATTACHED_SHADERS
Returns a GLint indicating the number of attached shaders to a program.
:ACTIVE_ATTRIBUTES
Returns a GLint indicating the number of active attribute variables to a program.
:ACTIVE_UNIFORMS
Returns a GLint indicating the number of active uniform variables to a program.
When using a WebGL 2 context, the following values are available additionally:
:TRANSFORM_FEEDBACK_BUFFER_MODE
Returns a GLenum indicating the buffer mode when transform feedback is active. May be :SEPARATE_ATTRIBS or :INTERLEAVED_ATTRIBS.
:TRANSFORM_FEEDBACK_VARYINGS
Returns a GLint indicating the number of varying variables to capture in transform feedback mode.
:ACTIVE_UNIFORM_BLOCKS
Returns a GLint indicating the number of uniform blocks containing active uniforms."))
(defmethod program-parameter ((obj clog-webgl-program) glenum-param) (defmethod program-parameter ((obj clog-webgl-program) glenum-param)
(query (gl obj) (format nil "getProgramParameter(~A, ~A.~A)" (query (gl obj) (format nil "getProgramParameter(~A, ~A.~A)"
(script-id obj) (script-id obj)
(script-id (gl obj)) glenum-param))) (script-id (gl obj)) glenum-param)))
(defgeneric attribute-location (clog-webgl-program name) (defgeneric attribute-location (clog-webgl-program name)
(:documentation "Returns the location of an attribute variable in clog-program")) (:documentation "Returns the location of an attribute variable in clog-webgl-program"))
(defmethod attribute-location ((obj clog-webgl-program) name) (defmethod attribute-location ((obj clog-webgl-program) name)
(query (gl obj) (format nil "getAttribLocation(~A, '~A')" (query (gl obj) (format nil "getAttribLocation(~A, '~A')"
(script-id obj) name))) (script-id obj) name)))
(defgeneric uniform-location (clog-webgl-program name) (defgeneric uniform-location (clog-webgl-program name)
(:documentation "Returns the location of an uniform variable in clog-program")) (:documentation "Returns the location of an uniform variable in clog-webgl-program"))
(defmethod uniform-location ((obj clog-webgl-program) name) (defmethod uniform-location ((obj clog-webgl-program) name)
(query (gl obj) (format nil "getUniformLocation(~A, '~A')" (query (gl obj) (format nil "getUniformLocation(~A, '~A')"
(script-id obj) name))) (script-id obj) name)))
(defgeneric uniform (clog-webgl-program location)
(:documentation "Returns the value of uniform at LOCATION in clog-webgl-program"))
(defmethod uniform ((obj clog-webgl-program) location)
(query (gl obj) (format nil "getUniform(~A, ~A)"
(script-id obj) location)))
(defgeneric program-info-log (clog-webgl-program)
(:documentation "Contains errors that occurred during failed linking or
validation of WebGLProgram objects."))
(defmethod program-info-log ((obj clog-webgl-program)) (defmethod program-info-log ((obj clog-webgl-program))
(query (gl obj) (format nil "getProgramInfoLog(~A)" (query (gl obj) (format nil "getProgramInfoLog(~A)"
(script-id obj)))) (script-id obj))))
@ -737,6 +1114,12 @@ in WebGL2 the following added:
(bind-buffer new-obj bind-type)) (bind-buffer new-obj bind-type))
new-obj))) new-obj)))
(defgeneric is-buffer (clog-webgl-buffer)
(:documentation "Return true if is valid"))
(defmethod is-buffer ((obj clog-webgl-buffer))
(js-true-p (query (gl obj) (format nil "isBuffer(~A)" (script-id obj)))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Methods - clog-webgl-buffer ;; Methods - clog-webgl-buffer
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -836,7 +1219,7 @@ and blit-frame-buffer."))
(defmethod create-webgl-frame-buffer ((obj clog-webgl) &key bind-type) (defmethod create-webgl-frame-buffer ((obj clog-webgl) &key bind-type)
(let ((web-id (clog-connection:generate-id))) (let ((web-id (clog-connection:generate-id)))
(js-execute obj (format nil "clog['~A']=~A.createFrameBuffer()" (js-execute obj (format nil "clog['~A']=~A.createFramebuffer()"
web-id web-id
(script-id obj))) (script-id obj)))
(let ((new-obj (make-instance 'clog-webgl-frame-buffer (let ((new-obj (make-instance 'clog-webgl-frame-buffer
@ -848,6 +1231,13 @@ and blit-frame-buffer."))
(bind-frame-buffer new-obj bind-type)) (bind-frame-buffer new-obj bind-type))
new-obj))) new-obj)))
(defgeneric is-frame-buffer (clog-webgl-frame-buffer)
(:documentation "Return true if is valid"))
(defmethod is-frame-buffer ((obj clog-webgl-frame-buffer))
(js-true-p (query (gl obj) (format nil "isFramebuffer(~A)" (script-id obj)))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Methods - clog-webgl-frame-buffer ;; Methods - clog-webgl-frame-buffer
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -861,13 +1251,13 @@ clear* and blit-frame-buffer.
and blit-frame-buffer")) and blit-frame-buffer"))
(defmethod bind-frame-buffer ((obj clog-webgl-frame-buffer) glenum-target) (defmethod bind-frame-buffer ((obj clog-webgl-frame-buffer) glenum-target)
(execute (gl obj) (format nil "bindFrameBuffer(~A.~A,~A)" (execute (gl obj) (format nil "bindFramebuffer(~A.~A,~A)"
(script-id (gl obj)) glenum-target (script-id (gl obj)) glenum-target
(script-id obj))) (script-id obj)))
(setf (gl-type obj) glenum-target)) (setf (gl-type obj) glenum-target))
(defmethod delete-frame-buffer ((obj clog-webgl-frame-buffer)) (defmethod delete-frame-buffer ((obj clog-webgl-frame-buffer))
(execute (gl obj) (format nil "deleteFrameBuffer(~A)" (execute (gl obj) (format nil "deleteFramebuffer(~A)"
(script-id obj)))) (script-id obj))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -884,7 +1274,7 @@ is set binds the render-buffer to :RENDERBUFFER"))
(defmethod create-webgl-render-buffer ((obj clog-webgl) &key bind-type) (defmethod create-webgl-render-buffer ((obj clog-webgl) &key bind-type)
(let ((web-id (clog-connection:generate-id))) (let ((web-id (clog-connection:generate-id)))
(js-execute obj (format nil "clog['~A']=~A.createRenderBuffer()" (js-execute obj (format nil "clog['~A']=~A.createRenderbuffer()"
web-id web-id
(script-id obj))) (script-id obj)))
(let ((new-obj (make-instance 'clog-webgl-render-buffer (let ((new-obj (make-instance 'clog-webgl-render-buffer
@ -896,6 +1286,12 @@ is set binds the render-buffer to :RENDERBUFFER"))
(bind-render-buffer new-obj bind-type)) (bind-render-buffer new-obj bind-type))
new-obj))) new-obj)))
(defgeneric is-render-buffer (clog-webgl-render-buffer)
(:documentation "Return true if is valid"))
(defmethod is-render-buffer ((obj clog-webgl-render-buffer))
(js-true-p (query (gl obj) (format nil "isRenderbuffer(~A)" (script-id obj)))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Methods - clog-webgl-render-buffer ;; Methods - clog-webgl-render-buffer
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -904,13 +1300,13 @@ is set binds the render-buffer to :RENDERBUFFER"))
(:documentation "Set BIND-TYPE of render-buffer to :RENDERBUFFER")) (:documentation "Set BIND-TYPE of render-buffer to :RENDERBUFFER"))
(defmethod bind-render-buffer ((obj clog-webgl-render-buffer) glenum-target) (defmethod bind-render-buffer ((obj clog-webgl-render-buffer) glenum-target)
(execute (gl obj) (format nil "bindRenderBuffer(~A.~A,~A)" (execute (gl obj) (format nil "bindRenderbuffer(~A.~A,~A)"
(script-id (gl obj)) glenum-target (script-id (gl obj)) glenum-target
(script-id obj))) (script-id obj)))
(setf (gl-type obj) glenum-target)) (setf (gl-type obj) glenum-target))
(defmethod delete-render-buffer ((obj clog-webgl-render-buffer)) (defmethod delete-render-buffer ((obj clog-webgl-render-buffer))
(execute (gl obj) (format nil "deleteRenderBuffer(~A)" (execute (gl obj) (format nil "deleteRenderbuffer(~A)"
(script-id obj)))) (script-id obj))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -944,6 +1340,12 @@ in WebGL 2 also:
(bind-texture new-obj bind-type)) (bind-texture new-obj bind-type))
new-obj))) new-obj)))
(defgeneric is-texture (clog-webgl-texture)
(:documentation "Return true if is valid"))
(defmethod is-texture ((obj clog-webgl-texture))
(js-true-p (query (gl obj) (format nil "isTexture(~A)" (script-id obj)))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Methods - clog-webgl-texture ;; Methods - clog-webgl-texture
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;