better extension loading for the OpenGL wrapper
This commit is contained in:
parent
5a83bd8812
commit
cf06131dec
6 changed files with 40 additions and 10 deletions
|
|
@ -552,10 +552,19 @@ proc SymInDynamicLib(m: BModule, sym: PSym) =
|
||||||
initLocExpr(m.initProc, n[i], a)
|
initLocExpr(m.initProc, n[i], a)
|
||||||
params.app(rdLoc(a))
|
params.app(rdLoc(a))
|
||||||
params.app(", ")
|
params.app(", ")
|
||||||
appcg(m, m.initProc.s(cpsStmts),
|
let load = ropef("\t$1 = ($2) ($3$4));$n",
|
||||||
"\t$1 = ($2) ($3$4));$n",
|
|
||||||
[tmp, getTypeDesc(m, sym.typ),
|
[tmp, getTypeDesc(m, sym.typ),
|
||||||
params, cstringLit(m, m.s[cfsDynLibInit], ropeToStr(extname))])
|
params, cstringLit(m, m.s[cfsDynLibInit], ropeToStr(extname))])
|
||||||
|
var last = lastSon(n)
|
||||||
|
if last.kind == nkHiddenStdConv: last = last.sons[1]
|
||||||
|
InternalAssert(last.kind == nkStrLit)
|
||||||
|
let idx = last.strVal
|
||||||
|
if idx.len == 0:
|
||||||
|
app(m.initProc.s(cpsStmts), load)
|
||||||
|
elif idx.len == 1 and idx[0] in {'0'..'9'}:
|
||||||
|
app(m.extensionLoaders[idx[0]], load)
|
||||||
|
else:
|
||||||
|
InternalError(sym.info, "wrong index: " & idx)
|
||||||
else:
|
else:
|
||||||
appcg(m, m.s[cfsDynLibInit],
|
appcg(m, m.s[cfsDynLibInit],
|
||||||
"\t$1 = ($2) #nimGetProcAddr($3, $4);$n",
|
"\t$1 = ($2) #nimGetProcAddr($3, $4);$n",
|
||||||
|
|
@ -973,6 +982,12 @@ proc genInitCode(m: BModule) =
|
||||||
# not support. So we add it to another special section: ``cfsInitProc``
|
# not support. So we add it to another special section: ``cfsInitProc``
|
||||||
app(m.s[cfsInitProc], prc)
|
app(m.s[cfsInitProc], prc)
|
||||||
|
|
||||||
|
for i, el in pairs(m.extensionLoaders):
|
||||||
|
if el != nil:
|
||||||
|
let ex = ropef("N_NIMCALL(void, nimLoadProcs$1)(void) {$2}$N$N",
|
||||||
|
(i.ord - '0'.ord).toRope, el)
|
||||||
|
app(m.s[cfsInitProc], ex)
|
||||||
|
|
||||||
proc genModule(m: BModule, cfilenoext: string): PRope =
|
proc genModule(m: BModule, cfilenoext: string): PRope =
|
||||||
result = getFileHeader(cfilenoext)
|
result = getFileHeader(cfilenoext)
|
||||||
result.app(genMergeInfo(m))
|
result.app(genMergeInfo(m))
|
||||||
|
|
|
||||||
|
|
@ -111,6 +111,8 @@ type
|
||||||
typeNodes*, nimTypes*: int # used for type info generation
|
typeNodes*, nimTypes*: int # used for type info generation
|
||||||
typeNodesName*, nimTypesName*: PRope # used for type info generation
|
typeNodesName*, nimTypesName*: PRope # used for type info generation
|
||||||
labels*: natural # for generating unique module-scope names
|
labels*: natural # for generating unique module-scope names
|
||||||
|
extensionLoaders*: array['0'..'9', PRope] # special procs for the
|
||||||
|
# OpenGL wrapper
|
||||||
|
|
||||||
var
|
var
|
||||||
mainModProcs*, mainModInit*, mainDatInit*: PRope # parts of the main module
|
mainModProcs*, mainModInit*, mainDatInit*: PRope # parts of the main module
|
||||||
|
|
|
||||||
|
|
@ -300,7 +300,7 @@ proc MainCommand =
|
||||||
#registerPass(rodwrite.rodwritePass())
|
#registerPass(rodwrite.rodwritePass())
|
||||||
discard CompileModule(options.libpath / "system", {sfSystemModule})
|
discard CompileModule(options.libpath / "system", {sfSystemModule})
|
||||||
service.serve(proc () =
|
service.serve(proc () =
|
||||||
let projectFile = gProjectFull
|
let projectFile = mainCommandArg()
|
||||||
discard CompileModule(projectFile, {sfMainModule})
|
discard CompileModule(projectFile, {sfMainModule})
|
||||||
)
|
)
|
||||||
else: rawMessage(errInvalidCommandX, command)
|
else: rawMessage(errInvalidCommandX, command)
|
||||||
|
|
|
||||||
|
|
@ -62,6 +62,7 @@ proc serve*(action: proc (){.nimcall.}) =
|
||||||
server.bindAddr(port, getConfigVar("server.address"))
|
server.bindAddr(port, getConfigVar("server.address"))
|
||||||
var inp = "".TaintedString
|
var inp = "".TaintedString
|
||||||
server.listen()
|
server.listen()
|
||||||
|
new(stdoutSocket)
|
||||||
while true:
|
while true:
|
||||||
accept(server, stdoutSocket)
|
accept(server, stdoutSocket)
|
||||||
discard stdoutSocket.recvLine(inp)
|
discard stdoutSocket.recvLine(inp)
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,9 @@
|
||||||
## ``useGlew`` this wrapper does not use Nimrod's ``dynlib`` mechanism,
|
## ``useGlew`` this wrapper does not use Nimrod's ``dynlib`` mechanism,
|
||||||
## but `glew`:idx: instead. However, this shouldn't be necessary anymore; even
|
## but `glew`:idx: instead. However, this shouldn't be necessary anymore; even
|
||||||
## extension loading for the different operating systems is handled here.
|
## extension loading for the different operating systems is handled here.
|
||||||
|
##
|
||||||
|
## You need to call ``loadExtensions`` after a rendering context has been
|
||||||
|
## created to load any extension proc that your code uses.
|
||||||
|
|
||||||
when defined(linux):
|
when defined(linux):
|
||||||
import X, XLib, XUtil
|
import X, XLib, XUtil
|
||||||
|
|
@ -75,13 +78,21 @@ else:
|
||||||
if gluHandle == nil: quit("could not load: " & gludll)
|
if gluHandle == nil: quit("could not load: " & gludll)
|
||||||
result = glGetProc(gluHandle, procname)
|
result = glGetProc(gluHandle, procname)
|
||||||
|
|
||||||
# undocumented 'dynlib' feature: the empty string literal is replaced by
|
# undocumented 'dynlib' feature: the string literal is replaced by
|
||||||
# the imported proc name:
|
# the imported proc name:
|
||||||
{.pragma: ogl, dynlib: glGetProc(oglHandle, "").}
|
{.pragma: ogl, dynlib: glGetProc(oglHandle, "").}
|
||||||
{.pragma: oglx, dynlib: glGetProc(oglHandle, "").}
|
{.pragma: oglx, dynlib: glGetProc(oglHandle, "0").}
|
||||||
{.pragma: wgl, dynlib: glGetProc(oglHandle, "").}
|
{.pragma: wgl, dynlib: glGetProc(oglHandle, "").}
|
||||||
{.pragma: glu, dynlib: gluGetProc("").}
|
{.pragma: glu, dynlib: gluGetProc("").}
|
||||||
|
|
||||||
|
proc nimLoadProcs0() {.importc.}
|
||||||
|
|
||||||
|
template loadExtensions*() =
|
||||||
|
## call this after your rendering context has been setup if you use
|
||||||
|
## extensions.
|
||||||
|
bind nimLoadProcs0
|
||||||
|
nimLoadProcs0()
|
||||||
|
|
||||||
#==============================================================================
|
#==============================================================================
|
||||||
#
|
#
|
||||||
# OpenGL 4.2 - Headertranslation
|
# OpenGL 4.2 - Headertranslation
|
||||||
|
|
|
||||||
7
todo.txt
7
todo.txt
|
|
@ -1,7 +1,10 @@
|
||||||
version 0.9.2
|
version 0.9.2
|
||||||
=============
|
=============
|
||||||
|
|
||||||
|
- memory profiler
|
||||||
- implement the compiler as a service
|
- implement the compiler as a service
|
||||||
|
- implement for loop transformation for first class iterators
|
||||||
|
- ``=`` should be overloadable; requires specialization for ``=``
|
||||||
- fix broken expr/stmt handling for proc bodies
|
- fix broken expr/stmt handling for proc bodies
|
||||||
- make 'bind' default for templates and introduce 'mixin'
|
- make 'bind' default for templates and introduce 'mixin'
|
||||||
- implicit deref for parameter matching; overloading based on 'var T'
|
- implicit deref for parameter matching; overloading based on 'var T'
|
||||||
|
|
@ -36,7 +39,6 @@ version 0.9.XX
|
||||||
|
|
||||||
- implement the "snoopResult" pragma
|
- implement the "snoopResult" pragma
|
||||||
- implement "closure tuple consists of a single 'ref'" optimization
|
- implement "closure tuple consists of a single 'ref'" optimization
|
||||||
- implement for loop transformation for first class iterators
|
|
||||||
- JS gen:
|
- JS gen:
|
||||||
- fix exception handling
|
- fix exception handling
|
||||||
- object branch transitions can't work with the current 'reset'; add a 'reset'
|
- object branch transitions can't work with the current 'reset'; add a 'reset'
|
||||||
|
|
@ -52,11 +54,10 @@ version 0.9.XX
|
||||||
is that often the scope of ``try`` is wrong and apart from that ``try`` is
|
is that often the scope of ``try`` is wrong and apart from that ``try`` is
|
||||||
a full blown statement; a ``try`` expression might be a good idea to make
|
a full blown statement; a ``try`` expression might be a good idea to make
|
||||||
error handling more light-weight
|
error handling more light-weight
|
||||||
- ``=`` should be overloadable; requires specialization for ``=``
|
|
||||||
- fix destructors; don't work yet when used as expression
|
- fix destructors; don't work yet when used as expression
|
||||||
- make use of ``tyIter`` to fix the implicit items/pairs issue
|
- make use of ``tyIter`` to fix the implicit items/pairs issue
|
||||||
- better support for macros that rewrite procs
|
- better support for macros that rewrite procs
|
||||||
- macros need access to types and symbols
|
- macros need access to types and symbols (partially implemented)
|
||||||
- document nimdoc properly finally
|
- document nimdoc properly finally
|
||||||
- make 'clamp' a magic for the range stuff
|
- make 'clamp' a magic for the range stuff
|
||||||
- implement a warning message for shadowed 'result' variable
|
- implement a warning message for shadowed 'result' variable
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue