├── .gitignore ├── LICENSE ├── README.md ├── examples ├── glut_example.nim └── nim.cfg ├── opengl.nimble └── src ├── opengl.nim └── opengl ├── glu.nim ├── glut.nim ├── glx.nim ├── private ├── constants.nim ├── errors.nim ├── prelude.nim ├── procs.nim └── types.nim └── wingl.nim /.gitignore: -------------------------------------------------------------------------------- 1 | nimcache/ 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # opengl 2 | An OpenGL interface 3 | 4 | # Extension loading 5 | ``loadExtensions()`` must be executed after the creation of a rendering context and before any OpenGL extension procs are used. 6 | 7 | # Automatic error checking 8 | The OpenGL procs do perform automatic error checking by default. This can be disabled at compile-time by defining the conditional symbol ``noAutoGLerrorCheck`` (-d:noAutoGLerrorCheck), in which case the error checking code will be omitted from the binary; or at run-time by executing this statement: ``enableAutoGLerrorCheck(false)``. 9 | 10 | # Building with x11 (linux) 11 | When receiving the following error: 12 | ``` 13 | /opengl/private/prelude.nim(5, 10) Error: cannot open file: X 14 | ``` 15 | Version 1.2.0 is broken for Linux builds, as x11 is imported incorrectly - use 1.2.2 or greater! 16 | -------------------------------------------------------------------------------- /examples/glut_example.nim: -------------------------------------------------------------------------------- 1 | # OpenGL example using glut 2 | # On windows: Requires glut32.dll or freeglut.dll 3 | import opengl/glut 4 | import opengl 5 | import opengl/glu 6 | 7 | proc display() {.cdecl.} = 8 | glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT) # Clear color and depth buffers 9 | glMatrixMode(GL_MODELVIEW) # To operate on model-view matrix 10 | glLoadIdentity() # Reset the model-view matrix 11 | glTranslatef(1.5, 0.0, -7.0) # Move right and into the screen 12 | 13 | # Render a cube consisting of 6 quads 14 | # Each quad consists of 2 triangles 15 | # Each triangle consists of 3 vertices 16 | 17 | glBegin(GL_TRIANGLES) # Begin drawing of triangles 18 | 19 | # Top face (y = 1.0f) 20 | glColor3f(0.0, 1.0, 0.0) # Green 21 | glVertex3f( 1.0, 1.0, -1.0) 22 | glVertex3f(-1.0, 1.0, -1.0) 23 | glVertex3f(-1.0, 1.0, 1.0) 24 | glVertex3f( 1.0, 1.0, 1.0) 25 | glVertex3f( 1.0, 1.0, -1.0) 26 | glVertex3f(-1.0, 1.0, 1.0) 27 | 28 | # Bottom face (y = -1.0f) 29 | glColor3f(1.0, 0.5, 0.0) # Orange 30 | glVertex3f( 1.0, -1.0, 1.0) 31 | glVertex3f(-1.0, -1.0, 1.0) 32 | glVertex3f(-1.0, -1.0, -1.0) 33 | glVertex3f( 1.0, -1.0, -1.0) 34 | glVertex3f( 1.0, -1.0, 1.0) 35 | glVertex3f(-1.0, -1.0, -1.0) 36 | 37 | # Front face (z = 1.0f) 38 | glColor3f(1.0, 0.0, 0.0) # Red 39 | glVertex3f( 1.0, 1.0, 1.0) 40 | glVertex3f(-1.0, 1.0, 1.0) 41 | glVertex3f(-1.0, -1.0, 1.0) 42 | glVertex3f( 1.0, -1.0, 1.0) 43 | glVertex3f( 1.0, 1.0, 1.0) 44 | glVertex3f(-1.0, -1.0, 1.0) 45 | 46 | # Back face (z = -1.0f) 47 | glColor3f(1.0, 1.0, 0.0) # Yellow 48 | glVertex3f( 1.0, -1.0, -1.0) 49 | glVertex3f(-1.0, -1.0, -1.0) 50 | glVertex3f(-1.0, 1.0, -1.0) 51 | glVertex3f( 1.0, 1.0, -1.0) 52 | glVertex3f( 1.0, -1.0, -1.0) 53 | glVertex3f(-1.0, 1.0, -1.0) 54 | 55 | # Left face (x = -1.0f) 56 | glColor3f(0.0, 0.0, 1.0) # Blue 57 | glVertex3f(-1.0, 1.0, 1.0) 58 | glVertex3f(-1.0, 1.0, -1.0) 59 | glVertex3f(-1.0, -1.0, -1.0) 60 | glVertex3f(-1.0, -1.0, 1.0) 61 | glVertex3f(-1.0, 1.0, 1.0) 62 | glVertex3f(-1.0, -1.0, -1.0) 63 | 64 | # Right face (x = 1.0f) 65 | glColor3f(1.0, 0.0, 1.0) # Magenta 66 | glVertex3f(1.0, 1.0, -1.0) 67 | glVertex3f(1.0, 1.0, 1.0) 68 | glVertex3f(1.0, -1.0, 1.0) 69 | glVertex3f(1.0, -1.0, -1.0) 70 | glVertex3f(1.0, 1.0, -1.0) 71 | glVertex3f(1.0, -1.0, 1.0) 72 | 73 | glEnd() # End of drawing 74 | 75 | glutSwapBuffers() # Swap the front and back frame buffers (double buffering) 76 | 77 | proc reshape(width: GLsizei, height: GLsizei) {.cdecl.} = 78 | # Compute aspect ratio of the new window 79 | if height == 0: 80 | return # To prevent divide by 0 81 | 82 | # Set the viewport to cover the new window 83 | glViewport(0, 0, width, height) 84 | 85 | # Set the aspect ratio of the clipping volume to match the viewport 86 | glMatrixMode(GL_PROJECTION) # To operate on the Projection matrix 87 | glLoadIdentity() # Reset 88 | # Enable perspective projection with fovy, aspect, zNear and zFar 89 | gluPerspective(45.0, width / height, 0.1, 100.0) 90 | 91 | var argc: cint = 0 92 | glutInit(addr argc, nil) 93 | glutInitDisplayMode(GLUT_DOUBLE) 94 | glutInitWindowSize(640, 480) 95 | glutInitWindowPosition(50, 50) 96 | discard glutCreateWindow("OpenGL Example") 97 | 98 | glutDisplayFunc(display) 99 | glutReshapeFunc(reshape) 100 | 101 | loadExtensions() 102 | 103 | glClearColor(0.0, 0.0, 0.0, 1.0) # Set background color to black and opaque 104 | glClearDepth(1.0) # Set background depth to farthest 105 | glEnable(GL_DEPTH_TEST) # Enable depth testing for z-culling 106 | glDepthFunc(GL_LEQUAL) # Set the type of depth-test 107 | glShadeModel(GL_SMOOTH) # Enable smooth shading 108 | glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST) # Nice perspective corrections 109 | 110 | glutMainLoop() 111 | -------------------------------------------------------------------------------- /examples/nim.cfg: -------------------------------------------------------------------------------- 1 | --path:"../src" 2 | -------------------------------------------------------------------------------- /opengl.nimble: -------------------------------------------------------------------------------- 1 | # Package 2 | 3 | version = "1.2.9" 4 | author = "Andreas Rumpf" 5 | description = "an OpenGL wrapper" 6 | license = "MIT" 7 | 8 | srcDir = "src" 9 | 10 | # Dependencies 11 | 12 | when defined(windows): 13 | requires "nim >= 0.11.0" 14 | else: 15 | requires "nim >= 0.11.0", "x11 >= 1.1" 16 | -------------------------------------------------------------------------------- /src/opengl.nim: -------------------------------------------------------------------------------- 1 | # 2 | # 3 | # Nim's Runtime Library 4 | # (c) Copyright 2012-2017 Andreas Rumpf 5 | # 6 | # See the file "copying.txt", included in this 7 | # distribution, for details about the copyright. 8 | # 9 | 10 | ## This module is a wrapper around `opengl`:idx:. If you define the symbol 11 | ## ``useGlew`` this wrapper does not use Nim's ``dynlib`` mechanism, 12 | ## but `glew`:idx: instead. However, this shouldn't be necessary anymore; even 13 | ## extension loading for the different operating systems is handled here. 14 | ## 15 | ## You need to call ``loadExtensions`` after a rendering context has been 16 | ## created to load any extension proc that your code uses. 17 | 18 | include opengl/private/prelude, opengl/private/types, 19 | opengl/private/errors, opengl/private/procs, opengl/private/constants -------------------------------------------------------------------------------- /src/opengl/glu.nim: -------------------------------------------------------------------------------- 1 | # 2 | # 3 | # Adaption of the delphi3d.net OpenGL units to FreePascal 4 | # Sebastian Guenther (sg@freepascal.org) in 2002 5 | # These units are free to use 6 | #****************************************************************************** 7 | # Converted to Delphi by Tom Nuydens (tom@delphi3d.net) 8 | # For the latest updates, visit Delphi3D: http://www.delphi3d.net 9 | #****************************************************************************** 10 | 11 | import opengl 12 | 13 | {.deadCodeElim: on.} 14 | 15 | when defined(windows): 16 | {.push, callconv: stdcall.} 17 | else: 18 | {.push, callconv: cdecl.} 19 | 20 | when defined(windows): 21 | const 22 | dllname = "glu32.dll" 23 | elif defined(macosx): 24 | const 25 | dllname = "/System/Library/Frameworks/OpenGL.framework/Libraries/libGLU.dylib" 26 | else: 27 | const 28 | dllname = "libGLU.so.1" 29 | 30 | type 31 | ViewPortArray* = array[0..3, GLint] 32 | T16dArray* = array[0..15, GLdouble] 33 | CallBack* = proc () {.cdecl.} 34 | T3dArray* = array[0..2, GLdouble] 35 | T4pArray* = array[0..3, pointer] 36 | T4fArray* = array[0..3, GLfloat] 37 | 38 | {.deprecated: [ 39 | TViewPortArray: ViewPortArray, 40 | TCallBack: CallBack, 41 | ].} 42 | 43 | type 44 | GLUnurbs*{.final.} = ptr object 45 | GLUquadric*{.final.} = ptr object 46 | GLUtesselator*{.final.} = ptr object 47 | GLUnurbsObj* = GLUnurbs 48 | GLUquadricObj* = GLUquadric 49 | GLUtesselatorObj* = GLUtesselator 50 | GLUtriangulatorObj* = GLUtesselator 51 | 52 | proc gluErrorString*(errCode: GLenum): cstring{.dynlib: dllname, 53 | importc: "gluErrorString".} 54 | when defined(Windows): 55 | proc gluErrorUnicodeStringEXT*(errCode: GLenum): ptr int16{.dynlib: dllname, 56 | importc: "gluErrorUnicodeStringEXT".} 57 | proc gluGetString*(name: GLenum): cstring{.dynlib: dllname, 58 | importc: "gluGetString".} 59 | proc gluOrtho2D*(left, right, bottom, top: GLdouble){.dynlib: dllname, 60 | importc: "gluOrtho2D".} 61 | proc gluPerspective*(fovy, aspect, zNear, zFar: GLdouble){.dynlib: dllname, 62 | importc: "gluPerspective".} 63 | proc gluPickMatrix*(x, y, width, height: GLdouble, viewport: var ViewPortArray){. 64 | dynlib: dllname, importc: "gluPickMatrix".} 65 | proc gluLookAt*(eyex, eyey, eyez, centerx, centery, centerz, upx, upy, upz: GLdouble){. 66 | dynlib: dllname, importc: "gluLookAt".} 67 | proc gluProject*(objx, objy, objz: GLdouble, 68 | modelMatrix, projMatrix: var T16dArray, 69 | viewport: var ViewPortArray, winx, winy, winz: ptr GLdouble): int{. 70 | dynlib: dllname, importc: "gluProject".} 71 | proc gluUnProject*(winx, winy, winz: GLdouble, 72 | modelMatrix, projMatrix: var T16dArray, 73 | viewport: var ViewPortArray, objx, objy, objz: ptr GLdouble): int{. 74 | dynlib: dllname, importc: "gluUnProject".} 75 | proc gluScaleImage*(format: GLenum, widthin, heightin: GLint, typein: GLenum, 76 | datain: pointer, widthout, heightout: GLint, 77 | typeout: GLenum, dataout: pointer): int{.dynlib: dllname, 78 | importc: "gluScaleImage".} 79 | proc gluBuild1DMipmaps*(target: GLenum, components, width: GLint, 80 | format, atype: GLenum, data: pointer): int{. 81 | dynlib: dllname, importc: "gluBuild1DMipmaps".} 82 | proc gluBuild2DMipmaps*(target: GLenum, components, width, height: GLint, 83 | format, atype: GLenum, data: pointer): int{. 84 | dynlib: dllname, importc: "gluBuild2DMipmaps".} 85 | proc gluNewQuadric*(): GLUquadric{.dynlib: dllname, importc: "gluNewQuadric".} 86 | proc gluDeleteQuadric*(state: GLUquadric){.dynlib: dllname, 87 | importc: "gluDeleteQuadric".} 88 | proc gluQuadricNormals*(quadObject: GLUquadric, normals: GLenum){. 89 | dynlib: dllname, importc: "gluQuadricNormals".} 90 | proc gluQuadricTexture*(quadObject: GLUquadric, textureCoords: GLboolean){. 91 | dynlib: dllname, importc: "gluQuadricTexture".} 92 | proc gluQuadricOrientation*(quadObject: GLUquadric, orientation: GLenum){. 93 | dynlib: dllname, importc: "gluQuadricOrientation".} 94 | proc gluQuadricDrawStyle*(quadObject: GLUquadric, drawStyle: GLenum){. 95 | dynlib: dllname, importc: "gluQuadricDrawStyle".} 96 | proc gluCylinder*(qobj: GLUquadric, baseRadius, topRadius, height: GLdouble, 97 | slices, stacks: GLint){.dynlib: dllname, 98 | importc: "gluCylinder".} 99 | proc gluDisk*(qobj: GLUquadric, innerRadius, outerRadius: GLdouble, 100 | slices, loops: GLint){.dynlib: dllname, importc: "gluDisk".} 101 | proc gluPartialDisk*(qobj: GLUquadric, innerRadius, outerRadius: GLdouble, 102 | slices, loops: GLint, startAngle, sweepAngle: GLdouble){. 103 | dynlib: dllname, importc: "gluPartialDisk".} 104 | proc gluSphere*(qobj: GLuquadric, radius: GLdouble, slices, stacks: GLint){. 105 | dynlib: dllname, importc: "gluSphere".} 106 | proc gluQuadricCallback*(qobj: GLUquadric, which: GLenum, fn: CallBack){. 107 | dynlib: dllname, importc: "gluQuadricCallback".} 108 | proc gluNewTess*(): GLUtesselator{.dynlib: dllname, importc: "gluNewTess".} 109 | proc gluDeleteTess*(tess: GLUtesselator){.dynlib: dllname, 110 | importc: "gluDeleteTess".} 111 | proc gluTessBeginPolygon*(tess: GLUtesselator, polygon_data: pointer){. 112 | dynlib: dllname, importc: "gluTessBeginPolygon".} 113 | proc gluTessBeginContour*(tess: GLUtesselator){.dynlib: dllname, 114 | importc: "gluTessBeginContour".} 115 | proc gluTessVertex*(tess: GLUtesselator, coords: var T3dArray, data: pointer){. 116 | dynlib: dllname, importc: "gluTessVertex".} 117 | proc gluTessEndContour*(tess: GLUtesselator){.dynlib: dllname, 118 | importc: "gluTessEndContour".} 119 | proc gluTessEndPolygon*(tess: GLUtesselator){.dynlib: dllname, 120 | importc: "gluTessEndPolygon".} 121 | proc gluTessProperty*(tess: GLUtesselator, which: GLenum, value: GLdouble){. 122 | dynlib: dllname, importc: "gluTessProperty".} 123 | proc gluTessNormal*(tess: GLUtesselator, x, y, z: GLdouble){.dynlib: dllname, 124 | importc: "gluTessNormal".} 125 | proc gluTessCallback*(tess: GLUtesselator, which: GLenum, fn: CallBack){. 126 | dynlib: dllname, importc: "gluTessCallback".} 127 | proc gluGetTessProperty*(tess: GLUtesselator, which: GLenum, value: ptr GLdouble){. 128 | dynlib: dllname, importc: "gluGetTessProperty".} 129 | proc gluNewNurbsRenderer*(): GLUnurbs{.dynlib: dllname, 130 | importc: "gluNewNurbsRenderer".} 131 | proc gluDeleteNurbsRenderer*(nobj: GLUnurbs){.dynlib: dllname, 132 | importc: "gluDeleteNurbsRenderer".} 133 | proc gluBeginSurface*(nobj: GLUnurbs){.dynlib: dllname, 134 | importc: "gluBeginSurface".} 135 | proc gluBeginCurve*(nobj: GLUnurbs){.dynlib: dllname, importc: "gluBeginCurve".} 136 | proc gluEndCurve*(nobj: GLUnurbs){.dynlib: dllname, importc: "gluEndCurve".} 137 | proc gluEndSurface*(nobj: GLUnurbs){.dynlib: dllname, importc: "gluEndSurface".} 138 | proc gluBeginTrim*(nobj: GLUnurbs){.dynlib: dllname, importc: "gluBeginTrim".} 139 | proc gluEndTrim*(nobj: GLUnurbs){.dynlib: dllname, importc: "gluEndTrim".} 140 | proc gluPwlCurve*(nobj: GLUnurbs, count: GLint, aarray: ptr GLfloat, 141 | stride: GLint, atype: GLenum){.dynlib: dllname, 142 | importc: "gluPwlCurve".} 143 | proc gluNurbsCurve*(nobj: GLUnurbs, nknots: GLint, knot: ptr GLfloat, 144 | stride: GLint, ctlarray: ptr GLfloat, order: GLint, 145 | atype: GLenum){.dynlib: dllname, importc: "gluNurbsCurve".} 146 | proc gluNurbsSurface*(nobj: GLUnurbs, sknot_count: GLint, sknot: ptr GLfloat, 147 | tknot_count: GLint, tknot: ptr GLfloat, 148 | s_stride, t_stride: GLint, ctlarray: ptr GLfloat, 149 | sorder, torder: GLint, atype: GLenum){.dynlib: dllname, 150 | importc: "gluNurbsSurface".} 151 | proc gluLoadSamplingMatrices*(nobj: GLUnurbs, 152 | modelMatrix, projMatrix: var T16dArray, 153 | viewport: var ViewPortArray){.dynlib: dllname, 154 | importc: "gluLoadSamplingMatrices".} 155 | proc gluNurbsProperty*(nobj: GLUnurbs, aproperty: GLenum, value: GLfloat){. 156 | dynlib: dllname, importc: "gluNurbsProperty".} 157 | proc gluGetNurbsProperty*(nobj: GLUnurbs, aproperty: GLenum, value: ptr GLfloat){. 158 | dynlib: dllname, importc: "gluGetNurbsProperty".} 159 | proc gluNurbsCallback*(nobj: GLUnurbs, which: GLenum, fn: CallBack){. 160 | dynlib: dllname, importc: "gluNurbsCallback".} 161 | #*** Callback function prototypes *** 162 | type # gluQuadricCallback 163 | GLUquadricErrorProc* = proc (p: GLenum) # gluTessCallback 164 | GLUtessBeginProc* = proc (p: GLenum) 165 | GLUtessEdgeFlagProc* = proc (p: GLboolean) 166 | GLUtessVertexProc* = proc (p: pointer) 167 | GLUtessEndProc* = proc () 168 | GLUtessErrorProc* = proc (p: GLenum) 169 | GLUtessCombineProc* = proc (p1: var T3dArray, p2: T4pArray, p3: T4fArray, 170 | p4: ptr pointer) 171 | GLUtessBeginDataProc* = proc (p1: GLenum, p2: pointer) 172 | GLUtessEdgeFlagDataProc* = proc (p1: GLboolean, p2: pointer) 173 | GLUtessVertexDataProc* = proc (p1, p2: pointer) 174 | GLUtessEndDataProc* = proc (p: pointer) 175 | GLUtessErrorDataProc* = proc (p1: GLenum, p2: pointer) 176 | GLUtessCombineDataProc* = proc (p1: var T3dArray, p2: var T4pArray, 177 | p3: var T4fArray, p4: ptr pointer, p5: pointer) # 178 | GLUnurbsErrorProc* = proc (p: GLenum) #*** Generic constants ****/ 179 | 180 | const # Version 181 | GLU_VERSION_1_1* = 1 182 | GLU_VERSION_1_2* = 1 # Errors: (return value 0 = no error) 183 | GLU_INVALID_ENUM* = 100900 184 | GLU_INVALID_VALUE* = 100901 185 | GLU_OUT_OF_MEMORY* = 100902 186 | GLU_INCOMPATIBLE_GL_VERSION* = 100903 # StringName 187 | GLU_VERSION* = 100800 188 | GLU_EXTENSIONS* = 100801 # Boolean 189 | GLU_TRUE* = GL_TRUE 190 | GLU_FALSE* = GL_FALSE #*** Quadric constants ****/ 191 | # QuadricNormal 192 | GLU_SMOOTH* = 100000 193 | GLU_FLAT* = 100001 194 | GLU_NONE* = 100002 # QuadricDrawStyle 195 | GLU_POINT* = 100010 196 | GLU_LINE* = 100011 197 | GLU_FILL* = 100012 198 | GLU_SILHOUETTE* = 100013 # QuadricOrientation 199 | GLU_OUTSIDE* = 100020 200 | GLU_INSIDE* = 100021 # Callback types: 201 | # GLU_ERROR = 100103; 202 | #*** Tesselation constants ****/ 203 | GLU_TESS_MAX_COORD* = 1.00000e+150 # TessProperty 204 | GLU_TESS_WINDING_RULE* = 100140 205 | GLU_TESS_BOUNDARY_ONLY* = 100141 206 | GLU_TESS_TOLERANCE* = 100142 # TessWinding 207 | GLU_TESS_WINDING_ODD* = 100130 208 | GLU_TESS_WINDING_NONZERO* = 100131 209 | GLU_TESS_WINDING_POSITIVE* = 100132 210 | GLU_TESS_WINDING_NEGATIVE* = 100133 211 | GLU_TESS_WINDING_ABS_GEQ_TWO* = 100134 # TessCallback 212 | GLU_TESS_BEGIN* = 100100 # void (CALLBACK*)(GLenum type) 213 | constGLU_TESS_VERTEX* = 100101 # void (CALLBACK*)(void *data) 214 | GLU_TESS_END* = 100102 # void (CALLBACK*)(void) 215 | GLU_TESS_ERROR* = 100103 # void (CALLBACK*)(GLenum errno) 216 | GLU_TESS_EDGE_FLAG* = 100104 # void (CALLBACK*)(GLboolean boundaryEdge) 217 | GLU_TESS_COMBINE* = 100105 # void (CALLBACK*)(GLdouble coords[3], 218 | # void *data[4], 219 | # GLfloat weight[4], 220 | # void **dataOut) 221 | GLU_TESS_BEGIN_DATA* = 100106 # void (CALLBACK*)(GLenum type, 222 | # void *polygon_data) 223 | GLU_TESS_VERTEX_DATA* = 100107 # void (CALLBACK*)(void *data, 224 | # void *polygon_data) 225 | GLU_TESS_END_DATA* = 100108 # void (CALLBACK*)(void *polygon_data) 226 | GLU_TESS_ERROR_DATA* = 100109 # void (CALLBACK*)(GLenum errno, 227 | # void *polygon_data) 228 | GLU_TESS_EDGE_FLAG_DATA* = 100110 # void (CALLBACK*)(GLboolean boundaryEdge, 229 | # void *polygon_data) 230 | GLU_TESS_COMBINE_DATA* = 100111 # void (CALLBACK*)(GLdouble coords[3], 231 | # void *data[4], 232 | # GLfloat weight[4], 233 | # void **dataOut, 234 | # void *polygon_data) 235 | # TessError 236 | GLU_TESS_ERROR1* = 100151 237 | GLU_TESS_ERROR2* = 100152 238 | GLU_TESS_ERROR3* = 100153 239 | GLU_TESS_ERROR4* = 100154 240 | GLU_TESS_ERROR5* = 100155 241 | GLU_TESS_ERROR6* = 100156 242 | GLU_TESS_ERROR7* = 100157 243 | GLU_TESS_ERROR8* = 100158 244 | GLU_TESS_MISSING_BEGIN_POLYGON* = GLU_TESS_ERROR1 245 | GLU_TESS_MISSING_BEGIN_CONTOUR* = GLU_TESS_ERROR2 246 | GLU_TESS_MISSING_END_POLYGON* = GLU_TESS_ERROR3 247 | GLU_TESS_MISSING_END_CONTOUR* = GLU_TESS_ERROR4 248 | GLU_TESS_COORD_TOO_LARGE* = GLU_TESS_ERROR5 249 | GLU_TESS_NEED_COMBINE_CALLBACK* = GLU_TESS_ERROR6 #*** NURBS constants ****/ 250 | # NurbsProperty 251 | GLU_AUTO_LOAD_MATRIX* = 100200 252 | GLU_CULLING* = 100201 253 | GLU_SAMPLING_TOLERANCE* = 100203 254 | GLU_DISPLAY_MODE* = 100204 255 | GLU_PARAMETRIC_TOLERANCE* = 100202 256 | GLU_SAMPLING_METHOD* = 100205 257 | GLU_U_STEP* = 100206 258 | GLU_V_STEP* = 100207 # NurbsSampling 259 | GLU_PATH_LENGTH* = 100215 260 | GLU_PARAMETRIC_ERROR* = 100216 261 | GLU_DOMAIN_DISTANCE* = 100217 # NurbsTrim 262 | GLU_MAP1_TRIM_2* = 100210 263 | GLU_MAP1_TRIM_3* = 100211 # NurbsDisplay 264 | # GLU_FILL = 100012; 265 | GLU_OUTLINE_POLYGON* = 100240 266 | GLU_OUTLINE_PATCH* = 100241 # NurbsCallback 267 | # GLU_ERROR = 100103; 268 | # NurbsErrors 269 | GLU_NURBS_ERROR1* = 100251 270 | GLU_NURBS_ERROR2* = 100252 271 | GLU_NURBS_ERROR3* = 100253 272 | GLU_NURBS_ERROR4* = 100254 273 | GLU_NURBS_ERROR5* = 100255 274 | GLU_NURBS_ERROR6* = 100256 275 | GLU_NURBS_ERROR7* = 100257 276 | GLU_NURBS_ERROR8* = 100258 277 | GLU_NURBS_ERROR9* = 100259 278 | GLU_NURBS_ERROR10* = 100260 279 | GLU_NURBS_ERROR11* = 100261 280 | GLU_NURBS_ERROR12* = 100262 281 | GLU_NURBS_ERROR13* = 100263 282 | GLU_NURBS_ERROR14* = 100264 283 | GLU_NURBS_ERROR15* = 100265 284 | GLU_NURBS_ERROR16* = 100266 285 | GLU_NURBS_ERROR17* = 100267 286 | GLU_NURBS_ERROR18* = 100268 287 | GLU_NURBS_ERROR19* = 100269 288 | GLU_NURBS_ERROR20* = 100270 289 | GLU_NURBS_ERROR21* = 100271 290 | GLU_NURBS_ERROR22* = 100272 291 | GLU_NURBS_ERROR23* = 100273 292 | GLU_NURBS_ERROR24* = 100274 293 | GLU_NURBS_ERROR25* = 100275 294 | GLU_NURBS_ERROR26* = 100276 295 | GLU_NURBS_ERROR27* = 100277 296 | GLU_NURBS_ERROR28* = 100278 297 | GLU_NURBS_ERROR29* = 100279 298 | GLU_NURBS_ERROR30* = 100280 299 | GLU_NURBS_ERROR31* = 100281 300 | GLU_NURBS_ERROR32* = 100282 301 | GLU_NURBS_ERROR33* = 100283 302 | GLU_NURBS_ERROR34* = 100284 303 | GLU_NURBS_ERROR35* = 100285 304 | GLU_NURBS_ERROR36* = 100286 305 | GLU_NURBS_ERROR37* = 100287 #*** Backwards compatibility for old tesselator ****/ 306 | 307 | proc gluBeginPolygon*(tess: GLUtesselator){.dynlib: dllname, 308 | importc: "gluBeginPolygon".} 309 | proc gluNextContour*(tess: GLUtesselator, atype: GLenum){.dynlib: dllname, 310 | importc: "gluNextContour".} 311 | proc gluEndPolygon*(tess: GLUtesselator){.dynlib: dllname, 312 | importc: "gluEndPolygon".} 313 | const # Contours types -- obsolete! 314 | GLU_CW* = 100120 315 | GLU_CCW* = 100121 316 | GLU_INTERIOR* = 100122 317 | GLU_EXTERIOR* = 100123 318 | GLU_UNKNOWN* = 100124 # Names without "TESS_" prefix 319 | GLU_BEGIN* = GLU_TESS_BEGIN 320 | GLU_VERTEX* = constGLU_TESS_VERTEX 321 | GLU_END* = GLU_TESS_END 322 | GLU_ERROR* = GLU_TESS_ERROR 323 | GLU_EDGE_FLAG* = GLU_TESS_EDGE_FLAG 324 | 325 | {.pop.} 326 | # implementation 327 | -------------------------------------------------------------------------------- /src/opengl/glut.nim: -------------------------------------------------------------------------------- 1 | # 2 | # 3 | # Adaption of the delphi3d.net OpenGL units to FreePascal 4 | # Sebastian Guenther (sg@freepascal.org) in 2002 5 | # These units are free to use 6 | # 7 | 8 | # Copyright (c) Mark J. Kilgard, 1994, 1995, 1996. 9 | # This program is freely distributable without licensing fees and is 10 | # provided without guarantee or warrantee expressed or implied. This 11 | # program is -not- in the public domain. 12 | #****************************************************************************** 13 | # Converted to Delphi by Tom Nuydens (tom@delphi3d.net) 14 | # Contributions by Igor Karpov (glygrik@hotbox.ru) 15 | # For the latest updates, visit Delphi3D: http://www.delphi3d.net 16 | #****************************************************************************** 17 | 18 | import opengl 19 | 20 | {.deadCodeElim: on.} 21 | 22 | when defined(windows): 23 | const 24 | dllname = "(freeglut.dll|glut32.dll)" 25 | elif defined(macosx): 26 | const 27 | dllname = "/System/Library/Frameworks/GLUT.framework/GLUT" 28 | else: 29 | const 30 | dllname = "libglut.so.3" 31 | type 32 | TGlutVoidCallback* = proc (){.cdecl.} 33 | TGlut1IntCallback* = proc (value: cint){.cdecl.} 34 | TGlut2IntCallback* = proc (v1, v2: cint){.cdecl.} 35 | TGlut3IntCallback* = proc (v1, v2, v3: cint){.cdecl.} 36 | TGlut4IntCallback* = proc (v1, v2, v3, v4: cint){.cdecl.} 37 | TGlut1Char2IntCallback* = proc (c: int8, v1, v2: cint){.cdecl.} 38 | TGlut1UInt3IntCallback* = proc (u, v1, v2, v3: cint){.cdecl.} 39 | 40 | {.deprecated: [Pointer: pointer].} 41 | 42 | const 43 | GLUT_API_VERSION* = 3 44 | GLUT_XLIB_IMPLEMENTATION* = 12 # Display mode bit masks. 45 | GLUT_RGB* = 0 46 | GLUT_RGBA* = GLUT_RGB 47 | GLUT_INDEX* = 1 48 | GLUT_SINGLE* = 0 49 | GLUT_DOUBLE* = 2 50 | GLUT_ACCUM* = 4 51 | GLUT_ALPHA* = 8 52 | GLUT_DEPTH* = 16 53 | GLUT_STENCIL* = 32 54 | GLUT_MULTISAMPLE* = 128 55 | GLUT_STEREO* = 256 56 | GLUT_LUMINANCE* = 512 # Mouse buttons. 57 | GLUT_LEFT_BUTTON* = 0 58 | GLUT_MIDDLE_BUTTON* = 1 59 | GLUT_RIGHT_BUTTON* = 2 # Mouse button state. 60 | GLUT_DOWN* = 0 61 | GLUT_UP* = 1 # function keys 62 | GLUT_KEY_F1* = 1 63 | GLUT_KEY_F2* = 2 64 | GLUT_KEY_F3* = 3 65 | GLUT_KEY_F4* = 4 66 | GLUT_KEY_F5* = 5 67 | GLUT_KEY_F6* = 6 68 | GLUT_KEY_F7* = 7 69 | GLUT_KEY_F8* = 8 70 | GLUT_KEY_F9* = 9 71 | GLUT_KEY_F10* = 10 72 | GLUT_KEY_F11* = 11 73 | GLUT_KEY_F12* = 12 # directional keys 74 | GLUT_KEY_LEFT* = 100 75 | GLUT_KEY_UP* = 101 76 | GLUT_KEY_RIGHT* = 102 77 | GLUT_KEY_DOWN* = 103 78 | GLUT_KEY_PAGE_UP* = 104 79 | GLUT_KEY_PAGE_DOWN* = 105 80 | GLUT_KEY_HOME* = 106 81 | GLUT_KEY_END* = 107 82 | GLUT_KEY_INSERT* = 108 # Entry/exit state. 83 | GLUT_LEFT* = 0 84 | GLUT_ENTERED* = 1 # Menu usage state. 85 | GLUT_MENU_NOT_IN_USE* = 0 86 | GLUT_MENU_IN_USE* = 1 # Visibility state. 87 | GLUT_NOT_VISIBLE* = 0 88 | GLUT_VISIBLE* = 1 # Window status state. 89 | GLUT_HIDDEN* = 0 90 | GLUT_FULLY_RETAINED* = 1 91 | GLUT_PARTIALLY_RETAINED* = 2 92 | GLUT_FULLY_COVERED* = 3 # Color index component selection values. 93 | GLUT_RED* = 0 94 | GLUT_GREEN* = 1 95 | GLUT_BLUE* = 2 # Layers for use. 96 | GLUT_NORMAL* = 0 97 | GLUT_OVERLAY* = 1 98 | 99 | {.push dynlib: dllname, importc.} 100 | 101 | when defined(Windows): 102 | const # Stroke font constants (use these in GLUT program). 103 | GLUT_STROKE_ROMAN* = cast[pointer](0) 104 | GLUT_STROKE_MONO_ROMAN* = cast[pointer](1) # Bitmap font constants (use these in GLUT program). 105 | GLUT_BITMAP_9_BY_15* = cast[pointer](2) 106 | GLUT_BITMAP_8_BY_13* = cast[pointer](3) 107 | GLUT_BITMAP_TIMES_ROMAN_10* = cast[pointer](4) 108 | GLUT_BITMAP_TIMES_ROMAN_24* = cast[pointer](5) 109 | GLUT_BITMAP_HELVETICA_10* = cast[pointer](6) 110 | GLUT_BITMAP_HELVETICA_12* = cast[pointer](7) 111 | GLUT_BITMAP_HELVETICA_18* = cast[pointer](8) 112 | else: 113 | var # Stroke font constants (use these in GLUT program). 114 | glutStrokeRoman {.importc: "glutStrokeRoman".}: pointer 115 | glutStrokeMonoRoman {.importc: "glutStrokeMonoRoman".}: pointer # Bitmap font constants (use these in GLUT program). 116 | glutBitmap9By15 {.importc: "glutBitmap9By15".}: pointer 117 | glutBitmap8By13 {.importc: "glutBitmap8By13".}: pointer 118 | glutBitmapTimesRoman10 {.importc: "glutBitmapTimesRoman10".}: pointer 119 | glutBitmapTimesRoman24 {.importc: "glutBitmapTimesRoman24".}: pointer 120 | glutBitmapHelvetica10 {.importc: "glutBitmapHelvetica10".}: pointer 121 | glutBitmapHelvetica12 {.importc: "glutBitmapHelvetica12".}: pointer 122 | glutBitmapHelvetica18 {.importc: "glutBitmapHelvetica18".}: pointer 123 | 124 | let 125 | GLUT_STROKE_ROMAN* = cast[pointer](addr glutStrokeRoman) 126 | GLUT_STROKE_MONO_ROMAN* = cast[pointer](addr glutStrokeMonoRoman) 127 | GLUT_BITMAP_9_BY_15* = cast[pointer](addr glutBitmap9By15) 128 | GLUT_BITMAP_8_BY_13* = cast[pointer](addr glutBitmap8By13) 129 | GLUT_BITMAP_TIMES_ROMAN_10* = cast[pointer](addr glutBitmapTimesRoman10) 130 | GLUT_BITMAP_TIMES_ROMAN_24* = cast[pointer](addr glutBitmapTimesRoman24) 131 | GLUT_BITMAP_HELVETICA_10* = cast[pointer](addr glutBitmapHelvetica10) 132 | GLUT_BITMAP_HELVETICA_12* = cast[pointer](addr glutBitmapHelvetica12) 133 | GLUT_BITMAP_HELVETICA_18* = cast[pointer](addr glutBitmapHelvetica18) 134 | 135 | const # glutGet parameters. 136 | GLUT_WINDOW_X* = 100 137 | GLUT_WINDOW_Y* = 101 138 | GLUT_WINDOW_WIDTH* = 102 139 | GLUT_WINDOW_HEIGHT* = 103 140 | GLUT_WINDOW_BUFFER_SIZE* = 104 141 | GLUT_WINDOW_STENCIL_SIZE* = 105 142 | GLUT_WINDOW_DEPTH_SIZE* = 106 143 | GLUT_WINDOW_RED_SIZE* = 107 144 | GLUT_WINDOW_GREEN_SIZE* = 108 145 | GLUT_WINDOW_BLUE_SIZE* = 109 146 | GLUT_WINDOW_ALPHA_SIZE* = 110 147 | GLUT_WINDOW_ACCUM_RED_SIZE* = 111 148 | GLUT_WINDOW_ACCUM_GREEN_SIZE* = 112 149 | GLUT_WINDOW_ACCUM_BLUE_SIZE* = 113 150 | GLUT_WINDOW_ACCUM_ALPHA_SIZE* = 114 151 | GLUT_WINDOW_DOUBLEBUFFER* = 115 152 | GLUT_WINDOW_RGBA* = 116 153 | GLUT_WINDOW_PARENT* = 117 154 | GLUT_WINDOW_NUM_CHILDREN* = 118 155 | GLUT_WINDOW_COLORMAP_SIZE* = 119 156 | GLUT_WINDOW_NUM_SAMPLES* = 120 157 | GLUT_WINDOW_STEREO* = 121 158 | GLUT_WINDOW_CURSOR* = 122 159 | GLUT_SCREEN_WIDTH* = 200 160 | GLUT_SCREEN_HEIGHT* = 201 161 | GLUT_SCREEN_WIDTH_MM* = 202 162 | GLUT_SCREEN_HEIGHT_MM* = 203 163 | GLUT_MENU_NUM_ITEMS* = 300 164 | GLUT_DISPLAY_MODE_POSSIBLE* = 400 165 | GLUT_INIT_WINDOW_X* = 500 166 | GLUT_INIT_WINDOW_Y* = 501 167 | GLUT_INIT_WINDOW_WIDTH* = 502 168 | GLUT_INIT_WINDOW_HEIGHT* = 503 169 | constGLUT_INIT_DISPLAY_MODE* = 504 170 | GLUT_ELAPSED_TIME* = 700 171 | GLUT_WINDOW_FORMAT_ID* = 123 # glutDeviceGet parameters. 172 | GLUT_HAS_KEYBOARD* = 600 173 | GLUT_HAS_MOUSE* = 601 174 | GLUT_HAS_SPACEBALL* = 602 175 | GLUT_HAS_DIAL_AND_BUTTON_BOX* = 603 176 | GLUT_HAS_TABLET* = 604 177 | GLUT_NUM_MOUSE_BUTTONS* = 605 178 | GLUT_NUM_SPACEBALL_BUTTONS* = 606 179 | GLUT_NUM_BUTTON_BOX_BUTTONS* = 607 180 | GLUT_NUM_DIALS* = 608 181 | GLUT_NUM_TABLET_BUTTONS* = 609 182 | GLUT_DEVICE_IGNORE_KEY_REPEAT* = 610 183 | GLUT_DEVICE_KEY_REPEAT* = 611 184 | GLUT_HAS_JOYSTICK* = 612 185 | GLUT_OWNS_JOYSTICK* = 613 186 | GLUT_JOYSTICK_BUTTONS* = 614 187 | GLUT_JOYSTICK_AXES* = 615 188 | GLUT_JOYSTICK_POLL_RATE* = 616 # glutLayerGet parameters. 189 | GLUT_OVERLAY_POSSIBLE* = 800 190 | GLUT_LAYER_IN_USE* = 801 191 | GLUT_HAS_OVERLAY* = 802 192 | GLUT_TRANSPARENT_INDEX* = 803 193 | GLUT_NORMAL_DAMAGED* = 804 194 | GLUT_OVERLAY_DAMAGED* = 805 # glutVideoResizeGet parameters. 195 | GLUT_VIDEO_RESIZE_POSSIBLE* = 900 196 | GLUT_VIDEO_RESIZE_IN_USE* = 901 197 | GLUT_VIDEO_RESIZE_X_DELTA* = 902 198 | GLUT_VIDEO_RESIZE_Y_DELTA* = 903 199 | GLUT_VIDEO_RESIZE_WIDTH_DELTA* = 904 200 | GLUT_VIDEO_RESIZE_HEIGHT_DELTA* = 905 201 | GLUT_VIDEO_RESIZE_X* = 906 202 | GLUT_VIDEO_RESIZE_Y* = 907 203 | GLUT_VIDEO_RESIZE_WIDTH* = 908 204 | GLUT_VIDEO_RESIZE_HEIGHT* = 909 # glutGetModifiers return mask. 205 | GLUT_ACTIVE_SHIFT* = 1 206 | GLUT_ACTIVE_CTRL* = 2 207 | GLUT_ACTIVE_ALT* = 4 # glutSetCursor parameters. 208 | # Basic arrows. 209 | GLUT_CURSOR_RIGHT_ARROW* = 0 210 | GLUT_CURSOR_LEFT_ARROW* = 1 # Symbolic cursor shapes. 211 | GLUT_CURSOR_INFO* = 2 212 | GLUT_CURSOR_DESTROY* = 3 213 | GLUT_CURSOR_HELP* = 4 214 | GLUT_CURSOR_CYCLE* = 5 215 | GLUT_CURSOR_SPRAY* = 6 216 | GLUT_CURSOR_WAIT* = 7 217 | GLUT_CURSOR_TEXT* = 8 218 | GLUT_CURSOR_CROSSHAIR* = 9 # Directional cursors. 219 | GLUT_CURSOR_UP_DOWN* = 10 220 | GLUT_CURSOR_LEFT_RIGHT* = 11 # Sizing cursors. 221 | GLUT_CURSOR_TOP_SIDE* = 12 222 | GLUT_CURSOR_BOTTOM_SIDE* = 13 223 | GLUT_CURSOR_LEFT_SIDE* = 14 224 | GLUT_CURSOR_RIGHT_SIDE* = 15 225 | GLUT_CURSOR_TOP_LEFT_CORNER* = 16 226 | GLUT_CURSOR_TOP_RIGHT_CORNER* = 17 227 | GLUT_CURSOR_BOTTOM_RIGHT_CORNER* = 18 228 | GLUT_CURSOR_BOTTOM_LEFT_CORNER* = 19 # Inherit from parent window. 229 | GLUT_CURSOR_INHERIT* = 100 # Blank cursor. 230 | GLUT_CURSOR_NONE* = 101 # Fullscreen crosshair (if available). 231 | GLUT_CURSOR_FULL_CROSSHAIR* = 102 # GLUT device control sub-API. 232 | # glutSetKeyRepeat modes. 233 | GLUT_KEY_REPEAT_OFF* = 0 234 | GLUT_KEY_REPEAT_ON* = 1 235 | GLUT_KEY_REPEAT_DEFAULT* = 2 # Joystick button masks. 236 | GLUT_JOYSTICK_BUTTON_A* = 1 237 | GLUT_JOYSTICK_BUTTON_B* = 2 238 | GLUT_JOYSTICK_BUTTON_C* = 4 239 | GLUT_JOYSTICK_BUTTON_D* = 8 # GLUT game mode sub-API. 240 | # glutGameModeGet. 241 | GLUT_GAME_MODE_ACTIVE* = 0 242 | GLUT_GAME_MODE_POSSIBLE* = 1 243 | GLUT_GAME_MODE_WIDTH* = 2 244 | GLUT_GAME_MODE_HEIGHT* = 3 245 | GLUT_GAME_MODE_PIXEL_DEPTH* = 4 246 | GLUT_GAME_MODE_REFRESH_RATE* = 5 247 | GLUT_GAME_MODE_DISPLAY_CHANGED* = 6 # GLUT initialization sub-API. 248 | 249 | proc glutInit*(argcp: ptr cint, argv: pointer) 250 | proc glutInitDisplayMode*(mode: int16) 251 | proc glutInitDisplayString*(str: cstring) 252 | proc glutInitWindowPosition*(x, y: int) 253 | proc glutInitWindowSize*(width, height: int) 254 | proc glutMainLoop*() 255 | # GLUT window sub-API. 256 | proc glutCreateWindow*(title: cstring): int 257 | proc glutCreateSubWindow*(win, x, y, width, height: int): int 258 | proc glutDestroyWindow*(win: int) 259 | proc glutPostRedisplay*() 260 | proc glutPostWindowRedisplay*(win: int) 261 | proc glutSwapBuffers*() 262 | proc glutSetWindow*(win: int) 263 | proc glutSetWindowTitle*(title: cstring) 264 | proc glutSetIconTitle*(title: cstring) 265 | proc glutPositionWindow*(x, y: int) 266 | proc glutReshapeWindow*(width, height: int) 267 | proc glutPopWindow*() 268 | proc glutPushWindow*() 269 | proc glutIconifyWindow*() 270 | proc glutShowWindow*() 271 | proc glutHideWindow*() 272 | proc glutFullScreen*() 273 | proc glutSetCursor*(cursor: int) 274 | proc glutWarpPointer*(x, y: int) 275 | # GLUT overlay sub-API. 276 | proc glutEstablishOverlay*() 277 | proc glutRemoveOverlay*() 278 | proc glutUseLayer*(layer: GLenum) 279 | proc glutPostOverlayRedisplay*() 280 | proc glutPostWindowOverlayRedisplay*(win: int) 281 | proc glutShowOverlay*() 282 | proc glutHideOverlay*() 283 | # GLUT menu sub-API. 284 | proc glutCreateMenu*(callback: TGlut1IntCallback): int 285 | proc glutDestroyMenu*(menu: int) 286 | proc glutSetMenu*(menu: int) 287 | proc glutAddMenuEntry*(caption: cstring, value: int) 288 | proc glutAddSubMenu*(caption: cstring, submenu: int) 289 | proc glutChangeToMenuEntry*(item: int, caption: cstring, value: int) 290 | proc glutChangeToSubMenu*(item: int, caption: cstring, submenu: int) 291 | proc glutRemoveMenuItem*(item: int) 292 | proc glutAttachMenu*(button: int) 293 | proc glutDetachMenu*(button: int) 294 | # GLUT window callback sub-API. 295 | proc glutDisplayFunc*(f: TGlutVoidCallback) 296 | proc glutReshapeFunc*(f: TGlut2IntCallback) 297 | proc glutKeyboardFunc*(f: TGlut1Char2IntCallback) 298 | proc glutMouseFunc*(f: TGlut4IntCallback) 299 | proc glutMotionFunc*(f: TGlut2IntCallback) 300 | proc glutPassiveMotionFunc*(f: TGlut2IntCallback) 301 | proc glutEntryFunc*(f: TGlut1IntCallback) 302 | proc glutVisibilityFunc*(f: TGlut1IntCallback) 303 | proc glutIdleFunc*(f: TGlutVoidCallback) 304 | proc glutTimerFunc*(millis: int16, f: TGlut1IntCallback, value: int) 305 | proc glutMenuStateFunc*(f: TGlut1IntCallback) 306 | proc glutSpecialFunc*(f: TGlut3IntCallback) 307 | proc glutSpaceballMotionFunc*(f: TGlut3IntCallback) 308 | proc glutSpaceballRotateFunc*(f: TGlut3IntCallback) 309 | proc glutSpaceballButtonFunc*(f: TGlut2IntCallback) 310 | proc glutButtonBoxFunc*(f: TGlut2IntCallback) 311 | proc glutDialsFunc*(f: TGlut2IntCallback) 312 | proc glutTabletMotionFunc*(f: TGlut2IntCallback) 313 | proc glutTabletButtonFunc*(f: TGlut4IntCallback) 314 | proc glutMenuStatusFunc*(f: TGlut3IntCallback) 315 | proc glutOverlayDisplayFunc*(f: TGlutVoidCallback) 316 | proc glutWindowStatusFunc*(f: TGlut1IntCallback) 317 | proc glutKeyboardUpFunc*(f: TGlut1Char2IntCallback) 318 | proc glutSpecialUpFunc*(f: TGlut3IntCallback) 319 | proc glutJoystickFunc*(f: TGlut1UInt3IntCallback, pollInterval: int) 320 | # GLUT color index sub-API. 321 | proc glutSetColor*(cell: int, red, green, blue: GLfloat) 322 | proc glutGetColor*(ndx, component: int): GLfloat 323 | proc glutCopyColormap*(win: int) 324 | # GLUT state retrieval sub-API. 325 | # GLUT extension support sub-API 326 | proc glutExtensionSupported*(name: cstring): int 327 | # GLUT font sub-API 328 | proc glutBitmapCharacter*(font: pointer, character: int) 329 | proc glutBitmapWidth*(font: pointer, character: int): int 330 | proc glutBitmapHeight*(font: pointer): int 331 | proc glutStrokeCharacter*(font: pointer, character: int) 332 | proc glutStrokeWidth*(font: pointer, character: int): int 333 | proc glutBitmapLength*(font: pointer, str: cstring): int 334 | proc glutStrokeLength*(font: pointer, str: cstring): int 335 | # GLUT pre-built models sub-API 336 | proc glutWireSphere*(radius: GLdouble, slices, stacks: GLint) 337 | proc glutSolidSphere*(radius: GLdouble, slices, stacks: GLint) 338 | proc glutWireCone*(base, height: GLdouble, slices, stacks: GLint) 339 | proc glutSolidCone*(base, height: GLdouble, slices, stacks: GLint) 340 | proc glutWireCube*(size: GLdouble) 341 | proc glutSolidCube*(size: GLdouble) 342 | proc glutWireTorus*(innerRadius, outerRadius: GLdouble, sides, rings: GLint) 343 | proc glutSolidTorus*(innerRadius, outerRadius: GLdouble, sides, rings: GLint) 344 | proc glutWireDodecahedron*() 345 | proc glutSolidDodecahedron*() 346 | proc glutWireTeapot*(size: GLdouble) 347 | proc glutSolidTeapot*(size: GLdouble) 348 | proc glutWireOctahedron*() 349 | proc glutSolidOctahedron*() 350 | proc glutWireTetrahedron*() 351 | proc glutSolidTetrahedron*() 352 | proc glutWireIcosahedron*() 353 | proc glutSolidIcosahedron*() 354 | # GLUT video resize sub-API. 355 | proc glutVideoResizeGet*(param: GLenum): int 356 | proc glutSetupVideoResizing*() 357 | proc glutStopVideoResizing*() 358 | proc glutVideoResize*(x, y, width, height: int) 359 | proc glutVideoPan*(x, y, width, height: int) 360 | # GLUT debugging sub-API. 361 | proc glutReportErrors*() 362 | # GLUT device control sub-API. 363 | proc glutIgnoreKeyRepeat*(ignore: int) 364 | proc glutSetKeyRepeat*(repeatMode: int) 365 | proc glutForceJoystickFunc*() 366 | # GLUT game mode sub-API. 367 | #example glutGameModeString('1280x1024:32@75'); 368 | proc glutGameModeString*(AString: cstring) 369 | proc glutLeaveGameMode*() 370 | proc glutGameModeGet*(mode: GLenum): int 371 | # implementation 372 | {.pop.} # dynlib: dllname, importc 373 | 374 | # Convenience procs 375 | proc glutInit*() = 376 | ## version that passes `argc` and `argc` implicitely. 377 | var 378 | cmdLine {.importc: "cmdLine".}: array[0..255, cstring] 379 | cmdCount {.importc: "cmdCount".}: cint 380 | glutInit(addr(cmdCount), addr(cmdLine)) 381 | -------------------------------------------------------------------------------- /src/opengl/glx.nim: -------------------------------------------------------------------------------- 1 | # 2 | # 3 | # Translation of the Mesa GLX headers for FreePascal 4 | # Copyright (C) 1999 Sebastian Guenther 5 | # 6 | # 7 | # Mesa 3-D graphics library 8 | # Version: 3.0 9 | # Copyright (C) 1995-1998 Brian Paul 10 | # 11 | 12 | import x11/x, x11/xlib, x11/xutil, opengl 13 | 14 | {.deadCodeElim: on.} 15 | 16 | when defined(windows): 17 | const 18 | dllname = "GL.dll" 19 | elif defined(macosx): 20 | const 21 | dllname = "/usr/X11R6/lib/libGL.dylib" 22 | elif defined(linux): 23 | const 24 | dllname = "libGL.so.1" 25 | else: 26 | const 27 | dllname = "libGL.so" 28 | const 29 | GLX_USE_GL* = 1'i32 30 | GLX_BUFFER_SIZE* = 2'i32 31 | GLX_LEVEL* = 3'i32 32 | GLX_RGBA* = 4'i32 33 | GLX_DOUBLEBUFFER* = 5'i32 34 | GLX_STEREO* = 6'i32 35 | GLX_AUX_BUFFERS* = 7'i32 36 | GLX_RED_SIZE* = 8'i32 37 | GLX_GREEN_SIZE* = 9'i32 38 | GLX_BLUE_SIZE* = 10'i32 39 | GLX_ALPHA_SIZE* = 11'i32 40 | GLX_DEPTH_SIZE* = 12'i32 41 | GLX_STENCIL_SIZE* = 13'i32 42 | GLX_ACCUM_RED_SIZE* = 14'i32 43 | GLX_ACCUM_GREEN_SIZE* = 15'i32 44 | GLX_ACCUM_BLUE_SIZE* = 16'i32 45 | GLX_ACCUM_ALPHA_SIZE* = 17'i32 # GLX_EXT_visual_info extension 46 | GLX_X_VISUAL_TYPE_EXT* = 0x00000022 47 | GLX_TRANSPARENT_TYPE_EXT* = 0x00000023 48 | GLX_TRANSPARENT_INDEX_VALUE_EXT* = 0x00000024 49 | GLX_TRANSPARENT_RED_VALUE_EXT* = 0x00000025 50 | GLX_TRANSPARENT_GREEN_VALUE_EXT* = 0x00000026 51 | GLX_TRANSPARENT_BLUE_VALUE_EXT* = 0x00000027 52 | GLX_TRANSPARENT_ALPHA_VALUE_EXT* = 0x00000028 # Error codes returned by glXGetConfig: 53 | GLX_BAD_SCREEN* = 1 54 | GLX_BAD_ATTRIBUTE* = 2 55 | GLX_NO_EXTENSION* = 3 56 | GLX_BAD_VISUAL* = 4 57 | GLX_BAD_CONTEXT* = 5 58 | GLX_BAD_VALUE* = 6 59 | GLX_BAD_ENUM* = 7 # GLX 1.1 and later: 60 | GLX_VENDOR* = 1 61 | GLX_VERSION* = 2 62 | GLX_EXTENSIONS* = 3 # GLX_visual_info extension 63 | GLX_TRUE_COLOR_EXT* = 0x00008002 64 | GLX_DIRECT_COLOR_EXT* = 0x00008003 65 | GLX_PSEUDO_COLOR_EXT* = 0x00008004 66 | GLX_STATIC_COLOR_EXT* = 0x00008005 67 | GLX_GRAY_SCALE_EXT* = 0x00008006 68 | GLX_STATIC_GRAY_EXT* = 0x00008007 69 | GLX_NONE_EXT* = 0x00008000 70 | GLX_TRANSPARENT_RGB_EXT* = 0x00008008 71 | GLX_TRANSPARENT_INDEX_EXT* = 0x00008009 72 | 73 | type # From XLib: 74 | XPixmap* = XID 75 | XFont* = XID 76 | XColormap* = XID 77 | GLXContext* = pointer 78 | GLXPixmap* = XID 79 | GLXDrawable* = XID 80 | GLXContextID* = XID 81 | TXPixmap* = XPixmap 82 | TXFont* = XFont 83 | TXColormap* = XColormap 84 | TGLXContext* = GLXContext 85 | TGLXPixmap* = GLXPixmap 86 | TGLXDrawable* = GLXDrawable 87 | TGLXContextID* = GLXContextID 88 | 89 | GLXBool = cint 90 | 91 | proc glXChooseVisual*(dpy: PDisplay, screen: cint, attribList: ptr int32): PXVisualInfo{. 92 | cdecl, dynlib: dllname, importc: "glXChooseVisual".} 93 | proc glXCreateContext*(dpy: PDisplay, vis: PXVisualInfo, shareList: GLXContext, 94 | direct: GLXBool): GLXContext{.cdecl, dynlib: dllname, 95 | importc: "glXCreateContext".} 96 | proc glXDestroyContext*(dpy: PDisplay, ctx: GLXContext){.cdecl, dynlib: dllname, 97 | importc: "glXDestroyContext".} 98 | proc glXMakeCurrent*(dpy: PDisplay, drawable: GLXDrawable, ctx: GLXContext): GLXBool{. 99 | cdecl, dynlib: dllname, importc: "glXMakeCurrent".} 100 | proc glXCopyContext*(dpy: PDisplay, src, dst: GLXContext, mask: int32){.cdecl, 101 | dynlib: dllname, importc: "glXCopyContext".} 102 | proc glXSwapBuffers*(dpy: PDisplay, drawable: GLXDrawable){.cdecl, 103 | dynlib: dllname, importc: "glXSwapBuffers".} 104 | proc glXCreateGLXPixmap*(dpy: PDisplay, visual: PXVisualInfo, pixmap: XPixmap): GLXPixmap{. 105 | cdecl, dynlib: dllname, importc: "glXCreateGLXPixmap".} 106 | proc glXDestroyGLXPixmap*(dpy: PDisplay, pixmap: GLXPixmap){.cdecl, 107 | dynlib: dllname, importc: "glXDestroyGLXPixmap".} 108 | proc glXQueryExtension*(dpy: PDisplay, errorb, event: var cint): GLXBool{.cdecl, 109 | dynlib: dllname, importc: "glXQueryExtension".} 110 | proc glXQueryVersion*(dpy: PDisplay, maj, min: var cint): GLXBool{.cdecl, 111 | dynlib: dllname, importc: "glXQueryVersion".} 112 | proc glXIsDirect*(dpy: PDisplay, ctx: GLXContext): GLXBool{.cdecl, dynlib: dllname, 113 | importc: "glXIsDirect".} 114 | proc glXGetConfig*(dpy: PDisplay, visual: PXVisualInfo, attrib: cint, 115 | value: var cint): cint{.cdecl, dynlib: dllname, 116 | importc: "glXGetConfig".} 117 | proc glXGetCurrentContext*(): GLXContext{.cdecl, dynlib: dllname, 118 | importc: "glXGetCurrentContext".} 119 | proc glXGetCurrentDrawable*(): GLXDrawable{.cdecl, dynlib: dllname, 120 | importc: "glXGetCurrentDrawable".} 121 | proc glXWaitGL*(){.cdecl, dynlib: dllname, importc: "glXWaitGL".} 122 | proc glXWaitX*(){.cdecl, dynlib: dllname, importc: "glXWaitX".} 123 | proc glXUseXFont*(font: XFont, first, count, list: cint){.cdecl, dynlib: dllname, 124 | importc: "glXUseXFont".} 125 | # GLX 1.1 and later 126 | proc glXQueryExtensionsString*(dpy: PDisplay, screen: cint): cstring{.cdecl, 127 | dynlib: dllname, importc: "glXQueryExtensionsString".} 128 | proc glXQueryServerString*(dpy: PDisplay, screen, name: cint): cstring{.cdecl, 129 | dynlib: dllname, importc: "glXQueryServerString".} 130 | proc glXGetClientString*(dpy: PDisplay, name: cint): cstring{.cdecl, 131 | dynlib: dllname, importc: "glXGetClientString".} 132 | # Mesa GLX Extensions 133 | proc glXCreateGLXPixmapMESA*(dpy: PDisplay, visual: PXVisualInfo, 134 | pixmap: XPixmap, cmap: XColormap): GLXPixmap{. 135 | cdecl, dynlib: dllname, importc: "glXCreateGLXPixmapMESA".} 136 | proc glXReleaseBufferMESA*(dpy: PDisplay, d: GLXDrawable): GLXBool{.cdecl, 137 | dynlib: dllname, importc: "glXReleaseBufferMESA".} 138 | proc glXCopySubBufferMESA*(dpy: PDisplay, drawbale: GLXDrawable, 139 | x, y, width, height: cint){.cdecl, dynlib: dllname, 140 | importc: "glXCopySubBufferMESA".} 141 | proc glXGetVideoSyncSGI*(counter: var int32): cint{.cdecl, dynlib: dllname, 142 | importc: "glXGetVideoSyncSGI".} 143 | proc glXWaitVideoSyncSGI*(divisor, remainder: cint, count: var int32): cint{. 144 | cdecl, dynlib: dllname, importc: "glXWaitVideoSyncSGI".} 145 | # implementation 146 | -------------------------------------------------------------------------------- /src/opengl/private/errors.nim: -------------------------------------------------------------------------------- 1 | import macros, sequtils 2 | 3 | proc glGetError*(): GLenum {.stdcall, importc, ogl.} 4 | 5 | macro wrapErrorChecking*(f: untyped): typed = 6 | f.expectKind nnkStmtList 7 | result = newStmtList() 8 | 9 | for child in f.children: 10 | if child.kind == nnkCommentStmt: 11 | continue 12 | child.expectKind nnkProcDef 13 | 14 | let params = toSeq(child.params.children) 15 | var glProc = copy child 16 | glProc.pragma = newTree(nnkPragma, 17 | newTree(nnkExprColonExpr, 18 | ident"importc" , newLit($child.name)), 19 | ident"ogl") 20 | 21 | let rawGLprocName = $glProc.name 22 | glProc.name = ident(rawGLprocName & "Impl") 23 | var 24 | body = newStmtList glProc 25 | returnsSomething = child.params[0].kind != nnkEmpty 26 | callParams = newSeq[NimNode]() 27 | for param in params[1 ..< params.len]: 28 | callParams.add param[0] 29 | 30 | let glCall = newCall(glProc.name, callParams) 31 | body.add if returnsSomething: 32 | newAssignment(ident"result", glCall) 33 | else: 34 | glCall 35 | 36 | if rawGLprocName == "glBegin": 37 | body.add newAssignment(ident"gInsideBeginEnd", ident"true") 38 | if rawGLprocName == "glEnd": 39 | body.add newAssignment(ident"gInsideBeginEnd", ident"false") 40 | 41 | template errCheck: untyped = 42 | when not (NoAutoGLerrorCheck): 43 | if gAutoGLerrorCheck and not gInsideBeginEnd: 44 | checkGLerror() 45 | 46 | body.add getAst(errCheck()) 47 | 48 | var procc = newProc(child.name, params, body) 49 | procc.pragma = newTree(nnkPragma, ident"inline") 50 | procc.name = postfix(procc.name, "*") 51 | result.add procc 52 | 53 | type 54 | GLerrorCode* {.size: GLenum.sizeof.} = enum 55 | glErrNoError = (0, "no error") 56 | glErrInvalidEnum = (0x0500, "invalid enum") 57 | glErrInvalidValue = (0x0501, "invalid value") 58 | glErrInvalidOperation = (0x0502, "invalid operation") 59 | glErrStackOverflow = (0x0503, "stack overflow") 60 | glErrStackUnderflow = (0x0504, "stack underflow") 61 | glErrOutOfMem = (0x0505, "out of memory") 62 | glErrInvalidFramebufferOperation = (0x0506, "invalid framebuffer operation") 63 | glErrTableTooLarge = (0x8031, "table too large") 64 | 65 | const AllErrorCodes = [ 66 | glErrNoError, 67 | glErrInvalidEnum, 68 | glErrInvalidValue, 69 | glErrInvalidOperation, 70 | glErrStackOverflow, 71 | glErrStackUnderflow, 72 | glErrOutOfMem, 73 | glErrInvalidFramebufferOperation, 74 | glErrTableTooLarge, 75 | ] 76 | 77 | proc getGLerrorCode*: GLerrorCode = glGetError().GLerrorCode 78 | ## Like ``glGetError`` but returns an enumerator instead. 79 | 80 | type 81 | GLerror* = object of Exception 82 | ## An exception for OpenGL errors. 83 | code*: GLerrorCode ## The error code. This might be invalid for two reasons: 84 | ## an outdated list of errors or a bad driver. 85 | 86 | proc checkGLerror* = 87 | ## Raise ``GLerror`` if the last call to an OpenGL function generated an error. 88 | ## You might want to call this once every frame for example if automatic 89 | ## error checking has been disabled. 90 | let error = getGLerrorCode() 91 | if error == glErrNoError: 92 | return 93 | 94 | var 95 | exc = new(GLerror) 96 | for e in AllErrorCodes: 97 | if e == error: 98 | exc.msg = "OpenGL error: " & $e 99 | raise exc 100 | 101 | exc.code = error 102 | exc.msg = "OpenGL error: unknown (" & $error & ")" 103 | raise exc 104 | 105 | {.push warning[User]: off.} 106 | 107 | const 108 | NoAutoGLerrorCheck* = defined(noAutoGLerrorCheck) ##\ 109 | ## This determines (at compile time) whether an exception should be raised 110 | ## if an OpenGL call generates an error. No additional code will be generated 111 | ## and ``enableAutoGLerrorCheck(bool)`` will have no effect when 112 | ## ``noAutoGLerrorCheck`` is defined. 113 | 114 | {.pop.} # warning[User]: off 115 | 116 | var 117 | gAutoGLerrorCheck = true 118 | gInsideBeginEnd* = false # do not change manually. 119 | 120 | proc enableAutoGLerrorCheck*(yes: bool) = 121 | ## This determines (at run time) whether an exception should be raised if an 122 | ## OpenGL call generates an error. This has no effect when 123 | ## ``noAutoGLerrorCheck`` is defined. 124 | gAutoGLerrorCheck = yes 125 | -------------------------------------------------------------------------------- /src/opengl/private/prelude.nim: -------------------------------------------------------------------------------- 1 | {.deadCodeElim: on.} 2 | {.push warning[User]: off.} 3 | 4 | when defined(windows): 5 | const 6 | ogldll* = "OpenGL32.dll" 7 | gludll* = "GLU32.dll" 8 | elif defined(macosx): 9 | #macosx has this notion of a framework, thus the path to the openGL dylib files 10 | #is absolute 11 | const 12 | ogldll* = "/System/Library/Frameworks/OpenGL.framework/Versions/Current/Libraries/libGL.dylib" 13 | gludll* = "/System/Library/Frameworks/OpenGL.framework/Versions/Current/Libraries/libGLU.dylib" 14 | else: 15 | const 16 | ogldll* = "libGL.so.1" 17 | gludll* = "libGLU.so.1" 18 | 19 | when defined(useGlew): 20 | {.pragma: ogl, header: "".} 21 | {.pragma: oglx, header: "".} 22 | {.pragma: wgl, header: "".} 23 | {.pragma: glu, dynlib: gludll.} 24 | 25 | when defined(linux) or defined(windows): 26 | {.passC: "-flto -useGlew".} 27 | when defined(windows): 28 | {.passL: "-lglew32 -lopengl32".} 29 | elif defined(linux): 30 | {.passL: "-lGLEW -lGL".} 31 | elif defined(ios): 32 | {.pragma: ogl.} 33 | {.pragma: oglx.} 34 | {.passC: "-framework OpenGLES", passL: "-framework OpenGLES".} 35 | elif defined(android) or defined(js) or defined(emscripten) or defined(wasm): 36 | {.pragma: ogl.} 37 | {.pragma: oglx.} 38 | else: 39 | # quite complex ... thanks to extension support for various platforms: 40 | import dynlib 41 | 42 | let oglHandle = loadLib(ogldll) 43 | if isNil(oglHandle): quit("could not load: " & ogldll) 44 | 45 | when defined(windows): 46 | var wglGetProcAddress = cast[proc (s: cstring): pointer {.stdcall.}]( 47 | symAddr(oglHandle, "wglGetProcAddress")) 48 | elif defined(linux): 49 | var glxGetProcAddress = cast[proc (s: cstring): pointer {.cdecl.}]( 50 | symAddr(oglHandle, "glXGetProcAddress")) 51 | var glxGetProcAddressArb = cast[proc (s: cstring): pointer {.cdecl.}]( 52 | symAddr(oglHandle, "glXGetProcAddressARB")) 53 | 54 | proc glGetProc(h: LibHandle; procName: cstring): pointer = 55 | when defined(windows): 56 | result = symAddr(h, procname) 57 | if result != nil: return 58 | if not isNil(wglGetProcAddress): result = wglGetProcAddress(procName) 59 | elif defined(linux): 60 | if not isNil(glxGetProcAddress): result = glxGetProcAddress(procName) 61 | if result != nil: return 62 | if not isNil(glxGetProcAddressArb): 63 | result = glxGetProcAddressArb(procName) 64 | if result != nil: return 65 | result = symAddr(h, procname) 66 | else: 67 | result = symAddr(h, procName) 68 | if result == nil: raiseInvalidLibrary(procName) 69 | 70 | proc glGetProc*(name: cstring): pointer {.inline.} = 71 | glGetProc(oglHandle, name) 72 | 73 | var gluHandle: LibHandle 74 | 75 | proc gluGetProc(procname: cstring): pointer = 76 | if gluHandle == nil: 77 | gluHandle = loadLib(gludll) 78 | if gluHandle == nil: quit("could not load: " & gludll) 79 | result = glGetProc(gluHandle, procname) 80 | 81 | # undocumented 'dynlib' feature: the string literal is replaced by 82 | # the imported proc name: 83 | {.pragma: ogl, dynlib: glGetProc("0").} 84 | {.pragma: oglx, dynlib: glGetProc("0").} 85 | {.pragma: wgl, dynlib: glGetProc("0").} 86 | {.pragma: glu, dynlib: gluGetProc("").} 87 | 88 | proc nimLoadProcs0() {.importc.} 89 | 90 | template loadExtensions*() = 91 | ## call this after your rendering context has been setup if you use 92 | ## extensions. 93 | bind nimLoadProcs0 94 | nimLoadProcs0() 95 | 96 | {.pop.} # warning[User]: off 97 | -------------------------------------------------------------------------------- /src/opengl/private/types.nim: -------------------------------------------------------------------------------- 1 | type 2 | GLenum* = distinct uint32 3 | GLboolean* = bool 4 | GLbitfield* = distinct uint32 5 | GLvoid* = pointer 6 | GLbyte* = int8 7 | GLshort* = int16 8 | GLint* = int32 9 | GLclampx* = int32 10 | GLubyte* = uint8 11 | GLushort* = uint16 12 | GLuint* = uint32 13 | GLhandle* = GLuint 14 | GLsizei* = int32 15 | GLfloat* = float32 16 | GLclampf* = float32 17 | GLdouble* = float64 18 | GLclampd* = float64 19 | GLeglImageOES* = distinct pointer 20 | GLchar* = char 21 | GLcharArb* = char 22 | GLfixed* = int32 23 | GLhalfNv* = uint16 24 | GLvdpauSurfaceNv* = uint 25 | GLintptr* = int 26 | GLintptrArb* = int 27 | GLint64EXT* = int64 28 | GLuint64EXT* = uint64 29 | GLint64* = int64 30 | GLsizeiptrArb* = int 31 | GLsizeiptr* = int 32 | GLsync* = distinct pointer 33 | GLuint64* = uint64 34 | GLvectorub2* = array[0..1, GLubyte] 35 | GLvectori2* = array[0..1, GLint] 36 | GLvectorf2* = array[0..1, GLfloat] 37 | GLvectord2* = array[0..1, GLdouble] 38 | GLvectorp2* = array[0..1, pointer] 39 | GLvectorb3* = array[0..2, GLbyte] 40 | GLvectorub3* = array[0..2, GLubyte] 41 | GLvectori3* = array[0..2, GLint] 42 | GLvectorui3* = array[0..2, GLuint] 43 | GLvectorf3* = array[0..2, GLfloat] 44 | GLvectord3* = array[0..2, GLdouble] 45 | GLvectorp3* = array[0..2, pointer] 46 | GLvectors3* = array[0..2, GLshort] 47 | GLvectorus3* = array[0..2, GLushort] 48 | GLvectorb4* = array[0..3, GLbyte] 49 | GLvectorub4* = array[0..3, GLubyte] 50 | GLvectori4* = array[0..3, GLint] 51 | GLvectorui4* = array[0..3, GLuint] 52 | GLvectorf4* = array[0..3, GLfloat] 53 | GLvectord4* = array[0..3, GLdouble] 54 | GLvectorp4* = array[0..3, pointer] 55 | GLvectors4* = array[0..3, GLshort] 56 | GLvectorus4* = array[0..3, GLshort] 57 | GLarray4f* = GLvectorf4 58 | GLarrayf3* = GLvectorf3 59 | GLarrayd3* = GLvectord3 60 | GLarrayi4* = GLvectori4 61 | GLarrayp4* = GLvectorp4 62 | GLmatrixub3* = array[0..2, array[0..2, GLubyte]] 63 | GLmatrixi3* = array[0..2, array[0..2, GLint]] 64 | GLmatrixf3* = array[0..2, array[0..2, GLfloat]] 65 | GLmatrixd3* = array[0..2, array[0..2, GLdouble]] 66 | GLmatrixub4* = array[0..3, array[0..3, GLubyte]] 67 | GLmatrixi4* = array[0..3, array[0..3, GLint]] 68 | GLmatrixf4* = array[0..3, array[0..3, GLfloat]] 69 | GLmatrixd4* = array[0..3, array[0..3, GLdouble]] 70 | ClContext* = distinct pointer 71 | ClEvent* = distinct pointer 72 | GLdebugProc* = proc ( 73 | source: GLenum, 74 | typ: GLenum, 75 | id: GLuint, 76 | severity: GLenum, 77 | length: GLsizei, 78 | message: ptr GLchar, 79 | userParam: pointer) {.stdcall.} 80 | GLdebugProcArb* = proc ( 81 | source: GLenum, 82 | typ: GLenum, 83 | id: GLuint, 84 | severity: GLenum, 85 | len: GLsizei, 86 | message: ptr GLchar, 87 | userParam: pointer) {.stdcall.} 88 | GLdebugProcAmd* = proc ( 89 | id: GLuint, 90 | category: GLenum, 91 | severity: GLenum, 92 | len: GLsizei, 93 | message: ptr GLchar, 94 | userParam: pointer) {.stdcall.} 95 | GLdebugProcKhr* = proc ( 96 | source, typ: GLenum, 97 | id: GLuint, 98 | severity: GLenum, 99 | length: GLsizei, 100 | message: ptr GLchar, 101 | userParam: pointer) {.stdcall.} 102 | 103 | when defined(macosx): 104 | type 105 | GLhandleArb = pointer 106 | else: 107 | type 108 | GLhandleArb = uint32 109 | 110 | proc `==`*(a, b: GLenum): bool {.borrow.} 111 | proc `==`*(a, b: GLbitfield): bool {.borrow.} 112 | proc `or`*(a, b: GLbitfield): GLbitfield {.borrow.} 113 | proc hash*(x: GLenum): int = x.int 114 | 115 | when defined(useGlew): 116 | proc glewInit*(): GLenum {.importc.} 117 | -------------------------------------------------------------------------------- /src/opengl/wingl.nim: -------------------------------------------------------------------------------- 1 | import opengl, windows 2 | 3 | {.deadCodeElim: on.} 4 | 5 | proc wglGetExtensionsStringARB*(hdc: HDC): cstring{.dynlib: dllname, 6 | importc: "wglGetExtensionsStringARB".} 7 | const 8 | WGL_FRONT_COLOR_BUFFER_BIT_ARB* = 0x00000001 9 | WGL_BACK_COLOR_BUFFER_BIT_ARB* = 0x00000002 10 | WGL_DEPTH_BUFFER_BIT_ARB* = 0x00000004 11 | WGL_STENCIL_BUFFER_BIT_ARB* = 0x00000008 12 | 13 | proc WinChoosePixelFormat*(DC: HDC, p2: PPixelFormatDescriptor): int{. 14 | dynlib: "gdi32", importc: "ChoosePixelFormat".} 15 | proc wglCreateBufferRegionARB*(hDC: HDC, iLayerPlane: TGLint, uType: TGLuint): THandle{. 16 | dynlib: dllname, importc: "wglCreateBufferRegionARB".} 17 | proc wglDeleteBufferRegionARB*(hRegion: THandle){.dynlib: dllname, 18 | importc: "wglDeleteBufferRegionARB".} 19 | proc wglSaveBufferRegionARB*(hRegion: THandle, x: TGLint, y: TGLint, 20 | width: TGLint, height: TGLint): BOOL{. 21 | dynlib: dllname, importc: "wglSaveBufferRegionARB".} 22 | proc wglRestoreBufferRegionARB*(hRegion: THandle, x: TGLint, y: TGLint, 23 | width: TGLint, height: TGLint, xSrc: TGLint, 24 | ySrc: TGLint): BOOL{.dynlib: dllname, 25 | importc: "wglRestoreBufferRegionARB".} 26 | proc wglAllocateMemoryNV*(size: TGLsizei, readFrequency: TGLfloat, 27 | writeFrequency: TGLfloat, priority: TGLfloat): PGLvoid{. 28 | dynlib: dllname, importc: "wglAllocateMemoryNV".} 29 | proc wglFreeMemoryNV*(pointer: PGLvoid){.dynlib: dllname, 30 | importc: "wglFreeMemoryNV".} 31 | const 32 | WGL_IMAGE_BUFFER_MIN_ACCESS_I3D* = 0x00000001 33 | WGL_IMAGE_BUFFER_LOCK_I3D* = 0x00000002 34 | 35 | proc wglCreateImageBufferI3D*(hDC: HDC, dwSize: DWORD, uFlags: UINT): PGLvoid{. 36 | dynlib: dllname, importc: "wglCreateImageBufferI3D".} 37 | proc wglDestroyImageBufferI3D*(hDC: HDC, pAddress: PGLvoid): BOOL{. 38 | dynlib: dllname, importc: "wglDestroyImageBufferI3D".} 39 | proc wglAssociateImageBufferEventsI3D*(hdc: HDC, pEvent: PHandle, 40 | pAddress: PGLvoid, pSize: PDWORD, 41 | count: UINT): BOOL{.dynlib: dllname, 42 | importc: "wglAssociateImageBufferEventsI3D".} 43 | proc wglReleaseImageBufferEventsI3D*(hdc: HDC, pAddress: PGLvoid, count: UINT): BOOL{. 44 | dynlib: dllname, importc: "wglReleaseImageBufferEventsI3D".} 45 | proc wglEnableFrameLockI3D*(): BOOL{.dynlib: dllname, 46 | importc: "wglEnableFrameLockI3D".} 47 | proc wglDisableFrameLockI3D*(): BOOL{.dynlib: dllname, 48 | importc: "wglDisableFrameLockI3D".} 49 | proc wglIsEnabledFrameLockI3D*(pFlag: PBOOL): BOOL{.dynlib: dllname, 50 | importc: "wglIsEnabledFrameLockI3D".} 51 | proc wglQueryFrameLockMasterI3D*(pFlag: PBOOL): BOOL{.dynlib: dllname, 52 | importc: "wglQueryFrameLockMasterI3D".} 53 | proc wglGetFrameUsageI3D*(pUsage: PGLfloat): BOOL{.dynlib: dllname, 54 | importc: "wglGetFrameUsageI3D".} 55 | proc wglBeginFrameTrackingI3D*(): BOOL{.dynlib: dllname, 56 | importc: "wglBeginFrameTrackingI3D".} 57 | proc wglEndFrameTrackingI3D*(): BOOL{.dynlib: dllname, 58 | importc: "wglEndFrameTrackingI3D".} 59 | proc wglQueryFrameTrackingI3D*(pFrameCount: PDWORD, pMissedFrames: PDWORD, 60 | pLastMissedUsage: PGLfloat): BOOL{. 61 | dynlib: dllname, importc: "wglQueryFrameTrackingI3D".} 62 | const 63 | WGL_NUMBER_PIXEL_FORMATS_ARB* = 0x00002000 64 | WGL_DRAW_TO_WINDOW_ARB* = 0x00002001 65 | WGL_DRAW_TO_BITMAP_ARB* = 0x00002002 66 | WGL_ACCELERATION_ARB* = 0x00002003 67 | WGL_NEED_PALETTE_ARB* = 0x00002004 68 | WGL_NEED_SYSTEM_PALETTE_ARB* = 0x00002005 69 | WGL_SWAP_LAYER_BUFFERS_ARB* = 0x00002006 70 | WGL_SWAP_METHOD_ARB* = 0x00002007 71 | WGL_NUMBER_OVERLAYS_ARB* = 0x00002008 72 | WGL_NUMBER_UNDERLAYS_ARB* = 0x00002009 73 | WGL_TRANSPARENT_ARB* = 0x0000200A 74 | WGL_TRANSPARENT_RED_VALUE_ARB* = 0x00002037 75 | WGL_TRANSPARENT_GREEN_VALUE_ARB* = 0x00002038 76 | WGL_TRANSPARENT_BLUE_VALUE_ARB* = 0x00002039 77 | WGL_TRANSPARENT_ALPHA_VALUE_ARB* = 0x0000203A 78 | WGL_TRANSPARENT_INDEX_VALUE_ARB* = 0x0000203B 79 | WGL_SHARE_DEPTH_ARB* = 0x0000200C 80 | WGL_SHARE_STENCIL_ARB* = 0x0000200D 81 | WGL_SHARE_ACCUM_ARB* = 0x0000200E 82 | WGL_SUPPORT_GDI_ARB* = 0x0000200F 83 | WGL_SUPPORT_OPENGL_ARB* = 0x00002010 84 | WGL_DOUBLE_BUFFER_ARB* = 0x00002011 85 | WGL_STEREO_ARB* = 0x00002012 86 | WGL_PIXEL_TYPE_ARB* = 0x00002013 87 | WGL_COLOR_BITS_ARB* = 0x00002014 88 | WGL_RED_BITS_ARB* = 0x00002015 89 | WGL_RED_SHIFT_ARB* = 0x00002016 90 | WGL_GREEN_BITS_ARB* = 0x00002017 91 | WGL_GREEN_SHIFT_ARB* = 0x00002018 92 | WGL_BLUE_BITS_ARB* = 0x00002019 93 | WGL_BLUE_SHIFT_ARB* = 0x0000201A 94 | WGL_ALPHA_BITS_ARB* = 0x0000201B 95 | WGL_ALPHA_SHIFT_ARB* = 0x0000201C 96 | WGL_ACCUM_BITS_ARB* = 0x0000201D 97 | WGL_ACCUM_RED_BITS_ARB* = 0x0000201E 98 | WGL_ACCUM_GREEN_BITS_ARB* = 0x0000201F 99 | WGL_ACCUM_BLUE_BITS_ARB* = 0x00002020 100 | WGL_ACCUM_ALPHA_BITS_ARB* = 0x00002021 101 | WGL_DEPTH_BITS_ARB* = 0x00002022 102 | WGL_STENCIL_BITS_ARB* = 0x00002023 103 | WGL_AUX_BUFFERS_ARB* = 0x00002024 104 | WGL_NO_ACCELERATION_ARB* = 0x00002025 105 | WGL_GENERIC_ACCELERATION_ARB* = 0x00002026 106 | WGL_FULL_ACCELERATION_ARB* = 0x00002027 107 | WGL_SWAP_EXCHANGE_ARB* = 0x00002028 108 | WGL_SWAP_COPY_ARB* = 0x00002029 109 | WGL_SWAP_UNDEFINED_ARB* = 0x0000202A 110 | WGL_TYPE_RGBA_ARB* = 0x0000202B 111 | WGL_TYPE_COLORINDEX_ARB* = 0x0000202C 112 | 113 | proc wglGetPixelFormatAttribivARB*(hdc: HDC, iPixelFormat: TGLint, 114 | iLayerPlane: TGLint, nAttributes: TGLuint, 115 | piAttributes: PGLint, piValues: PGLint): BOOL{. 116 | dynlib: dllname, importc: "wglGetPixelFormatAttribivARB".} 117 | proc wglGetPixelFormatAttribfvARB*(hdc: HDC, iPixelFormat: TGLint, 118 | iLayerPlane: TGLint, nAttributes: TGLuint, 119 | piAttributes: PGLint, pfValues: PGLfloat): BOOL{. 120 | dynlib: dllname, importc: "wglGetPixelFormatAttribfvARB".} 121 | proc wglChoosePixelFormatARB*(hdc: HDC, piAttribIList: PGLint, 122 | pfAttribFList: PGLfloat, nMaxFormats: TGLuint, 123 | piFormats: PGLint, nNumFormats: PGLuint): BOOL{. 124 | dynlib: dllname, importc: "wglChoosePixelFormatARB".} 125 | const 126 | WGL_ERROR_INVALID_PIXEL_TYPE_ARB* = 0x00002043 127 | WGL_ERROR_INCOMPATIBLE_DEVICE_CONTEXTS_ARB* = 0x00002054 128 | 129 | proc wglMakeContextCurrentARB*(hDrawDC: HDC, hReadDC: HDC, hglrc: HGLRC): BOOL{. 130 | dynlib: dllname, importc: "wglMakeContextCurrentARB".} 131 | proc wglGetCurrentReadDCARB*(): HDC{.dynlib: dllname, 132 | importc: "wglGetCurrentReadDCARB".} 133 | const 134 | WGL_DRAW_TO_PBUFFER_ARB* = 0x0000202D # WGL_DRAW_TO_PBUFFER_ARB { already defined } 135 | WGL_MAX_PBUFFER_PIXELS_ARB* = 0x0000202E 136 | WGL_MAX_PBUFFER_WIDTH_ARB* = 0x0000202F 137 | WGL_MAX_PBUFFER_HEIGHT_ARB* = 0x00002030 138 | WGL_PBUFFER_LARGEST_ARB* = 0x00002033 139 | WGL_PBUFFER_WIDTH_ARB* = 0x00002034 140 | WGL_PBUFFER_HEIGHT_ARB* = 0x00002035 141 | WGL_PBUFFER_LOST_ARB* = 0x00002036 142 | 143 | proc wglCreatePbufferARB*(hDC: HDC, iPixelFormat: TGLint, iWidth: TGLint, 144 | iHeight: TGLint, piAttribList: PGLint): THandle{. 145 | dynlib: dllname, importc: "wglCreatePbufferARB".} 146 | proc wglGetPbufferDCARB*(hPbuffer: THandle): HDC{.dynlib: dllname, 147 | importc: "wglGetPbufferDCARB".} 148 | proc wglReleasePbufferDCARB*(hPbuffer: THandle, hDC: HDC): TGLint{. 149 | dynlib: dllname, importc: "wglReleasePbufferDCARB".} 150 | proc wglDestroyPbufferARB*(hPbuffer: THandle): BOOL{.dynlib: dllname, 151 | importc: "wglDestroyPbufferARB".} 152 | proc wglQueryPbufferARB*(hPbuffer: THandle, iAttribute: TGLint, piValue: PGLint): BOOL{. 153 | dynlib: dllname, importc: "wglQueryPbufferARB".} 154 | proc wglSwapIntervalEXT*(interval: TGLint): BOOL{.dynlib: dllname, 155 | importc: "wglSwapIntervalEXT".} 156 | proc wglGetSwapIntervalEXT*(): TGLint{.dynlib: dllname, 157 | importc: "wglGetSwapIntervalEXT".} 158 | const 159 | WGL_BIND_TO_TEXTURE_RGB_ARB* = 0x00002070 160 | WGL_BIND_TO_TEXTURE_RGBA_ARB* = 0x00002071 161 | WGL_TEXTURE_FORMAT_ARB* = 0x00002072 162 | WGL_TEXTURE_TARGET_ARB* = 0x00002073 163 | WGL_MIPMAP_TEXTURE_ARB* = 0x00002074 164 | WGL_TEXTURE_RGB_ARB* = 0x00002075 165 | WGL_TEXTURE_RGBA_ARB* = 0x00002076 166 | WGL_NO_TEXTURE_ARB* = 0x00002077 167 | WGL_TEXTURE_CUBE_MAP_ARB* = 0x00002078 168 | WGL_TEXTURE_1D_ARB* = 0x00002079 169 | WGL_TEXTURE_2D_ARB* = 0x0000207A # WGL_NO_TEXTURE_ARB { already defined } 170 | WGL_MIPMAP_LEVEL_ARB* = 0x0000207B 171 | WGL_CUBE_MAP_FACE_ARB* = 0x0000207C 172 | WGL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB* = 0x0000207D 173 | WGL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB* = 0x0000207E 174 | WGL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB* = 0x0000207F 175 | WGL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB* = 0x00002080 176 | WGL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB* = 0x00002081 177 | WGL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB* = 0x00002082 178 | WGL_FRONT_LEFT_ARB* = 0x00002083 179 | WGL_FRONT_RIGHT_ARB* = 0x00002084 180 | WGL_BACK_LEFT_ARB* = 0x00002085 181 | WGL_BACK_RIGHT_ARB* = 0x00002086 182 | WGL_AUX0_ARB* = 0x00002087 183 | WGL_AUX1_ARB* = 0x00002088 184 | WGL_AUX2_ARB* = 0x00002089 185 | WGL_AUX3_ARB* = 0x0000208A 186 | WGL_AUX4_ARB* = 0x0000208B 187 | WGL_AUX5_ARB* = 0x0000208C 188 | WGL_AUX6_ARB* = 0x0000208D 189 | WGL_AUX7_ARB* = 0x0000208E 190 | WGL_AUX8_ARB* = 0x0000208F 191 | WGL_AUX9_ARB* = 0x00002090 192 | 193 | proc wglBindTexImageARB*(hPbuffer: THandle, iBuffer: TGLint): BOOL{. 194 | dynlib: dllname, importc: "wglBindTexImageARB".} 195 | proc wglReleaseTexImageARB*(hPbuffer: THandle, iBuffer: TGLint): BOOL{. 196 | dynlib: dllname, importc: "wglReleaseTexImageARB".} 197 | proc wglSetPbufferAttribARB*(hPbuffer: THandle, piAttribList: PGLint): BOOL{. 198 | dynlib: dllname, importc: "wglSetPbufferAttribARB".} 199 | proc wglGetExtensionsStringEXT*(): cstring{.dynlib: dllname, 200 | importc: "wglGetExtensionsStringEXT".} 201 | proc wglMakeContextCurrentEXT*(hDrawDC: HDC, hReadDC: HDC, hglrc: HGLRC): BOOL{. 202 | dynlib: dllname, importc: "wglMakeContextCurrentEXT".} 203 | proc wglGetCurrentReadDCEXT*(): HDC{.dynlib: dllname, 204 | importc: "wglGetCurrentReadDCEXT".} 205 | const 206 | WGL_DRAW_TO_PBUFFER_EXT* = 0x0000202D 207 | WGL_MAX_PBUFFER_PIXELS_EXT* = 0x0000202E 208 | WGL_MAX_PBUFFER_WIDTH_EXT* = 0x0000202F 209 | WGL_MAX_PBUFFER_HEIGHT_EXT* = 0x00002030 210 | WGL_OPTIMAL_PBUFFER_WIDTH_EXT* = 0x00002031 211 | WGL_OPTIMAL_PBUFFER_HEIGHT_EXT* = 0x00002032 212 | WGL_PBUFFER_LARGEST_EXT* = 0x00002033 213 | WGL_PBUFFER_WIDTH_EXT* = 0x00002034 214 | WGL_PBUFFER_HEIGHT_EXT* = 0x00002035 215 | 216 | proc wglCreatePbufferEXT*(hDC: HDC, iPixelFormat: TGLint, iWidth: TGLint, 217 | iHeight: TGLint, piAttribList: PGLint): THandle{. 218 | dynlib: dllname, importc: "wglCreatePbufferEXT".} 219 | proc wglGetPbufferDCEXT*(hPbuffer: THandle): HDC{.dynlib: dllname, 220 | importc: "wglGetPbufferDCEXT".} 221 | proc wglReleasePbufferDCEXT*(hPbuffer: THandle, hDC: HDC): TGLint{. 222 | dynlib: dllname, importc: "wglReleasePbufferDCEXT".} 223 | proc wglDestroyPbufferEXT*(hPbuffer: THandle): BOOL{.dynlib: dllname, 224 | importc: "wglDestroyPbufferEXT".} 225 | proc wglQueryPbufferEXT*(hPbuffer: THandle, iAttribute: TGLint, piValue: PGLint): BOOL{. 226 | dynlib: dllname, importc: "wglQueryPbufferEXT".} 227 | const 228 | WGL_NUMBER_PIXEL_FORMATS_EXT* = 0x00002000 229 | WGL_DRAW_TO_WINDOW_EXT* = 0x00002001 230 | WGL_DRAW_TO_BITMAP_EXT* = 0x00002002 231 | WGL_ACCELERATION_EXT* = 0x00002003 232 | WGL_NEED_PALETTE_EXT* = 0x00002004 233 | WGL_NEED_SYSTEM_PALETTE_EXT* = 0x00002005 234 | WGL_SWAP_LAYER_BUFFERS_EXT* = 0x00002006 235 | WGL_SWAP_METHOD_EXT* = 0x00002007 236 | WGL_NUMBER_OVERLAYS_EXT* = 0x00002008 237 | WGL_NUMBER_UNDERLAYS_EXT* = 0x00002009 238 | WGL_TRANSPARENT_EXT* = 0x0000200A 239 | WGL_TRANSPARENT_VALUE_EXT* = 0x0000200B 240 | WGL_SHARE_DEPTH_EXT* = 0x0000200C 241 | WGL_SHARE_STENCIL_EXT* = 0x0000200D 242 | WGL_SHARE_ACCUM_EXT* = 0x0000200E 243 | WGL_SUPPORT_GDI_EXT* = 0x0000200F 244 | WGL_SUPPORT_OPENGL_EXT* = 0x00002010 245 | WGL_DOUBLE_BUFFER_EXT* = 0x00002011 246 | WGL_STEREO_EXT* = 0x00002012 247 | WGL_PIXEL_TYPE_EXT* = 0x00002013 248 | WGL_COLOR_BITS_EXT* = 0x00002014 249 | WGL_RED_BITS_EXT* = 0x00002015 250 | WGL_RED_SHIFT_EXT* = 0x00002016 251 | WGL_GREEN_BITS_EXT* = 0x00002017 252 | WGL_GREEN_SHIFT_EXT* = 0x00002018 253 | WGL_BLUE_BITS_EXT* = 0x00002019 254 | WGL_BLUE_SHIFT_EXT* = 0x0000201A 255 | WGL_ALPHA_BITS_EXT* = 0x0000201B 256 | WGL_ALPHA_SHIFT_EXT* = 0x0000201C 257 | WGL_ACCUM_BITS_EXT* = 0x0000201D 258 | WGL_ACCUM_RED_BITS_EXT* = 0x0000201E 259 | WGL_ACCUM_GREEN_BITS_EXT* = 0x0000201F 260 | WGL_ACCUM_BLUE_BITS_EXT* = 0x00002020 261 | WGL_ACCUM_ALPHA_BITS_EXT* = 0x00002021 262 | WGL_DEPTH_BITS_EXT* = 0x00002022 263 | WGL_STENCIL_BITS_EXT* = 0x00002023 264 | WGL_AUX_BUFFERS_EXT* = 0x00002024 265 | WGL_NO_ACCELERATION_EXT* = 0x00002025 266 | WGL_GENERIC_ACCELERATION_EXT* = 0x00002026 267 | WGL_FULL_ACCELERATION_EXT* = 0x00002027 268 | WGL_SWAP_EXCHANGE_EXT* = 0x00002028 269 | WGL_SWAP_COPY_EXT* = 0x00002029 270 | WGL_SWAP_UNDEFINED_EXT* = 0x0000202A 271 | WGL_TYPE_RGBA_EXT* = 0x0000202B 272 | WGL_TYPE_COLORINDEX_EXT* = 0x0000202C 273 | 274 | proc wglGetPixelFormatAttribivEXT*(hdc: HDC, iPixelFormat: TGLint, 275 | iLayerPlane: TGLint, nAttributes: TGLuint, 276 | piAttributes: PGLint, piValues: PGLint): BOOL{. 277 | dynlib: dllname, importc: "wglGetPixelFormatAttribivEXT".} 278 | proc wglGetPixelFormatAttribfvEXT*(hdc: HDC, iPixelFormat: TGLint, 279 | iLayerPlane: TGLint, nAttributes: TGLuint, 280 | piAttributes: PGLint, pfValues: PGLfloat): BOOL{. 281 | dynlib: dllname, importc: "wglGetPixelFormatAttribfvEXT".} 282 | proc wglChoosePixelFormatEXT*(hdc: HDC, piAttribIList: PGLint, 283 | pfAttribFList: PGLfloat, nMaxFormats: TGLuint, 284 | piFormats: PGLint, nNumFormats: PGLuint): BOOL{. 285 | dynlib: dllname, importc: "wglChoosePixelFormatEXT".} 286 | const 287 | WGL_DIGITAL_VIDEO_CURSOR_ALPHA_FRAMEBUFFER_I3D* = 0x00002050 288 | WGL_DIGITAL_VIDEO_CURSOR_ALPHA_VALUE_I3D* = 0x00002051 289 | WGL_DIGITAL_VIDEO_CURSOR_INCLUDED_I3D* = 0x00002052 290 | WGL_DIGITAL_VIDEO_GAMMA_CORRECTED_I3D* = 0x00002053 291 | 292 | proc wglGetDigitalVideoParametersI3D*(hDC: HDC, iAttribute: TGLint, 293 | piValue: PGLint): BOOL{.dynlib: dllname, 294 | importc: "wglGetDigitalVideoParametersI3D".} 295 | proc wglSetDigitalVideoParametersI3D*(hDC: HDC, iAttribute: TGLint, 296 | piValue: PGLint): BOOL{.dynlib: dllname, 297 | importc: "wglSetDigitalVideoParametersI3D".} 298 | const 299 | WGL_GAMMA_TABLE_SIZE_I3D* = 0x0000204E 300 | WGL_GAMMA_EXCLUDE_DESKTOP_I3D* = 0x0000204F 301 | 302 | proc wglGetGammaTableParametersI3D*(hDC: HDC, iAttribute: TGLint, 303 | piValue: PGLint): BOOL{.dynlib: dllname, 304 | importc: "wglGetGammaTableParametersI3D".} 305 | proc wglSetGammaTableParametersI3D*(hDC: HDC, iAttribute: TGLint, 306 | piValue: PGLint): BOOL{.dynlib: dllname, 307 | importc: "wglSetGammaTableParametersI3D".} 308 | proc wglGetGammaTableI3D*(hDC: HDC, iEntries: TGLint, puRed: PGLUSHORT, 309 | puGreen: PGLUSHORT, puBlue: PGLUSHORT): BOOL{. 310 | dynlib: dllname, importc: "wglGetGammaTableI3D".} 311 | proc wglSetGammaTableI3D*(hDC: HDC, iEntries: TGLint, puRed: PGLUSHORT, 312 | puGreen: PGLUSHORT, puBlue: PGLUSHORT): BOOL{. 313 | dynlib: dllname, importc: "wglSetGammaTableI3D".} 314 | const 315 | WGL_GENLOCK_SOURCE_MULTIVIEW_I3D* = 0x00002044 316 | WGL_GENLOCK_SOURCE_EXTERNAL_SYNC_I3D* = 0x00002045 317 | WGL_GENLOCK_SOURCE_EXTERNAL_FIELD_I3D* = 0x00002046 318 | WGL_GENLOCK_SOURCE_EXTERNAL_TTL_I3D* = 0x00002047 319 | WGL_GENLOCK_SOURCE_DIGITAL_SYNC_I3D* = 0x00002048 320 | WGL_GENLOCK_SOURCE_DIGITAL_FIELD_I3D* = 0x00002049 321 | WGL_GENLOCK_SOURCE_EDGE_FALLING_I3D* = 0x0000204A 322 | WGL_GENLOCK_SOURCE_EDGE_RISING_I3D* = 0x0000204B 323 | WGL_GENLOCK_SOURCE_EDGE_BOTH_I3D* = 0x0000204C 324 | WGL_FLOAT_COMPONENTS_NV* = 0x000020B0 325 | WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_R_NV* = 0x000020B1 326 | WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RG_NV* = 0x000020B2 327 | WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGB_NV* = 0x000020B3 328 | WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGBA_NV* = 0x000020B4 329 | WGL_TEXTURE_FLOAT_R_NV* = 0x000020B5 330 | WGL_TEXTURE_FLOAT_RG_NV* = 0x000020B6 331 | WGL_TEXTURE_FLOAT_RGB_NV* = 0x000020B7 332 | WGL_TEXTURE_FLOAT_RGBA_NV* = 0x000020B8 333 | 334 | proc wglEnableGenlockI3D*(hDC: HDC): BOOL{.dynlib: dllname, 335 | importc: "wglEnableGenlockI3D".} 336 | proc wglDisableGenlockI3D*(hDC: HDC): BOOL{.dynlib: dllname, 337 | importc: "wglDisableGenlockI3D".} 338 | proc wglIsEnabledGenlockI3D*(hDC: HDC, pFlag: PBOOL): BOOL{.dynlib: dllname, 339 | importc: "wglIsEnabledGenlockI3D".} 340 | proc wglGenlockSourceI3D*(hDC: HDC, uSource: TGLuint): BOOL{.dynlib: dllname, 341 | importc: "wglGenlockSourceI3D".} 342 | proc wglGetGenlockSourceI3D*(hDC: HDC, uSource: PGLUINT): BOOL{.dynlib: dllname, 343 | importc: "wglGetGenlockSourceI3D".} 344 | proc wglGenlockSourceEdgeI3D*(hDC: HDC, uEdge: TGLuint): BOOL{.dynlib: dllname, 345 | importc: "wglGenlockSourceEdgeI3D".} 346 | proc wglGetGenlockSourceEdgeI3D*(hDC: HDC, uEdge: PGLUINT): BOOL{. 347 | dynlib: dllname, importc: "wglGetGenlockSourceEdgeI3D".} 348 | proc wglGenlockSampleRateI3D*(hDC: HDC, uRate: TGLuint): BOOL{.dynlib: dllname, 349 | importc: "wglGenlockSampleRateI3D".} 350 | proc wglGetGenlockSampleRateI3D*(hDC: HDC, uRate: PGLUINT): BOOL{. 351 | dynlib: dllname, importc: "wglGetGenlockSampleRateI3D".} 352 | proc wglGenlockSourceDelayI3D*(hDC: HDC, uDelay: TGLuint): BOOL{. 353 | dynlib: dllname, importc: "wglGenlockSourceDelayI3D".} 354 | proc wglGetGenlockSourceDelayI3D*(hDC: HDC, uDelay: PGLUINT): BOOL{. 355 | dynlib: dllname, importc: "wglGetGenlockSourceDelayI3D".} 356 | proc wglQueryGenlockMaxSourceDelayI3D*(hDC: HDC, uMaxLineDelay: PGLUINT, 357 | uMaxPixelDelay: PGLUINT): BOOL{. 358 | dynlib: dllname, importc: "wglQueryGenlockMaxSourceDelayI3D".} 359 | const 360 | WGL_BIND_TO_TEXTURE_RECTANGLE_RGB_NV* = 0x000020A0 361 | WGL_BIND_TO_TEXTURE_RECTANGLE_RGBA_NV* = 0x000020A1 362 | WGL_TEXTURE_RECTANGLE_NV* = 0x000020A2 363 | 364 | const 365 | WGL_RGBA_FLOAT_MODE_ATI* = 0x00008820 366 | WGL_COLOR_CLEAR_UNCLAMPED_VALUE_ATI* = 0x00008835 367 | WGL_TYPE_RGBA_FLOAT_ATI* = 0x000021A0 368 | 369 | # implementation 370 | --------------------------------------------------------------------------------