summary refs log tree commit diff stats
path: root/lib
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2012-10-09 17:11:33 +0200
committerAraq <rumpf_a@web.de>2012-10-09 17:11:33 +0200
commitcf06131decb2d46304874bd243c29267876e0076 (patch)
treeb00f51b14e0496b6a25ee2ea49e5e9e12d7efeb1 /lib
parent5a83bd8812eb10a9c7a9d18f060f8ad7cb902e90 (diff)
downloadNim-cf06131decb2d46304874bd243c29267876e0076.tar.gz
better extension loading for the OpenGL wrapper
Diffstat (limited to 'lib')
-rw-r--r--lib/wrappers/opengl/opengl.nim19
1 files changed, 15 insertions, 4 deletions
diff --git a/lib/wrappers/opengl/opengl.nim b/lib/wrappers/opengl/opengl.nim
index dacdbd02c..fab8183f5 100644
--- a/lib/wrappers/opengl/opengl.nim
+++ b/lib/wrappers/opengl/opengl.nim
@@ -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()

 

 #==============================================================================

 #