Permalink
Browse files

Support building with glew.

  • Loading branch information...
1 parent d36e49e commit b84edd202cbc73ccedbcd1e06bdb17801d4c50a4 @deanm deanm committed Jul 20, 2009
View
@@ -1,7 +1,18 @@
+
#include "glbind.h"
-Persistent<Object> GlFactory::self_;
+#if defined(V8_GL_USE_GLEW)
+#include "GL/glew.h"
+#elif defined(__APPLE__)
+#include <OpenGL/OpenGL.h>
+#else
+#define GL_GLEXT_PROTOTYPES
+#include <GL/gl.h>
+#endif
+
+using namespace v8;
+Persistent<Object> GlFactory::self_;
Handle<Value> GLglAccumCallback(const Arguments& args) {
@@ -8988,16 +8999,16 @@ Handle<Value> GLglPointParameterfvCallback(const Arguments& args) {
Handle<Array> arrHandle1 = Handle<Array>::Cast(args[1]);
- GLfloat* arg1 = new GLfloat[arrHandle1->Length()];
+ GLfloat* arg1 = new GLfloat[arrHandle1->Length()];
for (unsigned j = 0; j < arrHandle1->Length(); j++) {
Handle<Value> arg(arrHandle1->Get(Integer::New(j)));
- GLfloat aux = ( GLfloat)arg->NumberValue();
+ GLfloat aux = (GLfloat)arg->NumberValue();
arg1[j] = aux;
}
//make call
- glPointParameterfv((GLenum) arg0, (const GLfloat*) arg1);
+ glPointParameterfv((GLenum) arg0, (GLfloat*) arg1);
Handle<Object> res(GlFactory::self_);
return res;
}
@@ -9033,16 +9044,16 @@ Handle<Value> GLglPointParameterivCallback(const Arguments& args) {
Handle<Array> arrHandle1 = Handle<Array>::Cast(args[1]);
- GLint* arg1 = new GLint[arrHandle1->Length()];
+ GLint* arg1 = new GLint[arrHandle1->Length()];
for (unsigned j = 0; j < arrHandle1->Length(); j++) {
Handle<Value> arg(arrHandle1->Get(Integer::New(j)));
- GLint aux = ( GLint)arg->IntegerValue();
+ GLint aux = (GLint)arg->IntegerValue();
arg1[j] = aux;
}
//make call
- glPointParameteriv((GLenum) arg0, (const GLint*) arg1);
+ glPointParameteriv((GLenum) arg0, (GLint*) arg1);
Handle<Object> res(GlFactory::self_);
return res;
}
View
@@ -8,23 +8,13 @@
#ifndef GLBIND_H_
#define GLBIND_H_
-
-#include <v8-debug.h>
-
-#ifdef __APPLE__
-#include <OpenGL/OpenGL.h>
-#else
-#define GL_GLEXT_PROTOTYPES
-#include <GL/gl.h>
-#endif
-
-using namespace std;
-using namespace v8;
+#include <v8.h>
class GlFactory {
public:
- static Handle<ObjectTemplate> createGl(void);
+ static v8::Handle<v8::ObjectTemplate> createGl(void);
- static Persistent<Object> self_;
+ static v8::Persistent<v8::Object> self_;
};
+
#endif /* GLBIND_H_ */
@@ -8940,7 +8940,7 @@
"name": "glPointParameterfv",
"parameters": [
"GLenum",
- "const GLfloat*"
+ "GLfloat*"
]
},
{
@@ -8958,7 +8958,7 @@
"name": "glPointParameteriv",
"parameters": [
"GLenum",
- "const GLint*"
+ "GLint*"
]
},
{
View
@@ -38,8 +38,22 @@ def main():
pass
with open(OUT_FILE, 'w') as fout:
- fout.write('#include "glbind.h"\n\nPersistent<Object> GlFactory::self_;\n\n' \
- + '\n'.join(text_out) + '\n' + generate_main_function(constants, functions))
+ fout.write("""
+#include "glbind.h"
+
+#if defined(V8_GL_USE_GLEW)
+#include "GL/glew.h"
+#elif defined(__APPLE__)
+#include <OpenGL/OpenGL.h>
+#else
+#define GL_GLEXT_PROTOTYPES
+#include <GL/gl.h>
+#endif
+
+using namespace v8;
+
+Persistent<Object> GlFactory::self_;
+""" + '\n'.join(text_out) + '\n' + generate_main_function(constants, functions))
def generate_main_function(constants, functions):
@@ -1,8 +1,24 @@
+
#include "glesbind.h"
+#if defined(V8_GL_USE_GLEW)
+#include "GL/glew.h"
+#include "glew_desktop_shim.h"
+#elif defined(__APPLE__)
+#include <OpenGL/OpenGL.h>
+#else
+#define GL_GLEXT_PROTOTYPES
+#include <GL/gl.h>
+// If we're running on desktop OpenGL, some ES 2.0 constants don't exist, or
+// are under a name with EXT in them, etc.
+#include "gles_desktop_shim.h"
+#endif
+
+using namespace v8;
+
+
Persistent<Object> GlesFactory::self_;
Persistent<Context> GlesFactory::gles_persistent_context;
-
// glGenBuffers uses an output parameter to return an array of ints.
Handle<Value> GLESglGenBuffersCallback(const Arguments& args) {
if (args.Length() != 1)
@@ -6,31 +6,14 @@
#ifndef GLESBIND_H_
#define GLESBIND_H_
-#include <v8-debug.h>
-
-#ifdef __APPLE__
-#include <OpenGL/OpenGL.h>
-#else
-#define GL_GLEXT_PROTOTYPES
-#include <GL/gl.h>
-#endif
-
-// If we're running on desktop OpenGL, some ES 2.0 constants don't exist, or
-// are under a name with EXT in them, etc.
-#ifndef GL_ES_VERSION_2_0
-//#include "missing.h"
-#include "gles_desktop_shim.h"
-#endif
-
-using namespace std;
-using namespace v8;
+#include <v8.h>
class GlesFactory {
public:
- static Handle<ObjectTemplate> createGles(void);
+ static v8::Handle<v8::ObjectTemplate> createGles(void);
- static Persistent<Object> self_;
- static Persistent<Context> gles_persistent_context;
+ static v8::Persistent<v8::Object> self_;
+ static v8::Persistent<v8::Context> gles_persistent_context;
};
#endif /* GLESBIND_H_ */
@@ -124,9 +124,28 @@ def main():
functions.extend(accessor_extras)
with open(OUT_FILE, 'w') as fout:
- fout.write('#include "glesbind.h"\n\nPersistent<Object> GlesFactory::self_;\n' \
- + 'Persistent<Context> GlesFactory::gles_persistent_context;\n\n' \
- + custom_code + '\n'.join(text_out) + '\n' + generate_main_function(constants, functions))
+ fout.write("""
+#include "glesbind.h"
+
+#if defined(V8_GL_USE_GLEW)
+#include "GL/glew.h"
+#include "glew_desktop_shim.h"
+#elif defined(__APPLE__)
+#include <OpenGL/OpenGL.h>
+#else
+#define GL_GLEXT_PROTOTYPES
+#include <GL/gl.h>
+// If we're running on desktop OpenGL, some ES 2.0 constants don't exist, or
+// are under a name with EXT in them, etc.
+#include "gles_desktop_shim.h"
+#endif
+
+using namespace v8;
+
+
+Persistent<Object> GlesFactory::self_;
+Persistent<Context> GlesFactory::gles_persistent_context;
+""" + custom_code + '\n'.join(text_out) + '\n' + generate_main_function(constants, functions))
def generate_main_function(constants, functions):
@@ -0,0 +1,52 @@
+#define GL_ES_VERSION_2_0 1
+#define GL_FIXED 0x140C
+#define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB
+#define GL_MAX_VARYING_VECTORS 0x8DFC
+#define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD
+#define GL_SHADER_COMPILER 0x8DFA
+#define GL_SHADER_BINARY_FORMATS 0x8DF8
+#define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9
+#define GL_LOW_FLOAT 0x8DF0
+#define GL_MEDIUM_FLOAT 0x8DF1
+#define GL_HIGH_FLOAT 0x8DF2
+#define GL_LOW_INT 0x8DF3
+#define GL_MEDIUM_INT 0x8DF4
+#define GL_HIGH_INT 0x8DF5
+#define GL_FRAMEBUFFER 0x8D40
+#define GL_RENDERBUFFER 0x8D41
+#define GL_RGB565 0x8D62
+#define GL_STENCIL_INDEX8 0x8D48
+#define GL_RENDERBUFFER_WIDTH 0x8D42
+#define GL_RENDERBUFFER_HEIGHT 0x8D43
+#define GL_RENDERBUFFER_INTERNAL_FORMAT 0x8D44
+#define GL_RENDERBUFFER_RED_SIZE 0x8D50
+#define GL_RENDERBUFFER_GREEN_SIZE 0x8D51
+#define GL_RENDERBUFFER_BLUE_SIZE 0x8D52
+#define GL_RENDERBUFFER_ALPHA_SIZE 0x8D53
+#define GL_RENDERBUFFER_DEPTH_SIZE 0x8D54
+#define GL_RENDERBUFFER_STENCIL_SIZE 0x8D55
+#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE 0x8CD0
+#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 0x8CD1
+#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL 0x8CD2
+#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE 0x8CD3
+#define GL_COLOR_ATTACHMENT0 0x8CE0
+#define GL_DEPTH_ATTACHMENT 0x8D00
+#define GL_STENCIL_ATTACHMENT 0x8D20
+#define GL_FRAMEBUFFER_COMPLETE 0x8CD5
+#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6
+#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7
+#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS 0x8CD9
+#define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD
+#define GL_FRAMEBUFFER_BINDING 0x8CA6
+#define GL_RENDERBUFFER_BINDING 0x8CA7
+#define GL_MAX_RENDERBUFFER_SIZE 0x84E8
+
+// Some of the OpenGL 2.0 spec is defined as doubles, so ES 2.0 adds float
+// versions. Implement some simple shims here.
+#define glClearDepthf(depth) glClearDepth(depth)
+#define glDepthRangef(zNear, zFar) glDepthRange((zNear), (zFar))
+
+// These don't exist in desktop OpenGL, just stub them out.
+#define glReleaseShaderCompiler ((void) 0)
+#define glGetShaderPrecisionFormat(a, b, c, d) ((void) 0)
+

0 comments on commit b84edd2

Please sign in to comment.