some progress for jester+async

This commit is contained in:
Araq
2014-06-27 16:03:11 +02:00
parent 85a1d896c2
commit 7014d0c5c8
12 changed files with 7587 additions and 29 deletions

View File

@@ -154,12 +154,20 @@ proc getStateType(iter: PSym): PType =
addSon(n, newIntNode(nkIntLit, 0))
result = newType(tyRange, iter)
result.n = n
rawAddSon(result, getSysType(tyInt))
var intType = nilOrSysInt()
if intType.isNil: intType = newType(tyInt, iter)
rawAddSon(result, intType)
proc createStateField(iter: PSym): PSym =
result = newSym(skField, getIdent(":state"), iter, iter.info)
result.typ = getStateType(iter)
proc createEnvObj(owner: PSym): PType =
# YYY meh, just add the state field for every closure for now, it's too
# hard to figure out if it comes from a closure iterator:
result = createObj(owner, owner.info)
rawAddField(result, createStateField(owner))
proc newIterResult(iter: PSym): PSym =
if resultPos < iter.ast.len:
result = iter.ast.sons[resultPos].sym
@@ -197,24 +205,18 @@ proc initIter(iter: PSym): TIter =
if iter.kind == skClosureIterator:
var cp = getEnvParam(iter)
if cp == nil:
result.obj = createObj(iter, iter.info)
result.obj = createEnvObj(iter)
cp = newSym(skParam, getIdent(paramName), iter, iter.info)
incl(cp.flags, sfFromGeneric)
cp.typ = newType(tyRef, iter)
rawAddSon(cp.typ, result.obj)
addHiddenParam(iter, cp)
result.state = createStateField(iter)
rawAddField(result.obj, result.state)
else:
result.obj = cp.typ.sons[0]
assert result.obj.kind == tyObject
if result.obj.n.len > 0:
result.state = result.obj.n[0].sym
else:
result.state = createStateField(iter)
rawAddField(result.obj, result.state)
internalAssert result.obj.n.len > 0
result.state = result.obj.n[0].sym
result.closureParam = cp
if iter.typ.sons[0] != nil:
result.resultSym = newIterResult(iter)
@@ -231,20 +233,26 @@ proc newOuterContext(fn: PSym): POuterContext =
proc newEnv(o: POuterContext; up: PEnv, n: PNode; owner: PSym): PEnv =
new(result)
result.capturedVars = @[]
result.obj = createObj(owner, owner.info)
result.up = up
result.attachedNode = n
result.fn = owner
result.vars = initIntSet()
result.next = o.head
o.head = result
if owner.kind != skModule and (up == nil or up.fn != owner):
if owner.ast == nil:
debug owner
echo owner.name.s
let param = getEnvParam(owner)
if param != nil:
result.obj = param.typ.sons[0]
assert result.obj.kind == tyObject
if result.obj.isNil:
result.obj = createEnvObj(owner)
proc addCapturedVar(e: PEnv, v: PSym) =
for x in e.capturedVars:
if x == v: return
# YYY meh, just add the state field for every closure for now, it's too
# hard to figure out if it comes from a closure iterator:
if e.obj.n.len == 0: addField(e.obj, createStateField(v.owner))
e.capturedVars.add(v)
addField(e.obj, v)
@@ -262,7 +270,7 @@ proc isInnerProc(s, outerProc: PSym): bool =
owner = owner.owner
#s.typ.callConv == ccClosure
proc addClosureParam(fn: PSym; e: PEnv): PSym =
proc addClosureParam(fn: PSym; e: PEnv) =
var cp = getEnvParam(fn)
if cp == nil:
cp = newSym(skParam, getIdent(paramName), fn, fn.info)
@@ -270,11 +278,9 @@ proc addClosureParam(fn: PSym; e: PEnv): PSym =
cp.typ = newType(tyRef, fn)
rawAddSon(cp.typ, e.obj)
addHiddenParam(fn, cp)
else:
#assert e.obj == nil or e.obj == cp.typ.sons[0]
e.obj = cp.typ.sons[0]
assert e.obj.kind == tyObject
result = cp
#else:
#cp.typ.sons[0] = e.obj
#assert e.obj.kind == tyObject
proc illegalCapture(s: PSym): bool {.inline.} =
result = skipTypes(s.typ, abstractInst).kind in
@@ -296,7 +302,7 @@ proc nestedAccess(top: PEnv; local: PSym): PNode =
# echo [:paramI.up.]foo
# inner([:envO])
# outer([:env])
if not (interestingVar(local) and top.fn != local.owner):
if not interestingVar(local) or top.fn == local.owner:
return nil
# check it's in fact a captured variable:
var it = top
@@ -307,7 +313,6 @@ proc nestedAccess(top: PEnv; local: PSym): PNode =
let envParam = top.fn.getEnvParam
internalAssert(not envParam.isNil)
var access = newSymNode(envParam)
# we could also simply check the tuple type for the field here, I think.
it = top.up
while it != nil:
if it.vars.contains(local.id):
@@ -316,6 +321,17 @@ proc nestedAccess(top: PEnv; local: PSym): PNode =
internalAssert it.upField != nil
access = indirectAccess(access, it.upField, local.info)
it = it.up
when false:
# Type based expression construction works too, but turned out to hide
# other bugs:
while true:
let obj = access.typ.sons[0]
let field = getFieldFromObj(obj, local)
if field != nil:
return rawIndirectAccess(access, field, local.info)
let upField = lookupInRecord(obj.n, getIdent(upName))
if upField == nil: break
access = rawIndirectAccess(access, upField, local.info)
return nil
proc createUpField(obj, fieldType: PType): PSym =
@@ -324,6 +340,7 @@ proc createUpField(obj, fieldType: PType): PSym =
result.typ = newType(tyRef, obj.owner)
result.position = pos
rawAddSon(result.typ, fieldType)
#rawAddField(obj, result)
addField(obj, result)
proc captureVar(o: POuterContext; top: PEnv; local: PSym;
@@ -348,10 +365,13 @@ proc captureVar(o: POuterContext; top: PEnv; local: PSym;
if it.fn != local.owner:
it.fn.typ.callConv = ccClosure
incl(it.fn.typ.flags, tfCapturesEnv)
discard addClosureParam(it.fn, it.up)
var u = it.up
while u != nil and u.fn == it.fn: u = u.up
addClosureParam(it.fn, u)
if idTableGet(o.lambdasToEnv, it.fn) == nil:
idTablePut(o.lambdasToEnv, it.fn, it.up)
if u != nil: idTablePut(o.lambdasToEnv, it.fn, u)
it = it.up
# don't do this: 'top' might not require a closure:
@@ -521,7 +541,7 @@ proc searchForInnerProcs(o: POuterContext, n: PNode, env: PEnv) =
#assert tfCapturesEnv notin n.sym.typ.flags
if idTableGet(o.lambdasToEnv, fn) == nil:
idTablePut(o.lambdasToEnv, fn, env)
discard addClosureParam(fn, env)
addClosureParam(fn, env)
elif fn.getEnvParam != nil:
# only transform if it really needs a closure:
@@ -616,7 +636,7 @@ proc rawClosureCreation(o: POuterContext, scope: PEnv; env: PSym): PNode =
else:
result.add(newAsgnStmt(indirectAccess(env, scope.upField, env.info),
newSymNode(getClosureVar(scope.up)), env.info))
proc generateClosureCreation(o: POuterContext, scope: PEnv): PNode =
var env = getClosureVar(scope)
result = rawClosureCreation(o, scope, env)
@@ -643,6 +663,9 @@ proc interestingIterVar(s: PSym): bool {.inline.} =
proc transformOuterProc(o: POuterContext, n: PNode, it: TIter): PNode
proc transformYield(c: POuterContext, n: PNode, it: TIter): PNode =
assert it.state != nil
assert it.state.typ != nil
assert it.state.typ.n != nil
inc it.state.typ.n.sons[1].intVal
let stateNo = it.state.typ.n.sons[1].intVal
@@ -867,7 +890,7 @@ proc liftLambdas*(fn: PSym, body: PNode): PNode =
discard transformOuterProcBody(o, body, initIter(fn))
result = ex
finishEnvironments(o)
#if fn.name.s == "factory" or fn.name.s == "factory2":
#if fn.name.s == "cbOuter" or fn.name.s == "factory2":
# echo rendertree(result, {renderIds})
proc liftLambdasForTopLevel*(module: PSym, body: PNode): PNode =

View File

@@ -111,13 +111,28 @@ proc indirectAccess*(a: PNode, b: string, info: TLineInfo): PNode =
t = t.sons[0]
if t == nil: break
t = t.skipTypes(abstractInst)
assert field != nil, b
#if field == nil:
# debug deref.typ
# echo deref.typ.id
internalAssert field != nil, b
addSon(deref, a)
result = newNodeI(nkDotExpr, info)
addSon(result, deref)
addSon(result, newSymNode(field))
result.typ = field.typ
proc getFieldFromObj*(t: PType; v: PSym): PSym =
assert v.kind != skField
let fieldName = getIdent(v.name.s & $v.id)
var t = t
while true:
assert t.kind == tyObject
result = getSymFromList(t.n, fieldName)
if result != nil: break
t = t.sons[0]
if t == nil: break
t = t.skipTypes(abstractInst)
proc indirectAccess*(a: PNode, b: PSym, info: TLineInfo): PNode =
# returns a[].b as a node
result = indirectAccess(a, b.name.s & $b.id, info)

View File

@@ -27,6 +27,8 @@ var
gSysTypes: array[TTypeKind, PType]
compilerprocs: TStrTable
proc nilOrSysInt*: PType = gSysTypes[tyInt]
proc registerSysType(t: PType) =
if gSysTypes[t.kind] == nil: gSysTypes[t.kind] = t

View File

@@ -2,7 +2,8 @@ discard """
output: '''foo88
23 24foo 88
foo88
23 24foo 88'''
23 24foo 88
hohoho'''
"""
# test nested closure
@@ -34,3 +35,17 @@ proc dummy =
dummy()
main(24)
# Jester + async triggered this bug:
proc cbOuter() =
var response = "hohoho"
block:
proc cbIter() =
block:
proc fooIter() =
echo response
fooIter()
cbIter()
cbOuter()

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,335 @@
#
#
# Adaption of the delphi3d.net OpenGL units to FreePascal
# Sebastian Guenther (sg@freepascal.org) in 2002
# These units are free to use
#******************************************************************************
# Converted to Delphi by Tom Nuydens (tom@delphi3d.net)
# For the latest updates, visit Delphi3D: http://www.delphi3d.net
#******************************************************************************
import
GL
when defined(windows):
{.push, callconv: stdcall.}
else:
{.push, callconv: cdecl.}
when defined(windows):
const
dllname = "glu32.dll"
elif defined(macosx):
const
dllname = "/System/Library/Frameworks/OpenGL.framework/Libraries/libGLU.dylib"
else:
const
dllname = "libGLU.so.1"
type
TViewPortArray* = array[0..3, TGLint]
T16dArray* = array[0..15, TGLdouble]
TCallBack* = proc ()
T3dArray* = array[0..2, TGLdouble]
T4pArray* = array[0..3, Pointer]
T4fArray* = array[0..3, TGLfloat]
PPointer* = ptr Pointer
type
GLUnurbs*{.final.} = object
PGLUnurbs* = ptr GLUnurbs
GLUquadric*{.final.} = object
PGLUquadric* = ptr GLUquadric
GLUtesselator*{.final.} = object
PGLUtesselator* = ptr GLUtesselator # backwards compatibility:
GLUnurbsObj* = GLUnurbs
PGLUnurbsObj* = PGLUnurbs
GLUquadricObj* = GLUquadric
PGLUquadricObj* = PGLUquadric
GLUtesselatorObj* = GLUtesselator
PGLUtesselatorObj* = PGLUtesselator
GLUtriangulatorObj* = GLUtesselator
PGLUtriangulatorObj* = PGLUtesselator
TGLUnurbs* = GLUnurbs
TGLUquadric* = GLUquadric
TGLUtesselator* = GLUtesselator
TGLUnurbsObj* = GLUnurbsObj
TGLUquadricObj* = GLUquadricObj
TGLUtesselatorObj* = GLUtesselatorObj
TGLUtriangulatorObj* = GLUtriangulatorObj
proc gluErrorString*(errCode: TGLenum): cstring{.dynlib: dllname,
importc: "gluErrorString".}
proc gluErrorUnicodeStringEXT*(errCode: TGLenum): ptr int16{.dynlib: dllname,
importc: "gluErrorUnicodeStringEXT".}
proc gluGetString*(name: TGLenum): cstring{.dynlib: dllname,
importc: "gluGetString".}
proc gluOrtho2D*(left, right, bottom, top: TGLdouble){.dynlib: dllname,
importc: "gluOrtho2D".}
proc gluPerspective*(fovy, aspect, zNear, zFar: TGLdouble){.dynlib: dllname,
importc: "gluPerspective".}
proc gluPickMatrix*(x, y, width, height: TGLdouble, viewport: var TViewPortArray){.
dynlib: dllname, importc: "gluPickMatrix".}
proc gluLookAt*(eyex, eyey, eyez, centerx, centery, centerz, upx, upy, upz: TGLdouble){.
dynlib: dllname, importc: "gluLookAt".}
proc gluProject*(objx, objy, objz: TGLdouble,
modelMatrix, projMatrix: var T16dArray,
viewport: var TViewPortArray, winx, winy, winz: PGLdouble): int{.
dynlib: dllname, importc: "gluProject".}
proc gluUnProject*(winx, winy, winz: TGLdouble,
modelMatrix, projMatrix: var T16dArray,
viewport: var TViewPortArray, objx, objy, objz: PGLdouble): int{.
dynlib: dllname, importc: "gluUnProject".}
proc gluScaleImage*(format: TGLenum, widthin, heightin: TGLint, typein: TGLenum,
datain: Pointer, widthout, heightout: TGLint,
typeout: TGLenum, dataout: Pointer): int{.dynlib: dllname,
importc: "gluScaleImage".}
proc gluBuild1DMipmaps*(target: TGLenum, components, width: TGLint,
format, atype: TGLenum, data: Pointer): int{.
dynlib: dllname, importc: "gluBuild1DMipmaps".}
proc gluBuild2DMipmaps*(target: TGLenum, components, width, height: TGLint,
format, atype: TGLenum, data: Pointer): int{.
dynlib: dllname, importc: "gluBuild2DMipmaps".}
proc gluNewQuadric*(): PGLUquadric{.dynlib: dllname, importc: "gluNewQuadric".}
proc gluDeleteQuadric*(state: PGLUquadric){.dynlib: dllname,
importc: "gluDeleteQuadric".}
proc gluQuadricNormals*(quadObject: PGLUquadric, normals: TGLenum){.
dynlib: dllname, importc: "gluQuadricNormals".}
proc gluQuadricTexture*(quadObject: PGLUquadric, textureCoords: TGLboolean){.
dynlib: dllname, importc: "gluQuadricTexture".}
proc gluQuadricOrientation*(quadObject: PGLUquadric, orientation: TGLenum){.
dynlib: dllname, importc: "gluQuadricOrientation".}
proc gluQuadricDrawStyle*(quadObject: PGLUquadric, drawStyle: TGLenum){.
dynlib: dllname, importc: "gluQuadricDrawStyle".}
proc gluCylinder*(qobj: PGLUquadric, baseRadius, topRadius, height: TGLdouble,
slices, stacks: TGLint){.dynlib: dllname,
importc: "gluCylinder".}
proc gluDisk*(qobj: PGLUquadric, innerRadius, outerRadius: TGLdouble,
slices, loops: TGLint){.dynlib: dllname, importc: "gluDisk".}
proc gluPartialDisk*(qobj: PGLUquadric, innerRadius, outerRadius: TGLdouble,
slices, loops: TGLint, startAngle, sweepAngle: TGLdouble){.
dynlib: dllname, importc: "gluPartialDisk".}
proc gluSphere*(qobj: PGLuquadric, radius: TGLdouble, slices, stacks: TGLint){.
dynlib: dllname, importc: "gluSphere".}
proc gluQuadricCallback*(qobj: PGLUquadric, which: TGLenum, fn: TCallBack){.
dynlib: dllname, importc: "gluQuadricCallback".}
proc gluNewTess*(): PGLUtesselator{.dynlib: dllname, importc: "gluNewTess".}
proc gluDeleteTess*(tess: PGLUtesselator){.dynlib: dllname,
importc: "gluDeleteTess".}
proc gluTessBeginPolygon*(tess: PGLUtesselator, polygon_data: Pointer){.
dynlib: dllname, importc: "gluTessBeginPolygon".}
proc gluTessBeginContour*(tess: PGLUtesselator){.dynlib: dllname,
importc: "gluTessBeginContour".}
proc gluTessVertex*(tess: PGLUtesselator, coords: var T3dArray, data: Pointer){.
dynlib: dllname, importc: "gluTessVertex".}
proc gluTessEndContour*(tess: PGLUtesselator){.dynlib: dllname,
importc: "gluTessEndContour".}
proc gluTessEndPolygon*(tess: PGLUtesselator){.dynlib: dllname,
importc: "gluTessEndPolygon".}
proc gluTessProperty*(tess: PGLUtesselator, which: TGLenum, value: TGLdouble){.
dynlib: dllname, importc: "gluTessProperty".}
proc gluTessNormal*(tess: PGLUtesselator, x, y, z: TGLdouble){.dynlib: dllname,
importc: "gluTessNormal".}
proc gluTessCallback*(tess: PGLUtesselator, which: TGLenum, fn: TCallBack){.
dynlib: dllname, importc: "gluTessCallback".}
proc gluGetTessProperty*(tess: PGLUtesselator, which: TGLenum, value: PGLdouble){.
dynlib: dllname, importc: "gluGetTessProperty".}
proc gluNewNurbsRenderer*(): PGLUnurbs{.dynlib: dllname,
importc: "gluNewNurbsRenderer".}
proc gluDeleteNurbsRenderer*(nobj: PGLUnurbs){.dynlib: dllname,
importc: "gluDeleteNurbsRenderer".}
proc gluBeginSurface*(nobj: PGLUnurbs){.dynlib: dllname,
importc: "gluBeginSurface".}
proc gluBeginCurve*(nobj: PGLUnurbs){.dynlib: dllname, importc: "gluBeginCurve".}
proc gluEndCurve*(nobj: PGLUnurbs){.dynlib: dllname, importc: "gluEndCurve".}
proc gluEndSurface*(nobj: PGLUnurbs){.dynlib: dllname, importc: "gluEndSurface".}
proc gluBeginTrim*(nobj: PGLUnurbs){.dynlib: dllname, importc: "gluBeginTrim".}
proc gluEndTrim*(nobj: PGLUnurbs){.dynlib: dllname, importc: "gluEndTrim".}
proc gluPwlCurve*(nobj: PGLUnurbs, count: TGLint, aarray: PGLfloat,
stride: TGLint, atype: TGLenum){.dynlib: dllname,
importc: "gluPwlCurve".}
proc gluNurbsCurve*(nobj: PGLUnurbs, nknots: TGLint, knot: PGLfloat,
stride: TGLint, ctlarray: PGLfloat, order: TGLint,
atype: TGLenum){.dynlib: dllname, importc: "gluNurbsCurve".}
proc gluNurbsSurface*(nobj: PGLUnurbs, sknot_count: TGLint, sknot: PGLfloat,
tknot_count: TGLint, tknot: PGLfloat,
s_stride, t_stride: TGLint, ctlarray: PGLfloat,
sorder, torder: TGLint, atype: TGLenum){.dynlib: dllname,
importc: "gluNurbsSurface".}
proc gluLoadSamplingMatrices*(nobj: PGLUnurbs,
modelMatrix, projMatrix: var T16dArray,
viewport: var TViewPortArray){.dynlib: dllname,
importc: "gluLoadSamplingMatrices".}
proc gluNurbsProperty*(nobj: PGLUnurbs, aproperty: TGLenum, value: TGLfloat){.
dynlib: dllname, importc: "gluNurbsProperty".}
proc gluGetNurbsProperty*(nobj: PGLUnurbs, aproperty: TGLenum, value: PGLfloat){.
dynlib: dllname, importc: "gluGetNurbsProperty".}
proc gluNurbsCallback*(nobj: PGLUnurbs, which: TGLenum, fn: TCallBack){.
dynlib: dllname, importc: "gluNurbsCallback".}
#*** Callback function prototypes ***
type # gluQuadricCallback
GLUquadricErrorProc* = proc (p: TGLenum) # gluTessCallback
GLUtessBeginProc* = proc (p: TGLenum)
GLUtessEdgeFlagProc* = proc (p: TGLboolean)
GLUtessVertexProc* = proc (p: Pointer)
GLUtessEndProc* = proc ()
GLUtessErrorProc* = proc (p: TGLenum)
GLUtessCombineProc* = proc (p1: var T3dArray, p2: T4pArray, p3: T4fArray,
p4: PPointer)
GLUtessBeginDataProc* = proc (p1: TGLenum, p2: Pointer)
GLUtessEdgeFlagDataProc* = proc (p1: TGLboolean, p2: Pointer)
GLUtessVertexDataProc* = proc (p1, p2: Pointer)
GLUtessEndDataProc* = proc (p: Pointer)
GLUtessErrorDataProc* = proc (p1: TGLenum, p2: Pointer)
GLUtessCombineDataProc* = proc (p1: var T3dArray, p2: var T4pArray,
p3: var T4fArray, p4: PPointer, p5: Pointer) #
#
# gluNurbsCallback
GLUnurbsErrorProc* = proc (p: TGLenum) #*** Generic constants ****/
const # Version
GLU_VERSION_1_1* = 1
GLU_VERSION_1_2* = 1 # Errors: (return value 0 = no error)
GLU_INVALID_ENUM* = 100900
GLU_INVALID_VALUE* = 100901
GLU_OUT_OF_MEMORY* = 100902
GLU_INCOMPATIBLE_GL_VERSION* = 100903 # StringName
GLU_VERSION* = 100800
GLU_EXTENSIONS* = 100801 # Boolean
GLU_TRUE* = GL_TRUE
GLU_FALSE* = GL_FALSE #*** Quadric constants ****/
# QuadricNormal
GLU_SMOOTH* = 100000
GLU_FLAT* = 100001
GLU_NONE* = 100002 # QuadricDrawStyle
GLU_POINT* = 100010
GLU_LINE* = 100011
GLU_FILL* = 100012
GLU_SILHOUETTE* = 100013 # QuadricOrientation
GLU_OUTSIDE* = 100020
GLU_INSIDE* = 100021 # Callback types:
# GLU_ERROR = 100103;
#*** Tesselation constants ****/
GLU_TESS_MAX_COORD* = 1.00000e+150 # TessProperty
GLU_TESS_WINDING_RULE* = 100140
GLU_TESS_BOUNDARY_ONLY* = 100141
GLU_TESS_TOLERANCE* = 100142 # TessWinding
GLU_TESS_WINDING_ODD* = 100130
GLU_TESS_WINDING_NONZERO* = 100131
GLU_TESS_WINDING_POSITIVE* = 100132
GLU_TESS_WINDING_NEGATIVE* = 100133
GLU_TESS_WINDING_ABS_GEQ_TWO* = 100134 # TessCallback
GLU_TESS_BEGIN* = 100100 # void (CALLBACK*)(TGLenum type)
constGLU_TESS_VERTEX* = 100101 # void (CALLBACK*)(void *data)
GLU_TESS_END* = 100102 # void (CALLBACK*)(void)
GLU_TESS_ERROR* = 100103 # void (CALLBACK*)(TGLenum errno)
GLU_TESS_EDGE_FLAG* = 100104 # void (CALLBACK*)(TGLboolean boundaryEdge)
GLU_TESS_COMBINE* = 100105 # void (CALLBACK*)(TGLdouble coords[3],
# void *data[4],
# TGLfloat weight[4],
# void **dataOut)
GLU_TESS_BEGIN_DATA* = 100106 # void (CALLBACK*)(TGLenum type,
# void *polygon_data)
GLU_TESS_VERTEX_DATA* = 100107 # void (CALLBACK*)(void *data,
# void *polygon_data)
GLU_TESS_END_DATA* = 100108 # void (CALLBACK*)(void *polygon_data)
GLU_TESS_ERROR_DATA* = 100109 # void (CALLBACK*)(TGLenum errno,
# void *polygon_data)
GLU_TESS_EDGE_FLAG_DATA* = 100110 # void (CALLBACK*)(TGLboolean boundaryEdge,
# void *polygon_data)
GLU_TESS_COMBINE_DATA* = 100111 # void (CALLBACK*)(TGLdouble coords[3],
# void *data[4],
# TGLfloat weight[4],
# void **dataOut,
# void *polygon_data)
# TessError
GLU_TESS_ERROR1* = 100151
GLU_TESS_ERROR2* = 100152
GLU_TESS_ERROR3* = 100153
GLU_TESS_ERROR4* = 100154
GLU_TESS_ERROR5* = 100155
GLU_TESS_ERROR6* = 100156
GLU_TESS_ERROR7* = 100157
GLU_TESS_ERROR8* = 100158
GLU_TESS_MISSING_BEGIN_POLYGON* = GLU_TESS_ERROR1
GLU_TESS_MISSING_BEGIN_CONTOUR* = GLU_TESS_ERROR2
GLU_TESS_MISSING_END_POLYGON* = GLU_TESS_ERROR3
GLU_TESS_MISSING_END_CONTOUR* = GLU_TESS_ERROR4
GLU_TESS_COORD_TOO_LARGE* = GLU_TESS_ERROR5
GLU_TESS_NEED_COMBINE_CALLBACK* = GLU_TESS_ERROR6 #*** NURBS constants ****/
# NurbsProperty
GLU_AUTO_LOAD_MATRIX* = 100200
GLU_CULLING* = 100201
GLU_SAMPLING_TOLERANCE* = 100203
GLU_DISPLAY_MODE* = 100204
GLU_PARAMETRIC_TOLERANCE* = 100202
GLU_SAMPLING_METHOD* = 100205
GLU_U_STEP* = 100206
GLU_V_STEP* = 100207 # NurbsSampling
GLU_PATH_LENGTH* = 100215
GLU_PARAMETRIC_ERROR* = 100216
GLU_DOMAIN_DISTANCE* = 100217 # NurbsTrim
GLU_MAP1_TRIM_2* = 100210
GLU_MAP1_TRIM_3* = 100211 # NurbsDisplay
# GLU_FILL = 100012;
GLU_OUTLINE_POLYGON* = 100240
GLU_OUTLINE_PATCH* = 100241 # NurbsCallback
# GLU_ERROR = 100103;
# NurbsErrors
GLU_NURBS_ERROR1* = 100251
GLU_NURBS_ERROR2* = 100252
GLU_NURBS_ERROR3* = 100253
GLU_NURBS_ERROR4* = 100254
GLU_NURBS_ERROR5* = 100255
GLU_NURBS_ERROR6* = 100256
GLU_NURBS_ERROR7* = 100257
GLU_NURBS_ERROR8* = 100258
GLU_NURBS_ERROR9* = 100259
GLU_NURBS_ERROR10* = 100260
GLU_NURBS_ERROR11* = 100261
GLU_NURBS_ERROR12* = 100262
GLU_NURBS_ERROR13* = 100263
GLU_NURBS_ERROR14* = 100264
GLU_NURBS_ERROR15* = 100265
GLU_NURBS_ERROR16* = 100266
GLU_NURBS_ERROR17* = 100267
GLU_NURBS_ERROR18* = 100268
GLU_NURBS_ERROR19* = 100269
GLU_NURBS_ERROR20* = 100270
GLU_NURBS_ERROR21* = 100271
GLU_NURBS_ERROR22* = 100272
GLU_NURBS_ERROR23* = 100273
GLU_NURBS_ERROR24* = 100274
GLU_NURBS_ERROR25* = 100275
GLU_NURBS_ERROR26* = 100276
GLU_NURBS_ERROR27* = 100277
GLU_NURBS_ERROR28* = 100278
GLU_NURBS_ERROR29* = 100279
GLU_NURBS_ERROR30* = 100280
GLU_NURBS_ERROR31* = 100281
GLU_NURBS_ERROR32* = 100282
GLU_NURBS_ERROR33* = 100283
GLU_NURBS_ERROR34* = 100284
GLU_NURBS_ERROR35* = 100285
GLU_NURBS_ERROR36* = 100286
GLU_NURBS_ERROR37* = 100287 #*** Backwards compatibility for old tesselator ****/
proc gluBeginPolygon*(tess: PGLUtesselator){.dynlib: dllname,
importc: "gluBeginPolygon".}
proc gluNextContour*(tess: PGLUtesselator, atype: TGLenum){.dynlib: dllname,
importc: "gluNextContour".}
proc gluEndPolygon*(tess: PGLUtesselator){.dynlib: dllname,
importc: "gluEndPolygon".}
const # Contours types -- obsolete!
GLU_CW* = 100120
GLU_CCW* = 100121
GLU_INTERIOR* = 100122
GLU_EXTERIOR* = 100123
GLU_UNKNOWN* = 100124 # Names without "TESS_" prefix
GLU_BEGIN* = GLU_TESS_BEGIN
GLU_VERTEX* = constGLU_TESS_VERTEX
GLU_END* = GLU_TESS_END
GLU_ERROR* = GLU_TESS_ERROR
GLU_EDGE_FLAG* = GLU_TESS_EDGE_FLAG
{.pop.}
# implementation

View File

@@ -0,0 +1,438 @@
#
#
# Adaption of the delphi3d.net OpenGL units to FreePascal
# Sebastian Guenther (sg@freepascal.org) in 2002
# These units are free to use
#
# Copyright (c) Mark J. Kilgard, 1994, 1995, 1996.
# This program is freely distributable without licensing fees and is
# provided without guarantee or warrantee expressed or implied. This
# program is -not- in the public domain.
#******************************************************************************
# Converted to Delphi by Tom Nuydens (tom@delphi3d.net)
# Contributions by Igor Karpov (glygrik@hotbox.ru)
# For the latest updates, visit Delphi3D: http://www.delphi3d.net
#******************************************************************************
import
GL
when defined(windows):
const
dllname = "glut32.dll"
elif defined(macosx):
const
dllname = "/System/Library/Frameworks/GLUT.framework/GLUT"
else:
const
dllname = "libglut.so.3"
type
TGlutVoidCallback* = proc (){.cdecl.}
TGlut1IntCallback* = proc (value: cint){.cdecl.}
TGlut2IntCallback* = proc (v1, v2: cint){.cdecl.}
TGlut3IntCallback* = proc (v1, v2, v3: cint){.cdecl.}
TGlut4IntCallback* = proc (v1, v2, v3, v4: cint){.cdecl.}
TGlut1Char2IntCallback* = proc (c: int8, v1, v2: cint){.cdecl.}
TGlut1UInt3IntCallback* = proc (u, v1, v2, v3: cint){.cdecl.}
const
GLUT_API_VERSION* = 3
GLUT_XLIB_IMPLEMENTATION* = 12 # Display mode bit masks.
GLUT_RGB* = 0
GLUT_RGBA* = GLUT_RGB
GLUT_INDEX* = 1
GLUT_SINGLE* = 0
GLUT_DOUBLE* = 2
GLUT_ACCUM* = 4
GLUT_ALPHA* = 8
GLUT_DEPTH* = 16
GLUT_STENCIL* = 32
GLUT_MULTISAMPLE* = 128
GLUT_STEREO* = 256
GLUT_LUMINANCE* = 512 # Mouse buttons.
GLUT_LEFT_BUTTON* = 0
GLUT_MIDDLE_BUTTON* = 1
GLUT_RIGHT_BUTTON* = 2 # Mouse button state.
GLUT_DOWN* = 0
GLUT_UP* = 1 # function keys
GLUT_KEY_F1* = 1
GLUT_KEY_F2* = 2
GLUT_KEY_F3* = 3
GLUT_KEY_F4* = 4
GLUT_KEY_F5* = 5
GLUT_KEY_F6* = 6
GLUT_KEY_F7* = 7
GLUT_KEY_F8* = 8
GLUT_KEY_F9* = 9
GLUT_KEY_F10* = 10
GLUT_KEY_F11* = 11
GLUT_KEY_F12* = 12 # directional keys
GLUT_KEY_LEFT* = 100
GLUT_KEY_UP* = 101
GLUT_KEY_RIGHT* = 102
GLUT_KEY_DOWN* = 103
GLUT_KEY_PAGE_UP* = 104
GLUT_KEY_PAGE_DOWN* = 105
GLUT_KEY_HOME* = 106
GLUT_KEY_END* = 107
GLUT_KEY_INSERT* = 108 # Entry/exit state.
GLUT_LEFT* = 0
GLUT_ENTERED* = 1 # Menu usage state.
GLUT_MENU_NOT_IN_USE* = 0
GLUT_MENU_IN_USE* = 1 # Visibility state.
GLUT_NOT_VISIBLE* = 0
GLUT_VISIBLE* = 1 # Window status state.
GLUT_HIDDEN* = 0
GLUT_FULLY_RETAINED* = 1
GLUT_PARTIALLY_RETAINED* = 2
GLUT_FULLY_COVERED* = 3 # Color index component selection values.
GLUT_RED* = 0
GLUT_GREEN* = 1
GLUT_BLUE* = 2 # Layers for use.
GLUT_NORMAL* = 0
GLUT_OVERLAY* = 1
when defined(Windows):
const # Stroke font constants (use these in GLUT program).
GLUT_STROKE_ROMAN* = cast[Pointer](0)
GLUT_STROKE_MONO_ROMAN* = cast[Pointer](1) # Bitmap font constants (use these in GLUT program).
GLUT_BITMAP_9_BY_15* = cast[Pointer](2)
GLUT_BITMAP_8_BY_13* = cast[Pointer](3)
GLUT_BITMAP_TIMES_ROMAN_10* = cast[Pointer](4)
GLUT_BITMAP_TIMES_ROMAN_24* = cast[Pointer](5)
GLUT_BITMAP_HELVETICA_10* = cast[Pointer](6)
GLUT_BITMAP_HELVETICA_12* = cast[Pointer](7)
GLUT_BITMAP_HELVETICA_18* = cast[Pointer](8)
else:
var # Stroke font constants (use these in GLUT program).
GLUT_STROKE_ROMAN*: Pointer
GLUT_STROKE_MONO_ROMAN*: Pointer # Bitmap font constants (use these in GLUT program).
GLUT_BITMAP_9_BY_15*: Pointer
GLUT_BITMAP_8_BY_13*: Pointer
GLUT_BITMAP_TIMES_ROMAN_10*: Pointer
GLUT_BITMAP_TIMES_ROMAN_24*: Pointer
GLUT_BITMAP_HELVETICA_10*: Pointer
GLUT_BITMAP_HELVETICA_12*: Pointer
GLUT_BITMAP_HELVETICA_18*: Pointer
const # glutGet parameters.
GLUT_WINDOW_X* = 100
GLUT_WINDOW_Y* = 101
GLUT_WINDOW_WIDTH* = 102
GLUT_WINDOW_HEIGHT* = 103
GLUT_WINDOW_BUFFER_SIZE* = 104
GLUT_WINDOW_STENCIL_SIZE* = 105
GLUT_WINDOW_DEPTH_SIZE* = 106
GLUT_WINDOW_RED_SIZE* = 107
GLUT_WINDOW_GREEN_SIZE* = 108
GLUT_WINDOW_BLUE_SIZE* = 109
GLUT_WINDOW_ALPHA_SIZE* = 110
GLUT_WINDOW_ACCUM_RED_SIZE* = 111
GLUT_WINDOW_ACCUM_GREEN_SIZE* = 112
GLUT_WINDOW_ACCUM_BLUE_SIZE* = 113
GLUT_WINDOW_ACCUM_ALPHA_SIZE* = 114
GLUT_WINDOW_DOUBLEBUFFER* = 115
GLUT_WINDOW_RGBA* = 116
GLUT_WINDOW_PARENT* = 117
GLUT_WINDOW_NUM_CHILDREN* = 118
GLUT_WINDOW_COLORMAP_SIZE* = 119
GLUT_WINDOW_NUM_SAMPLES* = 120
GLUT_WINDOW_STEREO* = 121
GLUT_WINDOW_CURSOR* = 122
GLUT_SCREEN_WIDTH* = 200
GLUT_SCREEN_HEIGHT* = 201
GLUT_SCREEN_WIDTH_MM* = 202
GLUT_SCREEN_HEIGHT_MM* = 203
GLUT_MENU_NUM_ITEMS* = 300
GLUT_DISPLAY_MODE_POSSIBLE* = 400
GLUT_INIT_WINDOW_X* = 500
GLUT_INIT_WINDOW_Y* = 501
GLUT_INIT_WINDOW_WIDTH* = 502
GLUT_INIT_WINDOW_HEIGHT* = 503
constGLUT_INIT_DISPLAY_MODE* = 504
GLUT_ELAPSED_TIME* = 700
GLUT_WINDOW_FORMAT_ID* = 123 # glutDeviceGet parameters.
GLUT_HAS_KEYBOARD* = 600
GLUT_HAS_MOUSE* = 601
GLUT_HAS_SPACEBALL* = 602
GLUT_HAS_DIAL_AND_BUTTON_BOX* = 603
GLUT_HAS_TABLET* = 604
GLUT_NUM_MOUSE_BUTTONS* = 605
GLUT_NUM_SPACEBALL_BUTTONS* = 606
GLUT_NUM_BUTTON_BOX_BUTTONS* = 607
GLUT_NUM_DIALS* = 608
GLUT_NUM_TABLET_BUTTONS* = 609
GLUT_DEVICE_IGNORE_KEY_REPEAT* = 610
GLUT_DEVICE_KEY_REPEAT* = 611
GLUT_HAS_JOYSTICK* = 612
GLUT_OWNS_JOYSTICK* = 613
GLUT_JOYSTICK_BUTTONS* = 614
GLUT_JOYSTICK_AXES* = 615
GLUT_JOYSTICK_POLL_RATE* = 616 # glutLayerGet parameters.
GLUT_OVERLAY_POSSIBLE* = 800
GLUT_LAYER_IN_USE* = 801
GLUT_HAS_OVERLAY* = 802
GLUT_TRANSPARENT_INDEX* = 803
GLUT_NORMAL_DAMAGED* = 804
GLUT_OVERLAY_DAMAGED* = 805 # glutVideoResizeGet parameters.
GLUT_VIDEO_RESIZE_POSSIBLE* = 900
GLUT_VIDEO_RESIZE_IN_USE* = 901
GLUT_VIDEO_RESIZE_X_DELTA* = 902
GLUT_VIDEO_RESIZE_Y_DELTA* = 903
GLUT_VIDEO_RESIZE_WIDTH_DELTA* = 904
GLUT_VIDEO_RESIZE_HEIGHT_DELTA* = 905
GLUT_VIDEO_RESIZE_X* = 906
GLUT_VIDEO_RESIZE_Y* = 907
GLUT_VIDEO_RESIZE_WIDTH* = 908
GLUT_VIDEO_RESIZE_HEIGHT* = 909 # glutGetModifiers return mask.
GLUT_ACTIVE_SHIFT* = 1
GLUT_ACTIVE_CTRL* = 2
GLUT_ACTIVE_ALT* = 4 # glutSetCursor parameters.
# Basic arrows.
GLUT_CURSOR_RIGHT_ARROW* = 0
GLUT_CURSOR_LEFT_ARROW* = 1 # Symbolic cursor shapes.
GLUT_CURSOR_INFO* = 2
GLUT_CURSOR_DESTROY* = 3
GLUT_CURSOR_HELP* = 4
GLUT_CURSOR_CYCLE* = 5
GLUT_CURSOR_SPRAY* = 6
GLUT_CURSOR_WAIT* = 7
GLUT_CURSOR_TEXT* = 8
GLUT_CURSOR_CROSSHAIR* = 9 # Directional cursors.
GLUT_CURSOR_UP_DOWN* = 10
GLUT_CURSOR_LEFT_RIGHT* = 11 # Sizing cursors.
GLUT_CURSOR_TOP_SIDE* = 12
GLUT_CURSOR_BOTTOM_SIDE* = 13
GLUT_CURSOR_LEFT_SIDE* = 14
GLUT_CURSOR_RIGHT_SIDE* = 15
GLUT_CURSOR_TOP_LEFT_CORNER* = 16
GLUT_CURSOR_TOP_RIGHT_CORNER* = 17
GLUT_CURSOR_BOTTOM_RIGHT_CORNER* = 18
GLUT_CURSOR_BOTTOM_LEFT_CORNER* = 19 # Inherit from parent window.
GLUT_CURSOR_INHERIT* = 100 # Blank cursor.
GLUT_CURSOR_NONE* = 101 # Fullscreen crosshair (if available).
GLUT_CURSOR_FULL_CROSSHAIR* = 102 # GLUT device control sub-API.
# glutSetKeyRepeat modes.
GLUT_KEY_REPEAT_OFF* = 0
GLUT_KEY_REPEAT_ON* = 1
GLUT_KEY_REPEAT_DEFAULT* = 2 # Joystick button masks.
GLUT_JOYSTICK_BUTTON_A* = 1
GLUT_JOYSTICK_BUTTON_B* = 2
GLUT_JOYSTICK_BUTTON_C* = 4
GLUT_JOYSTICK_BUTTON_D* = 8 # GLUT game mode sub-API.
# glutGameModeGet.
GLUT_GAME_MODE_ACTIVE* = 0
GLUT_GAME_MODE_POSSIBLE* = 1
GLUT_GAME_MODE_WIDTH* = 2
GLUT_GAME_MODE_HEIGHT* = 3
GLUT_GAME_MODE_PIXEL_DEPTH* = 4
GLUT_GAME_MODE_REFRESH_RATE* = 5
GLUT_GAME_MODE_DISPLAY_CHANGED* = 6 # GLUT initialization sub-API.
proc glutInit*(argcp: ptr cint, argv: pointer){.dynlib: dllname,
importc: "glutInit".}
proc glutInit*() =
## version that passes `argc` and `argc` implicitely.
var
cmdLine {.importc: "cmdLine".}: array[0..255, cstring]
cmdCount {.importc: "cmdCount".}: cint
glutInit(addr(cmdCount), addr(cmdLine))
proc glutInitDisplayMode*(mode: int16){.dynlib: dllname,
importc: "glutInitDisplayMode".}
proc glutInitDisplayString*(str: cstring){.dynlib: dllname,
importc: "glutInitDisplayString".}
proc glutInitWindowPosition*(x, y: int){.dynlib: dllname,
importc: "glutInitWindowPosition".}
proc glutInitWindowSize*(width, height: int){.dynlib: dllname,
importc: "glutInitWindowSize".}
proc glutMainLoop*(){.dynlib: dllname, importc: "glutMainLoop".}
# GLUT window sub-API.
proc glutCreateWindow*(title: cstring): int{.dynlib: dllname,
importc: "glutCreateWindow".}
proc glutCreateSubWindow*(win, x, y, width, height: int): int{.dynlib: dllname,
importc: "glutCreateSubWindow".}
proc glutDestroyWindow*(win: int){.dynlib: dllname, importc: "glutDestroyWindow".}
proc glutPostRedisplay*(){.dynlib: dllname, importc: "glutPostRedisplay".}
proc glutPostWindowRedisplay*(win: int){.dynlib: dllname,
importc: "glutPostWindowRedisplay".}
proc glutSwapBuffers*(){.dynlib: dllname, importc: "glutSwapBuffers".}
proc glutGetWindow*(): int{.dynlib: dllname, importc: "glutGetWindow".}
proc glutSetWindow*(win: int){.dynlib: dllname, importc: "glutSetWindow".}
proc glutSetWindowTitle*(title: cstring){.dynlib: dllname,
importc: "glutSetWindowTitle".}
proc glutSetIconTitle*(title: cstring){.dynlib: dllname,
importc: "glutSetIconTitle".}
proc glutPositionWindow*(x, y: int){.dynlib: dllname,
importc: "glutPositionWindow".}
proc glutReshapeWindow*(width, height: int){.dynlib: dllname,
importc: "glutReshapeWindow".}
proc glutPopWindow*(){.dynlib: dllname, importc: "glutPopWindow".}
proc glutPushWindow*(){.dynlib: dllname, importc: "glutPushWindow".}
proc glutIconifyWindow*(){.dynlib: dllname, importc: "glutIconifyWindow".}
proc glutShowWindow*(){.dynlib: dllname, importc: "glutShowWindow".}
proc glutHideWindow*(){.dynlib: dllname, importc: "glutHideWindow".}
proc glutFullScreen*(){.dynlib: dllname, importc: "glutFullScreen".}
proc glutSetCursor*(cursor: int){.dynlib: dllname, importc: "glutSetCursor".}
proc glutWarpPointer*(x, y: int){.dynlib: dllname, importc: "glutWarpPointer".}
# GLUT overlay sub-API.
proc glutEstablishOverlay*(){.dynlib: dllname, importc: "glutEstablishOverlay".}
proc glutRemoveOverlay*(){.dynlib: dllname, importc: "glutRemoveOverlay".}
proc glutUseLayer*(layer: TGLenum){.dynlib: dllname, importc: "glutUseLayer".}
proc glutPostOverlayRedisplay*(){.dynlib: dllname,
importc: "glutPostOverlayRedisplay".}
proc glutPostWindowOverlayRedisplay*(win: int){.dynlib: dllname,
importc: "glutPostWindowOverlayRedisplay".}
proc glutShowOverlay*(){.dynlib: dllname, importc: "glutShowOverlay".}
proc glutHideOverlay*(){.dynlib: dllname, importc: "glutHideOverlay".}
# GLUT menu sub-API.
proc glutCreateMenu*(callback: TGlut1IntCallback): int{.dynlib: dllname,
importc: "glutCreateMenu".}
proc glutDestroyMenu*(menu: int){.dynlib: dllname, importc: "glutDestroyMenu".}
proc glutGetMenu*(): int{.dynlib: dllname, importc: "glutGetMenu".}
proc glutSetMenu*(menu: int){.dynlib: dllname, importc: "glutSetMenu".}
proc glutAddMenuEntry*(caption: cstring, value: int){.dynlib: dllname,
importc: "glutAddMenuEntry".}
proc glutAddSubMenu*(caption: cstring, submenu: int){.dynlib: dllname,
importc: "glutAddSubMenu".}
proc glutChangeToMenuEntry*(item: int, caption: cstring, value: int){.
dynlib: dllname, importc: "glutChangeToMenuEntry".}
proc glutChangeToSubMenu*(item: int, caption: cstring, submenu: int){.
dynlib: dllname, importc: "glutChangeToSubMenu".}
proc glutRemoveMenuItem*(item: int){.dynlib: dllname,
importc: "glutRemoveMenuItem".}
proc glutAttachMenu*(button: int){.dynlib: dllname, importc: "glutAttachMenu".}
proc glutDetachMenu*(button: int){.dynlib: dllname, importc: "glutDetachMenu".}
# GLUT window callback sub-API.
proc glutDisplayFunc*(f: TGlutVoidCallback){.dynlib: dllname,
importc: "glutDisplayFunc".}
proc glutReshapeFunc*(f: TGlut2IntCallback){.dynlib: dllname,
importc: "glutReshapeFunc".}
proc glutKeyboardFunc*(f: TGlut1Char2IntCallback){.dynlib: dllname,
importc: "glutKeyboardFunc".}
proc glutMouseFunc*(f: TGlut4IntCallback){.dynlib: dllname,
importc: "glutMouseFunc".}
proc glutMotionFunc*(f: TGlut2IntCallback){.dynlib: dllname,
importc: "glutMotionFunc".}
proc glutPassiveMotionFunc*(f: TGlut2IntCallback){.dynlib: dllname,
importc: "glutPassiveMotionFunc".}
proc glutEntryFunc*(f: TGlut1IntCallback){.dynlib: dllname,
importc: "glutEntryFunc".}
proc glutVisibilityFunc*(f: TGlut1IntCallback){.dynlib: dllname,
importc: "glutVisibilityFunc".}
proc glutIdleFunc*(f: TGlutVoidCallback){.dynlib: dllname,
importc: "glutIdleFunc".}
proc glutTimerFunc*(millis: int16, f: TGlut1IntCallback, value: int){.
dynlib: dllname, importc: "glutTimerFunc".}
proc glutMenuStateFunc*(f: TGlut1IntCallback){.dynlib: dllname,
importc: "glutMenuStateFunc".}
proc glutSpecialFunc*(f: TGlut3IntCallback){.dynlib: dllname,
importc: "glutSpecialFunc".}
proc glutSpaceballMotionFunc*(f: TGlut3IntCallback){.dynlib: dllname,
importc: "glutSpaceballMotionFunc".}
proc glutSpaceballRotateFunc*(f: TGlut3IntCallback){.dynlib: dllname,
importc: "glutSpaceballRotateFunc".}
proc glutSpaceballButtonFunc*(f: TGlut2IntCallback){.dynlib: dllname,
importc: "glutSpaceballButtonFunc".}
proc glutButtonBoxFunc*(f: TGlut2IntCallback){.dynlib: dllname,
importc: "glutButtonBoxFunc".}
proc glutDialsFunc*(f: TGlut2IntCallback){.dynlib: dllname,
importc: "glutDialsFunc".}
proc glutTabletMotionFunc*(f: TGlut2IntCallback){.dynlib: dllname,
importc: "glutTabletMotionFunc".}
proc glutTabletButtonFunc*(f: TGlut4IntCallback){.dynlib: dllname,
importc: "glutTabletButtonFunc".}
proc glutMenuStatusFunc*(f: TGlut3IntCallback){.dynlib: dllname,
importc: "glutMenuStatusFunc".}
proc glutOverlayDisplayFunc*(f: TGlutVoidCallback){.dynlib: dllname,
importc: "glutOverlayDisplayFunc".}
proc glutWindowStatusFunc*(f: TGlut1IntCallback){.dynlib: dllname,
importc: "glutWindowStatusFunc".}
proc glutKeyboardUpFunc*(f: TGlut1Char2IntCallback){.dynlib: dllname,
importc: "glutKeyboardUpFunc".}
proc glutSpecialUpFunc*(f: TGlut3IntCallback){.dynlib: dllname,
importc: "glutSpecialUpFunc".}
proc glutJoystickFunc*(f: TGlut1UInt3IntCallback, pollInterval: int){.
dynlib: dllname, importc: "glutJoystickFunc".}
# GLUT color index sub-API.
proc glutSetColor*(cell: int, red, green, blue: TGLfloat){.dynlib: dllname,
importc: "glutSetColor".}
proc glutGetColor*(ndx, component: int): TGLfloat{.dynlib: dllname,
importc: "glutGetColor".}
proc glutCopyColormap*(win: int){.dynlib: dllname, importc: "glutCopyColormap".}
# GLUT state retrieval sub-API.
proc glutGet*(t: TGLenum): int{.dynlib: dllname, importc: "glutGet".}
proc glutDeviceGet*(t: TGLenum): int{.dynlib: dllname, importc: "glutDeviceGet".}
# GLUT extension support sub-API
proc glutExtensionSupported*(name: cstring): int{.dynlib: dllname,
importc: "glutExtensionSupported".}
proc glutGetModifiers*(): int{.dynlib: dllname, importc: "glutGetModifiers".}
proc glutLayerGet*(t: TGLenum): int{.dynlib: dllname, importc: "glutLayerGet".}
# GLUT font sub-API
proc glutBitmapCharacter*(font: pointer, character: int){.dynlib: dllname,
importc: "glutBitmapCharacter".}
proc glutBitmapWidth*(font: pointer, character: int): int{.dynlib: dllname,
importc: "glutBitmapWidth".}
proc glutStrokeCharacter*(font: pointer, character: int){.dynlib: dllname,
importc: "glutStrokeCharacter".}
proc glutStrokeWidth*(font: pointer, character: int): int{.dynlib: dllname,
importc: "glutStrokeWidth".}
proc glutBitmapLength*(font: pointer, str: cstring): int{.dynlib: dllname,
importc: "glutBitmapLength".}
proc glutStrokeLength*(font: pointer, str: cstring): int{.dynlib: dllname,
importc: "glutStrokeLength".}
# GLUT pre-built models sub-API
proc glutWireSphere*(radius: TGLdouble, slices, stacks: TGLint){.
dynlib: dllname, importc: "glutWireSphere".}
proc glutSolidSphere*(radius: TGLdouble, slices, stacks: TGLint){.
dynlib: dllname, importc: "glutSolidSphere".}
proc glutWireCone*(base, height: TGLdouble, slices, stacks: TGLint){.
dynlib: dllname, importc: "glutWireCone".}
proc glutSolidCone*(base, height: TGLdouble, slices, stacks: TGLint){.
dynlib: dllname, importc: "glutSolidCone".}
proc glutWireCube*(size: TGLdouble){.dynlib: dllname, importc: "glutWireCube".}
proc glutSolidCube*(size: TGLdouble){.dynlib: dllname, importc: "glutSolidCube".}
proc glutWireTorus*(innerRadius, outerRadius: TGLdouble, sides, rings: TGLint){.
dynlib: dllname, importc: "glutWireTorus".}
proc glutSolidTorus*(innerRadius, outerRadius: TGLdouble, sides, rings: TGLint){.
dynlib: dllname, importc: "glutSolidTorus".}
proc glutWireDodecahedron*(){.dynlib: dllname, importc: "glutWireDodecahedron".}
proc glutSolidDodecahedron*(){.dynlib: dllname, importc: "glutSolidDodecahedron".}
proc glutWireTeapot*(size: TGLdouble){.dynlib: dllname,
importc: "glutWireTeapot".}
proc glutSolidTeapot*(size: TGLdouble){.dynlib: dllname,
importc: "glutSolidTeapot".}
proc glutWireOctahedron*(){.dynlib: dllname, importc: "glutWireOctahedron".}
proc glutSolidOctahedron*(){.dynlib: dllname, importc: "glutSolidOctahedron".}
proc glutWireTetrahedron*(){.dynlib: dllname, importc: "glutWireTetrahedron".}
proc glutSolidTetrahedron*(){.dynlib: dllname, importc: "glutSolidTetrahedron".}
proc glutWireIcosahedron*(){.dynlib: dllname, importc: "glutWireIcosahedron".}
proc glutSolidIcosahedron*(){.dynlib: dllname, importc: "glutSolidIcosahedron".}
# GLUT video resize sub-API.
proc glutVideoResizeGet*(param: TGLenum): int{.dynlib: dllname,
importc: "glutVideoResizeGet".}
proc glutSetupVideoResizing*(){.dynlib: dllname,
importc: "glutSetupVideoResizing".}
proc glutStopVideoResizing*(){.dynlib: dllname, importc: "glutStopVideoResizing".}
proc glutVideoResize*(x, y, width, height: int){.dynlib: dllname,
importc: "glutVideoResize".}
proc glutVideoPan*(x, y, width, height: int){.dynlib: dllname,
importc: "glutVideoPan".}
# GLUT debugging sub-API.
proc glutReportErrors*(){.dynlib: dllname, importc: "glutReportErrors".}
# GLUT device control sub-API.
proc glutIgnoreKeyRepeat*(ignore: int){.dynlib: dllname,
importc: "glutIgnoreKeyRepeat".}
proc glutSetKeyRepeat*(repeatMode: int){.dynlib: dllname,
importc: "glutSetKeyRepeat".}
proc glutForceJoystickFunc*(){.dynlib: dllname, importc: "glutForceJoystickFunc".}
# GLUT game mode sub-API.
#example glutGameModeString('1280x1024:32@75');
proc glutGameModeString*(AString: cstring){.dynlib: dllname,
importc: "glutGameModeString".}
proc glutEnterGameMode*(): int{.dynlib: dllname, importc: "glutEnterGameMode".}
proc glutLeaveGameMode*(){.dynlib: dllname, importc: "glutLeaveGameMode".}
proc glutGameModeGet*(mode: TGLenum): int{.dynlib: dllname,
importc: "glutGameModeGet".}
# implementation

View File

@@ -0,0 +1,153 @@
#
#
# Translation of the Mesa GLX headers for FreePascal
# Copyright (C) 1999 Sebastian Guenther
#
#
# Mesa 3-D graphics library
# Version: 3.0
# Copyright (C) 1995-1998 Brian Paul
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Library General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Library General Public License for more details.
#
# You should have received a copy of the GNU Library General Public
# License along with this library; if not, write to the Free
# Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
import
X, XLib, XUtil, gl
when defined(windows):
const
dllname = "GL.dll"
elif defined(macosx):
const
dllname = "/usr/X11R6/lib/libGL.dylib"
else:
const
dllname = "libGL.so"
const
GLX_USE_GL* = 1
GLX_BUFFER_SIZE* = 2
GLX_LEVEL* = 3
GLX_RGBA* = 4
GLX_DOUBLEBUFFER* = 5
GLX_STEREO* = 6
GLX_AUX_BUFFERS* = 7
GLX_RED_SIZE* = 8
GLX_GREEN_SIZE* = 9
GLX_BLUE_SIZE* = 10
GLX_ALPHA_SIZE* = 11
GLX_DEPTH_SIZE* = 12
GLX_STENCIL_SIZE* = 13
GLX_ACCUM_RED_SIZE* = 14
GLX_ACCUM_GREEN_SIZE* = 15
GLX_ACCUM_BLUE_SIZE* = 16
GLX_ACCUM_ALPHA_SIZE* = 17 # GLX_EXT_visual_info extension
GLX_X_VISUAL_TYPE_EXT* = 0x00000022
GLX_TRANSPARENT_TYPE_EXT* = 0x00000023
GLX_TRANSPARENT_INDEX_VALUE_EXT* = 0x00000024
GLX_TRANSPARENT_RED_VALUE_EXT* = 0x00000025
GLX_TRANSPARENT_GREEN_VALUE_EXT* = 0x00000026
GLX_TRANSPARENT_BLUE_VALUE_EXT* = 0x00000027
GLX_TRANSPARENT_ALPHA_VALUE_EXT* = 0x00000028 # Error codes returned by glXGetConfig:
GLX_BAD_SCREEN* = 1
GLX_BAD_ATTRIBUTE* = 2
GLX_NO_EXTENSION* = 3
GLX_BAD_VISUAL* = 4
GLX_BAD_CONTEXT* = 5
GLX_BAD_VALUE* = 6
GLX_BAD_ENUM* = 7 # GLX 1.1 and later:
GLX_VENDOR* = 1
GLX_VERSION* = 2
GLX_EXTENSIONS* = 3 # GLX_visual_info extension
GLX_TRUE_COLOR_EXT* = 0x00008002
GLX_DIRECT_COLOR_EXT* = 0x00008003
GLX_PSEUDO_COLOR_EXT* = 0x00008004
GLX_STATIC_COLOR_EXT* = 0x00008005
GLX_GRAY_SCALE_EXT* = 0x00008006
GLX_STATIC_GRAY_EXT* = 0x00008007
GLX_NONE_EXT* = 0x00008000
GLX_TRANSPARENT_RGB_EXT* = 0x00008008
GLX_TRANSPARENT_INDEX_EXT* = 0x00008009
type # From XLib:
XPixmap* = TXID
XFont* = TXID
XColormap* = TXID
GLXContext* = Pointer
GLXPixmap* = TXID
GLXDrawable* = TXID
GLXContextID* = TXID
TXPixmap* = XPixmap
TXFont* = XFont
TXColormap* = XColormap
TGLXContext* = GLXContext
TGLXPixmap* = GLXPixmap
TGLXDrawable* = GLXDrawable
TGLXContextID* = GLXContextID
proc glXChooseVisual*(dpy: PDisplay, screen: int, attribList: ptr int32): PXVisualInfo{.
cdecl, dynlib: dllname, importc: "glXChooseVisual".}
proc glXCreateContext*(dpy: PDisplay, vis: PXVisualInfo, shareList: GLXContext,
direct: bool): GLXContext{.cdecl, dynlib: dllname,
importc: "glXCreateContext".}
proc glXDestroyContext*(dpy: PDisplay, ctx: GLXContext){.cdecl, dynlib: dllname,
importc: "glXDestroyContext".}
proc glXMakeCurrent*(dpy: PDisplay, drawable: GLXDrawable, ctx: GLXContext): bool{.
cdecl, dynlib: dllname, importc: "glXMakeCurrent".}
proc glXCopyContext*(dpy: PDisplay, src, dst: GLXContext, mask: int32){.cdecl,
dynlib: dllname, importc: "glXCopyContext".}
proc glXSwapBuffers*(dpy: PDisplay, drawable: GLXDrawable){.cdecl,
dynlib: dllname, importc: "glXSwapBuffers".}
proc glXCreateGLXPixmap*(dpy: PDisplay, visual: PXVisualInfo, pixmap: XPixmap): GLXPixmap{.
cdecl, dynlib: dllname, importc: "glXCreateGLXPixmap".}
proc glXDestroyGLXPixmap*(dpy: PDisplay, pixmap: GLXPixmap){.cdecl,
dynlib: dllname, importc: "glXDestroyGLXPixmap".}
proc glXQueryExtension*(dpy: PDisplay, errorb, event: var int): bool{.cdecl,
dynlib: dllname, importc: "glXQueryExtension".}
proc glXQueryVersion*(dpy: PDisplay, maj, min: var int): bool{.cdecl,
dynlib: dllname, importc: "glXQueryVersion".}
proc glXIsDirect*(dpy: PDisplay, ctx: GLXContext): bool{.cdecl, dynlib: dllname,
importc: "glXIsDirect".}
proc glXGetConfig*(dpy: PDisplay, visual: PXVisualInfo, attrib: int,
value: var int): int{.cdecl, dynlib: dllname,
importc: "glXGetConfig".}
proc glXGetCurrentContext*(): GLXContext{.cdecl, dynlib: dllname,
importc: "glXGetCurrentContext".}
proc glXGetCurrentDrawable*(): GLXDrawable{.cdecl, dynlib: dllname,
importc: "glXGetCurrentDrawable".}
proc glXWaitGL*(){.cdecl, dynlib: dllname, importc: "glXWaitGL".}
proc glXWaitX*(){.cdecl, dynlib: dllname, importc: "glXWaitX".}
proc glXUseXFont*(font: XFont, first, count, list: int){.cdecl, dynlib: dllname,
importc: "glXUseXFont".}
# GLX 1.1 and later
proc glXQueryExtensionsString*(dpy: PDisplay, screen: int): cstring{.cdecl,
dynlib: dllname, importc: "glXQueryExtensionsString".}
proc glXQueryServerString*(dpy: PDisplay, screen, name: int): cstring{.cdecl,
dynlib: dllname, importc: "glXQueryServerString".}
proc glXGetClientString*(dpy: PDisplay, name: int): cstring{.cdecl,
dynlib: dllname, importc: "glXGetClientString".}
# Mesa GLX Extensions
proc glXCreateGLXPixmapMESA*(dpy: PDisplay, visual: PXVisualInfo,
pixmap: XPixmap, cmap: XColormap): GLXPixmap{.
cdecl, dynlib: dllname, importc: "glXCreateGLXPixmapMESA".}
proc glXReleaseBufferMESA*(dpy: PDisplay, d: GLXDrawable): bool{.cdecl,
dynlib: dllname, importc: "glXReleaseBufferMESA".}
proc glXCopySubBufferMESA*(dpy: PDisplay, drawbale: GLXDrawable,
x, y, width, height: int){.cdecl, dynlib: dllname,
importc: "glXCopySubBufferMESA".}
proc glXGetVideoSyncSGI*(counter: var int32): int{.cdecl, dynlib: dllname,
importc: "glXGetVideoSyncSGI".}
proc glXWaitVideoSyncSGI*(divisor, remainder: int, count: var int32): int{.
cdecl, dynlib: dllname, importc: "glXWaitVideoSyncSGI".}
# implementation

View File

@@ -0,0 +1,368 @@
import
gl, windows
proc wglGetExtensionsStringARB*(hdc: HDC): cstring{.dynlib: dllname,
importc: "wglGetExtensionsStringARB".}
const
WGL_FRONT_COLOR_BUFFER_BIT_ARB* = 0x00000001
WGL_BACK_COLOR_BUFFER_BIT_ARB* = 0x00000002
WGL_DEPTH_BUFFER_BIT_ARB* = 0x00000004
WGL_STENCIL_BUFFER_BIT_ARB* = 0x00000008
proc WinChoosePixelFormat*(DC: HDC, p2: PPixelFormatDescriptor): int{.
dynlib: "gdi32", importc: "ChoosePixelFormat".}
proc wglCreateBufferRegionARB*(hDC: HDC, iLayerPlane: TGLint, uType: TGLuint): THandle{.
dynlib: dllname, importc: "wglCreateBufferRegionARB".}
proc wglDeleteBufferRegionARB*(hRegion: THandle){.dynlib: dllname,
importc: "wglDeleteBufferRegionARB".}
proc wglSaveBufferRegionARB*(hRegion: THandle, x: TGLint, y: TGLint,
width: TGLint, height: TGLint): BOOL{.
dynlib: dllname, importc: "wglSaveBufferRegionARB".}
proc wglRestoreBufferRegionARB*(hRegion: THandle, x: TGLint, y: TGLint,
width: TGLint, height: TGLint, xSrc: TGLint,
ySrc: TGLint): BOOL{.dynlib: dllname,
importc: "wglRestoreBufferRegionARB".}
proc wglAllocateMemoryNV*(size: TGLsizei, readFrequency: TGLfloat,
writeFrequency: TGLfloat, priority: TGLfloat): PGLvoid{.
dynlib: dllname, importc: "wglAllocateMemoryNV".}
proc wglFreeMemoryNV*(pointer: PGLvoid){.dynlib: dllname,
importc: "wglFreeMemoryNV".}
const
WGL_IMAGE_BUFFER_MIN_ACCESS_I3D* = 0x00000001
WGL_IMAGE_BUFFER_LOCK_I3D* = 0x00000002
proc wglCreateImageBufferI3D*(hDC: HDC, dwSize: DWORD, uFlags: UINT): PGLvoid{.
dynlib: dllname, importc: "wglCreateImageBufferI3D".}
proc wglDestroyImageBufferI3D*(hDC: HDC, pAddress: PGLvoid): BOOL{.
dynlib: dllname, importc: "wglDestroyImageBufferI3D".}
proc wglAssociateImageBufferEventsI3D*(hdc: HDC, pEvent: PHandle,
pAddress: PGLvoid, pSize: PDWORD,
count: UINT): BOOL{.dynlib: dllname,
importc: "wglAssociateImageBufferEventsI3D".}
proc wglReleaseImageBufferEventsI3D*(hdc: HDC, pAddress: PGLvoid, count: UINT): BOOL{.
dynlib: dllname, importc: "wglReleaseImageBufferEventsI3D".}
proc wglEnableFrameLockI3D*(): BOOL{.dynlib: dllname,
importc: "wglEnableFrameLockI3D".}
proc wglDisableFrameLockI3D*(): BOOL{.dynlib: dllname,
importc: "wglDisableFrameLockI3D".}
proc wglIsEnabledFrameLockI3D*(pFlag: PBOOL): BOOL{.dynlib: dllname,
importc: "wglIsEnabledFrameLockI3D".}
proc wglQueryFrameLockMasterI3D*(pFlag: PBOOL): BOOL{.dynlib: dllname,
importc: "wglQueryFrameLockMasterI3D".}
proc wglGetFrameUsageI3D*(pUsage: PGLfloat): BOOL{.dynlib: dllname,
importc: "wglGetFrameUsageI3D".}
proc wglBeginFrameTrackingI3D*(): BOOL{.dynlib: dllname,
importc: "wglBeginFrameTrackingI3D".}
proc wglEndFrameTrackingI3D*(): BOOL{.dynlib: dllname,
importc: "wglEndFrameTrackingI3D".}
proc wglQueryFrameTrackingI3D*(pFrameCount: PDWORD, pMissedFrames: PDWORD,
pLastMissedUsage: PGLfloat): BOOL{.
dynlib: dllname, importc: "wglQueryFrameTrackingI3D".}
const
WGL_NUMBER_PIXEL_FORMATS_ARB* = 0x00002000
WGL_DRAW_TO_WINDOW_ARB* = 0x00002001
WGL_DRAW_TO_BITMAP_ARB* = 0x00002002
WGL_ACCELERATION_ARB* = 0x00002003
WGL_NEED_PALETTE_ARB* = 0x00002004
WGL_NEED_SYSTEM_PALETTE_ARB* = 0x00002005
WGL_SWAP_LAYER_BUFFERS_ARB* = 0x00002006
WGL_SWAP_METHOD_ARB* = 0x00002007
WGL_NUMBER_OVERLAYS_ARB* = 0x00002008
WGL_NUMBER_UNDERLAYS_ARB* = 0x00002009
WGL_TRANSPARENT_ARB* = 0x0000200A
WGL_TRANSPARENT_RED_VALUE_ARB* = 0x00002037
WGL_TRANSPARENT_GREEN_VALUE_ARB* = 0x00002038
WGL_TRANSPARENT_BLUE_VALUE_ARB* = 0x00002039
WGL_TRANSPARENT_ALPHA_VALUE_ARB* = 0x0000203A
WGL_TRANSPARENT_INDEX_VALUE_ARB* = 0x0000203B
WGL_SHARE_DEPTH_ARB* = 0x0000200C
WGL_SHARE_STENCIL_ARB* = 0x0000200D
WGL_SHARE_ACCUM_ARB* = 0x0000200E
WGL_SUPPORT_GDI_ARB* = 0x0000200F
WGL_SUPPORT_OPENGL_ARB* = 0x00002010
WGL_DOUBLE_BUFFER_ARB* = 0x00002011
WGL_STEREO_ARB* = 0x00002012
WGL_PIXEL_TYPE_ARB* = 0x00002013
WGL_COLOR_BITS_ARB* = 0x00002014
WGL_RED_BITS_ARB* = 0x00002015
WGL_RED_SHIFT_ARB* = 0x00002016
WGL_GREEN_BITS_ARB* = 0x00002017
WGL_GREEN_SHIFT_ARB* = 0x00002018
WGL_BLUE_BITS_ARB* = 0x00002019
WGL_BLUE_SHIFT_ARB* = 0x0000201A
WGL_ALPHA_BITS_ARB* = 0x0000201B
WGL_ALPHA_SHIFT_ARB* = 0x0000201C
WGL_ACCUM_BITS_ARB* = 0x0000201D
WGL_ACCUM_RED_BITS_ARB* = 0x0000201E
WGL_ACCUM_GREEN_BITS_ARB* = 0x0000201F
WGL_ACCUM_BLUE_BITS_ARB* = 0x00002020
WGL_ACCUM_ALPHA_BITS_ARB* = 0x00002021
WGL_DEPTH_BITS_ARB* = 0x00002022
WGL_STENCIL_BITS_ARB* = 0x00002023
WGL_AUX_BUFFERS_ARB* = 0x00002024
WGL_NO_ACCELERATION_ARB* = 0x00002025
WGL_GENERIC_ACCELERATION_ARB* = 0x00002026
WGL_FULL_ACCELERATION_ARB* = 0x00002027
WGL_SWAP_EXCHANGE_ARB* = 0x00002028
WGL_SWAP_COPY_ARB* = 0x00002029
WGL_SWAP_UNDEFINED_ARB* = 0x0000202A
WGL_TYPE_RGBA_ARB* = 0x0000202B
WGL_TYPE_COLORINDEX_ARB* = 0x0000202C
proc wglGetPixelFormatAttribivARB*(hdc: HDC, iPixelFormat: TGLint,
iLayerPlane: TGLint, nAttributes: TGLuint,
piAttributes: PGLint, piValues: PGLint): BOOL{.
dynlib: dllname, importc: "wglGetPixelFormatAttribivARB".}
proc wglGetPixelFormatAttribfvARB*(hdc: HDC, iPixelFormat: TGLint,
iLayerPlane: TGLint, nAttributes: TGLuint,
piAttributes: PGLint, pfValues: PGLfloat): BOOL{.
dynlib: dllname, importc: "wglGetPixelFormatAttribfvARB".}
proc wglChoosePixelFormatARB*(hdc: HDC, piAttribIList: PGLint,
pfAttribFList: PGLfloat, nMaxFormats: TGLuint,
piFormats: PGLint, nNumFormats: PGLuint): BOOL{.
dynlib: dllname, importc: "wglChoosePixelFormatARB".}
const
WGL_ERROR_INVALID_PIXEL_TYPE_ARB* = 0x00002043
WGL_ERROR_INCOMPATIBLE_DEVICE_CONTEXTS_ARB* = 0x00002054
proc wglMakeContextCurrentARB*(hDrawDC: HDC, hReadDC: HDC, hglrc: HGLRC): BOOL{.
dynlib: dllname, importc: "wglMakeContextCurrentARB".}
proc wglGetCurrentReadDCARB*(): HDC{.dynlib: dllname,
importc: "wglGetCurrentReadDCARB".}
const
WGL_DRAW_TO_PBUFFER_ARB* = 0x0000202D # WGL_DRAW_TO_PBUFFER_ARB { already defined }
WGL_MAX_PBUFFER_PIXELS_ARB* = 0x0000202E
WGL_MAX_PBUFFER_WIDTH_ARB* = 0x0000202F
WGL_MAX_PBUFFER_HEIGHT_ARB* = 0x00002030
WGL_PBUFFER_LARGEST_ARB* = 0x00002033
WGL_PBUFFER_WIDTH_ARB* = 0x00002034
WGL_PBUFFER_HEIGHT_ARB* = 0x00002035
WGL_PBUFFER_LOST_ARB* = 0x00002036
proc wglCreatePbufferARB*(hDC: HDC, iPixelFormat: TGLint, iWidth: TGLint,
iHeight: TGLint, piAttribList: PGLint): THandle{.
dynlib: dllname, importc: "wglCreatePbufferARB".}
proc wglGetPbufferDCARB*(hPbuffer: THandle): HDC{.dynlib: dllname,
importc: "wglGetPbufferDCARB".}
proc wglReleasePbufferDCARB*(hPbuffer: THandle, hDC: HDC): TGLint{.
dynlib: dllname, importc: "wglReleasePbufferDCARB".}
proc wglDestroyPbufferARB*(hPbuffer: THandle): BOOL{.dynlib: dllname,
importc: "wglDestroyPbufferARB".}
proc wglQueryPbufferARB*(hPbuffer: THandle, iAttribute: TGLint, piValue: PGLint): BOOL{.
dynlib: dllname, importc: "wglQueryPbufferARB".}
proc wglSwapIntervalEXT*(interval: TGLint): BOOL{.dynlib: dllname,
importc: "wglSwapIntervalEXT".}
proc wglGetSwapIntervalEXT*(): TGLint{.dynlib: dllname,
importc: "wglGetSwapIntervalEXT".}
const
WGL_BIND_TO_TEXTURE_RGB_ARB* = 0x00002070
WGL_BIND_TO_TEXTURE_RGBA_ARB* = 0x00002071
WGL_TEXTURE_FORMAT_ARB* = 0x00002072
WGL_TEXTURE_TARGET_ARB* = 0x00002073
WGL_MIPMAP_TEXTURE_ARB* = 0x00002074
WGL_TEXTURE_RGB_ARB* = 0x00002075
WGL_TEXTURE_RGBA_ARB* = 0x00002076
WGL_NO_TEXTURE_ARB* = 0x00002077
WGL_TEXTURE_CUBE_MAP_ARB* = 0x00002078
WGL_TEXTURE_1D_ARB* = 0x00002079
WGL_TEXTURE_2D_ARB* = 0x0000207A # WGL_NO_TEXTURE_ARB { already defined }
WGL_MIPMAP_LEVEL_ARB* = 0x0000207B
WGL_CUBE_MAP_FACE_ARB* = 0x0000207C
WGL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB* = 0x0000207D
WGL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB* = 0x0000207E
WGL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB* = 0x0000207F
WGL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB* = 0x00002080
WGL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB* = 0x00002081
WGL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB* = 0x00002082
WGL_FRONT_LEFT_ARB* = 0x00002083
WGL_FRONT_RIGHT_ARB* = 0x00002084
WGL_BACK_LEFT_ARB* = 0x00002085
WGL_BACK_RIGHT_ARB* = 0x00002086
WGL_AUX0_ARB* = 0x00002087
WGL_AUX1_ARB* = 0x00002088
WGL_AUX2_ARB* = 0x00002089
WGL_AUX3_ARB* = 0x0000208A
WGL_AUX4_ARB* = 0x0000208B
WGL_AUX5_ARB* = 0x0000208C
WGL_AUX6_ARB* = 0x0000208D
WGL_AUX7_ARB* = 0x0000208E
WGL_AUX8_ARB* = 0x0000208F
WGL_AUX9_ARB* = 0x00002090
proc wglBindTexImageARB*(hPbuffer: THandle, iBuffer: TGLint): BOOL{.
dynlib: dllname, importc: "wglBindTexImageARB".}
proc wglReleaseTexImageARB*(hPbuffer: THandle, iBuffer: TGLint): BOOL{.
dynlib: dllname, importc: "wglReleaseTexImageARB".}
proc wglSetPbufferAttribARB*(hPbuffer: THandle, piAttribList: PGLint): BOOL{.
dynlib: dllname, importc: "wglSetPbufferAttribARB".}
proc wglGetExtensionsStringEXT*(): cstring{.dynlib: dllname,
importc: "wglGetExtensionsStringEXT".}
proc wglMakeContextCurrentEXT*(hDrawDC: HDC, hReadDC: HDC, hglrc: HGLRC): BOOL{.
dynlib: dllname, importc: "wglMakeContextCurrentEXT".}
proc wglGetCurrentReadDCEXT*(): HDC{.dynlib: dllname,
importc: "wglGetCurrentReadDCEXT".}
const
WGL_DRAW_TO_PBUFFER_EXT* = 0x0000202D
WGL_MAX_PBUFFER_PIXELS_EXT* = 0x0000202E
WGL_MAX_PBUFFER_WIDTH_EXT* = 0x0000202F
WGL_MAX_PBUFFER_HEIGHT_EXT* = 0x00002030
WGL_OPTIMAL_PBUFFER_WIDTH_EXT* = 0x00002031
WGL_OPTIMAL_PBUFFER_HEIGHT_EXT* = 0x00002032
WGL_PBUFFER_LARGEST_EXT* = 0x00002033
WGL_PBUFFER_WIDTH_EXT* = 0x00002034
WGL_PBUFFER_HEIGHT_EXT* = 0x00002035
proc wglCreatePbufferEXT*(hDC: HDC, iPixelFormat: TGLint, iWidth: TGLint,
iHeight: TGLint, piAttribList: PGLint): THandle{.
dynlib: dllname, importc: "wglCreatePbufferEXT".}
proc wglGetPbufferDCEXT*(hPbuffer: THandle): HDC{.dynlib: dllname,
importc: "wglGetPbufferDCEXT".}
proc wglReleasePbufferDCEXT*(hPbuffer: THandle, hDC: HDC): TGLint{.
dynlib: dllname, importc: "wglReleasePbufferDCEXT".}
proc wglDestroyPbufferEXT*(hPbuffer: THandle): BOOL{.dynlib: dllname,
importc: "wglDestroyPbufferEXT".}
proc wglQueryPbufferEXT*(hPbuffer: THandle, iAttribute: TGLint, piValue: PGLint): BOOL{.
dynlib: dllname, importc: "wglQueryPbufferEXT".}
const
WGL_NUMBER_PIXEL_FORMATS_EXT* = 0x00002000
WGL_DRAW_TO_WINDOW_EXT* = 0x00002001
WGL_DRAW_TO_BITMAP_EXT* = 0x00002002
WGL_ACCELERATION_EXT* = 0x00002003
WGL_NEED_PALETTE_EXT* = 0x00002004
WGL_NEED_SYSTEM_PALETTE_EXT* = 0x00002005
WGL_SWAP_LAYER_BUFFERS_EXT* = 0x00002006
WGL_SWAP_METHOD_EXT* = 0x00002007
WGL_NUMBER_OVERLAYS_EXT* = 0x00002008
WGL_NUMBER_UNDERLAYS_EXT* = 0x00002009
WGL_TRANSPARENT_EXT* = 0x0000200A
WGL_TRANSPARENT_VALUE_EXT* = 0x0000200B
WGL_SHARE_DEPTH_EXT* = 0x0000200C
WGL_SHARE_STENCIL_EXT* = 0x0000200D
WGL_SHARE_ACCUM_EXT* = 0x0000200E
WGL_SUPPORT_GDI_EXT* = 0x0000200F
WGL_SUPPORT_OPENGL_EXT* = 0x00002010
WGL_DOUBLE_BUFFER_EXT* = 0x00002011
WGL_STEREO_EXT* = 0x00002012
WGL_PIXEL_TYPE_EXT* = 0x00002013
WGL_COLOR_BITS_EXT* = 0x00002014
WGL_RED_BITS_EXT* = 0x00002015
WGL_RED_SHIFT_EXT* = 0x00002016
WGL_GREEN_BITS_EXT* = 0x00002017
WGL_GREEN_SHIFT_EXT* = 0x00002018
WGL_BLUE_BITS_EXT* = 0x00002019
WGL_BLUE_SHIFT_EXT* = 0x0000201A
WGL_ALPHA_BITS_EXT* = 0x0000201B
WGL_ALPHA_SHIFT_EXT* = 0x0000201C
WGL_ACCUM_BITS_EXT* = 0x0000201D
WGL_ACCUM_RED_BITS_EXT* = 0x0000201E
WGL_ACCUM_GREEN_BITS_EXT* = 0x0000201F
WGL_ACCUM_BLUE_BITS_EXT* = 0x00002020
WGL_ACCUM_ALPHA_BITS_EXT* = 0x00002021
WGL_DEPTH_BITS_EXT* = 0x00002022
WGL_STENCIL_BITS_EXT* = 0x00002023
WGL_AUX_BUFFERS_EXT* = 0x00002024
WGL_NO_ACCELERATION_EXT* = 0x00002025
WGL_GENERIC_ACCELERATION_EXT* = 0x00002026
WGL_FULL_ACCELERATION_EXT* = 0x00002027
WGL_SWAP_EXCHANGE_EXT* = 0x00002028
WGL_SWAP_COPY_EXT* = 0x00002029
WGL_SWAP_UNDEFINED_EXT* = 0x0000202A
WGL_TYPE_RGBA_EXT* = 0x0000202B
WGL_TYPE_COLORINDEX_EXT* = 0x0000202C
proc wglGetPixelFormatAttribivEXT*(hdc: HDC, iPixelFormat: TGLint,
iLayerPlane: TGLint, nAttributes: TGLuint,
piAttributes: PGLint, piValues: PGLint): BOOL{.
dynlib: dllname, importc: "wglGetPixelFormatAttribivEXT".}
proc wglGetPixelFormatAttribfvEXT*(hdc: HDC, iPixelFormat: TGLint,
iLayerPlane: TGLint, nAttributes: TGLuint,
piAttributes: PGLint, pfValues: PGLfloat): BOOL{.
dynlib: dllname, importc: "wglGetPixelFormatAttribfvEXT".}
proc wglChoosePixelFormatEXT*(hdc: HDC, piAttribIList: PGLint,
pfAttribFList: PGLfloat, nMaxFormats: TGLuint,
piFormats: PGLint, nNumFormats: PGLuint): BOOL{.
dynlib: dllname, importc: "wglChoosePixelFormatEXT".}
const
WGL_DIGITAL_VIDEO_CURSOR_ALPHA_FRAMEBUFFER_I3D* = 0x00002050
WGL_DIGITAL_VIDEO_CURSOR_ALPHA_VALUE_I3D* = 0x00002051
WGL_DIGITAL_VIDEO_CURSOR_INCLUDED_I3D* = 0x00002052
WGL_DIGITAL_VIDEO_GAMMA_CORRECTED_I3D* = 0x00002053
proc wglGetDigitalVideoParametersI3D*(hDC: HDC, iAttribute: TGLint,
piValue: PGLint): BOOL{.dynlib: dllname,
importc: "wglGetDigitalVideoParametersI3D".}
proc wglSetDigitalVideoParametersI3D*(hDC: HDC, iAttribute: TGLint,
piValue: PGLint): BOOL{.dynlib: dllname,
importc: "wglSetDigitalVideoParametersI3D".}
const
WGL_GAMMA_TABLE_SIZE_I3D* = 0x0000204E
WGL_GAMMA_EXCLUDE_DESKTOP_I3D* = 0x0000204F
proc wglGetGammaTableParametersI3D*(hDC: HDC, iAttribute: TGLint,
piValue: PGLint): BOOL{.dynlib: dllname,
importc: "wglGetGammaTableParametersI3D".}
proc wglSetGammaTableParametersI3D*(hDC: HDC, iAttribute: TGLint,
piValue: PGLint): BOOL{.dynlib: dllname,
importc: "wglSetGammaTableParametersI3D".}
proc wglGetGammaTableI3D*(hDC: HDC, iEntries: TGLint, puRed: PGLUSHORT,
puGreen: PGLUSHORT, puBlue: PGLUSHORT): BOOL{.
dynlib: dllname, importc: "wglGetGammaTableI3D".}
proc wglSetGammaTableI3D*(hDC: HDC, iEntries: TGLint, puRed: PGLUSHORT,
puGreen: PGLUSHORT, puBlue: PGLUSHORT): BOOL{.
dynlib: dllname, importc: "wglSetGammaTableI3D".}
const
WGL_GENLOCK_SOURCE_MULTIVIEW_I3D* = 0x00002044
WGL_GENLOCK_SOURCE_EXTERNAL_SYNC_I3D* = 0x00002045
WGL_GENLOCK_SOURCE_EXTERNAL_FIELD_I3D* = 0x00002046
WGL_GENLOCK_SOURCE_EXTERNAL_TTL_I3D* = 0x00002047
WGL_GENLOCK_SOURCE_DIGITAL_SYNC_I3D* = 0x00002048
WGL_GENLOCK_SOURCE_DIGITAL_FIELD_I3D* = 0x00002049
WGL_GENLOCK_SOURCE_EDGE_FALLING_I3D* = 0x0000204A
WGL_GENLOCK_SOURCE_EDGE_RISING_I3D* = 0x0000204B
WGL_GENLOCK_SOURCE_EDGE_BOTH_I3D* = 0x0000204C
WGL_FLOAT_COMPONENTS_NV* = 0x000020B0
WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_R_NV* = 0x000020B1
WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RG_NV* = 0x000020B2
WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGB_NV* = 0x000020B3
WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGBA_NV* = 0x000020B4
WGL_TEXTURE_FLOAT_R_NV* = 0x000020B5
WGL_TEXTURE_FLOAT_RG_NV* = 0x000020B6
WGL_TEXTURE_FLOAT_RGB_NV* = 0x000020B7
WGL_TEXTURE_FLOAT_RGBA_NV* = 0x000020B8
proc wglEnableGenlockI3D*(hDC: HDC): BOOL{.dynlib: dllname,
importc: "wglEnableGenlockI3D".}
proc wglDisableGenlockI3D*(hDC: HDC): BOOL{.dynlib: dllname,
importc: "wglDisableGenlockI3D".}
proc wglIsEnabledGenlockI3D*(hDC: HDC, pFlag: PBOOL): BOOL{.dynlib: dllname,
importc: "wglIsEnabledGenlockI3D".}
proc wglGenlockSourceI3D*(hDC: HDC, uSource: TGLuint): BOOL{.dynlib: dllname,
importc: "wglGenlockSourceI3D".}
proc wglGetGenlockSourceI3D*(hDC: HDC, uSource: PGLUINT): BOOL{.dynlib: dllname,
importc: "wglGetGenlockSourceI3D".}
proc wglGenlockSourceEdgeI3D*(hDC: HDC, uEdge: TGLuint): BOOL{.dynlib: dllname,
importc: "wglGenlockSourceEdgeI3D".}
proc wglGetGenlockSourceEdgeI3D*(hDC: HDC, uEdge: PGLUINT): BOOL{.
dynlib: dllname, importc: "wglGetGenlockSourceEdgeI3D".}
proc wglGenlockSampleRateI3D*(hDC: HDC, uRate: TGLuint): BOOL{.dynlib: dllname,
importc: "wglGenlockSampleRateI3D".}
proc wglGetGenlockSampleRateI3D*(hDC: HDC, uRate: PGLUINT): BOOL{.
dynlib: dllname, importc: "wglGetGenlockSampleRateI3D".}
proc wglGenlockSourceDelayI3D*(hDC: HDC, uDelay: TGLuint): BOOL{.
dynlib: dllname, importc: "wglGenlockSourceDelayI3D".}
proc wglGetGenlockSourceDelayI3D*(hDC: HDC, uDelay: PGLUINT): BOOL{.
dynlib: dllname, importc: "wglGetGenlockSourceDelayI3D".}
proc wglQueryGenlockMaxSourceDelayI3D*(hDC: HDC, uMaxLineDelay: PGLUINT,
uMaxPixelDelay: PGLUINT): BOOL{.
dynlib: dllname, importc: "wglQueryGenlockMaxSourceDelayI3D".}
const
WGL_BIND_TO_TEXTURE_RECTANGLE_RGB_NV* = 0x000020A0
WGL_BIND_TO_TEXTURE_RECTANGLE_RGBA_NV* = 0x000020A1
WGL_TEXTURE_RECTANGLE_NV* = 0x000020A2
const
WGL_RGBA_FLOAT_MODE_ATI* = 0x00008820
WGL_COLOR_CLEAR_UNCLAMPED_VALUE_ATI* = 0x00008835
WGL_TYPE_RGBA_FLOAT_ATI* = 0x000021A0
# implementation

View File

View File