Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Initial revision.

darcs-hash:20060131115438-b2d16-c1c46d0dcef4db384fd1ec2643bfd337d381ff15.gz
  • Loading branch information...
commit 3027f6eca969c985823faec1e41cd668aa9178a6 0 parents
Oliver Markovic authored
27 COPYING
@@ -0,0 +1,27 @@
+
+Copyright (c) 2004, Oliver Markovic <entrox@entrox.org>
+ All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ o Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ o Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ o Neither the name of the author nor the names of the contributors may be
+ used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
7 Makefile
@@ -0,0 +1,7 @@
+# -*- Mode: Makefile; tab-width: 3; indent-tabs-mode: t -*-
+
+clean:
+ find . -name ".fasls" | xargs rm -rf
+ find . \( -name "*.dfsl" -o -name "*.fasl" -o -name "*.fas" -o -name "*.lib" -o -name "*.x86f" -o -name "*.ppcf" -o -name "*.nfasl" -o -name "*.fsl" \) -exec rm {} \;
+
+# vim: ft=make ts=3 noet
3  README
@@ -0,0 +1,3 @@
+cl-opengl is a set of bindings and utilites for accessing the OpenGL,
+GLU and GLUT APIs using CFFI.
+
50 cl-opengl.asd
@@ -0,0 +1,50 @@
+;;; -*- Mode: Lisp; indent-tabs-mode: nil -*-
+;;;
+;;; Copyright (c) 2004, Oliver Markovic <entrox@entrox.org>
+;;; All rights reserved.
+;;;
+;;; Redistribution and use in source and binary forms, with or without
+;;; modification, are permitted provided that the following conditions are met:
+;;;
+;;; o Redistributions of source code must retain the above copyright notice,
+;;; this list of conditions and the following disclaimer.
+;;; o Redistributions in binary form must reproduce the above copyright
+;;; notice, this list of conditions and the following disclaimer in the
+;;; documentation and/or other materials provided with the distribution.
+;;; o Neither the name of the author nor the names of the contributors may be
+;;; used to endorse or promote products derived from this software without
+;;; specific prior written permission.
+;;;
+;;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+;;; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+;;; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+;;; ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+;;; LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+;;; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+;;; SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+;;; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+;;; CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+;;; ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+;;; POSSIBILITY OF SUCH DAMAGE.
+
+(defpackage :cl-opengl-system
+ (:use :cl :asdf))
+(in-package :cl-opengl-system)
+
+
+(defsystem :cl-opengl
+ :depends-on (:cffi)
+ :components
+ ((:module "gl"
+ :components
+ ((:file "package")
+ (:file "library" :depends-on ("package"))
+ (:file "types" :depends-on ("package"))
+ (:file "enums" :depends-on ("types"))
+ (:file "funcs" :depends-on ("enums"))
+ (:file "util" :depends-on ("enums" "types"))
+ (:file "opengl" :depends-on ("funcs" "util"))
+ (:file "rasterization" :depends-on ("funcs" "util"))
+ (:file "framebuffer" :depends-on ("funcs" "util"))
+ (:file "special" :depends-on ("funcs" "util"))
+ (:file "state" :depends-on ("funcs" "util"))))))
770 gl/enums.lisp
@@ -0,0 +1,770 @@
+;;; -*- Mode: Lisp; indent-tabs-mode: nil -*-
+;;;
+;;; Copyright (c) 2004, Oliver Markovic <entrox@entrox.org>
+;;; All rights reserved.
+;;;
+;;; Redistribution and use in source and binary forms, with or without
+;;; modification, are permitted provided that the following conditions are met:
+;;;
+;;; o Redistributions of source code must retain the above copyright notice,
+;;; this list of conditions and the following disclaimer.
+;;; o Redistributions in binary form must reproduce the above copyright
+;;; notice, this list of conditions and the following disclaimer in the
+;;; documentation and/or other materials provided with the distribution.
+;;; o Neither the name of the author nor the names of the contributors may be
+;;; used to endorse or promote products derived from this software without
+;;; specific prior written permission.
+;;;
+;;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+;;; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+;;; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+;;; ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+;;; LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+;;; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+;;; SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+;;; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+;;; CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+;;; ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+;;; POSSIBILITY OF SUCH DAMAGE.
+
+(in-package :cl-opengl)
+
+
+;;; A
+
+(defcenum accum-op
+ (:accum #x100)
+ (:load #x101)
+ (:return #x102)
+ (:mult #x103)
+ (:add #x104))
+
+
+;;; B
+
+(defcenum begin-mode
+ (:points #x0)
+ (:lines #x1)
+ (:line-loop #x2)
+ (:line-strip #x3)
+ (:triangles #x4)
+ (:triangle-strip #x5)
+ (:triangle-fan #x6)
+ (:quads #x7)
+ (:quad-strip #x8)
+ (:polygon #x9))
+
+(defcenum blend-equation
+ (:func-add #x8006)
+ (:func-subtract #x800A)
+ (:func-reverse-subtract #x800B)
+ (:min #x8007)
+ (:max #x8008)
+ (:logic-op #xBF1))
+
+(defcenum blend-func
+ (:zero #x0)
+ (:one #x1)
+ (:src-color #x300)
+ (:one-minus-src-color #x301)
+ (:dst-color #x306)
+ (:one-minus-dst-color #x307)
+ (:src-alpha #x302)
+ (:one-minus-src-alpha #x303)
+ (:dst-alpha #x304)
+ (:one-minus-dst-alpha #x305)
+ (:constant-color #x8001)
+ (:one-minus-constant-color #x8002)
+ (:constant-alpha #x8003)
+ (:one-minus-constant-alpha #x8004)
+ (:src-alpha-saturate #x308))
+
+
+;;; C
+
+(defcenum call-lists-type
+ (:byte #x1400)
+ (:unsigned-byte #x1401)
+ (:short #x1402)
+ (:unsigned-short #x1403)
+ (:int #x1404)
+ (:unsigned-int #x1405)
+ (:float #x1406))
+
+(defcenum client-attributes
+ (:client-pixel-store-bit #x1)
+ (:client-vertex-array-bit #x2)
+ (:client-all-attrib-bits #xFFFFFFFF))
+
+(defcenum clear-buffer-bits
+ (:depth-buffer-bit #x100)
+ (:accum-buffer-bit #x200)
+ (:stencil-buffer-bit #x400)
+ (:color-buffer-bit #x4000))
+
+(defcenum clip-plane-name
+ (:clip-plane0 #x3000)
+ (:clip-plane1)
+ (:clip-plane2)
+ (:clip-plane3)
+ (:clip-plane4)
+ (:clip-plane5))
+
+(defcenum color-material-mode
+ (:emission #x1600)
+ (:ambient #x1200)
+ (:diffuse #x1201)
+ (:specular #x1202)
+ (:ambient-and-diffuse #x1602))
+
+(defcenum color-table-name
+ (:color-table #x80D0)
+ (:post-convolution-color-table #x80D1)
+ (:post-color-matrix-color-table #x80D2)
+ (:proxy-color-table #x80D3)
+ (:proxy-post-convolution-color-table #x80D4)
+ (:proxy-post-color-matrix-color-table #x80D5))
+
+(defcenum compare-func
+ (:never #x200)
+ (:less #x201)
+ (:equal #x202)
+ (:lequal #x203)
+ (:greater #x204)
+ (:notequal #x205)
+ (:gequal #x206)
+ (:always #x207))
+
+(defcenum copy-pixels-type
+ (:color #x1800)
+ (:depth #x18001)
+ (:stencil #x1802))
+
+;;; D
+
+(defcenum depth-texture-mode
+ (:luminance #x1909)
+ (:intensity #x8049)
+ (:alpha #x1906))
+
+(defcenum display-list-mode
+ (:compile #x1300)
+ (:compile-and-execute #x1301))
+
+(defcenum draw-buffer
+ (:none #x0)
+ (:front-left #x400)
+ (:front-right #x401)
+ (:back-left #x402)
+ (:back-right #x403)
+ (:front #x404)
+ (:back #x405)
+ (:left #x406)
+ (:right #x407)
+ (:front-and-back #x408)
+ (:aux0 #x409)
+ (:aux1 #x40A)
+ (:aux2 #x40B)
+ (:aux3 #x40C))
+
+
+;;; E
+
+(defcenum enable-cap
+ (:point-smooth #xB10)
+ (:line-smooth #xB20)
+ (:line-stipple #xB24)
+ (:polygon-smooth #xB41)
+ (:polygon-stipple #xB42)
+ (:cull-face #xB44)
+ (:lighting #xB50)
+ (:color-material #xB57)
+ (:fog #xB60)
+ (:depth-test #xB71)
+ (:stencil-test #xB90)
+ (:normalize #xBA1)
+ (:alpha-test #xBC0)
+ (:blend #xBE2)
+ (:dither #xBD0)
+ (:index-logic-op #xBF1)
+ (:color-logic-op #xBF2)
+ (:scissor-test #xC11)
+ (:texture-gen-s #xC60)
+ (:texture-gen-t #xC61)
+ (:texture-gen-r #xC62)
+ (:texture-gen-q #xC63)
+ (:auto-normal #xD80)
+ (:map1-grid-domain #xDD0)
+ (:map1-grid-segments #xDD1)
+ (:map2-grid-domain #xDD2)
+ (:map2-grid-segments #xDD3)
+ (:texture-1d #xDE0)
+ (:texture-2d #xDE1)
+ (:polygon-offset-point #x2A01)
+ (:polygon-offset-line #x2A02)
+ (:clip-plane0 #x3000)
+ (:clip-plane1 #x3001)
+ (:clip-plane2 #x3002)
+ (:clip-plane3 #x3003)
+ (:clip-plane4 #x3004)
+ (:clip-plane5 #x3005)
+ (:light0 #x4000)
+ (:light1 #x4001)
+ (:light2 #x4002)
+ (:light3 #x4003)
+ (:light4 #x4004)
+ (:light5 #x4005)
+ (:light6 #x4006)
+ (:light7 #x4007)
+ (:convolution-1d #x8010)
+ (:convolution-2d #x8011)
+ (:separable-2d #x8012)
+ (:histogram #x8024)
+ (:minmax #x802E)
+ (:polygon-offset-fill #x8037)
+ (:rescale-normal #x803A)
+ (:texture-3d #x806F)
+ (:vertex-array #x8074)
+ (:normal-array #x8075)
+ (:color-array #x8076)
+ (:index-array #x8077)
+ (:texture-coord-array #x8078)
+ (:edge-flag-array #x8079)
+ (:multisample #x809D)
+ (:sample-alpha-to-coverage #x809E)
+ (:sample-alpha-to-one #x809F)
+ (:sample-coverage #x80A0)
+ (:color-table #x80D0)
+ (:post-convolution-color-table #x80D1)
+ (:post-color-matrix-color-table #x80D2)
+ (:fog-coord-array #x8457)
+ (:color-sum #x8458)
+ (:secondary-color-array #x845E)
+ (:texture-cube-map #x8513)
+ (:vertex-program-point-size #x8642)
+ (:vertex-program-two-side #x8643)
+ (:point-sprite #x8861))
+
+(defcenum eval-mesh-1-mode
+ (:point #x1B00)
+ (:line #x1B01))
+
+(defcenum eval-mesh-2-mode
+ (:point #x1B00)
+ (:line #x1B01)
+ (:fill #x1B02))
+
+
+;;; F
+
+(defcenum face-direction
+ (:cw #x900)
+ (:ccw #x901))
+
+(defcenum feedback-type
+ (:2d #x600)
+ (:3d #x601)
+ (:3d-color #x602)
+ (:3d-color-texture #x603)
+ (:4d-color-texture #x604))
+
+(defcenum fog-coord-src
+ (:fragment-depth #x8452)
+ (:fog-coord #x8451))
+
+(defcenum fog-mode
+ (:exp #x800)
+ (:exp2 #x801)
+ (:linear #x2601))
+
+(defcenum fog-parameter
+ (:fog-mode #xB65)
+ (:fog-coord-src #x8450)
+ (:fog-density #xB62)
+ (:fog-start #xB63)
+ (:fog-end #xB64))
+
+
+;;; G
+
+(defcenum gl-error
+ (:no-error #x0)
+ (:invalid-enum #x500)
+ (:invalid-value #x501)
+ (:invalid-operation #x502)
+ (:stack-overflow #x503)
+ (:stack-underflow #x504)
+ (:out-of-memory #x505)
+ (:table-too-large #x8031))
+
+
+;;; H
+
+(defcenum hint
+ (:dont-care #x1100)
+ (:fastest #x1101)
+ (:nicest #x1102))
+
+(defcenum hint-target
+ (:perspective-correction-hint #xC50)
+ (:point-smooth-hint #xC51)
+ (:line-smooth-hint #xC52)
+ (:polygon-smooth-hint #xC53)
+ (:fog-hint #xC54)
+ (:generate-mipmap-hint #x8192)
+ (:texture-compression-hint #x84EF)
+ (:fragment-shader-derivative-hint #x8B8B))
+
+
+;;; L
+
+(defcenum light-model-color-control
+ (:single-color #x81F9)
+ (:separate-specular-color #x81FA))
+
+(defcenum light-model-parameter
+ (:light-model-ambient #xB53)
+ (:light-model-local-viewer #xB51)
+ (:light-model-two-side #xB52)
+ (:light-model-color-sontrol #x81F8))
+
+(defcenum light-name
+ (:light0 #x4000)
+ (:light1)
+ (:light2)
+ (:light3)
+ (:light4)
+ (:light5)
+ (:light6)
+ (:light7))
+
+(defcenum light-parameter
+ (:ambient #x1200)
+ (:diffuse #x1201)
+ (:specular #x1202)
+ (:position #x1203)
+ (:spot-direction #x1204)
+ (:spot-exponent #x1205)
+ (:spot-cutoff #x1206)
+ (:constant-attenuation #x1207)
+ (:linear-attenuation #x1208)
+ (:quadratic-attenuation #x1209))
+
+(defcenum logic-op
+ (:clear #x1500)
+ (:and #x1501)
+ (:and-reverse #x1502)
+ (:copy #x1503)
+ (:and-inverted #x1504)
+ (:noop #x1505)
+ (:xor #x1506)
+ (:or #x1507)
+ (:nor #x1508)
+ (:equiv #x1509)
+ (:invert #x150A)
+ (:or-reverse #x150B)
+ (:copy-inverted #x150C)
+ (:or-inverted #x150D)
+ (:nand #x150E)
+ (:set #x150F))
+
+
+;;; M
+
+(defcenum map1-target
+ (:map1-vertex-3 #xD97)
+ (:map1-vertex-4 #xD98)
+ (:map1-index #xD91)
+ (:map1-color-4 #xD90)
+ (:map1-normal #xD92)
+ (:map1-texture-coord-1 #xD93)
+ (:map1-texture-coord-2 #xD94)
+ (:map1-texture-coord-3 #xD95)
+ (:map1-texture-coord-4 #xD96))
+
+(defcenum map2-target
+ (:map2-vertex-3 #xDB7)
+ (:map2-vertex-4 #xDB8)
+ (:map2-index #xDB1)
+ (:map2-color-4 #xDB0)
+ (:map2-normal #xDB2)
+ (:map2-texture-coord-1 #xDB3)
+ (:map2-texture-coord-2 #xDB4)
+ (:map2-texture-coord-3 #xDB5)
+ (:map2-texture-coord-4 #xDB6))
+
+(defcenum material-parameter
+ (:ambient #x1200)
+ (:diffuse #x1201)
+ (:ambient-and-diffuse #x1602)
+ (:specular #x1202)
+ (:emission #x1600)
+ (:shininess #x1601)
+ (:color-indexes #x1603))
+
+(defcenum matrix-mode
+ (:modelview #x1700)
+ (:projection #x1701)
+ (:texture #x1702)
+ (:color #x1800))
+
+
+;;; P
+
+(defcenum pixel-data-type
+ (:byte #x1400)
+ (:unsigned-byte #x1401)
+ (:bitmap #x1A00)
+ (:short #x1402)
+ (:unsigned-short #x1403)
+ (:int #x14004)
+ (:unsigned-int #x1405)
+ (:float #x1406)
+ (:unsigned-byte-3-3-2 #x8032)
+ (:unsigned-byte-2-3-3-rev #x8362)
+ (:unsigned-short-5-6-5 #x8363)
+ (:unsigned-short-5-6-5-rev #x8364)
+ (:unsigned-short-4-4-4-4 #x8033)
+ (:unsigned-short-4-4-4-4-rev #x8365)
+ (:unsigned-short-5-5-5-1 #x8034)
+ (:unsigned-short-1-5-5-5-rev #x8366)
+ (:unsigned-int-8-8-8-8 #x8035)
+ (:unsigned-int-8-8-8-8-rev #x8367)
+ (:unsigned-int-10-10-10-2 #x8036)
+ (:unsigned-int-2-10-10-10-rev #x8368))
+
+(defcenum pixel-data-format
+ (:color-index #x1900)
+ (:stencil-index #x1901)
+ (:depth-component #x1902)
+ (:red #x1903)
+ (:green #x1904)
+ (:blue #x1905)
+ (:alpha #x1906)
+ (:rgb #x1907)
+ (:rgba #x1908)
+ (:bgr #x80E0)
+ (:bgra #x80E1)
+ (:luminance #x1909)
+ (:luminance-alpha #x190A))
+
+(defcenum pixel-data-internal-format
+ (:alpha #x1906)
+ (:alpha4 #x803B)
+ (:alpha8 #x803C)
+ (:alpha12 #x803D)
+ (:alpha16 #x803E)
+ (:depth-component #x1902)
+ (:depth-component16 #x81A5)
+ (:depth-component24 #x81A6)
+ (:depth-component32 #x81A7)
+ (:luminance #x1909)
+ (:luminance4 #x803F)
+ (:luminance8 #x8040)
+ (:luminance12 #x8041)
+ (:luminance16 #x8042)
+ (:luminance-alpha #x190A)
+ (:luminance4-alpha4 #x8043)
+ (:luminance6-alpha2 #x8044)
+ (:luminance8-alpha8 #x8045)
+ (:luminance12-alpha4 #x8046)
+ (:luminance12-alpha12 #x8047)
+ (:luminance16-alpha16 #x8048)
+ (:intensity #x8049)
+ (:intensity4 #x804A)
+ (:intensity8 #x804B)
+ (:intensity12 #x804C)
+ (:intensity16 #x804D)
+ (:rgb #x1907)
+ (:r3-g3-b2 #x2A10)
+ (:rgb4 #x804F)
+ (:rgb5 #x8050)
+ (:rgb8 #x8051)
+ (:rgb10 #x8052)
+ (:rgb12 #x8053)
+ (:rgb16 #x8054)
+ (:rgba #x1908)
+ (:rgba2 #x8055)
+ (:rgba4 #x8056)
+ (:rgb5-a1 #x8057)
+ (:rgba8 #x8058)
+ (:rgb10-a2 #x8059)
+ (:rgba12 #x805A)
+ (:rgba16 #x805B))
+
+(defcenum pixel-map
+ (:pixel-map-i-to-i #xC70)
+ (:pixel-map-s-to-s #xC71)
+ (:pixel-map-i-to-r #xC72)
+ (:pixel-map-i-to-g #xC73)
+ (:pixel-map-i-to-b #xC74)
+ (:pixel-map-i-to-a #xC75)
+ (:pixel-map-r-to-r #xC76)
+ (:pixel-map-g-to-g #xC77)
+ (:pixel-map-b-to-b #xC78)
+ (:pixel-map-a-to-a #xC79))
+
+(defcenum pixel-store-mode
+ (:unpack-swap-bytes #xCF0)
+ (:unpack-lsb-first #xCF1)
+ (:unpack-row-length #xCF2)
+ (:unpack-skip-rows #xCF3)
+ (:unpack-skip-pixels #xCF4)
+ (:unpack-alignment #xCF5)
+ (:unpack-image-height #x806E)
+ (:unpack-skip-images #x806D))
+
+(defcenum pixel-transfer-mode
+ (:map-color #xD10)
+ (:map-stencil #xD11)
+ (:index-shift #xD12)
+ (:index-offset #xD13)
+ (:red-scale #xD14)
+ (:green-scale #xD18)
+ (:blue-scale #xD1A)
+ (:depth-scale #xD1E)
+ (:alpha-scale #xD1C)
+ (:red-bias #xD15)
+ (:green-bias #xD19)
+ (:blue-bias #xD1B)
+ (:depth-bias #xD1F)
+ (:alpha-bias #xD1D)
+ (:post-convolution-red-scale #x801C)
+ (:post-convolution-green-scale #x801D)
+ (:post-convolution-blue-scale #x801E)
+ (:post-convolution-alpha-scale #x801F)
+ (:post-convolution-red-bias #x8020)
+ (:post-convolution-green-bias #x8021)
+ (:post-convolution-blue-bias #x8022)
+ (:post-convolution-alpha-bias #x8023)
+ (:post-color-matrix-red-scale #x80B4)
+ (:post-color-matrix-green-scale #x80B5)
+ (:post-color-matrix-blue-scale #x80B6)
+ (:post-color-matrix-alpha-scale #x80B7)
+ (:post-color-matrix-red-bias #x80B8)
+ (:post-color-matrix-green-bias #x80B9)
+ (:post-color-matrix-blue-bias #x80BA)
+ (:post-color-matrix-alpha-bias #x80BB))
+
+(defcenum point-parameter
+ (:point-size-min #x8126)
+ (:point-size-max #x8127)
+ (:point-fade-threshold-size #x8128)
+ (:point-distance-attenuation #x8129)
+ (:point-sprite-coord-origin #x8CA0))
+
+(defcenum point-sprite-coord-origin
+ (:lower-left #x8CA1)
+ (:upper-left #x8CA2))
+
+(defcenum polygon-face
+ (:front #x404)
+ (:back #x405)
+ (:front-and-back #x408))
+
+(defcenum polygon-mode
+ (:point #x1B00)
+ (:line #x1B01)
+ (:fill #x1B02))
+
+(defcenum program-attribute-type
+ (:float #x1406)
+ (:float-vec2 #x8B50)
+ (:float-vec3 #x8B51)
+ (:float-vec4 #x8B52)
+ (:float-mat2 #x8B5A)
+ (:float-mat3 #x8B5B)
+ (:float-mat4 #x8B5C))
+
+(defcenum program-uniform-type
+ (:float #x1406)
+ (:float-vec2 #x8B50)
+ (:float-vec3 #x8B51)
+ (:float-vec4 #x8B52)
+ (:int #x1404)
+ (:int-vec2 #x8B53)
+ (:int-vec3 #x8B54)
+ (:int-vec4 #x8B55)
+ (:bool #x8B56)
+ (:bool-vec2 #x8B57)
+ (:bool-vec3 #x8B58)
+ (:bool-vec4 #x8B59)
+ (:float-mat2 #x8B5A)
+ (:float-mat3 #x8B5B)
+ (:float-mat4 #x8B5C)
+ (:sampler-1d #x8B5D)
+ (:sampler-2d #x8B5E)
+ (:sampler-3d #x8B5F)
+ (:sampler-cube #x8B60)
+ (:sampler-1d-shadow #x8B61)
+ (:sampler-2d-shadow #x8B62))
+
+
+;;; Q
+
+(defcenum query-target
+ (:samples-passed #x8914))
+
+
+;;; R
+
+(defcenum render-mode
+ (:render )
+ (:select)
+ (:feedback))
+
+
+;;; S
+
+(defcenum server-attributes
+ (:current-bit #x1)
+ (:point-bit #x2)
+ (:line-bit #x4)
+ (:polygon-bit #x8)
+ (:polygon-stipple-bit #x10)
+ (:pixel-mode-bit #x20)
+ (:lighting-bit #x40)
+ (:fog-bit #x80)
+ (:depth-buffer-bit #x100)
+ (:accum-buffer-bit #x200)
+ (:stencil-buffer-bit #x400)
+ (:viewport-bit #x800)
+ (:transform-bit #x1000)
+ (:enable-bit #x2000)
+ (:color-buffer-bit #x4000)
+ (:hint-bit #x8000)
+ (:eval-bit #x10000)
+ (:list-bit #x20000)
+ (:texture-bit #x40000)
+ (:scissor-bit #x80000)
+ (:multisample-bit #x20000000)
+ (:all-attrib-bits #xFFFFF))
+
+(defcenum shade-model
+ (:smooth #x1D01)
+ (:flat #x1D00))
+
+(defcenum shader-type
+ (:vertex-shader #x8b31)
+ (:fragment-shader #x8b30))
+
+(defcenum stencil-op
+ (:keep #x1E00)
+ (:zero #x0)
+ (:replace #x1E01)
+ (:incr #x1E02)
+ (:decr #x1E03)
+ (:invert #x150A)
+ (:incr-wrap #x8507)
+ (:decr-wrap #x8508))
+
+(defcenum string-name
+ (:vendor #x1F00)
+ (:renderer #x1F01)
+ (:version #x1F02)
+ (:extensions #x1F03)
+ (:shading-language-version #x8B8C))
+
+
+;;; T
+
+(defcenum texture-compare-mode
+ (:none #x0)
+ (:compare-r-to-texture #x884E))
+
+(defcenum tex-image-1d-target
+ (:texture-1d #xDE0)
+ (:proxy-texture-1d #x8063))
+
+(defcenum tex-image-2d-target
+ (:texture-2d #xDE1)
+ (:proxy-texture-2d #x8064)
+ (:proxy-texture-cube-map #x851B)
+ (:texture-cube-map-positive-x #x8515)
+ (:texture-cube-map-positive-y #x8517)
+ (:texture-cube-map-positive-z #x8519)
+ (:texture-cube-map-negative-x #x8516)
+ (:texture-cube-map-negative-y #x8518)
+ (:texture-cube-map-negative-z #x851A))
+
+(defcenum tex-image-3d-target
+ (:texture-3d #x806F)
+ (:proxy-texture-3d #x8070))
+
+(defcenum texture-mag-filter
+ (:nearest #x2600)
+ (:linear #x2601))
+
+(defcenum texture-min-filter
+ (:nearest #x2600)
+ (:linear #x2601)
+ (:nearest-mipmap-nearest #x2700)
+ (:linear-mipmap-nearest #x2701)
+ (:nearest-mipmap-linear #x2702)
+ (:linear-mipmap-linear #x2703))
+
+(defcenum texture-name
+ (:texture0 #x84C0)
+ (:texture1)
+ (:texture2)
+ (:texture3)
+ (:texture4)
+ (:texture5)
+ (:texture6)
+ (:texture7)
+ (:texture8)
+ (:texture9)
+ (:texture10)
+ (:texture11)
+ (:texture12)
+ (:texture13)
+ (:texture14)
+ (:texture15)
+ (:texture16)
+ (:texture17)
+ (:texture18)
+ (:texture19)
+ (:texture20)
+ (:texture21)
+ (:texture22)
+ (:texture23)
+ (:texture24)
+ (:texture25)
+ (:texture26)
+ (:texture27)
+ (:texture28)
+ (:texture29)
+ (:texture30)
+ (:texture31))
+
+(defcenum texture-parameter
+ (:texture-wrap-s #x2802)
+ (:texture-wrap-t #x2803)
+ (:texture-wrap-r #x8072)
+ (:texture-min-filter #x2801)
+ (:texture-mag-filter #x2800)
+ (:texture-border-color #x1004)
+ (:texture-priority #x8066)
+ (:texture-min-lod #x813A)
+ (:texture-max-lod #x813B)
+ (:texture-base-level #x813C)
+ (:texture-max-level #x813D)
+ (:texture-lod-bias #x8501)
+ (:depth-texture-mode #x884B)
+ (:texture-compare-mode #x884C)
+ (:texture-compare-func #x884D)
+ (:generate-mipmap #x8191))
+
+(defcenum texture-target
+ (:texture-1d #xDE0)
+ (:texture-2d #xDE1)
+ (:texture-3d #x806F)
+ (:texture-cube-map #x8513))
+
+(defcenum texture-wrap-mode
+ (:clamp #x2900)
+ (:clamp-to-edge #x812F)
+ (:clamp-to-border #x812D)
+ (:repeat #x2901)
+ (:mirrored-repeat #x8370))
+
295 gl/framebuffer.lisp
@@ -0,0 +1,295 @@
+;;; -*- Mode: Lisp; indent-tabs-mode: nil -*-
+;;;
+;;; Copyright (c) 2004, Oliver Markovic <entrox@entrox.org>
+;;; All rights reserved.
+;;;
+;;; Redistribution and use in source and binary forms, with or without
+;;; modification, are permitted provided that the following conditions are met:
+;;;
+;;; o Redistributions of source code must retain the above copyright notice,
+;;; this list of conditions and the following disclaimer.
+;;; o Redistributions in binary form must reproduce the above copyright
+;;; notice, this list of conditions and the following disclaimer in the
+;;; documentation and/or other materials provided with the distribution.
+;;; o Neither the name of the author nor the names of the contributors may be
+;;; used to endorse or promote products derived from this software without
+;;; specific prior written permission.
+;;;
+;;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+;;; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+;;; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+;;; ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+;;; LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+;;; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+;;; SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+;;; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+;;; CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+;;; ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+;;; POSSIBILITY OF SUCH DAMAGE.
+
+(in-package :cl-opengl)
+
+;;;
+;;; Chapter 4 - Per-fragment Operations and the Framebuffer
+;;;
+
+;;;
+;;; 4.1 Per-fragment Operations
+;;;
+
+;;; 4.1.2 Scissor Test
+
+(declaim (inline scissor))
+(defun scissor (left bottom width height)
+ "Specifies the scissoring rectangle used by the scissor test (enabled with
+the symbolic constant :SCISSOR-TEST"
+ (%glScissor left bottom width height))
+
+
+;;; 4.1.3 Multisample Fragment Operations
+
+(declaim (inline sample-coverage))
+(defun sample-coverage (value invertp)
+ "Specifies the values for SAMPLE-COVERAGE-VALUE and SAMPLE-COVERAGE-INVERT."
+ (%glSampleCoverage (float value) (if invertp 1 0)))
+
+
+;;; 4.1.4 Alpha Test
+
+(declaim (inline alpha-func))
+(defun alpha-func (func ref)
+ "Specifies the comparison function for use in the alpha test (enabled by
+:ALPHA-TEST). REF is a reference value in the range [0, 1]. The possible constants
+specifying the test function are :NEVER, :ALWAYS, :LESS, :LEQUAL, :EQUAL, :GEQUAL,
+:GREATER, or :NOTEQUAL, meaning pass the fragment never, always, if the fragment's
+alpha value is less than, less than or equal to, equal to, greater than or equal to,
+greater than, or not equal to the reference value, respectively."
+ (%glAlphaFunc func (float ref)))
+
+
+;;; 4.1.5 Stencil Test
+
+(declaim (inline stencil-func))
+(defun stencil-func (func ref mask)
+ (%glStencilFunc func ref mask))
+
+(declaim (inline stencil-func-separate))
+(defun stencil-func-separate (face func ref mask)
+ (%glStencilFuncSeparate face func ref mask))
+
+(declaim (inline stencil-op))
+(defun stencil-op (sfail dpfail dppass)
+ "Specifies the action that happens to the stencil value in the current fragment
+if the stencil test fails (SFAIL), depth buffer test fails (DPFAIL) and depth buffer
+test passes (DPPASS). Possible values are :KEEP, :ZERO, :REPLACE, :INCR, :DECR,
+:INVERT, :INCR-WRAP, and :DECR-WRAP."
+ (%glStencilOp sfail dpfail dppass))
+
+(declaim (inline stencil-op-separate))
+(defun stencil-op-separate (face sfail dpfail dppass)
+ "Specifies the action that happens to the stencil value in the current fragment
+if the stencil test fails (SFAIL), depth buffer test fails (DPFAIL) and depth buffer
+test passes (DPPASS). Possible values are :KEEP, :ZERO, :REPLACE, :INCR, :DECR,
+:INVERT, :INCR-WRAP, and :DECR-WRAP. The argument FACE indicates which set of state
+is affected and is one of :FRONT, :BACK or :FRONT-AND-BACK."
+ (%glStencilOpSeparate face sfail dpfail dppass))
+
+
+;;; 4.1.6 Depth Buffer Test
+
+(declaim (inline depth-func))
+(defun depth-func (func)
+ "Specifies the comparison function to be used for the depth test (enabled
+with the symbolic constant :DEPTH-TEST). FUNC must be one of :NEVER, :ALWAYS,
+:LESS, :LEQUAL, :EQUAL, :GREATER, :GEQUAL or :NOTEQUAL. Accordingly, the depth buffer
+test passes never, always, if the incoming fragment's zw value is less than, less
+than or equal to, equal to, greater than, greater than or equal to, or not equal to
+the depth value stored at the location given by the incoming fragment."
+ (%glDepthFunc func))
+
+
+
+;;; 4.1.7 Occlusion Queries
+
+(declaim (inline begin-query))
+(defun begin-query (target id)
+ "Starts an occlusion query. TARGET must be the symbolic constant :SAMPLES-PASSED.
+If called with an unused id, that name is marked as used and associated with a new
+query object."
+ (%glBeginQuery target id))
+
+(declaim (inline end-query))
+(defun end-query (target)
+ "Finishes an occlusion query currently running on target TARGET."
+ (%glEndQuery target))
+
+(defun gen-queries (n)
+ "Returns N previously unused query object names in a list. These names are marked
+as used, but no object is associated with them until the first time they are used by
+BEGIN-QUERY."
+ (with-foreign-object (ids 'GLuint n)
+ (%glGenQueries n ids)
+ (loop for i below n
+ collecting (mem-aref ids 'GLuint i))))
+
+(defun delete-queries (ids)
+ "Deletes the names of the query objects contained in the sequence IDS."
+ (let ((count (length ids)))
+ (with-foreign-object (id-array 'GLuint count)
+ (loop for id in ids
+ counting id into i
+ do (setf (mem-aref id-array 'GLuint (1- i)) id))
+ (%glDeleteQueries count id-array))))
+
+
+;;; 4.1.8 Blending
+
+(declaim (inline blend-equation))
+(defun blend-equation (mode)
+ "Specifies the blend equation to be used for both RGB and alpha values. MODE
+must be one of the symbolic constants :FUNC-ADD, :FUNC-SUBTRACT, :FUNC-REVERSE-SUBTRACT,
+:MIN, :MAX or :LOGIC-OP."
+ (%glBlendEquation mode))
+
+(declaim (inline blend-equation-separate))
+(defun blend-equation-separate (mode-rgb mode-alpha)
+ "Specifies the blend equations to be used for RGB and alpha values respectively.
+MODE-RGB and MODE-ALPHA must be one of the symbolic constants :FUNC-ADD, :FUNC-SUBTRACT,
+:FUNC-REVERSE-SUBTRACT, :MIN, :MAX or :LOGIC-OP."
+ (%glBlendEquationSeparate mode-rgb mode-alpha))
+
+(declaim (inline blend-func))
+(defun blend-func (src dst)
+ "Specifies the blend functions. SRC determines both RGB and alpha source functions,
+while DST determines both RGB and alpha destination functions. Possible values are
+:ZERO, :ONE, :SRC-COLOR, :ONE-MINUS-SRC-COLOR, :DST-COLOR, :ONE-MINUS-DST-COLOR,
+:SRC-ALPHA, :ONE-MINUS-SRC-ALPHA, :DST-ALPHA, :ONE-MINUS-DST-ALPHA, :CONSTANT-COLOR,
+:ONE-MINUS-CONSTANT-COLOR, :CONSTANT-ALPHA, :ONE-MINUS-CONSTANT-ALPHA and
+:SRC-ALPHA-SATURATE (only valid for source blending functions)."
+ (%glBlendFunc src dst))
+
+(declaim (inline blend-func-separate))
+(defun blend-func-separate (src-rgb dst-rgb src-alpha dst-alpha)
+ "Specifies the blend functions. SRC-RGB and DST-RGB determine the source and
+destination RGB blend functions, respectively, while SRC-ALPHA and DST-ALPHA determine
+the source and destination alpha blend functions. Possible values are
+:ZERO, :ONE, :SRC-COLOR, :ONE-MINUS-SRC-COLOR, :DST-COLOR, :ONE-MINUS-DST-COLOR,
+:SRC-ALPHA, :ONE-MINUS-SRC-ALPHA, :DST-ALPHA, :ONE-MINUS-DST-ALPHA, :CONSTANT-COLOR,
+:ONE-MINUS-CONSTANT-COLOR, :CONSTANT-ALPHA, :ONE-MINUS-CONSTANT-ALPHA and
+:SRC-ALPHA-SATURATE (only valid for source blending functions)."
+ (%glBlendFuncSeparate src-rgb dst-rgb src-alpha dst-alpha))
+
+(declaim (inline blend-color))
+(defun blend-color (red green blue alpha)
+ "Specifies the constant color to be used in blending. The four parameters are
+clamped to the range [0, 1] before being stored."
+ (%glBlendColor (float red) (float green) (float blue) (float alpha)))
+
+
+;;; 4.1.10 Logical Operation
+
+(declaim (inline logic-op))
+(defun logic-op (op)
+ "Selects the logical operation used when :INDEX-LOGIC-OP or :COLOR-LOGIC-OP is
+enabled. Possible values are :CLEAR, :AND, :AND-REVERSE, :COPY, :AND-INVERTED,
+:NOOP, :XOR, :OR, :NOR, :EQUIV, :INVERT, :OR-REVERSE, :COPY-INVERTED, :OR-INVERTED,
+:NAND and :SET."
+ (%glLogicOp op))
+
+
+
+;;;
+;;; 4.2 Whole Framebuffer Operation
+;;;
+
+;;; 4.2.1 Selecting a Buffer for Writing
+
+(declaim (inline draw-buffer))
+(defun draw-buffer (buffer)
+ (%glDrawBuffer buffer))
+
+(defun draw-buffers (buffers)
+ (with-opengl-sequence (seq 'GLenum buffers)
+ (%glDrawBuffers (length buffers) seq)))
+
+
+;;; 4.2.2 Fine Control of Buffer Updates
+
+(declaim (inline index-mask))
+(defun index-mask (mask)
+ (%glIndexMask mask))
+
+(declaim (inline color-mask))
+(defun color-mask (r g b a)
+ (%glColorMask (if r 1 0) (if g 1 0) (if b 1 0) (if a 1 0)))
+
+(declaim (inline depth-mask))
+(defun depth-mask (mask)
+ (%glDepthMask mask))
+
+(declaim (inline stencil-mask))
+(defun stencil-mask (mask)
+ (%glStencilMask mask))
+
+(declaim (inline stencil-mask-separate))
+(defun stencil-mask-separate (face mask)
+ (%glStencilMaskSeparate face mask))
+
+
+
+;;; 4.2.3 Clearing the Buffers
+
+(declaim (inline clear))
+(defun clear (&rest bufs)
+ (%glClear (make-bitfield 'clear-buffer-bits bufs)))
+
+(define-compiler-macro clear (&whole form &rest bufs)
+ (if (every #'keywordp bufs)
+ `(%glClear ,(make-bitfield 'clear-buffer-bits bufs))
+ form))
+
+(declaim (inline clear-color))
+(defun clear-color (r g b a)
+ (%glClearColor (float r) (float g) (float b) (float a)))
+
+(declaim (inline clear-index))
+(defun clear-index (index)
+ (%glClearIndex (float index)))
+
+(declaim (inline clear-depth))
+(defun clear-depth (depth)
+ (%glClearDepth (float depth 1.0d0)))
+
+(declaim (inline clear-stencil))
+(defun clear-stencil (s)
+ (%glClearStencil s))
+
+(declaim (inline clear-accum))
+(defun clear-accum (r g b a)
+ (%glClearAccum (float r) (float g) (float b) (float a)))
+
+
+;;; 4.2.4 The Accumulation Buffer
+
+(declaim (inline accum))
+(defun accum (op value)
+ (%glAccum op (float value)))
+
+
+;;;
+;;; 4.3 Drawing, Reading and Copying Pixels
+;;;
+
+;;; 4.3.2 Reading Pixels
+
+(defun read-pixels (x y width height)
+ (declare (ignore x y width height))
+ (error "not implemented"))
+
+(defun read-buffer (src)
+ (%glReadBuffer src))
+
+;;; 4.3.3 Copying Pixels
+
+(defun copy-pixels (x y width height type)
+ (%glCopyPixels x y width height type))
853 gl/funcs.lisp
@@ -0,0 +1,853 @@
+;;; -*- Mode: Lisp; indent-tabs-mode: nil -*-
+;;;
+;;; Copyright (c) 2004, Oliver Markovic <entrox@entrox.org>
+;;; All rights reserved.
+;;;
+;;; Redistribution and use in source and binary forms, with or without
+;;; modification, are permitted provided that the following conditions are met:
+;;;
+;;; o Redistributions of source code must retain the above copyright notice,
+;;; this list of conditions and the following disclaimer.
+;;; o Redistributions in binary form must reproduce the above copyright
+;;; notice, this list of conditions and the following disclaimer in the
+;;; documentation and/or other materials provided with the distribution.
+;;; o Neither the name of the author nor the names of the contributors may be
+;;; used to endorse or promote products derived from this software without
+;;; specific prior written permission.
+;;;
+;;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+;;; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+;;; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+;;; ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+;;; LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+;;; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+;;; SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+;;; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+;;; CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+;;; ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+;;; POSSIBILITY OF SUCH DAMAGE.
+
+(in-package :cl-opengl)
+
+
+;;; A
+
+(defcfun ("glAccum" %glAccum) :void
+ (op accum-op)
+ (value GLfloat))
+
+(defcfun ("glActiveTexture" %glActiveTexture) :void
+ (name texture-name))
+
+(defcfun ("glAlphaFunc" %glAlphaFunc) :void
+ (func compare-func)
+ (ref GLclampf))
+
+(defcfun ("glAttachShader" %glAttachShader) :void
+ (program GLuint)
+ (shader GLuint))
+
+;;; B
+
+(defcfun ("glBegin" %glBegin) :void
+ (mode begin-mode))
+
+(defcfun ("glBeginQuery" %glBeginQuery) :void
+ (target query-target)
+ (id GLuint))
+
+(defcfun ("glBindAttribLocation" %glBindAttribLocation) :void
+ (program GLuint)
+ (index GLuint)
+ (name :pointer))
+
+(defcfun ("glBlendColor" %glBlendColor) :void
+ (red GLclampf)
+ (green GLclampf)
+ (blue GLclampf)
+ (alpha GLclampf))
+
+(defcfun ("glBlendEquation" %glBlendEquation) :void
+ (mode blend-equation))
+
+(defcfun ("glBlendEquationSeparate" %glBlendEquationSeparate) :void
+ (mode-rgb blend-equation)
+ (mode-alpha blend-equation))
+
+(defcfun ("glBlendFunc" %glBlendFunc) :void
+ (src blend-func)
+ (dst blend-func))
+
+(defcfun ("glBlendFuncSeparate" %glBlendFuncSeparate) :void
+ (src-rgb blend-func)
+ (dst-rgb blend-func)
+ (src-alpha blend-func)
+ (dst-alpha blend-func))
+
+
+;;; C
+
+(defcfun ("glCallList" %glCallList) :void
+ (n GLuint))
+
+(defcfun ("glCallLists" %glCallLists) :void
+ (n GLsizei)
+ (type call-lists-type)
+ (lists :pointer))
+
+(defcfun ("glClear" %glClear) :void
+ (bufs GLbitfield))
+
+(defcfun ("glClearAccum" %glClearAccum) :void
+ (r GLfloat)
+ (g GLfloat)
+ (b GLfloat)
+ (a GLfloat))
+
+(defcfun ("glClearColor" %glClearColor) :void
+ (r GLclampf)
+ (g GLclampf)
+ (b GLclampf)
+ (a GLclampf))
+
+(defcfun ("glClearDepth" %glClearDepth) :void
+ (depth GLclampd))
+
+(defcfun ("glClearIndex" %glClearIndex) :void
+ (index GLfloat))
+
+(defcfun ("glClearStencil" %glClearStencil) :void
+ (s GLint))
+
+(defcfun ("glClipPlane" %glClipPlane) :void
+ (p clip-plane-name)
+ (eqn :pointer))
+
+(defcfun ("glColor3f" %glColor3f) :void
+ (r GLfloat)
+ (g GLfloat)
+ (b GLfloat))
+
+(defcfun ("glColor4f" %glColor4f) :void
+ (r GLfloat)
+ (g GLfloat)
+ (b GLfloat)
+ (a GLfloat))
+
+(defcfun ("glColorMask" %glColorMask) :void
+ (r GLboolean)
+ (g GLboolean)
+ (b GLboolean)
+ (a GLboolean))
+
+(defcfun ("glColorMaterial" %glColorMaterial) :void
+ (face polygon-face)
+ (mode color-material-mode))
+
+(defcfun ("glCompileShader" %glCompileShader) :void
+ (shader GLuint))
+
+(defcfun ("glCopyPixels" %glCopyPixels) :void
+ (x GLint)
+ (y GLint)
+ (width GLsizei)
+ (height GLsizei)
+ (type copy-pixels-type))
+
+(defcfun ("glCreateProgram" %glCreateProgram) GLuint)
+
+(defcfun ("glCreateShader" %glCreateShader) GLuint
+ (type shader-type))
+
+(defcfun ("glCullFace" %glCullFace) :void
+ (face polygon-face))
+
+
+;;; D
+
+(defcfun ("glDeleteLists" %glDeleteLists) :void
+ (list GLuint)
+ (range GLsizei))
+
+(defcfun ("glDeleteProgram" %glDeleteProgram) :void
+ (object GLuint))
+
+(defcfun ("glDeleteQueries" %glDeleteQueries) :void
+ (n GLsizei)
+ (ids :pointer))
+
+(defcfun ("glDeleteShader" %glDeleteShader) :void
+ (shader GLuint))
+
+(defcfun ("glDepthFunc" %glDepthFunc) :void
+ (func compare-func))
+
+(defcfun ("glDepthMask" %glDepthMask) :void
+ (mask GLboolean))
+
+(defcfun ("glDepthRange" %glDepthRange) :void
+ (n GLclampd)
+ (f GLclampd))
+
+(defcfun ("glDetachShader" %glDetachShader) :void
+ (program GLuint)
+ (shader GLuint))
+
+(defcfun ("glDrawBuffer" %glDrawBuffer) :void
+ (buffer draw-buffer))
+
+(defcfun ("glDrawBuffers" %glDrawBuffers) :void
+ (n GLsizei)
+ (bufs :pointer))
+
+
+
+;;; E
+
+(defcfun ("glEdgeFlag" %glEdgeFlag) :void
+ (flag GLboolean))
+
+(defcfun ("glEnd" %glEnd) :void)
+
+(defcfun ("glEndList" %glEndList) :void)
+
+(defcfun ("glEndQuery" %glEndQuery) :void
+ (target query-target))
+
+(defcfun ("glEvalCoord1f" %glEvalCoord1f) :void
+ (x GLfloat))
+
+(defcfun ("glEvalCoord2f" %glEvalCoord2f) :void
+ (x GLfloat)
+ (y GLfloat))
+
+(defcfun ("glEvalMesh1" %glEvalMesh1) :void
+ (mode eval-mesh-1-mode)
+ (p1 GLint)
+ (p2 GLint))
+
+(defcfun ("glEvalMesh2" %glEvalMesh2) :void
+ (mode eval-mesh-2-mode)
+ (p1 GLint)
+ (p2 GLint)
+ (q1 GLint)
+ (q2 GLint))
+
+(defcfun ("glEvalPoint1" %glEvalPoint1) :void
+ (p GLint))
+
+(defcfun ("glEvalPoint2" %glEvalPoint2) :void
+ (p GLint)
+ (q GLint))
+
+
+;;; F
+
+(defcfun ("glFeedbackBuffer" %glFeedbackBuffer) :void
+ (n GLsizei)
+ (type feedback-type)
+ (buffer :pointer))
+
+(defcfun ("glFinish" %glFinish) :void)
+
+(defcfun ("glFlush" %glFlush) :void)
+
+(defcfun ("glFogCoordf" %glFogCoordf) :void
+ (coord GLfloat))
+
+(defcfun ("glFogi" %glFogi) :void
+ (pname fog-parameter)
+ (value GLint))
+
+(defcfun ("glFogf" %glFogf) :void
+ (pname fog-parameter)
+ (value GLfloat))
+
+(defcfun ("glFrontFace" %glFrontFace) :void
+ (dir face-direction))
+
+(defcfun ("glFrustum" %glFrustum) :void
+ (left GLdouble)
+ (right GLdouble)
+ (bottom GLdouble)
+ (top GLdouble)
+ (near GLdouble)
+ (far GLdouble))
+
+
+;;; G
+
+(defcfun ("glGenLists" %glGenLists) GLuint
+ (range GLsizei))
+
+(defcfun ("glGenQueries" %glGenQueries) :void
+ (n GLsizei)
+ (ids :pointer))
+
+(defcfun ("glGetActiveAttrib" %glGetActiveAttrib) :void
+ (program GLuint)
+ (index GLuint)
+ (buffer-size GLsizei)
+ (length :pointer)
+ (size :pointer)
+ (type :pointer)
+ (name :pointer))
+
+(defcfun ("glGetActiveUniform" %glGetActiveUniform) :void
+ (program GLuint)
+ (index GLuint)
+ (buffer-size GLsizei)
+ (length :pointer)
+ (size :pointer)
+ (type :pointer)
+ (name :pointer))
+
+(defcfun ("glGetAttribLocation" %glGetAttribLocation) GLint
+ (program GLuint)
+ (name :pointer))
+
+(defcfun ("glGetError" %glGetError) gl-error)
+
+(defcfun ("glGetUniformLocation" %glGetUniformLocation) GLint
+ (program GLuint)
+ (name :pointer))
+
+
+;;; H
+
+(defcfun ("glHint" %glHint) :void
+ (target hint-target)
+ (hint hint))
+
+
+;;; I
+
+(defcfun ("glIndexi" %glIndexi) :void
+ (index GLint))
+
+(defcfun ("glIndexMask" %glIndexMask) :void
+ (mask GLuint))
+
+(defcfun ("glInitNames" %glInitNames) :void)
+
+(defcfun ("glIsList" %glIsList) GLboolean
+ (list GLuint))
+
+
+;;; J
+
+
+;;; K
+
+
+;;; L
+
+(defcfun ("glLightf" %glLightf) :void
+ (light light-name)
+ (pname light-parameter)
+ (param GLfloat))
+
+(defcfun ("glLightfv" %glLightfv) :void
+ (light light-name)
+ (pname light-parameter)
+ (param :pointer))
+
+(defcfun ("glLightModelfv" %glLightModelfv) :void
+ (pname light-model-parameter)
+ (value :pointer))
+
+(defcfun ("glLightModeli" %glLightModeli) :void
+ (pname light-model-parameter)
+ (value GLint))
+
+(defcfun ("glLineStipple" %glLineStipple) :void
+ (factor GLint)
+ (pattern GLushort))
+
+(defcfun ("glLineWidth" %glLineWidth) :void
+ (width GLfloat))
+
+(defcfun ("glLinkProgram" %glLinkProgram) :void
+ (program GLuint))
+
+(defcfun ("glListBase" %glListBase) :void
+ (base GLuint))
+
+(defcfun ("glLoadIdentity" %glLoadIdentity) :void)
+
+(defcfun ("glLoadMatrixf" %glLoadMatrixf) :void
+ (matrix :pointer))
+
+(defcfun ("glLoadName" %glLoadName) :void
+ (name GLuint))
+
+(defcfun ("glLoadTransposeMatrixf" %glLoadTransposeMatrixf) :void
+ (matrix :pointer))
+
+(defcfun ("glLogicOp" %glLogicOp) :void
+ (op logic-op))
+
+
+;;; M
+
+(defcfun ("glMap1f" %glMap1f) :void
+ (target map1-target)
+ (u1 GLfloat)
+ (u2 GLfloat)
+ (stride GLint)
+ (order GLint)
+ (points :pointer))
+
+(defcfun ("glMap2f" %glMap2f) :void
+ (target map2-target)
+ (u1 GLfloat)
+ (u2 GLfloat)
+ (ustride GLint)
+ (uorder GLint)
+ (v1 GLfloat)
+ (v2 GLfloat)
+ (vstride GLint)
+ (vorder GLint)
+ (points :pointer))
+
+(defcfun ("glMapGrid1f" %glMapGrid1f) :void
+ (n GLint)
+ (u1 GLfloat)
+ (u2 GLfloat))
+
+(defcfun ("glMapGrid2f" %glMapGrid2f) :void
+ (nu GLint)
+ (u1 GLfloat)
+ (u2 GLfloat)
+ (nv GLint)
+ (v1 GLfloat)
+ (v2 GLfloat))
+
+(defcfun ("glMaterialf" %glMaterialf) :void
+ (face polygon-face)
+ (pname material-parameter)
+ (param GLfloat))
+
+(defcfun ("glMaterialfv" %glMaterialfv) :void
+ (face polygon-face)
+ (pname material-parameter)
+ (param :pointer))
+
+(defcfun ("glMaterialiv" %glMaterialiv) :void
+ (face polygon-face)
+ (pname material-parameter)
+ (param :pointer))
+
+(defcfun ("glMatrixMode" %glMatrixMode) :void
+ (mode matrix-mode))
+
+(defcfun ("glMultiTexCoord4f" %glMultiTexCoord4f) :void
+ (texture texture-name)
+ (s GLfloat)
+ (t* GLfloat)
+ (r GLfloat)
+ (q GLfloat))
+
+(defcfun ("glMultMatrixf" %glMultMatrixf) :void
+ (matrix :pointer))
+
+(defcfun ("glMultTransposeMatrixf" %glMultTransposeMatrixf) :void
+ (matrix :pointer))
+
+
+;;; N
+
+(defcfun ("glNewList" %glNewList) :void
+ (n GLuint)
+ (mode display-list-mode))
+
+(defcfun ("glNormal3f" %glNormal3f) :void
+ (x GLfloat)
+ (y GLfloat)
+ (z GLfloat))
+
+
+;;; O
+
+(defcfun ("glOrtho" %glOrtho) :void
+ (left GLdouble)
+ (right GLdouble)
+ (bottom GLdouble)
+ (top GLdouble)
+ (near GLdouble)
+ (far GLdouble))
+
+
+;;; P
+
+(defcfun ("glPassThrough" %glPassThrough) :void
+ (token GLfloat))
+
+(defcfun ("glPixelMapfv" %glPixelMapfv) :void
+ (map pixel-map)
+ (size GLsizei)
+ (values :pointer))
+
+(defcfun ("glPixelStorei" %glPixelStorei) :void
+ (pname pixel-store-mode)
+ (value GLint))
+
+(defcfun ("glPixelStoref" %glPixelStoref) :void
+ (pname pixel-store-mode)
+ (value GLfloat))
+
+(defcfun ("glPixelTransferi" %glPixelTransferi) :void
+ (pname pixel-transfer-mode)
+ (value GLint))
+
+(defcfun ("glPixelTransferf" %glPixelTransferf) :void
+ (pname pixel-transfer-mode)
+ (value GLfloat))
+
+(defcfun ("glPointParameteri" %glPointParameteri) :void
+ (pname point-parameter)
+ (value GLint))
+
+(defcfun ("glPointParameterf" %glPointParameterf) :void
+ (pname point-parameter)
+ (value GLfloat))
+
+(defcfun ("glPointParameteriv" %glPointParameteriv) :void
+ (pname point-parameter)
+ (value :pointer))
+
+(defcfun ("glPointParameterfv" %glPointParameterfv) :void
+ (pname point-parameter)
+ (value :pointer))
+
+(defcfun ("glPointSize" %glPointSize) :void
+ (size GLfloat))
+
+(defcfun ("glPolygonMode" %glPolygonMode) :void
+ (face polygon-face)
+ (mode polygon-mode))
+
+(defcfun ("glPolygonOffst" %glPolygonOffset) :void
+ (factor GLfloat)
+ (units GLfloat))
+
+(defcfun ("glPopMatrix" %glPopMatrix) :void)
+
+(defcfun ("glPopName" %glPopName) :void)
+
+(defcfun ("glPushMatrix" %glPushMatrix) :void)
+
+(defcfun ("glPushName" %glPushName) :void
+ (name GLuint))
+
+
+;;; Q
+
+
+;;; R
+
+(defcfun ("glRasterPos4f" %glRasterPos4f) :void
+ (x GLfloat)
+ (y GLfloat)
+ (z GLfloat)
+ (w GLfloat))
+
+(defcfun ("glReadBuffer" %glReadBuffer) :void
+ (src draw-buffer))
+
+(defcfun ("glReadPixels" %glReadPixels) :void
+ (x GLint)
+ (y GLint)
+ (width GLsizei)
+ (height GLsizei)
+ (format pixel-data-format)
+ (type pixel-data-type)
+ (data :pointer))
+
+(defcfun ("glRectf" %glRectf) :void
+ (x1 GLfloat)
+ (y1 GLfloat)
+ (x2 GLfloat)
+ (y2 GLfloat))
+
+(defcfun ("glRenderMode" %glRenderMode) GLint
+ (mode render-mode))
+
+(defcfun ("glRotatef" %glRotatef) :void
+ (theta GLfloat)
+ (x GLfloat)
+ (y GLfloat)
+ (z GLfloat))
+
+
+;;; S
+
+(defcfun ("glSampleCoverage" %glSampleCoverage) :void
+ (value GLclampf)
+ (invert GLboolean))
+
+(defcfun ("glScalef" %glScalef) :void
+ (x GLfloat)
+ (y GLfloat)
+ (z GLfloat))
+
+(defcfun ("glScissor" %glScissor) :void
+ (left GLint)
+ (bottom GLint)
+ (width GLsizei)
+ (height GLsizei))
+
+(defcfun ("glSecondaryColor3f" %glSecondaryColor3f) :void
+ (r GLfloat)
+ (g GLfloat)
+ (b GLfloat))
+
+(defcfun ("glSelectBuffer" %glSelectBuffer) :void
+ (n GLsizei)
+ (buffer :pointer))
+
+(defcfun ("glShadeModel" %glShadeModel) :void
+ (mode shade-model))
+
+(defcfun ("glShaderSource" %glShaderSource) :void
+ (shader GLuint)
+ (num-strings GLsizei)
+ (strings :pointer)
+ (lengths :pointer))
+
+(defcfun ("glStencilFunc" %glStencilFunc) :void
+ (func compare-func)
+ (ref GLint)
+ (mask GLuint))
+
+(defcfun ("glStencilFuncSeparate" %glStencilFuncSeparate) :void
+ (face polygon-face)
+ (func compare-func)
+ (ref GLint)
+ (mask GLuint))
+
+(defcfun ("glStencilMask" %glStencilMask) :void
+ (mask GLuint))
+
+(defcfun ("glStencilMaskSeparate" %glStencilMaskSeparate) :void
+ (face polygon-face)
+ (mask GLuint))
+
+(defcfun ("glStencilOp" %glStencilOp) :void
+ (sfail stencil-op)
+ (dpfail stencil-op)
+ (dppass stencil-op))
+
+(defcfun ("glStencilOpSeparate" %glStencilOpSeparate) :void
+ (face polygon-face)
+ (sfail stencil-op)
+ (dpfail stencil-op)
+ (dppass stencil-op))
+
+
+;;; T
+
+(defcfun ("glTexCoord1f" %glTexCoord1f) :void
+ (s GLfloat))
+
+(defcfun ("glTexCoord2f" %glTexCoord2f) :void
+ (s GLfloat)
+ (t* GLfloat))
+
+(defcfun ("glTexCoord3f" %glTexCoord3f) :void
+ (s GLfloat)
+ (t* GLfloat)
+ (r GLfloat))
+
+(defcfun ("glTexCoord4f" %glTexCoord4f) :void
+ (s GLfloat)
+ (t* GLfloat)
+ (r GLfloat)
+ (q GLfloat))
+
+(defcfun ("glTexParameteri" %glTexParameteri) :void
+ (target texture-target)
+ (pname texture-parameter)
+ (param GLint))
+
+(defcfun ("glTexParameterf" %glTexParameterf) :void
+ (target texture-target)
+ (pname texture-parameter)
+ (param GLfloat))
+
+(defcfun ("glTexParameterfv" %glTexParameterfv) :void
+ (target texture-target)
+ (pname texture-parameter)
+ (params :pointer))
+
+(defcfun ("glTexImage1D" %glTexImage1D) :void
+ (target tex-image-1d-target)
+ (level GLint)
+ (internal-format GLint)
+ (width GLsizei)
+ (border GLint)
+ (format pixel-data-format)
+ (type pixel-data-type)
+ (data :pointer))
+
+(defcfun ("glTexImage2D" %glTexImage2D) :void
+ (target tex-image-2d-target)
+ (level GLint)
+ (internal-format GLint)
+ (width GLsizei)
+ (height GLsizei)
+ (border GLint)
+ (format pixel-data-format)
+ (type pixel-data-type)
+ (data :pointer))
+
+(defcfun ("glTexImage3D" %glTexImage3D) :void
+ (target tex-image-3d-target)
+ (level GLint)
+ (internal-format GLint)
+ (width GLsizei)
+ (height GLsizei)
+ (depth GLsizei)
+ (border GLint)
+ (format pixel-data-format)
+ (type pixel-data-type)
+ (data :pointer))
+
+(defcfun ("glTranslatef" %glTranslatef) :void
+ (x GLfloat)
+ (y GLfloat)
+ (z GLfloat))
+
+
+;;; U
+
+(defcfun ("glUniform1f" %glUniform1f) :void
+ (location GLint)
+ (x GLfloat))
+
+(defcfun ("glUniform2f" %glUniform2f) :void
+ (location GLint)
+ (x GLfloat)
+ (y GLfloat))
+
+(defcfun ("glUniform3f" %glUniform3f) :void
+ (location GLint)
+ (x GLfloat)
+ (y GLfloat)
+ (z GLfloat))
+
+(defcfun ("glUniform4f" %glUniform4f) :void
+ (location GLint)
+ (x GLfloat)
+ (y GLfloat)
+ (z GLfloat)
+ (w GLfloat))
+
+(defcfun ("glUniform1i" %glUniform1i) :void
+ (location GLint)
+ (x GLint))
+
+(defcfun ("glUniform2i" %glUniform2i) :void
+ (location GLint)
+ (x GLint)
+ (y GLint))
+
+(defcfun ("glUniform3i" %glUniform3i) :void
+ (location GLint)
+ (x GLint)
+ (y GLint)
+ (z GLint))
+
+(defcfun ("glUniform4i" %glUniform4i) :void
+ (location GLint)
+ (x GLint)
+ (y GLint)
+ (z GLint)
+ (w GLint))
+
+(defcfun ("glUniformMatrix2fv" %glUniformMatrix2fv) :void
+ (location GLint)
+ (count GLsizei)
+ (transpose GLboolean)
+ (value :pointer))
+
+(defcfun ("glUniformMatrix3fv" %glUniformMatrix3fv) :void
+ (location GLint)
+ (count GLsizei)
+ (transpose GLboolean)
+ (value :pointer))
+
+(defcfun ("glUniformMatrix4fv" %glUniformMatrix4fv) :void
+ (location GLint)
+ (count GLsizei)
+ (transpose GLboolean)
+ (value :pointer))
+
+(defcfun ("glUseProgram" %glUseProgram) :void
+ (program GLuint))
+
+
+;;; V
+
+(defcfun ("glValidateProgram" %glValidateProgram) :void
+ (program GLuint))
+
+(defcfun ("glVertex2f" %glVertex2f) :void
+ (x GLfloat)
+ (y GLfloat))
+
+(defcfun ("glVertex3f" %glVertex3f) :void
+ (x GLfloat)
+ (y GLfloat)
+ (z GLfloat))
+
+(defcfun ("glVertex4f" %glVertex4f) :void
+ (x GLfloat)
+ (y GLfloat)
+ (z GLfloat)
+ (w GLfloat))
+
+(defcfun ("glVertexAttrib1f" %glVertexAttrib1f) :void
+ (index GLuint)
+ (x GLfloat))
+
+(defcfun ("glVertexAttrib2f" %glVertexAttrib2f) :void
+ (index GLuint)
+ (x GLfloat)
+ (y GLfloat))
+
+(defcfun ("glVertexAttrib3f" %glVertexAttrib3f) :void
+ (index GLuint)
+ (x GLfloat)
+ (y GLfloat)
+ (z GLfloat))
+
+(defcfun ("glVertexAttrib4f" %glVertexAttrib4f) :void
+ (index GLuint)
+ (x GLfloat)
+ (y GLfloat)
+ (z GLfloat)
+ (w GLfloat))
+
+(defcfun ("glViewport" %glViewport) :void
+ (x GLint)
+ (y GLint)
+ (w GLsizei)
+ (h GLsizei))
+
+
+;;; W
+
+(defcfun ("glWindowPos3f" %glWindowPos3f) :void
+ (x GLfloat)
+ (y GLfloat)
+ (z GLfloat))
+
+
+;;; X
+
+
+;;; Y
+
+
+;;; Z
35 gl/library.lisp
@@ -0,0 +1,35 @@
+;;;; -*- Mode: lisp; indent-tabs-mode: nil -*-
+;;;
+;;; library.lisp --- Foreign library definition
+;;;
+;;; Copyright (C) 2006, Luis Oliveira <loliveira@common-lisp.net>
+;;;
+;;; Permission is hereby granted, free of charge, to any person
+;;; obtaining a copy of this software and associated documentation
+;;; files (the "Software"), to deal in the Software without
+;;; restriction, including without limitation the rights to use, copy,
+;;; modify, merge, publish, distribute, sublicense, and/or sell copies
+;;; of the Software, and to permit persons to whom the Software is
+;;; furnished to do so, subject to the following conditions:
+;;;
+;;; The above copyright notice and this permission notice shall be
+;;; included in all copies or substantial portions of the Software.
+;;;
+;;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+;;; EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+;;; MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+;;; NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+;;; HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+;;; WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+;;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+;;; DEALINGS IN THE SOFTWARE.
+;;;
+
+(in-package :cl-opengl)
+
+(define-foreign-library opengl
+ (:darwin (:framework "OpenGL"))
+ (:windows "opengl32.dll")
+ (t (:default "libGL")))
+
+(use-foreign-library opengl)
470 gl/opengl.lisp
@@ -0,0 +1,470 @@
+;;; -*- Mode: Lisp; indent-tabs-mode: nil -*-
+;;;
+;;; Copyright (c) 2004, Oliver Markovic <entrox@entrox.org>
+;;; All rights reserved.
+;;;
+;;; Redistribution and use in source and binary forms, with or without
+;;; modification, are permitted provided that the following conditions are met:
+;;;
+;;; o Redistributions of source code must retain the above copyright notice,
+;;; this list of conditions and the following disclaimer.
+;;; o Redistributions in binary form must reproduce the above copyright
+;;; notice, this list of conditions and the following disclaimer in the
+;;; documentation and/or other materials provided with the distribution.
+;;; o Neither the name of the author nor the names of the contributors may be
+;;; used to endorse or promote products derived from this software without
+;;; specific prior written permission.
+;;;
+;;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+;;; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+;;; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+;;; ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+;;; LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+;;; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+;;; SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+;;; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+;;; CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+;;; ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+;;; POSSIBILITY OF SUCH DAMAGE.
+
+(in-package :cl-opengl)
+
+
+;;;
+;;; Chapter 2 - OpenGL Operation
+;;;
+;;; 2.5 GL Errors
+;;;
+
+(define-condition opengl-error (simple-error)
+ ((error-code :initarg :error-code :reader opengl-error.error-code))
+ (:report (lambda (c s)
+ (format s "OpenGL signalled ~A."
+ (opengl-error.error-code c)))))
+
+(defun get-error ()
+ (%glGetError))
+
+(defun check-error ()
+ (let ((error-code (get-error)))
+ (unless (eql error-code :no-error)
+ (error 'opengl-error :error-code error-code))))
+
+;;;
+;;; 2.6 Begin/End Paradigm
+;;;
+
+;;; 2.6.1 Begin and End
+
+(declaim (inline begin))
+(defun begin (mode)
+ (%glBegin mode))
+
+(declaim (inline end))
+(defun end ()
+ (%glEnd))
+
+(defmacro with-primitives (mode &body body)
+ `(prog2
+ (begin ,mode)
+ (progn ,@body)
+ (end)))
+
+
+;;; 2.6.2 Polygon Edges
+
+(declaim (inline edge-flag))
+(defun edge-flag (flag)
+ (%glEdgeFlag (if flag 1 0)))
+
+
+
+;;;
+;;; 2.7 Vertex Specification
+;;;
+
+(declaim (inline vertex))
+(defun vertex (x y &optional (z 0.0) (w 1.0))
+ (%glVertex4f (float x) (float y) (float z) (float w)))
+
+(declaim (inline tex-coord))
+(defun tex-coord (s &optional (r 0.0) (t* 0.0) (q 1.0))
+ (%glTexCoord4f (float s) (float r) (float t*) (float q)))
+
+(declaim (inline multi-tex-coord))
+(defun multi-tex-coord (texture s &optional (t* 0.0) (r 0.0) (q 1.0))
+ (%glMultiTexCoord4f texture (float s) (float t*) (float r) (float q)))
+
+(declaim (inline normal))
+(defun normal (x y z)
+ (%glNormal3f (float x) (float y) (float z)))
+
+(declaim (inline fog-coord))
+(defun fog-coord (coord)
+ (%glFogCoordf (float coord)))
+
+(declaim (inline color))
+(defun color (r g b &optional (a 1.0))
+ (%glColor4f (float r) (float g) (float b) (float a)))
+
+(declaim (inline secondary-color))
+(defun secondary-color (r g b)
+ (%glSecondaryColor3f (float r) (float g) (float b)))
+
+(declaim (inline index))
+(defun index (index)
+ (%glIndexi (truncate index)))
+
+(declaim (inline vertex-attrib))
+(defun vertex-attrib (index x &optional (y 0.0) (z 0.0) (w 1.0))
+ (%glVertexAttrib4f index (float x) (float y) (float z) (float w)))
+
+
+
+;;;
+;;; 2.10 Rectangles
+;;;
+
+(declaim (inline rect))
+(defun rect (x1 y1 x2 y2)
+ (%glRectf (float x1) (float y1) (float x2) (float y2)))
+
+
+;;;
+;;; 2.11 Coordinate Transformations
+;;;
+
+;;; 2.11.1 Controlling the Viewport
+
+(declaim (inline depth-range))
+(defun depth-range (near far)
+ (%glDepthRange (float near 1.0d0) (float far 1.0d0)))
+
+(declaim (inline viewport))
+(defun viewport (x y width height)
+ (%glViewport (truncate x) (truncate y) (truncate width) (truncate height)))
+
+
+;;; 2.11.2 Matrices
+
+(defun matrix-mode (mode)
+ (%glMatrixMode mode))
+
+(defmacro with-foreign-matrix ((sym matrix) &body body)
+ `(with-foreign-object (,sym :float 16)
+ (dotimes (i 16)
+ (setf (mem-aref ,sym :float i) (row-major-aref ,matrix i)))
+ ,@body))
+
+
+(defun load-matrix (matrix)
+ (with-foreign-matrix (foreign-matrix matrix)
+ (%glLoadMatrixf foreign-matrix)))
+
+(defun mult-matrix (matrix)
+ (with-foreign-matrix (foreign-matrix matrix)
+ (%glMultMatrixf foreign-matrix)))
+
+(defun load-transpose-matrix (matrix)
+ (with-foreign-matrix (foreign-matrix matrix)
+ (%glLoadTransposeMatrixf foreign-matrix)))
+
+(defun mult-transpose-matrix (matrix)
+ (with-foreign-matrix (foreign-matrix matrix)
+ (%glMultTransposeMatrixf foreign-matrix)))
+
+
+
+(declaim (inline rotate))
+(defun rotate (theta x y z)
+ (%glRotatef (float theta) (float x) (float y) (float z)))
+
+(declaim (inline translate))
+(defun translate (x y z)
+ (%glTranslatef (float x) (float y) (float z)))
+
+(declaim (inline scale))
+(defun scale (x y z)
+ (%glScalef (float x) (float y) (float z)))
+
+(declaim (inline frustum))
+(defun frustum (left right bottom top near far)
+ (%glFrustum (float left 1.0d0) (float right 1.0d0)
+ (float bottom 1.0d0) (float top 1.0d0)
+ (float near 1.0d0) (float far 1.0d0)))
+
+(declaim (inline ortho))
+(defun ortho (left right bottom top near far)
+ (%glOrtho (float left 1.0d0) (float right 1.0d0)
+ (float bottom 1.0d0) (float top 1.0d0)
+ (float near 1.0d0) (float far 1.0d0)))
+
+
+(declaim (inline active-texture))
+(defun active-texture (texture)
+ (%glActiveTexture texture))
+
+(declaim (inline load-identity))
+(defun load-identity ()
+ (%glLoadIdentity))
+
+(declaim (inline push-matrix))
+(defun push-matrix ()
+ (%glPushMatrix))
+
+(declaim (inline pop-matrix))
+(defun pop-matrix ()
+ (%glPopMatrix))
+
+
+;;;
+;;; 2.12 Clipping
+;;;
+
+(defun clip-plane (plane eqn)
+ (when (< (length eqn) 4)
+ (error "EQN must have 4 coefficents."))
+ (with-opengl-sequence (p 'GLdouble eqn)
+ (%glClipPlane plane p)))
+
+
+;;;
+;;; 2.13 Current Raster Position
+;;;
+
+(declaim (inline raster-pos))
+(defun raster-pos (x y &optional (z 0.0) (w 1.0))
+ (%glRasterPos4f (float x) (float y) (float z) (float w)))
+
+(declaim (inline window-pos))
+(defun window-pos (x y &optional (z 0.0))
+ (%glWindowPos3f (float x) (float y) (float z)))
+
+
+
+;;;
+;;; 2.14 Colors and Coloring
+;;;
+
+;;; 2.14.1 Lighting
+
+(declaim (inline front-face))
+(defun front-face (dir)
+ (%glFrontFace dir))
+
+;;; 2.14.2 Lighting Parameter Specification
+
+(defun material (face pname param)
+ (ecase pname
+ ((:ambient :diffuse :ambient-and-diffuse :specular :emission)
+ (with-foreign-object (p 'GLfloat 4)
+ (dotimes (i 4)
+ (setf (mem-aref p 'GLfloat i) (float (elt param i))))
+ (%glMaterialfv face pname p)))
+ (:shininess
+ (%glMaterialf face pname (float param)))
+ (:color-indexes
+ (with-foreign-object (p 'GLint 3)
+ (dotimes (i 3)
+ (setf (mem-aref p 'GLint i) (elt param i)))
+ (%glMaterialiv face pname p)))))
+
+
+(defun light (light pname value)
+ (ecase pname
+ ((:ambient :diffuse :specular :position)
+ (with-foreign-object (p 'GLfloat 4)
+ (dotimes (i 4)
+ (setf (mem-aref p 'GLfloat i) (float (elt value i))))
+ (%glLightfv light pname p)))
+ (:spot-direction
+ (with-foreign-object (p 'GLfloat 3)
+ (dotimes (i 3)
+ (setf (mem-aref p 'GLfloat i) (float (elt value i))))
+ (%glLightfv light pname p)))
+ ((:spot-exponent :spot-cutoff :constant-attenuation:linear-attenuation :quadratic-attenuation)
+ (%glLightf light pname (float value)))))
+
+
+(defun light-model (pname value)
+ (ecase pname
+ (:light-model-ambient
+ (with-foreign-object (p 'GLfloat 4)
+ (dotimes (i 4)
+ (setf (mem-aref p 'GLfloat i) (float (elt value i))))
+ (%glLightModelfv pname p)))
+ (:light-model-color-control
+ (%glLightmodeli pname (foreign-enum-value 'light-model-color-control value)))
+ ((:light-model-local-viewer :light-model-two-side)
+ (%glLightModeli pname (if value 1 0)))))
+
+
+;;; 2.14.3 ColorMaterial
+
+(declaim (inline color-material))
+(defun color-material (face mode)
+ (%glColorMaterial face mode))
+
+;;; 2.14.7 Flatshading
+
+(declaim (inline shade-model))
+(defun shade-model (mode)
+ (%glShadeModel mode))
+
+
+
+;;;
+;;; 2.15 Vertex Shaders
+;;;
+
+;;; 2.15.1 Shader Objects
+
+(declaim (inline create-shader))
+(defun create-shader (type)
+ (%glCreateShader type))
+
+(defun shader-source (shader string-list)
+ (let ((num-lines (length string-list)))
+ (with-foreign-object (string-array :pointer num-lines)
+ ;; copy the list of Lisp strings into an array of C strings
+ (loop for line in string-list
+ count line into i
+ do (setf (mem-aref string-array :pointer (1- i)) (foreign-string-alloc line)))
+
+ ;; set the source
+ (%glShaderSource shader num-lines string-array (null-pointer))
+
+ ;; free all allocated strings
+ (dotimes (i num-lines)
+ (foreign-string-free (mem-aref string-array :pointer i)))))
+ string-list)
+
+(declaim (inline compile-shader))
+(defun compile-shader (shader)
+ (%glCompileShader shader))
+
+(declaim (inline delete-shader))
+(defun delete-shader (shader)
+ (%glDeleteShader shader))
+
+
+
+;;; 2.15.2 Program Objects
+
+(defun create-program ()
+ (%glCreateProgram))
+
+(defun attach-shader (program shader)
+ (%glAttachShader program shader))
+
+(defun detach-shader (program shader)
+ (%glDetachShader program shader))
+
+(defun link-program (program)
+ (%glLinkProgram program))
+
+(defun use-program (program)
+ (%glUseProgram program))
+
+(defun delete-program (program)
+ (%glDeleteProgram program))
+
+
+
+;;; 2.15.3 Shader Variables
+
+(defun get-active-attrib (program index)
+ "Returns information about the active attribute variable at index INDEX in program PROGRAM
+as multiple values. 1: Size of attribute. 2: Type of attribute. 3: Name of attribute"
+ ;; FIXME: query size of character buffer
+ (with-foreign-objects ((characters-written 'GLsizei)
+ (size 'GLint)
+ (type :long)
+ (name 'GLchar 1024))
+ (%glGetActiveAttrib program index 1024 characters-written size type name)
+
+ (when (< 0 characters-written)
+ (values (mem-ref size 'GLint)
+ (foreign-enum-keyword 'program-attribute-type (mem-ref type :long))
+ (foreign-string-to-lisp name)))))
+
+
+(defun get-attrib-location (program name)
+ (with-foreign-string (s name)
+ (%glGetAttribLocation program s)))
+
+(defun bind-attrib-location (program index name)
+ (with-foreign-string (s name)
+ (%glBindAttribLocation program index s)))
+
+(defun get-uniform-location (program name)
+ (with-foreign-string (s name)
+ (%glGetUniformLocation program s)))
+
+(defun get-active-uniform (program index)
+ "Returns information about the active uniform attribute at index INDEX in program PROGRAM
+as multiple values. 1: Size of attribute. 2: Type of attribute. 3: Name of attribute"
+ ;; FIXME: query size of character buffer
+ (with-foreign-objects ((characters-written 'GLsizei)
+ (size 'GLint)
+ (type :long)
+ (name 'GLchar 1024))
+ (%glGetActiveUniform program index 1024 characters-written size type name)
+
+ (when (< 0 characters-written)
+ (values (mem-ref size 'GLint)
+ (foreign-enum-keyword 'program-uniform-type (mem-ref type :long))
+ (foreign-string-to-lisp name)))))
+
+
+
+(defun uniformi (location x &optional y z w)
+ (cond
+ (w (%glUniform4i location x y z w))
+ (z (%glUniform3i location x y z))
+ (y (%glUniform2i location x y))
+ (x (%glUniform1i location x))))
+
+(define-compiler-macro uniformi (&whole form location x &optional y z w)
+ (cond
+ (w `(%glUniform4i ,location ,x ,y ,z ,w))
+ (z `(%glUniform3i ,location ,x ,y ,z))
+ (y `(%glUniform2i ,location ,x ,y))
+ (x `(%glUniform1i ,location ,x))))
+
+
+(defun uniformf (location x &optional y z w)
+ (cond
+ (w (%glUniform4f location (float x) (float y) (float z) (float w)))
+ (z (%glUniform3f location (float x) (float y) (float z)))
+ (y (%glUniform2f location (float x) (float y)))
+ (x (%glUniform1f location (float x)))))
+
+(define-compiler-macro uniformf (&whole form location x &optional y z w)
+ (cond
+ (w `(%glUniform4f ,location ,(float x) ,(float y) ,(float z) ,(float w)))
+ (z `(%glUniform3f ,location ,(float x) ,(float y) ,(float z)))
+ (y `(%glUniform2f ,location ,(float x) ,(float y)))
+ (x `(%glUniform1f ,location ,(float x)))))
+
+
+(defun uniform-matrix (location dim matrices &optional (transpose t))
+ (check-type dim '(integer 2 4))
+ (let ((matrix-count (length matrices))
+ (matrix-size (* dim dim)))
+ (with-foreign-object (array 'GLfloat (* matrix-count matrix-size))
+ (dotimes (i matrix-count)
+ (let ((matrix (aref matrices i)))
+ (dotimes (j matrix-size)
+ (setf (mem-aref array 'GLfloat (* i j)) (row-major-aref matrix j)))))
+ (case dim
+ (2 (%glUniformMatrix2fv location matrix-count (if transpose 1 0) array))
+ (3 (%glUniformMatrix3fv location matrix-count (if transpose 1 0) array))
+ (4 (%glUniformMatrix4fv location matrix-count (if transpose 1 0) array))))))
+
+
+;;; 2.15.4 Shader Execution
+
+(declaim (inline validate-program))
+(defun validate-program (program)
+ (%glValidateProgram program))
238 gl/package.lisp
@@ -0,0 +1,238 @@
+;;; -*- Mode: Lisp; indent-tabs-mode: nil -*-
+;;;
+;;; Copyright (c) 2004, Oliver Markovic <entrox@entrox.org>
+;;; All rights reserved.
+;;;
+;;; Redistribution and use in source and binary forms, with or without
+;;; modification, are permitted provided that the following conditions are met:
+;;;
+;;; o Redistributions of source code must retain the above copyright notice,
+;;; this list of conditions and the following disclaimer.
+;;; o Redistributions in binary form must reproduce the above copyright
+;;; notice, this list of conditions and the following disclaimer in the
+;;; documentation and/or other materials provided with the distribution.
+;;; o Neither the name of the author nor the names of the contributors may be
+;;; used to endorse or promote products derived from this software without
+;;; specific prior written permission.
+;;;
+;;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+;;; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+;;; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+;;; ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+;;; LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+;;; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+;;; SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+;;; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+;;; CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+;;; ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+;;; POSSIBILITY OF SUCH DAMAGE.
+
+(defpackage :cl-opengl
+ (:use :cl :cffi)
+ (:nicknames :opengl :gl)
+ (:export ;; 2.5 GL Errors
+ #:get-error
+ #:opengl-error #:opengl-error.error-code
+ #:check-error
+ ;; 2.6 Begin/End Paradigm
+ ;; 2.6.1 Begin and End
+ #:begin
+ #:end
+ #:with-primitives
+ ;; 2.6.2 Polygon Edges
+ #:edge-flag
+ ;; 2.7 Vertex Specification
+ #:vertex
+ #:tex-coord
+ #:multi-tex-coord
+ #:normal
+ #:fog-coord
+ #:color
+ #:secondary-color
+ #:index
+ #:vertex-attrib
+ ;; 2.10 Rectangles
+ #:rect
+ ;; 2.11.2 Controlling the Viewport
+ #:depth-range
+ #:viewport
+ ;; 2.11.3 Matrices
+ #:matrix-mode
+ #:load-matrix
+ #:mult-matrix
+ #:load-transpose-matrix
+ #:mult-transpose-matrix
+ #:rotate
+ #:translate
+ #:scale
+ #:frustum
+ #:ortho
+ #:active-texture
+ #:load-identity
+ #:push-matrix
+ #:pop-matrix
+ ;;; 2.12 Clipping
+ #:clip-plane
+ ;;; 2.13 Current Raster Position
+ #:raster-pos
+ #:window-pos
+ ;;; 2.14.1 Lighting
+ #:front-face
+ ;;; 2.14.2 Lighting Parameter Specification
+ #:material
+ #:light
+ #:light-model
+ ;;; 2.14.3 ColorMaterial
+ #:color-material
+ ;;; 2.14.7 Flatshading
+ #:shade-model
+ ;;; 2.15.1 Shader Objects
+ #:create-shader
+ #:shader-source
+ #:compile-shader
+ #:delete-shader
+ ;;; 2.15.2 Program Objects
+ #:create-program
+ #:attach-shader
+ #:detach-shader
+ #:link-program
+ #:use-program
+ #:delete-program
+ ;;; 2.15.3 Shader Variables
+ #:get-active-attrib
+ #:get-attrib-location
+ #:bind-attrib-location
+ #:get-uniform-location
+ #:get-active-uniform
+ #:uniformi
+ #:uniformf
+ #:uniform-matrix
+ ;;; 2.15.4 Shader Execution
+ #:validate-program
+ ;;; 3.3 Points
+ #:point-size
+ #:point-parameter
+ ;;; 3.4 Line Segments
+ #:line-width
+ #:line-stipple
+ ;;; 3.5 Polygons
+ ;;; 3.5.1 Basic Polygon Rasterization
+ #:cull-face
+ ;;; 3.5.4 Options Controlling Polygon Rasterization
+ #:polygon-mode
+ #:polygon-offset
+ ;;; 3.8.1 Texture Image Specification
+ #:tex-image-2d
+ ;;; 3.8.4 Texture Parameters
+ #:tex-parameter
+ ;;; 3.8.12 Texture Objects
+ #:bind-texture
+ #:delete-textures
+ #:gen-textures
+ ;;; 3.10 Fog
+ #:fog
+ ;;; 5.4 Display Lists
+ #:new-list
+ #:end-list
+ #:call-list
+ #:list-base
+ #:gen-lists
+ #:display-list-p
+ #:delete-lists
+ ;;; 4.1.2 Scissor Test
+ #:scissor
+ ;;; 4.1.3 Multisample Fragment Operations
+ #:sample-coverage
+ ;;; 4.1.4 Alpha Test
+ #:alpha-func
+ ;;; 4.1.5 Stencil Test
+ #:stencil-func