better extension loading for the OpenGL wrapper

This commit is contained in:
Araq
2012-10-09 17:11:33 +02:00
parent 5a83bd8812
commit cf06131dec
6 changed files with 40 additions and 10 deletions

View File

@@ -10,7 +10,10 @@
## This module is a wrapper around `opengl`:idx:. If you define the symbol
## ``useGlew`` this wrapper does not use Nimrod's ``dynlib`` mechanism,
## 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):
import X, XLib, XUtil
@@ -75,12 +78,20 @@ else:
if gluHandle == nil: quit("could not load: " & gludll)
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:
{.pragma: ogl, dynlib: glGetProc(oglHandle, "").}
{.pragma: oglx, dynlib: glGetProc(oglHandle, "").}
{.pragma: oglx, dynlib: glGetProc(oglHandle, "0").}
{.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()
#==============================================================================
#