forked from philogb/v8-gl
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathnode-gl.cpp
executable file
·43 lines (35 loc) · 1.16 KB
/
node-gl.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/*
* node-gl.cpp
*
*/
#include "node-gl.h"
void init(Handle<Object> target) {
Persistent<Context> currentContext = Persistent<Context>::New(Context::GetCurrent());
#ifdef BUILD_GLUT_BINDINGS
GlutFactory::glut_persistent_context = currentContext;
#endif
#ifdef BUILD_GLES_BINDINGS
GlesFactory::gles_persistent_context = currentContext;
#endif
//Append *this* as Gl static variable so we can do dot-this-dot-that stuff
#ifdef BUILD_GL_BINDINGS
GlFactory::self_ = Persistent<Object>::New(GlFactory::createGl()->NewInstance());
#endif
#ifdef BUILD_GLES_BINDINGS
GlesFactory::self_ = Persistent<Object>::New(GlesFactory::createGles()->NewInstance());
#endif
//Set global objects and functions.
#ifdef BUILD_GL_BINDINGS
target->Set(String::New("Gl"), GlFactory::self_);
#endif
#ifdef BUILD_GLES_BINDINGS
target->Set(String::New("Gles"), GlesFactory::self_);
#endif
#ifdef BUILD_GLU_BINDINGS
target->Set(String::New("Glu"), Persistent<Object>::New(createGlu()->NewInstance()));
#endif
#ifdef BUILD_GLUT_BINDINGS
target->Set(String::New("Glut"), Persistent<Object>::New(GlutFactory::createGlut()->NewInstance()));
#endif
}
NODE_MODULE(nodegl, init);