added missing new Lua and openGl wrappers

This commit is contained in:
Araq
2011-02-20 20:12:58 +01:00
parent 2cdfe35e73
commit 3c4f0bf905
9 changed files with 8181 additions and 0 deletions

225
lib/wrappers/lua/lauxlib.nim Executable file
View File

@@ -0,0 +1,225 @@
#*****************************************************************************
# * *
# * File: lauxlib.pas *
# * Authors: TeCGraf (C headers + actual Lua libraries) *
# * Lavergne Thomas (original translation to Pascal) *
# * Bram Kuijvenhoven (update to Lua 5.1.1 for FreePascal) *
# * Description: Lua auxiliary library *
# * *
# *****************************************************************************
#
#** $Id: lauxlib.h,v 1.59 2003/03/18 12:25:32 roberto Exp $
#** Auxiliary functions for building Lua libraries
#** See Copyright Notice in lua.h
#
#
#** Translated to pascal by Lavergne Thomas
#** Notes :
#** - Pointers type was prefixed with 'P'
#** Bug reports :
#** - thomas.lavergne@laposte.net
#** In french or in english
#
import
lua
proc pushstring*(L: PState, s: string)
# compatibilty macros
proc getn*(L: PState, n: int): int
# calls lua_objlen
proc setn*(L: PState, t, n: int)
# does nothing!
type
Treg*{.final.} = object
name*: cstring
func*: CFunction
Preg* = ptr Treg
proc openlib*(L: PState, libname: cstring, lr: Preg, nup: int){.cdecl,
dynlib: lua.LIB_NAME, importc: "luaL_openlib".}
proc register*(L: PState, libname: cstring, lr: Preg){.cdecl,
dynlib: lua.LIB_NAME, importc: "luaL_register".}
proc getmetafield*(L: PState, obj: int, e: cstring): int{.cdecl,
dynlib: lua.LIB_NAME, importc: "luaL_getmetafield".}
proc callmeta*(L: PState, obj: int, e: cstring): int{.cdecl,
dynlib: LIB_NAME, importc: "luaL_callmeta".}
proc typerror*(L: PState, narg: int, tname: cstring): int{.cdecl,
dynlib: LIB_NAME, importc: "luaL_typerror".}
proc argerror*(L: PState, numarg: int, extramsg: cstring): int{.cdecl,
dynlib: LIB_NAME, importc: "luaL_argerror".}
proc checklstring*(L: PState, numArg: int, len: ptr int): cstring{.cdecl,
dynlib: LIB_NAME, importc: "luaL_checklstring".}
proc optlstring*(L: PState, numArg: int, def: cstring, len: ptr int): cstring{.
cdecl, dynlib: LIB_NAME, importc: "luaL_optlstring".}
proc checknumber*(L: PState, numArg: int): Number{.cdecl,
dynlib: LIB_NAME, importc: "luaL_checknumber".}
proc optnumber*(L: PState, nArg: int, def: Number): Number{.cdecl,
dynlib: LIB_NAME, importc: "luaL_optnumber".}
proc checkinteger*(L: PState, numArg: int): Integer{.cdecl,
dynlib: LIB_NAME, importc: "luaL_checkinteger".}
proc optinteger*(L: PState, nArg: int, def: Integer): Integer{.
cdecl, dynlib: LIB_NAME, importc: "luaL_optinteger".}
proc checkstack*(L: PState, sz: int, msg: cstring){.cdecl,
dynlib: LIB_NAME, importc: "luaL_checkstack".}
proc checktype*(L: PState, narg, t: int){.cdecl, dynlib: LIB_NAME,
importc: "luaL_checktype".}
proc checkany*(L: PState, narg: int){.cdecl, dynlib: LIB_NAME,
importc: "luaL_checkany".}
proc newmetatable*(L: PState, tname: cstring): int{.cdecl,
dynlib: LIB_NAME, importc: "luaL_newmetatable".}
proc checkudata*(L: PState, ud: int, tname: cstring): Pointer{.cdecl,
dynlib: LIB_NAME, importc: "luaL_checkudata".}
proc where*(L: PState, lvl: int){.cdecl, dynlib: LIB_NAME,
importc: "luaL_where".}
proc error*(L: PState, fmt: cstring): int{.cdecl, varargs,
dynlib: LIB_NAME, importc: "luaL_error".}
proc checkoption*(L: PState, narg: int, def: cstring, lst: cstringArray): int{.
cdecl, dynlib: LIB_NAME, importc: "luaL_checkoption".}
proc reference*(L: PState, t: int): int{.cdecl, dynlib: LIB_NAME,
importc: "luaL_ref".}
proc unref*(L: PState, t, theref: int){.cdecl, dynlib: LIB_NAME,
importc: "luaL_unref".}
proc loadfile*(L: PState, filename: cstring): int{.cdecl,
dynlib: LIB_NAME, importc: "luaL_loadfile".}
proc loadbuffer*(L: PState, buff: cstring, size: int, name: cstring): int{.
cdecl, dynlib: LIB_NAME, importc: "luaL_loadbuffer".}
proc loadstring*(L: PState, s: cstring): int{.cdecl, dynlib: LIB_NAME,
importc: "luaL_loadstring".}
proc newstate*(): PState{.cdecl, dynlib: LIB_NAME,
importc: "luaL_newstate".}
proc open*(): PState
# compatibility; moved from unit lua to lauxlib because it needs luaL_newstate
#
#** ===============================================================
#** some useful macros
#** ===============================================================
#
proc argcheck*(L: PState, cond: bool, numarg: int, extramsg: cstring)
proc checkstring*(L: PState, n: int): cstring
proc optstring*(L: PState, n: int, d: cstring): cstring
proc checkint*(L: PState, n: int): int
proc checklong*(L: PState, n: int): int32
proc optint*(L: PState, n: int, d: float64): int
proc optlong*(L: PState, n: int, d: float64): int32
proc dofile*(L: PState, filename: cstring): int
proc dostring*(L: PState, str: cstring): int
proc getmetatable*(L: PState, tname: cstring)
# not translated:
# #define luaL_opt(L,f,n,d) (lua_isnoneornil(L,(n)) ? (d) : f(L,(n)))
#
#** =======================================================
#** Generic Buffer manipulation
#** =======================================================
#
const # note: this is just arbitrary, as it related to the BUFSIZ defined in stdio.h ...
BUFFERSIZE* = 4096
type
Buffer*{.final.} = object
p*: cstring # current position in buffer
lvl*: int # number of strings in the stack (level)
L*: PState
buffer*: array[0..BUFFERSIZE - 1, Char] # warning: see note above about LUAL_BUFFERSIZE
PBuffer* = ptr Buffer
proc addchar*(B: PBuffer, c: Char)
# warning: see note above about LUAL_BUFFERSIZE
# compatibility only (alias for luaL_addchar)
proc putchar*(B: PBuffer, c: Char)
# warning: see note above about LUAL_BUFFERSIZE
proc addsize*(B: PBuffer, n: int)
proc buffinit*(L: PState, B: PBuffer){.cdecl, dynlib: LIB_NAME,
importc: "luaL_buffinit".}
proc prepbuffer*(B: PBuffer): cstring{.cdecl, dynlib: LIB_NAME,
importc: "luaL_prepbuffer".}
proc addlstring*(B: PBuffer, s: cstring, L: int){.cdecl,
dynlib: LIB_NAME, importc: "luaL_addlstring".}
proc addstring*(B: PBuffer, s: cstring){.cdecl, dynlib: LIB_NAME,
importc: "luaL_addstring".}
proc addvalue*(B: PBuffer){.cdecl, dynlib: LIB_NAME,
importc: "luaL_addvalue".}
proc pushresult*(B: PBuffer){.cdecl, dynlib: LIB_NAME,
importc: "luaL_pushresult".}
proc gsub*(L: PState, s, p, r: cstring): cstring{.cdecl,
dynlib: LIB_NAME, importc: "luaL_gsub".}
proc findtable*(L: PState, idx: int, fname: cstring, szhint: int): cstring{.
cdecl, dynlib: LIB_NAME, importc: "luaL_findtable".}
# compatibility with ref system
# pre-defined references
const
NOREF* = - 2
REFNIL* = - 1
proc unref*(L: PState, theref: int)
proc getref*(L: PState, theref: int)
#
#** Compatibility macros and functions
#
# implementation
proc pushstring(L: PState, s: string) =
pushlstring(L, cstring(s), len(s))
proc getn(L: PState, n: int): int =
Result = objlen(L, n)
proc setn(L: PState, t, n: int) =
# does nothing as this operation is deprecated
nil
proc open(): PState =
Result = newstate()
proc dofile(L: PState, filename: cstring): int =
Result = loadfile(L, filename)
if Result == 0: Result = pcall(L, 0, MULTRET, 0)
proc dostring(L: PState, str: cstring): int =
Result = loadstring(L, str)
if Result == 0: Result = pcall(L, 0, MULTRET, 0)
proc getmetatable(L: PState, tname: cstring) =
getfield(L, REGISTRYINDEX, tname)
proc argcheck(L: PState, cond: bool, numarg: int, extramsg: cstring) =
if not cond:
discard argerror(L, numarg, extramsg)
proc checkstring(L: PState, n: int): cstring =
Result = checklstring(L, n, nil)
proc optstring(L: PState, n: int, d: cstring): cstring =
Result = optlstring(L, n, d, nil)
proc checkint(L: PState, n: int): int =
Result = toInt(checknumber(L, n))
proc checklong(L: PState, n: int): int32 =
Result = int32(ToInt(checknumber(L, n)))
proc optint(L: PState, n: int, d: float64): int =
Result = int(ToInt(optnumber(L, n, d)))
proc optlong(L: PState, n: int, d: float64): int32 =
Result = int32(ToInt(optnumber(L, n, d)))
proc addchar(B: PBuffer, c: Char) =
if cast[int](addr((B.p))) < (cast[int](addr((B.buffer[0]))) + BUFFERSIZE):
discard prepbuffer(B)
B.p[1] = c
B.p = cast[cstring](cast[int](B.p) + 1)
proc putchar(B: PBuffer, c: Char) =
addchar(B, c)
proc addsize(B: PBuffer, n: int) =
B.p = cast[cstring](cast[int](B.p) + n)
proc unref(L: PState, theref: int) =
unref(L, REGISTRYINDEX, theref)
proc getref(L: PState, theref: int) =
rawgeti(L, REGISTRYINDEX, theref)

399
lib/wrappers/lua/lua.nim Executable file
View File

@@ -0,0 +1,399 @@
#*****************************************************************************
# * *
# * File: lua.pas *
# * Authors: TeCGraf (C headers + actual Lua libraries) *
# * Lavergne Thomas (original translation to Pascal) *
# * Bram Kuijvenhoven (update to Lua 5.1.1 for FreePascal) *
# * Description: Basic Lua library *
# * *
# *****************************************************************************
#
#** $Id: lua.h,v 1.175 2003/03/18 12:31:39 roberto Exp $
#** Lua - An Extensible Extension Language
#** TeCGraf: Computer Graphics Technology Group, PUC-Rio, Brazil
#** http://www.lua.org mailto:info@lua.org
#** See Copyright Notice at the end of this file
#
#
#** Updated to Lua 5.1.1 by Bram Kuijvenhoven (bram at kuijvenhoven dot net),
#** Hexis BV (http://www.hexis.nl), the Netherlands
#** Notes:
#** - Only tested with FPC (FreePascal Compiler)
#** - Using LuaBinaries styled DLL/SO names, which include version names
#** - LUA_YIELD was suffixed by '_' for avoiding name collision
#
#
#** Translated to pascal by Lavergne Thomas
#** Notes :
#** - Pointers type was prefixed with 'P'
#** - lua_upvalueindex constant was transformed to function
#** - Some compatibility function was isolated because with it you must have
#** lualib.
#** - LUA_VERSION was suffixed by '_' for avoiding name collision.
#** Bug reports :
#** - thomas.lavergne@laposte.net
#** In french or in english
#
when defined(MACOSX):
const
NAME* = "liblua(|5.2|5.1|5.0).dylib"
LIB_NAME* = "liblua(|5.2|5.1|5.0).dylib"
elif defined(UNIX):
const
NAME* = "liblua(|5.2|5.1|5.0).so(|.0)"
LIB_NAME* = "liblua(|5.2|5.1|5.0).so(|.0)"
else:
const
NAME* = "lua(|5.2|5.1|5.0).dll"
LIB_NAME* = "lua(|5.2|5.1|5.0).dll"
const
VERSION* = "Lua 5.1"
RELEASE* = "Lua 5.1.1"
VERSION_NUM* = 501
COPYRIGHT* = "Copyright (C) 1994-2006 Lua.org, PUC-Rio"
AUTHORS* = "R. Ierusalimschy, L. H. de Figueiredo & W. Celes"
# option for multiple returns in `lua_pcall' and `lua_call'
MULTRET* = - 1 #
#** pseudo-indices
#
REGISTRYINDEX* = - 10000
ENVIRONINDEX* = - 10001
GLOBALSINDEX* = - 10002
proc upvalueindex*(I: int): int
const # thread status; 0 is OK
constYIELD* = 1
ERRRUN* = 2
ERRSYNTAX* = 3
ERRMEM* = 4
ERRERR* = 5
type
PState* = Pointer
CFunction* = proc (L: PState): int{.cdecl.}
#
#** functions that read/write blocks when loading/dumping Lua chunks
#
type
Reader* = proc (L: PState, ud: Pointer, sz: ptr int): cstring{.cdecl.}
Writer* = proc (L: PState, p: Pointer, sz: int, ud: Pointer): int{.cdecl.}
Alloc* = proc (ud, theptr: Pointer, osize, nsize: int){.cdecl.}
const
TNONE* = - 1
TNIL* = 0
TBOOLEAN* = 1
TLIGHTUSERDATA* = 2
TNUMBER* = 3
TSTRING* = 4
TTABLE* = 5
TFUNCTION* = 6
TUSERDATA* = 7
TTHREAD* = 8 # minimum Lua stack available to a C function
MINSTACK* = 20
type # Type of Numbers in Lua
Number* = float
Integer* = int
proc newstate*(f: Alloc, ud: Pointer): PState{.cdecl, dynlib: NAME,
importc: "lua_newstate".}
proc close*(L: PState){.cdecl, dynlib: NAME, importc: "lua_close".}
proc newthread*(L: PState): PState{.cdecl, dynlib: NAME,
importc: "lua_newthread".}
proc atpanic*(L: PState, panicf: CFunction): CFunction{.cdecl, dynlib: NAME,
importc: "lua_atpanic".}
proc gettop*(L: PState): int{.cdecl, dynlib: NAME, importc: "lua_gettop".}
proc settop*(L: PState, idx: int){.cdecl, dynlib: NAME, importc: "lua_settop".}
proc pushvalue*(L: PState, Idx: int){.cdecl, dynlib: NAME,
importc: "lua_pushvalue".}
proc remove*(L: PState, idx: int){.cdecl, dynlib: NAME, importc: "lua_remove".}
proc insert*(L: PState, idx: int){.cdecl, dynlib: NAME, importc: "lua_insert".}
proc replace*(L: PState, idx: int){.cdecl, dynlib: NAME, importc: "lua_replace".}
proc checkstack*(L: PState, sz: int): cint{.cdecl, dynlib: NAME,
importc: "lua_checkstack".}
proc xmove*(`from`, `to`: PState, n: int){.cdecl, dynlib: NAME,
importc: "lua_xmove".}
proc isnumber*(L: PState, idx: int): cint{.cdecl, dynlib: NAME,
importc: "lua_isnumber".}
proc isstring*(L: PState, idx: int): cint{.cdecl, dynlib: NAME,
importc: "lua_isstring".}
proc iscfunction*(L: PState, idx: int): cint{.cdecl, dynlib: NAME,
importc: "lua_iscfunction".}
proc isuserdata*(L: PState, idx: int): cint{.cdecl, dynlib: NAME,
importc: "lua_isuserdata".}
proc luatype*(L: PState, idx: int): int{.cdecl, dynlib: NAME, importc: "lua_type".}
proc typename*(L: PState, tp: int): cstring{.cdecl, dynlib: NAME,
importc: "lua_typename".}
proc equal*(L: PState, idx1, idx2: int): cint{.cdecl, dynlib: NAME,
importc: "lua_equal".}
proc rawequal*(L: PState, idx1, idx2: int): cint{.cdecl, dynlib: NAME,
importc: "lua_rawequal".}
proc lessthan*(L: PState, idx1, idx2: int): cint{.cdecl, dynlib: NAME,
importc: "lua_lessthan".}
proc tonumber*(L: PState, idx: int): Number{.cdecl, dynlib: NAME,
importc: "lua_tonumber".}
proc tointeger*(L: PState, idx: int): Integer{.cdecl, dynlib: NAME,
importc: "lua_tointeger".}
proc toboolean*(L: PState, idx: int): cint{.cdecl, dynlib: NAME,
importc: "lua_toboolean".}
proc tolstring*(L: PState, idx: int, length: ptr int): cstring{.cdecl,
dynlib: NAME, importc: "lua_tolstring".}
proc objlen*(L: PState, idx: int): int{.cdecl, dynlib: NAME,
importc: "lua_objlen".}
proc tocfunction*(L: PState, idx: int): CFunction{.cdecl, dynlib: NAME,
importc: "lua_tocfunction".}
proc touserdata*(L: PState, idx: int): Pointer{.cdecl, dynlib: NAME,
importc: "lua_touserdata".}
proc tothread*(L: PState, idx: int): PState{.cdecl, dynlib: NAME,
importc: "lua_tothread".}
proc topointer*(L: PState, idx: int): Pointer{.cdecl, dynlib: NAME,
importc: "lua_topointer".}
proc pushnil*(L: PState){.cdecl, dynlib: NAME, importc: "lua_pushnil".}
proc pushnumber*(L: PState, n: Number){.cdecl, dynlib: NAME,
importc: "lua_pushnumber".}
proc pushinteger*(L: PState, n: Integer){.cdecl, dynlib: NAME,
importc: "lua_pushinteger".}
proc pushlstring*(L: PState, s: cstring, len: int){.cdecl, dynlib: NAME,
importc: "lua_pushlstring".}
proc pushstring*(L: PState, s: cstring){.cdecl, dynlib: NAME,
importc: "lua_pushstring".}
proc pushvfstring*(L: PState, fmt: cstring, argp: Pointer): cstring{.cdecl,
dynlib: NAME, importc: "lua_pushvfstring".}
proc pushfstring*(L: PState, fmt: cstring): cstring{.cdecl, varargs,
dynlib: NAME, importc: "lua_pushfstring".}
proc pushcclosure*(L: PState, fn: CFunction, n: int){.cdecl, dynlib: NAME,
importc: "lua_pushcclosure".}
proc pushboolean*(L: PState, b: cint){.cdecl, dynlib: NAME,
importc: "lua_pushboolean".}
proc pushlightuserdata*(L: PState, p: Pointer){.cdecl, dynlib: NAME,
importc: "lua_pushlightuserdata".}
proc pushthread*(L: PState){.cdecl, dynlib: NAME, importc: "lua_pushthread".}
proc gettable*(L: PState, idx: int){.cdecl, dynlib: NAME,
importc: "lua_gettable".}
proc getfield*(L: Pstate, idx: int, k: cstring){.cdecl, dynlib: NAME,
importc: "lua_getfield".}
proc rawget*(L: PState, idx: int){.cdecl, dynlib: NAME, importc: "lua_rawget".}
proc rawgeti*(L: PState, idx, n: int){.cdecl, dynlib: NAME,
importc: "lua_rawgeti".}
proc createtable*(L: PState, narr, nrec: int){.cdecl, dynlib: NAME,
importc: "lua_createtable".}
proc newuserdata*(L: PState, sz: int): Pointer{.cdecl, dynlib: NAME,
importc: "lua_newuserdata".}
proc getmetatable*(L: PState, objindex: int): int{.cdecl, dynlib: NAME,
importc: "lua_getmetatable".}
proc getfenv*(L: PState, idx: int){.cdecl, dynlib: NAME, importc: "lua_getfenv".}
proc settable*(L: PState, idx: int){.cdecl, dynlib: NAME,
importc: "lua_settable".}
proc setfield*(L: PState, idx: int, k: cstring){.cdecl, dynlib: NAME,
importc: "lua_setfield".}
proc rawset*(L: PState, idx: int){.cdecl, dynlib: NAME, importc: "lua_rawset".}
proc rawseti*(L: PState, idx, n: int){.cdecl, dynlib: NAME,
importc: "lua_rawseti".}
proc setmetatable*(L: PState, objindex: int): int{.cdecl, dynlib: NAME,
importc: "lua_setmetatable".}
proc setfenv*(L: PState, idx: int): int{.cdecl, dynlib: NAME,
importc: "lua_setfenv".}
proc call*(L: PState, nargs, nresults: int){.cdecl, dynlib: NAME,
importc: "lua_call".}
proc pcall*(L: PState, nargs, nresults, errf: int): int{.cdecl, dynlib: NAME,
importc: "lua_pcall".}
proc cpcall*(L: PState, func: CFunction, ud: Pointer): int{.cdecl, dynlib: NAME,
importc: "lua_cpcall".}
proc load*(L: PState, reader: Reader, dt: Pointer, chunkname: cstring): int{.
cdecl, dynlib: NAME, importc: "lua_load".}
proc dump*(L: PState, writer: Writer, data: Pointer): int{.cdecl, dynlib: NAME,
importc: "lua_dump".}
proc luayield*(L: PState, nresults: int): int{.cdecl, dynlib: NAME,
importc: "lua_yield".}
proc resume*(L: PState, narg: int): int{.cdecl, dynlib: NAME,
importc: "lua_resume".}
proc status*(L: PState): int{.cdecl, dynlib: NAME, importc: "lua_status".}
proc gc*(L: PState, what, data: int): int{.cdecl, dynlib: NAME,
importc: "lua_gc".}
proc error*(L: PState): int{.cdecl, dynlib: NAME, importc: "lua_error".}
proc next*(L: PState, idx: int): int{.cdecl, dynlib: NAME, importc: "lua_next".}
proc concat*(L: PState, n: int){.cdecl, dynlib: NAME, importc: "lua_concat".}
proc getallocf*(L: PState, ud: ptr Pointer): Alloc{.cdecl, dynlib: NAME,
importc: "lua_getallocf".}
proc setallocf*(L: PState, f: Alloc, ud: Pointer){.cdecl, dynlib: NAME,
importc: "lua_setallocf".}
#
#** Garbage-collection functions and options
#
const
GCSTOP* = 0
GCRESTART* = 1
GCCOLLECT* = 2
GCCOUNT* = 3
GCCOUNTB* = 4
GCSTEP* = 5
GCSETPAUSE* = 6
GCSETSTEPMUL* = 7
#
#** ===============================================================
#** some useful macros
#** ===============================================================
#
proc pop*(L: PState, n: int)
proc newtable*(L: Pstate)
proc register*(L: PState, n: cstring, f: CFunction)
proc pushcfunction*(L: PState, f: CFunction)
proc strlen*(L: Pstate, i: int): int
proc isfunction*(L: PState, n: int): bool
proc istable*(L: PState, n: int): bool
proc islightuserdata*(L: PState, n: int): bool
proc isnil*(L: PState, n: int): bool
proc isboolean*(L: PState, n: int): bool
proc isthread*(L: PState, n: int): bool
proc isnone*(L: PState, n: int): bool
proc isnoneornil*(L: PState, n: int): bool
proc pushliteral*(L: PState, s: cstring)
proc setglobal*(L: PState, s: cstring)
proc getglobal*(L: PState, s: cstring)
proc tostring*(L: PState, i: int): cstring
#
#** compatibility macros and functions
#
proc getregistry*(L: PState)
proc getgccount*(L: PState): int
type
Chunkreader* = Reader
Chunkwriter* = Writer
#
#** ======================================================================
#** Debug API
#** ======================================================================
#
const
HOOKCALL* = 0
HOOKRET* = 1
HOOKLINE* = 2
HOOKCOUNT* = 3
HOOKTAILRET* = 4
const
MASKCALL* = 1 shl Ord(HOOKCALL)
MASKRET* = 1 shl Ord(HOOKRET)
MASKLINE* = 1 shl Ord(HOOKLINE)
MASKCOUNT* = 1 shl Ord(HOOKCOUNT)
const
IDSIZE* = 60
type
TDebug*{.final.} = object # activation record
event*: int
name*: cstring # (n)
namewhat*: cstring # (n) `global', `local', `field', `method'
what*: cstring # (S) `Lua', `C', `main', `tail'
source*: cstring # (S)
currentline*: int # (l)
nups*: int # (u) number of upvalues
linedefined*: int # (S)
lastlinedefined*: int # (S)
short_src*: array[0..IDSIZE - 1, Char] # (S)
# private part
i_ci*: int # active function
PDebug* = ptr TDebug
Hook* = proc (L: PState, ar: PDebug){.cdecl.}
#
#** ======================================================================
#** Debug API
#** ======================================================================
#
proc getstack*(L: PState, level: int, ar: PDebug): int{.cdecl, dynlib: NAME,
importc: "lua_getstack".}
proc getinfo*(L: PState, what: cstring, ar: PDebug): int{.cdecl, dynlib: NAME,
importc: "lua_getinfo".}
proc getlocal*(L: PState, ar: PDebug, n: int): cstring{.cdecl, dynlib: NAME,
importc: "lua_getlocal".}
proc setlocal*(L: PState, ar: PDebug, n: int): cstring{.cdecl, dynlib: NAME,
importc: "lua_setlocal".}
proc getupvalue*(L: PState, funcindex: int, n: int): cstring{.cdecl,
dynlib: NAME, importc: "lua_getupvalue".}
proc setupvalue*(L: PState, funcindex: int, n: int): cstring{.cdecl,
dynlib: NAME, importc: "lua_setupvalue".}
proc sethook*(L: PState, func: Hook, mask: int, count: int): int{.cdecl,
dynlib: NAME, importc: "lua_sethook".}
proc gethook*(L: PState): Hook{.cdecl, dynlib: NAME, importc: "lua_gethook".}
proc gethookmask*(L: PState): int{.cdecl, dynlib: NAME,
importc: "lua_gethookmask".}
proc gethookcount*(L: PState): int{.cdecl, dynlib: NAME,
importc: "lua_gethookcount".}
# implementation
proc upvalueindex(I: int): int =
Result = GLOBALSINDEX - i
proc pop(L: PState, n: int) =
settop(L, - n - 1)
proc newtable(L: PState) =
createtable(L, 0, 0)
proc register(L: PState, n: cstring, f: CFunction) =
pushcfunction(L, f)
setglobal(L, n)
proc pushcfunction(L: PState, f: CFunction) =
pushcclosure(L, f, 0)
proc strlen(L: PState, i: int): int =
Result = objlen(L, i)
proc isfunction(L: PState, n: int): bool =
Result = luatype(L, n) == TFUNCTION
proc istable(L: PState, n: int): bool =
Result = luatype(L, n) == TTABLE
proc islightuserdata(L: PState, n: int): bool =
Result = luatype(L, n) == TLIGHTUSERDATA
proc isnil(L: PState, n: int): bool =
Result = luatype(L, n) == TNIL
proc isboolean(L: PState, n: int): bool =
Result = luatype(L, n) == TBOOLEAN
proc isthread(L: PState, n: int): bool =
Result = luatype(L, n) == TTHREAD
proc isnone(L: PState, n: int): bool =
Result = luatype(L, n) == TNONE
proc isnoneornil(L: PState, n: int): bool =
Result = luatype(L, n) <= 0
proc pushliteral(L: PState, s: cstring) =
pushlstring(L, s, len(s))
proc setglobal(L: PState, s: cstring) =
setfield(L, GLOBALSINDEX, s)
proc getglobal(L: PState, s: cstring) =
getfield(L, GLOBALSINDEX, s)
proc tostring(L: PState, i: int): cstring =
Result = tolstring(L, i, nil)
proc getregistry(L: PState) =
pushvalue(L, REGISTRYINDEX)
proc getgccount(L: PState): int =
Result = gc(L, GCCOUNT, 0)

66
lib/wrappers/lua/lualib.nim Executable file
View File

@@ -0,0 +1,66 @@
#*****************************************************************************
# * *
# * File: lualib.pas *
# * Authors: TeCGraf (C headers + actual Lua libraries) *
# * Lavergne Thomas (original translation to Pascal) *
# * Bram Kuijvenhoven (update to Lua 5.1.1 for FreePascal) *
# * Description: Standard Lua libraries *
# * *
# *****************************************************************************
#
#** $Id: lualib.h,v 1.28 2003/03/18 12:24:26 roberto Exp $
#** Lua standard libraries
#** See Copyright Notice in lua.h
#
#
#** Translated to pascal by Lavergne Thomas
#** Bug reports :
#** - thomas.lavergne@laposte.net
#** In french or in english
#
import
lua
const
COLIBNAME* = "coroutine"
TABLIBNAME* = "table"
IOLIBNAME* = "io"
OSLIBNAME* = "os"
STRLINAME* = "string"
MATHLIBNAME* = "math"
DBLIBNAME* = "debug"
LOADLIBNAME* = "package"
proc open_base*(L: PState): cint{.cdecl, dynlib: LIB_NAME,
importc: "luaopen_base".}
proc open_table*(L: PState): cint{.cdecl, dynlib: LIB_NAME,
importc: "luaopen_table".}
proc open_io*(L: PState): cint{.cdecl, dynlib: LIB_NAME, importc: "luaopen_io".}
proc open_string*(L: PState): cint{.cdecl, dynlib: LIB_NAME,
importc: "luaopen_string".}
proc open_math*(L: PState): cint{.cdecl, dynlib: LIB_NAME,
importc: "luaopen_math".}
proc open_debug*(L: PState): cint{.cdecl, dynlib: LIB_NAME,
importc: "luaopen_debug".}
proc open_package*(L: PState): cint{.cdecl, dynlib: LIB_NAME,
importc: "luaopen_package".}
proc openlibs*(L: PState){.cdecl, dynlib: LIB_NAME, importc: "luaL_openlibs".}
proc baselibopen*(L: PState): Bool =
Result = open_base(L) != 0'i32
proc tablibopen*(L: PState): Bool =
Result = open_table(L) != 0'i32
proc iolibopen*(L: PState): Bool =
Result = open_io(L) != 0'i32
proc strlibopen*(L: PState): Bool =
Result = open_string(L) != 0'i32
proc mathlibopen*(L: PState): Bool =
Result = open_math(L) != 0'i32
proc dblibopen*(L: PState): Bool =
Result = open_debug(L) != 0'i32

1536
lib/wrappers/opengl/gl.nim Executable file

File diff suppressed because it is too large Load Diff

4673
lib/wrappers/opengl/glext.nim Executable file

File diff suppressed because it is too large Load Diff

329
lib/wrappers/opengl/glu.nim Executable file
View File

@@ -0,0 +1,329 @@
#
#
# 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):
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
# implementation

432
lib/wrappers/opengl/glut.nim Executable file
View File

@@ -0,0 +1,432 @@
#
#
# 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
PInteger* = ptr int
PPChar* = ptr cstring
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: PInteger, argv: PPChar){.dynlib: dllname,
importc: "glutInit".}
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

153
lib/wrappers/opengl/glx.nim Executable file
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

368
lib/wrappers/opengl/wingl.nim Executable file
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