Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
executable file 4813 lines (3479 sloc) 150 KB
#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>
#include "gles_desktop_shim.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
#include <fstream>
#include <string>
#include <string.h>
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 less that nbr of formal parameters then throw exception
if (args.Length() != 1 || !args[0]->IsNumber())
return ThrowException(String::New("Bad arguments"));
GLsizei num_buffers = args[0]->Int32Value();
GLuint* buffers = new GLuint[num_buffers];
glGenBuffers(num_buffers, buffers);
// TODO(deanm): There should be a way to initialize the array faster.
Local<Array> res = Array::New(num_buffers);
for (int i = 0; i < num_buffers; ++i) {
res->Set(Integer::New(i), Integer::New(buffers[i]));
}
delete[] buffers;
return res;
}
Handle<Value> GLESglGenRenderbuffersCallback(const Arguments& args) {
//if less that nbr of formal parameters then throw exception
if (args.Length() != 1 || !args[0]->IsNumber())
return ThrowException(String::New("Bad arguments"));
GLsizei num_buffers = args[0]->Int32Value();
GLuint* buffers = new GLuint[num_buffers];
glGenRenderbuffers(num_buffers, buffers);
// TODO(deanm): There should be a way to initialize the array faster.
Local<Array> res = Array::New(num_buffers);
for (int i = 0; i < num_buffers; ++i) {
res->Set(Integer::New(i), Integer::New(buffers[i]));
}
delete[] buffers;
return res;
}
Handle<Value> GLESglGenFramebuffersCallback(const Arguments& args) {
//if less that nbr of formal parameters then throw exception
if (args.Length() != 1 || !args[0]->IsNumber())
return ThrowException(String::New("Bad arguments"));
GLsizei num_buffers = args[0]->Int32Value();
GLuint* buffers = new GLuint[num_buffers];
glGenFramebuffers(num_buffers, buffers);
// TODO(deanm): There should be a way to initialize the array faster.
Local<Array> res = Array::New(num_buffers);
for (int i = 0; i < num_buffers; ++i) {
res->Set(Integer::New(i), Integer::New(buffers[i]));
}
delete[] buffers;
return res;
}
Handle<Value> GLESglGenTexturesCallback(const Arguments& args) {
//if less that nbr of formal parameters then throw exception
if (args.Length() != 1 || !args[0]->IsNumber())
return ThrowException(String::New("Bad arguments"));
GLsizei num_textures = args[0]->Int32Value();
GLuint* textures = new GLuint[num_textures];
glGenTextures(num_textures, textures);
Local<Array> res = Array::New(num_textures);
for (int i = 0; i < num_textures; ++i) {
res->Set(Integer::New(i), Integer::New(textures[i]));
}
delete[] textures;
return res;
}
// glGetShaderiv uses an output parameter to return an int.
Handle<Value> GLESglGetShaderivCallback(const Arguments& args) {
if (args.Length() != 2 || !args[0]->IsUint32() || !args[1]->IsNumber())
return ThrowException(String::New("Bad arguments"));
unsigned int arg0 = args[0]->Uint32Value();
int arg1 = args[1]->IntegerValue();
int out;
glGetShaderiv((GLuint) arg0, (GLenum) arg1, (GLint*)&out);
v8::Local<v8::Value> val = v8::Integer::New(out);
return val;
}
// We expect to be called with a shader id and a single string.
Handle<Value> GLESglShaderSourceCallback(const Arguments& args) {
if (args.Length() != 2 || !args[0]->IsUint32())
return ThrowException(String::New("Bad arguments"));
GLuint shader_id = args[0]->Uint32Value();
// GLSL source is defined as an ASCII subset.
v8::String::AsciiValue code_ascii(args[1]);
if (!*code_ascii)
return v8::Undefined();
const char* code_str = *code_ascii;
GLsizei code_len = code_ascii.length();
glShaderSource(shader_id, 1, &code_str, &code_len);
Handle<Object> res(GlesFactory::self_);
return res;
}
Handle<Value> GLESglVertexAttribPointerCallback(const Arguments& args) {
if (args.Length() < 6 || !args[0]->IsUint32() || !args[1]->IsUint32() ||
!args[2]->IsUint32() || !(args[3]->IsUint32() || args[3]->IsBoolean()) ||
!args[4]->IsNumber() || (args.Length() > 6 && !args[6]->IsUint32()))
return ThrowException(String::New("Bad arguments"));
unsigned int index = args[0]->Uint32Value();
unsigned int size = args[1]->Uint32Value();
unsigned int type = args[2]->Uint32Value();
bool normalized = args[3]->BooleanValue();
int stride = args[4]->IntegerValue();
unsigned int offset = 0;
if (args.Length() > 6)
offset = args[6]->Uint32Value();
void* ans;
if(args[5]->IsArray()) {
Handle<Array> data = Handle<Array>::Cast(args[5]);
//I guess most of these types could be thrown away
switch(type) {
// case GL_BYTE:
// GLbyte* arg1 = new GLbyte[data->Length()];
// for (unsigned j = 0; j < data->Length(); j++) {
// Handle<Value> arg(data->Get(Integer::New(j)));
// arg1[j] = (GLbyte)arg->IntegerValue();
// }
// ans = (void *)arg1;
// break;
//
// case GL_UNSIGNED_BYTE:
// GLubyte* arg1 = new GLubyte[data->Length()];
// for (unsigned j = 0; j < data->Length(); j++) {
// Handle<Value> arg(data->Get(Integer::New(j)));
// arg1[j] = (GLubyte)arg->Uint32Value();
// }
// ans = (void *)arg1;
// break;
case GL_SHORT:
{
GLshort* arg1 = new GLshort[data->Length()];
for (unsigned j = 0; j < data->Length(); j++) {
Handle<Value> arg(data->Get(Integer::New(j)));
arg1[j] = (GLshort)arg->IntegerValue();
}
ans = (void *)arg1;
}
break;
case GL_UNSIGNED_SHORT:
{
GLushort* arg1 = new GLushort[data->Length()];
for (unsigned j = 0; j < data->Length(); j++) {
Handle<Value> arg(data->Get(Integer::New(j)));
arg1[j] = (GLushort)arg->Uint32Value();
}
ans = (void *)arg1;
}
break;
case GL_FLOAT:
{
GLfloat* arg1 = new GLfloat[data->Length()];
for (unsigned j = 0; j < data->Length(); j++) {
Handle<Value> arg(data->Get(Integer::New(j)));
arg1[j] = (GLfloat)arg->NumberValue();
}
ans = (void *)arg1;
}
break;
// case GL_FIXED:
// {
// GLfixed* arg1 = new GLfixed[data->Length()];
// for (unsigned j = 0; j < data->Length(); j++) {
// Handle<Value> arg(data->Get(Integer::New(j)));
// arg1[j] = (GLfixed)arg->IntegerValue();
// }
// ans = (void *)arg1;
// }
// break;
default:
return ThrowException(String::New("Unsupported array type"));
}
} else {
ans = (void *)args[5]->IntegerValue();
}
glVertexAttribPointer((GLuint)index,
(GLint)size,
(GLenum)type,
(normalized?GL_TRUE:GL_FALSE),
(GLsizei)stride,
((const void*)ans)+offset);
//should I delete[] ans?
Handle<Object> res(GlesFactory::self_);
return res;
}
Handle<Value> GLESglDrawElementsCallback(const Arguments& args) {
if (args.Length() != 4 || !args[0]->IsUint32() || !args[1]->IsNumber() ||
!args[2]->IsUint32())
return ThrowException(String::New("Bad arguments"));
unsigned int mode = args[0]->Uint32Value();
int count = args[1]->IntegerValue();
unsigned int type = args[2]->Uint32Value();
void* ans;
if(args[3]->IsArray()) {
Handle<Array> data = Handle<Array>::Cast(args[3]);
switch(type) {
case GL_UNSIGNED_SHORT:
{
GLushort* arg1 = new GLushort[data->Length()];
for (unsigned j = 0; j < data->Length(); j++) {
Handle<Value> arg(data->Get(Integer::New(j)));
arg1[j] = (GLushort)arg->Uint32Value();
}
ans = (void *)arg1;
}
break;
default:
return ThrowException(String::New("Unsupported array type"));
}
} else {
ans = (void *)args[3]->IntegerValue();
}
glDrawElements((GLenum)mode,
(GLsizei)count,
(GLenum)type,
(const GLvoid*)ans);
//should I delete[] ans?
Handle<Object> res(GlesFactory::self_);
return res;
}
static int _ExternalArrayTypeToElementSize(ExternalArrayType type) {
switch (type) {
case kExternalByteArray: return sizeof(int8_t);
case kExternalUnsignedByteArray: return sizeof(uint8_t);
case kExternalShortArray: return sizeof(int16_t);
case kExternalUnsignedShortArray: return sizeof(uint16_t);
case kExternalIntArray: return sizeof(int32_t);
case kExternalUnsignedIntArray: return sizeof(uint32_t);
case kExternalFloatArray: return sizeof(float);
case kExternalDoubleArray: return sizeof(double);
case kExternalPixelArray: return sizeof(uint8_t);
default: return 0;
}
}
//Accepts GL_UNSIGNED_SHORT and GL_FLOAT as types
//TODO(nico): deal with interleaved data
Handle<Value> GLESglBufferDataCallback(const Arguments& args) {
if (args.Length() != 4 || !args[0]->IsUint32() ||
!args[1]->IsObject() || !args[2]->IsUint32() ||
!args[3]->IsUint32())
return ThrowException(String::New("Bad arguments"));
unsigned int target = args[0]->Uint32Value();
unsigned int type = args[2]->Uint32Value();
unsigned int usage = args[3]->Uint32Value();
Handle<Object> source = Handle<Object>::Cast(args[1]);
if (source->HasIndexedPropertiesInExternalArrayData()) {
const void *data = source->GetIndexedPropertiesExternalArrayData();
int len = source->GetIndexedPropertiesExternalArrayDataLength();
int element_size= _ExternalArrayTypeToElementSize
(source->GetIndexedPropertiesExternalArrayDataType());
if (element_size==0)
return ThrowException(String::New("unknown array type"));
glBufferData((GLenum)target, (GLsizeiptr) (len * element_size),
data, (GLenum)usage);
Handle<Object> res(GlesFactory::self_);
return res;
}
if (!source->IsArray())
return ThrowException(String::New("Second argument not an array"));
Handle<Array> data = Handle<Array>::Cast(source);
unsigned int len = data->Length();
if (type == GL_FLOAT) {
GLfloat* arg1 = new GLfloat[len];
for (unsigned j = 0; j < len; j++) {
Handle<Value> arg(data->Get(Integer::New(j)));
arg1[j] = (GLfloat)arg->NumberValue();
}
glBufferData((GLenum)target,
(GLsizeiptr)(len * sizeof(*arg1)),
(const void*)arg1,
(GLenum)usage);
delete[] arg1;
} else if (type == GL_UNSIGNED_SHORT) {
GLushort* arg1 = new GLushort[len];
for (unsigned j = 0; j < len; j++) {
Handle<Value> arg(data->Get(Integer::New(j)));
arg1[j] = (GLushort)arg->Uint32Value();
}
glBufferData((GLenum)target,
(GLsizeiptr)(len * sizeof(*arg1)),
(const void*)arg1,
(GLenum)usage);
delete[] arg1;
} else {
return ThrowException(String::New("Unsupported type"));
}
Handle<Object> res(GlesFactory::self_);
return res;
}
//Accepts GL_UNSIGNED_SHORT and GL_FLOAT as types
//TODO(nico): deal with interleaved data
Handle<Value> GLESglBufferSubDataCallback(const Arguments& args) {
if (args.Length() != 4 || !args[0]->IsUint32() ||
!args[1]->IsUint32() || !args[2]->IsObject() ||
!args[3]->IsUint32())
return ThrowException(String::New("Bad arguments"));
unsigned int target = args[0]->Uint32Value();
unsigned int offset = args[1]->Uint32Value();
unsigned int type = args[3]->Uint32Value();
void* ans;
if(args[2]->IsArray()) {
Handle<Array> data = Handle<Array>::Cast(args[2]);
unsigned int len = data->Length();
switch(type) {
case GL_FLOAT:
{
GLfloat* arg1 = new GLfloat[len];
for (unsigned j = 0; j < data->Length(); j++) {
Handle<Value> arg(data->Get(Integer::New(j)));
arg1[j] = (GLfloat)arg->NumberValue();
}
ans = (void *)arg1;
}
break;
case GL_UNSIGNED_SHORT:
{
GLushort* arg1 = new GLushort[len];
for (unsigned j = 0; j < data->Length(); j++) {
Handle<Value> arg(data->Get(Integer::New(j)));
arg1[j] = (GLushort)arg->Uint32Value();
}
ans = (void *)arg1;
}
break;
default: return v8::Undefined();
}
glBufferSubData((GLenum)target,
(GLintptr)offset,
(GLsizeiptr)len,
(const void*)ans);
//should I delete[] ans?
}
Handle<Object> res(GlesFactory::self_);
return res;
}
Handle<Value> GLESglReadPixelsCallback(const Arguments& args) {
if (args.Length() != 6 ||
!args[0]->IsNumber() || !args[1]->IsNumber() ||
!args[2]->IsUint32() || !args[3]->IsUint32() ||
!args[4]->IsUint32() || !args[5]->IsUint32())
return ThrowException(String::New("Bad arguments"));
int x = args[0]->IntegerValue();
int y = args[1]->IntegerValue();
unsigned width = args[2]->Uint32Value();
unsigned height = args[3]->Uint32Value();
unsigned format = args[4]->Uint32Value();
unsigned type = args[5]->Uint32Value();
//TODO(nico): should support other formats also
if(format == GL_RGB && type == GL_UNSIGNED_BYTE) {
unsigned len = width * height * 3;
GLubyte *ans = new GLubyte[len];
glReadPixels((GLint)x,
(GLint)y,
(GLsizei)width,
(GLsizei)height,
(GLenum)format,
(GLenum)type, ans);
Local<Array> res = Array::New(len);
for (unsigned i = 0; i < len; ++i) {
res->Set(Integer::New(i), Integer::New(ans[i]));
}
delete[] ans;
return res;
}
return v8::Undefined();
}
Handle<Value> GLESglGetActiveAttribCallback(const Arguments& args) {
if (args.Length() != 2 ||
!args[0]->IsUint32() || !args[1]->IsUint32())
return ThrowException(String::New("Bad arguments"));
unsigned program = args[0]->Uint32Value();
unsigned index = args[1]->Uint32Value();
char name[256];
int length = 0;
int size = 0;
unsigned type = 0;
glGetActiveAttrib((GLuint)program,
(GLuint)index,
(GLsizei)sizeof(name),
(GLsizei*)&length,
(GLint*)&size,
(GLenum*)&type,
(GLchar*)name);
Handle<Object> ans = Object::New();
ans->Set(String::New("type"), Uint32::New(type));
ans->Set(String::New("size"), Integer::New(size));
ans->Set(String::New("name"), String::New(name, length));
return ans;
}
Handle<Value> GLESglGetActiveUniformCallback(const Arguments& args) {
if (args.Length() != 2 ||
!args[0]->IsUint32() || !args[1]->IsUint32())
return ThrowException(String::New("Bad arguments"));
unsigned program = args[0]->Uint32Value();
unsigned index = args[1]->Uint32Value();
char name[256];
int length = 0;
int size = 0;
unsigned type = 0;
glGetActiveUniform((GLuint)program,
(GLuint)index,
(GLsizei)sizeof(name),
(GLsizei*)&length,
(GLint*)&size,
(GLenum*)&type,
(GLchar*)name);
// Create a template for the answer object that'll hold
// type/size/name as properties
Handle<Object> ans = Object::New();
ans->Set(String::New("type"), Uint32::New(type));
ans->Set(String::New("size"), Integer::New(size));
ans->Set(String::New("name"), String::New(name));
return ans;
}
Handle<Value> GLESglGetAttachedShadersCallback(const Arguments& args) {
//if less that nbr of formal parameters then throw exception
if (args.Length() != 1 || !args[0]->IsUint32())
return ThrowException(String::New("Bad arguments"));
unsigned program = args[0]->Uint32Value();
int maxcount = 500;
int count = 0;
unsigned* shaders = new unsigned[maxcount];
glGetAttachedShaders((GLuint)program,
(GLsizei)maxcount,
(GLsizei*)&count,
(GLuint*)shaders);
Local<Array> res = Array::New(count);
for (int i = 0; i < count; ++i) {
res->Set(Integer::New(i), Uint32::New(shaders[i]));
}
delete[] shaders;
return res;
}
Handle<Value> GLESglGetBufferParameterivCallback(const Arguments& args) {
//if less that nbr of formal parameters then do nothing
if (args.Length() < 2) return ThrowException(String::New("Bad arguments"));
//get arguments
unsigned target = args[0]->IntegerValue();
unsigned pname = args[1]->IntegerValue();
int ans = 0;
//TODO(nico): does this return an array or just GLint?
glGetBufferParameteriv((GLenum)target,
(GLenum)pname,
(GLint*)&ans);
return Integer::New(ans);
}
//GetBooleanv, GetIntegerv, GetString, GetFloatv, GetDoublev should map here.
Handle<Value> GLESglGetParameterCallback(const Arguments& args) {
//if less that nbr of formal parameters then throw exception
if (args.Length() != 1 || !args[0]->IsUint32())
return ThrowException(String::New("Bad arguments"));
//get arguments
unsigned pname = args[0]->Uint32Value();
switch(pname) {
// return 1 string value
case GL_VENDOR:
case GL_RENDERER:
case GL_VERSION:
case GL_SHADING_LANGUAGE_VERSION:
case GL_EXTENSIONS:
{
const GLubyte *result;
result = glGetString((GLenum)pname);
if (result==0) { return v8::Undefined(); }
return String::New((const char*)result);
}
//return 1 int value
#ifdef DESKTOP_GL
case GL_ALPHA_TEST_FUNC:
case GL_ACCUM_ALPHA_BITS:
case GL_ACCUM_BLUE_BITS:
case GL_ACCUM_GREEN_BITS:
case GL_ACCUM_RED_BITS:
#endif
case GL_ALPHA_BITS:
#ifdef DESKTOP_GL
case GL_ATTRIB_STACK_DEPTH:
case GL_AUX_BUFFERS:
case GL_BLEND_DST:
case GL_BLEND_EQUATION_EXT:
case GL_BLEND_SRC:
#endif
case GL_BLUE_BITS:
#ifdef DESKTOP_GL
case GL_CLIENT_ATTRIB_STACK_DEPTH:
case GL_COLOR_ARRAY_SIZE:
case GL_COLOR_ARRAY_STRIDE:
case GL_COLOR_ARRAY_TYPE:
case GL_COLOR_MATERIAL_FACE:
case GL_COLOR_MATERIAL_PARAMETER:
#endif
case GL_DEPTH_BITS:
#ifdef DESKTOP_GL
case GL_DRAW_BUFFER:
case GL_EDGE_FLAG_ARRAY_STRIDE:
case GL_FOG_HINT:
case GL_FOG_MODE:
#endif
case GL_GREEN_BITS:
#ifdef DESKTOP_GL
case GL_INDEX_ARRAY_STRIDE:
case GL_INDEX_ARRAY_TYPE:
case GL_INDEX_BITS:
case GL_INDEX_WRITEMASK:
case GL_LINE_SMOOTH_HINT:
case GL_LINE_STIPPLE_PATTERN:
case GL_LINE_STIPPLE_REPEAT:
case GL_LIST_BASE:
case GL_LIST_INDEX: //name of the display list
case GL_LIST_MODE:
case GL_LOGIC_OP_MODE:
case GL_MAP1_GRID_SEGMENTS:
case GL_MATRIX_MODE:
case GL_MAX_CLIENT_ATTRIB_STACK_DEPTH:
case GL_MAX_ATTRIB_STACK_DEPTH:
case GL_MAX_CLIP_PLANES:
case GL_MAX_EVAL_ORDER:
case GL_MAX_LIGHTS:
case GL_MAX_LIST_NESTING:
case GL_MAX_MODELVIEW_STACK_DEPTH:
case GL_MAX_NAME_STACK_DEPTH:
case GL_MAX_PIXEL_MAP_TABLE:
case GL_MAX_PROJECTION_STACK_DEPTH:
#endif
case GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS:
case GL_MAX_CUBE_MAP_TEXTURE_SIZE:
case GL_MAX_FRAGMENT_UNIFORM_VECTORS:
case GL_MAX_RENDERBUFFER_SIZE:
case GL_MAX_TEXTURE_IMAGE_UNITS:
case GL_MAX_TEXTURE_SIZE:
case GL_MAX_VARYING_VECTORS:
case GL_MAX_VERTEX_ATTRIBS:
case GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS:
case GL_MAX_VERTEX_UNIFORM_VECTORS:
#ifdef DESKTOP_GL
case GL_MAX_TEXTURE_STACK_DEPTH:
case GL_MODELVIEW_STACK_DEPTH:
case GL_NAME_STACK_DEPTH:
case GL_NORMAL_ARRAY_STRIDE:
case GL_NORMAL_ARRAY_TYPE:
#endif
case GL_NUM_COMPRESSED_TEXTURE_FORMATS:
case GL_PACK_ALIGNMENT:
#ifdef DESKTOP_GL
case GL_PACK_ROW_LENGTH:
case GL_PACK_SKIP_PIXELS:
case GL_PACK_SKIP_ROWS:
case GL_PERSPECTIVE_CORRECTION_HINT:
case GL_PIXEL_MAP_A_TO_A_SIZE:
case GL_PIXEL_MAP_B_TO_B_SIZE:
case GL_PIXEL_MAP_G_TO_G_SIZE:
case GL_PIXEL_MAP_I_TO_A_SIZE:
case GL_PIXEL_MAP_I_TO_B_SIZE:
case GL_PIXEL_MAP_I_TO_G_SIZE:
case GL_PIXEL_MAP_I_TO_I_SIZE:
case GL_PIXEL_MAP_I_TO_R_SIZE:
case GL_PIXEL_MAP_R_TO_R_SIZE:
case GL_PIXEL_MAP_S_TO_S_SIZE:
case GL_POINT_SMOOTH_HINT:
case GL_POLYGON_SMOOTH_HINT:
case GL_PROJECTION_STACK_DEPTH:
#endif
case GL_RED_BITS:
#ifdef DESKTOP_GL
case GL_RENDER_MODE:
case GL_SHADE_MODEL:
#endif
case GL_SAMPLE_BUFFERS:
case GL_SAMPLES:
case GL_STENCIL_BACK_REF:
case GL_STENCIL_BITS:
case GL_STENCIL_CLEAR_VALUE:
case GL_STENCIL_REF:
case GL_SUBPIXEL_BITS:
// case GL_TEXTURE_1D_BINDING:
// case GL_TEXTURE_2D_BINDING:
#ifdef DESKTOP_GL
case GL_TEXTURE_COORD_ARRAY_SIZE:
case GL_TEXTURE_COORD_ARRAY_STRIDE:
case GL_TEXTURE_COORD_ARRAY_TYPE:
case GL_TEXTURE_STACK_DEPTH:
#endif
case GL_UNPACK_ALIGNMENT:
#ifdef DESKTOP_GL
case GL_UNPACK_ROW_LENGTH:
case GL_UNPACK_SKIP_PIXELS:
case GL_UNPACK_SKIP_ROWS:
case GL_VERTEX_ARRAY_SIZE:
case GL_VERTEX_ARRAY_STRIDE:
case GL_VERTEX_ARRAY_TYPE:
#endif
{
int ans = 0;
glGetIntegerv((GLenum)pname, (GLint*)&ans);
return Integer::New(ans);
}
//1 unsigned int
case GL_ACTIVE_TEXTURE:
case GL_BLEND_DST_ALPHA:
case GL_BLEND_DST_RGB:
case GL_BLEND_EQUATION_ALPHA:
case GL_BLEND_EQUATION_RGB:
case GL_BLEND_SRC_ALPHA:
case GL_BLEND_SRC_RGB:
case GL_CULL_FACE_MODE:
case GL_DEPTH_FUNC:
case GL_FRONT_FACE:
case GL_GENERATE_MIPMAP_HINT:
case GL_STENCIL_BACK_FAIL:
case GL_STENCIL_BACK_FUNC:
case GL_STENCIL_BACK_PASS_DEPTH_FAIL:
case GL_STENCIL_BACK_PASS_DEPTH_PASS:
case GL_STENCIL_BACK_VALUE_MASK:
case GL_STENCIL_BACK_WRITEMASK:
case GL_STENCIL_FAIL:
case GL_STENCIL_FUNC:
case GL_STENCIL_PASS_DEPTH_FAIL:
case GL_STENCIL_PASS_DEPTH_PASS:
case GL_STENCIL_VALUE_MASK:
case GL_STENCIL_WRITEMASK:
{
unsigned int ans = 0;
glGetIntegerv((GLenum)pname, (GLint*)&ans);
return Integer::NewFromUnsigned(ans);
}
//2 values int
#ifdef DESKTOP_GL
case GL_LINE_WIDTH_RANGE:
case GL_MAP2_GRID_SEGMENTS:
#endif
case GL_MAX_VIEWPORT_DIMS:
#ifdef DESKTOP_GL
case GL_POLYGON_MODE:
#endif
{
int* ans = new int[2];
glGetIntegerv((GLenum)pname, ans);
Local<Array> res = Array::New(2);
for (int i = 0; i < 2; ++i) {
res->Set(Integer::New(i), Integer::New(ans[i]));
}
delete[] ans;
return res;
}
//4 values int
case GL_SCISSOR_BOX:
case GL_VIEWPORT:
{
int* ans = new int[4];
glGetIntegerv((GLenum)pname, ans);
Local<Array> res = Array::New(4);
for (int i = 0; i < 4; ++i) {
res->Set(Integer::New(i), Integer::New(ans[i]));
}
delete[] ans;
return res;
}
//1 value boolean
#ifdef DESKTOP_GL
case GL_ALPHA_TEST:
case GL_AUTO_NORMAL:
#endif
case GL_BLEND:
case GL_DEPTH_TEST:
// case GL_CLIP_PLANEi:
#ifdef DESKTOP_GL
case GL_COLOR_ARRAY:
case GL_COLOR_LOGIC_OP:
case GL_COLOR_MATERIAL:
#endif
case GL_CULL_FACE:
#ifdef DESKTOP_GL
case GL_CURRENT_RASTER_POSITION_VALID:
#endif
case GL_DEPTH_WRITEMASK:
case GL_DITHER:
#ifdef DESKTOP_GL
case GL_DOUBLEBUFFER:
case GL_EDGE_FLAG:
case GL_EDGE_FLAG_ARRAY:
case GL_FOG:
case GL_INDEX_ARRAY:
case GL_INDEX_LOGIC_OP:
case GL_INDEX_MODE:
// case GL_LIGHTi:
case GL_LIGHTING:
case GL_LIGHT_MODEL_LOCAL_VIEWER:
case GL_LIGHT_MODEL_TWO_SIDE:
case GL_LINE_SMOOTH:
case GL_LINE_STIPPLE:
case GL_MAP1_COLOR_4:
case GL_MAP1_INDEX:
case GL_MAP1_NORMAL:
case GL_MAP1_TEXTURE_COORD_1:
case GL_MAP1_TEXTURE_COORD_2:
case GL_MAP1_TEXTURE_COORD_3:
case GL_MAP1_TEXTURE_COORD_4:
case GL_MAP1_VERTEX_3:
case GL_MAP1_VERTEX_4:
case GL_MAP2_COLOR_4:
case GL_MAP2_INDEX:
case GL_MAP2_NORMAL:
case GL_MAP2_TEXTURE_COORD_1:
case GL_MAP2_TEXTURE_COORD_2:
case GL_MAP2_TEXTURE_COORD_3:
case GL_MAP2_TEXTURE_COORD_4:
case GL_MAP2_VERTEX_3:
case GL_MAP2_VERTEX_4:
case GL_MAP_COLOR:
case GL_MAP_STENCIL:
case GL_NORMAL_ARRAY:
case GL_NORMALIZE:
case GL_PACK_LSB_FIRST:
case GL_PACK_SWAP_BYTES:
case GL_POINT_SMOOTH:
#endif
case GL_POLYGON_OFFSET_FILL:
#ifdef DESKTOP_GL
case GL_POLYGON_OFFSET_LINE:
case GL_POLYGON_OFFSET_POINT:
case GL_POLYGON_SMOOTH:
case GL_POLYGON_STIPPLE:
case GL_READ_BUFFER:
case GL_RGBA_MODE:
#endif
case GL_SCISSOR_TEST:
case GL_STENCIL_TEST:
#ifdef DESKTOP_GL
case GL_STEREO:
case GL_TEXTURE_1D:
#endif
case GL_TEXTURE_2D:
#ifdef DESKTOP_GL
case GL_TEXTURE_COORD_ARRAY:
case GL_TEXTURE_GEN_Q:
case GL_TEXTURE_GEN_R:
case GL_TEXTURE_GEN_S:
case GL_TEXTURE_GEN_T:
case GL_UNPACK_LSB_FIRST:
case GL_VERTEX_ARRAY:
case GL_UNPACK_SWAP_BYTES:
#endif
{
GLboolean ans = 0;
glGetBooleanv((GLenum)pname, &ans);
return Boolean::New(ans != GL_FALSE);
}
//1 value float
#ifdef DESKTOP_GL
case GL_ALPHA_BIAS:
case GL_ALPHA_SCALE:
case GL_BLUE_BIAS:
case GL_BLUE_SCALE:
case GL_RED_BIAS:
case GL_RED_SCALE:
case GL_GREEN_BIAS:
case GL_GREEN_SCALE:
case GL_DEPTH_BIAS:
case GL_DEPTH_SCALE:
case GL_ALPHA_TEST_REF:
case GL_ZOOM_X:
case GL_ZOOM_Y:
case GL_CURRENT_INDEX:
case GL_CURRENT_RASTER_DISTANCE:
case GL_CURRENT_RASTER_INDEX:
#endif
case GL_DEPTH_CLEAR_VALUE:
#ifdef DESKTOP_GL
case GL_FOG_DENSITY:
case GL_FOG_END:
case GL_FOG_INDEX:
case GL_FOG_START:
case GL_INDEX_CLEAR_VALUE:
case GL_INDEX_OFFSET:
case GL_INDEX_SHIFT:
#endif
case GL_LINE_WIDTH:
#ifdef DESKTOP_GL
case GL_LINE_WIDTH_GRANULARITY:
case GL_POINT_SIZE:
case GL_POINT_SIZE_GRANULARITY:
#endif
{
float ans = 0.0f;
glGetFloatv((GLenum)pname, &ans);
return Number::New(ans);
}
//4 values float
#ifdef DESKTOP_GL
case GL_BLEND_COLOR_EXT:
case GL_ACCUM_CLEAR_VALUE:
#endif
case GL_COLOR_CLEAR_VALUE:
#ifdef DESKTOP_GL
case GL_CURRENT_COLOR:
case GL_CURRENT_RASTER_COLOR:
case GL_CURRENT_RASTER_POSITION:
case GL_CURRENT_RASTER_TEXTURE_COORDS:
case GL_CURRENT_TEXTURE_COORDS:
case GL_FOG_COLOR:
case GL_LIGHT_MODEL_AMBIENT:
case GL_MAP2_GRID_DOMAIN:
#endif
case GL_POLYGON_OFFSET_FACTOR:
case GL_POLYGON_OFFSET_UNITS:
{
float* ans = new float[4];
glGetFloatv((GLenum)pname, ans);
Local<Array> res = Array::New(4);
for (int i = 0; i < 4; ++i) {
res->Set(Integer::New(i), Number::New(ans[i]));
}
delete[] ans;
return res;
}
//3 values float
#ifdef DESKTOP_GL
case GL_CURRENT_NORMAL:
{
float* ans = new float[3];
glGetFloatv((GLenum)pname, ans);
Local<Array> res = Array::New(3);
for (int i = 0; i < 3; ++i) {
res->Set(Integer::New(i), Number::New(ans[i]));
}
delete[] ans;
return res;
}
#endif
//2 values float
case GL_DEPTH_RANGE:
#ifdef DESKTOP_GL
case GL_MAP1_GRID_DOMAIN:
case GL_POINT_SIZE_RANGE:
#endif
{
float* ans = new float[2];
glGetFloatv((GLenum)pname, ans);
Local<Array> res = Array::New(2);
for (int i = 0; i < 2; ++i) {
res->Set(Integer::New(i), Number::New(ans[i]));
}
delete[] ans;
return res;
}
//16 values float
#ifdef DESKTOP_GL
case GL_MODELVIEW_MATRIX:
case GL_PROJECTION_MATRIX:
case GL_TEXTURE_MATRIX:
{
float* ans = new float[16];
glGetFloatv((GLenum)pname, ans);
Local<Array> res = Array::New(16);
for (int i = 0; i < 16; ++i) {
res->Set(Integer::New(i), Number::New(ans[i]));
}
delete[] ans;
return res;
}
#endif
//4 values boolean
case GL_COLOR_WRITEMASK:
{
GLboolean* ans = new GLboolean[4];
glGetBooleanv((GLenum)pname, ans);
Local<Array> res = Array::New(4);
for (int i = 0; i < 4; ++i) {
res->Set(Integer::New(i), Boolean::New(ans[i] != GL_FALSE));
}
delete[] ans;
return res;
}
}
return ThrowException(String::New("Unknown parameter"));
}
Handle<Value> GLESglGetProgramivCallback(const Arguments& args) {
//if less that nbr of formal parameters then do nothing
if (args.Length() != 2) return ThrowException(String::New("Bad arguments"));
//get arguments
unsigned program = args[0]->Uint32Value();
unsigned pname = args[1]->Uint32Value();
int ans;
//TODO(nico): I haven't seen any case where this function might return
//an array.
glGetProgramiv((GLuint)program, (GLenum)pname, (GLint*) &ans);
return Integer::New(ans);
}
Handle<Value> GLESglGetProgramInfoLogCallback(const Arguments& args) {
if (args.Length() != 1) return ThrowException(String::New("Bad arguments"));
//get arguments
unsigned program = args[0]->Uint32Value();
//query string length
int len = 0;
glGetProgramiv((GLuint)program, GL_INFO_LOG_LENGTH, &len);
char* log = new char[len];
glGetProgramInfoLog((GLuint)program, (GLsizei)len, NULL, log);
return String::New(log);
}
Handle<Value> GLESglGetTexParameterCallback(const Arguments& args) {
if (args.Length() != 2) return ThrowException(String::New("Bad arguments"));
//get arguments
unsigned target = args[0]->Uint32Value();
unsigned pname = args[1]->Uint32Value();
switch(pname) {
//1 int
case GL_TEXTURE_MAG_FILTER:
case GL_TEXTURE_MIN_FILTER:
case GL_TEXTURE_WRAP_S:
case GL_TEXTURE_WRAP_T:
{
int ans = 0;
glTexParameteriv((GLenum)target, (GLenum)pname, (GLint*) &ans);
return Integer::New(ans);
}
//4 floats
#ifdef DESKTOP_GL
case GL_TEXTURE_BORDER_COLOR:
{
float* ans = new float[4];
glTexParameterfv((GLenum)target, (GLenum)pname, (GLfloat*) ans);
Local<Array> res = Array::New(4);
for (int i = 0; i < 4; ++i) {
res->Set(Integer::New(i), Number::New(ans[i]));
}
delete[] ans;
return res;
}
//1 float
case GL_TEXTURE_PRIORITY:
{
float ans = 0;
glTexParameterfv((GLenum)target, (GLenum)pname, (GLfloat*) &ans);
return Number::New(ans);
}
//1 boolean
case GL_TEXTURE_RESIDENT:
{
int ans = 0;
glTexParameteriv((GLenum)target, (GLenum)pname, (GLint*) &ans);
return Boolean::New(ans != GL_FALSE);
}
#endif
}
return ThrowException(String::New("Bad arguments"));
}
Handle<Value> GLESglGetVertexAttribCallback(const Arguments& args) {
if (args.Length() != 2) return ThrowException(String::New("Bad arguments"));
//get arguments
unsigned index = args[0]->Uint32Value();
unsigned pname = args[1]->Uint32Value();
switch(pname) {
//1 int value
case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING:
case GL_VERTEX_ATTRIB_ARRAY_SIZE:
case GL_VERTEX_ATTRIB_ARRAY_STRIDE:
case GL_VERTEX_ATTRIB_ARRAY_TYPE:
{
GLint ans = 0;
glGetVertexAttribiv((GLuint)index, (GLenum)pname, &ans);
return Integer::New(ans);
}
//1 boolean value
case GL_VERTEX_ATTRIB_ARRAY_ENABLED:
case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED:
{
GLint ans = 0;
glGetVertexAttribiv((GLuint)index, (GLenum)pname, &ans);
return Boolean::New(ans != GL_FALSE);
}
//4 float values
case GL_CURRENT_VERTEX_ATTRIB: //(?)
{
GLfloat* ans = new GLfloat[4];
glGetVertexAttribfv((GLuint)index, (GLenum)pname, ans);
Local<Array> res = Array::New(4);
for (int i = 0; i < 4; ++i) {
res->Set(Integer::New(i), Integer::New(ans[i]));
}
delete[] ans;
return res;
}
}
return ThrowException(String::New("Bad arguments"));
}
Handle<Value> GLESglTexImage2DCallback(const Arguments& args) {
if (args.Length() != 9) return ThrowException(String::New("Bad arguments"));
//get arguments
unsigned target = args[0]->Uint32Value();
int level = args[1]->IntegerValue();
int internal_format = args[2]->IntegerValue();
int width = args[3]->IntegerValue();
int height = args[4]->IntegerValue();
int border = args[5]->IntegerValue();
unsigned format = args[6]->Uint32Value();
unsigned type = args[7]->Uint32Value();
if(args[8]->IsObject() &&
Handle<Object>::Cast(args[8])->HasIndexedPropertiesInExternalArrayData()) {
Handle<Object> obj = Handle<Object>::Cast(args[8]);
const void *pixels = obj->GetIndexedPropertiesExternalArrayData();
ExternalArrayType atype = obj->GetIndexedPropertiesExternalArrayDataType();
unsigned int length = obj->GetIndexedPropertiesExternalArrayDataLength();
if (type == GL_UNSIGNED_BYTE &&
atype == kExternalUnsignedByteArray) {
// XXX check length here
glTexImage2D((GLenum)target, (GLint)level, (GLenum)internal_format,
(GLsizei)width, (GLsizei)height, (GLint)border,
(GLenum)format, (GLenum)type,
pixels);
return v8::Undefined();
}
if ((type == GL_UNSIGNED_SHORT_5_6_5 ||
type == GL_UNSIGNED_SHORT_4_4_4_4 ||
type == GL_UNSIGNED_SHORT_5_5_5_1) &&
atype == kExternalUnsignedShortArray) {
// XXX check length here
glTexImage2D((GLenum)target, (GLint)level, (GLenum)internal_format,
(GLsizei)width, (GLsizei)height, (GLint)border,
(GLenum)format, (GLenum)type,
pixels);
return v8::Undefined();
}
}
if(args[8]->IsArray()) {
Handle<Array> arr_handle = Handle<Array>::Cast(args[8]);
if( type == GL_UNSIGNED_BYTE ) {
GLubyte* pixels = new GLubyte[arr_handle->Length()];
for (unsigned j = 0; j < arr_handle->Length(); j++) {
Handle<Value> arg(arr_handle->Get(Integer::New(j)));
GLubyte aux = (GLubyte)arg->Uint32Value();
pixels[j] = aux;
}
glTexImage2D((GLenum)target,
(GLint)level,
(GLenum)internal_format,
(GLsizei)width,
(GLsizei)height,
(GLint)border,
(GLenum)format,
(GLenum)type,
(const void*)pixels);
delete[] pixels;
return v8::Undefined();
} else if( type == GL_BYTE ) {
GLbyte* pixels = new GLbyte[arr_handle->Length()];
for (unsigned j = 0; j < arr_handle->Length(); j++) {
Handle<Value> arg(arr_handle->Get(Integer::New(j)));
GLbyte aux = (GLbyte)arg->Uint32Value();
pixels[j] = aux;
}
glTexImage2D((GLenum)target,
(GLint)level,
(GLenum)internal_format,
(GLsizei)width,
(GLsizei)height,
(GLint)border,
(GLenum)format,
(GLenum)type,
(const void*)pixels);
delete[] pixels;
return v8::Undefined();
#ifdef DESKTOP_GL
} else if( type == GL_BITMAP ) {
GLbitfield* pixels = new GLbitfield[arr_handle->Length()];
for (unsigned j = 0; j < arr_handle->Length(); j++) {
Handle<Value> arg(arr_handle->Get(Integer::New(j)));
GLbitfield aux = (GLbitfield)arg->IntegerValue();
pixels[j] = aux;
}
glTexImage2D((GLenum)target,
(GLint)level,
(GLenum)internal_format,
(GLsizei)width,
(GLsizei)height,
(GLint)border,
(GLenum)format,
(GLenum)type,
(const void*)pixels);
delete[] pixels;
return v8::Undefined();
#endif
} else if( type == GL_UNSIGNED_SHORT ) {
GLushort* pixels = new GLushort[arr_handle->Length()];
for (unsigned j = 0; j < arr_handle->Length(); j++) {
Handle<Value> arg(arr_handle->Get(Integer::New(j)));
GLushort aux = (GLushort)arg->Uint32Value();
pixels[j] = aux;
}
glTexImage2D((GLenum)target,
(GLint)level,
(GLenum)internal_format,
(GLsizei)width,
(GLsizei)height,
(GLint)border,
(GLenum)format,
(GLenum)type,
(const void*)pixels);
delete[] pixels;
return v8::Undefined();
} else if( type == GL_SHORT ) {
GLshort* pixels = new GLshort[arr_handle->Length()];
for (unsigned j = 0; j < arr_handle->Length(); j++) {
Handle<Value> arg(arr_handle->Get(Integer::New(j)));
GLshort aux = (GLshort)arg->IntegerValue();
pixels[j] = aux;
}
glTexImage2D((GLenum)target,
(GLint)level,
(GLenum)internal_format,
(GLsizei)width,
(GLsizei)height,
(GLint)border,
(GLenum)format,
(GLenum)type,
(const void*)pixels);
delete[] pixels;
return v8::Undefined();
} else if( type == GL_UNSIGNED_INT ) {
GLuint* pixels = new GLuint[arr_handle->Length()];
for (unsigned j = 0; j < arr_handle->Length(); j++) {
Handle<Value> arg(arr_handle->Get(Integer::New(j)));
GLuint aux = (GLuint)arg->Uint32Value();
pixels[j] = aux;
}
glTexImage2D((GLenum)target,
(GLint)level,
(GLenum)internal_format,
(GLsizei)width,
(GLsizei)height,
(GLint)border,
(GLenum)format,
(GLenum)type,
(const void*)pixels);
delete[] pixels;
return v8::Undefined();
} else if( type == GL_INT ) {
GLint* pixels = new GLint[arr_handle->Length()];
for (unsigned j = 0; j < arr_handle->Length(); j++) {
Handle<Value> arg(arr_handle->Get(Integer::New(j)));
GLint aux = (GLint)arg->IntegerValue();
pixels[j] = aux;
}
glTexImage2D((GLenum)target,
(GLint)level,
(GLenum)internal_format,
(GLsizei)width,
(GLsizei)height,
(GLint)border,
(GLenum)format,
(GLenum)type,
(const void*)pixels);
delete[] pixels;
return v8::Undefined();
} else if( type == GL_FLOAT ) {
GLfloat* pixels = new GLfloat[arr_handle->Length()];
for (unsigned j = 0; j < arr_handle->Length(); j++) {
Handle<Value> arg(arr_handle->Get(Integer::New(j)));
GLfloat aux = (GLfloat)arg->NumberValue();
pixels[j] = aux;
}
glTexImage2D((GLenum)target,
(GLint)level,
(GLenum)internal_format,
(GLsizei)width,
(GLsizei)height,
(GLint)border,
(GLenum)format,
(GLenum)type,
(const void*)pixels);
delete[] pixels;
return v8::Undefined();
}
}
return ThrowException(String::New("Bad arguments"));
}
Handle<Value> GLESglTexImage2DFileCallback(const Arguments& args) {
if (args.Length() != 1) return ThrowException(String::New("Bad arguments"));
//get arguments
String::Utf8Value value(args[0]);
char* filepath_str = *value;
char* filename = V8GLUtils::getRealPath(filepath_str);
//take care of relative/absolute paths.
Image* img = loadPNG(filename);
glTexImage2D(GL_TEXTURE_2D, // target
0, // level
GL_RGB, // interal format
img->width, img->height, // width, height
0, // border
GL_RGB, // format
GL_UNSIGNED_BYTE, // type
(const void*)img->pixels);
delete[] filename;
return ThrowException(String::New("Bad arguments"));
}
Handle<Value> GLESglTexSubImage2DCallback(const Arguments& args) {
if (args.Length() != 9) return ThrowException(String::New("Bad arguments"));
//get arguments
unsigned target = args[0]->Uint32Value();
int level = args[1]->IntegerValue();
int xoffset = args[2]->IntegerValue();
int yoffset = args[3]->IntegerValue();
int width = args[4]->IntegerValue();
int height = args[5]->IntegerValue();
unsigned format = args[6]->Uint32Value();
unsigned type = args[7]->Uint32Value();
if(args[8]->IsArray()) {
Handle<Array> arr_handle = Handle<Array>::Cast(args[8]);
switch(type) {
case GL_UNSIGNED_BYTE:
{
GLubyte* pixels = new GLubyte[arr_handle->Length()];
for (unsigned j = 0; j < arr_handle->Length(); j++) {
Handle<Value> arg(arr_handle->Get(Integer::New(j)));
GLubyte aux = (GLubyte)arg->Uint32Value();
pixels[j] = aux;
}
glTexSubImage2D((GLenum)target,
(GLint)level,
(GLint)xoffset,
(GLint)yoffset,
(GLsizei)width,
(GLsizei)height,
(GLenum)format,
(GLenum)type,
(const void*)pixels);
delete[] pixels;
return v8::Undefined();
}
case GL_BYTE:
{
GLbyte* pixels = new GLbyte[arr_handle->Length()];
for (unsigned j = 0; j < arr_handle->Length(); j++) {
Handle<Value> arg(arr_handle->Get(Integer::New(j)));
GLbyte aux = (GLbyte)arg->Uint32Value();
pixels[j] = aux;
}
glTexSubImage2D((GLenum)target,
(GLint)level,
(GLint)xoffset,
(GLint)yoffset,
(GLsizei)width,
(GLsizei)height,
(GLenum)format,
(GLenum)type,
(const void*)pixels);
delete[] pixels;
return v8::Undefined();
}
#ifdef DESKTOP_GL
case GL_BITMAP:
{
GLbitfield* pixels = new GLbitfield[arr_handle->Length()];
for (unsigned j = 0; j < arr_handle->Length(); j++) {
Handle<Value> arg(arr_handle->Get(Integer::New(j)));
GLbitfield aux = (GLbitfield)arg->IntegerValue();
pixels[j] = aux;
}
glTexSubImage2D((GLenum)target,
(GLint)level,
(GLint)xoffset,
(GLint)yoffset,
(GLsizei)width,
(GLsizei)height,
(GLenum)format,
(GLenum)type,
(const void*)pixels);
delete[] pixels;
return v8::Undefined();
}
#endif
case GL_UNSIGNED_SHORT:
{
GLushort* pixels = new GLushort[arr_handle->Length()];
for (unsigned j = 0; j < arr_handle->Length(); j++) {
Handle<Value> arg(arr_handle->Get(Integer::New(j)));
GLushort aux = (GLushort)arg->Uint32Value();
pixels[j] = aux;
}
glTexSubImage2D((GLenum)target,
(GLint)level,
(GLint)xoffset,
(GLint)yoffset,
(GLsizei)width,
(GLsizei)height,
(GLenum)format,
(GLenum)type,
(const void*)pixels);
delete[] pixels;
return v8::Undefined();
}
case GL_SHORT:
{
GLshort* pixels = new GLshort[arr_handle->Length()];
for (unsigned j = 0; j < arr_handle->Length(); j++) {
Handle<Value> arg(arr_handle->Get(Integer::New(j)));
GLshort aux = (GLshort)arg->IntegerValue();
pixels[j] = aux;
}
glTexSubImage2D((GLenum)target,
(GLint)level,
(GLint)xoffset,
(GLint)yoffset,
(GLsizei)width,
(GLsizei)height,
(GLenum)format,
(GLenum)type,
(const void*)pixels);
delete[] pixels;
return v8::Undefined();
}
case GL_UNSIGNED_INT:
{
GLuint* pixels = new GLuint[arr_handle->Length()];
for (unsigned j = 0; j < arr_handle->Length(); j++) {
Handle<Value> arg(arr_handle->Get(Integer::New(j)));
GLuint aux = (GLuint)arg->Uint32Value();
pixels[j] = aux;
}
glTexSubImage2D((GLenum)target,
(GLint)level,
(GLint)xoffset,
(GLint)yoffset,
(GLsizei)width,
(GLsizei)height,
(GLenum)format,
(GLenum)type,
(const void*)pixels);
delete[] pixels;
return v8::Undefined();
}
case GL_INT:
{
GLint* pixels = new GLint[arr_handle->Length()];
for (unsigned j = 0; j < arr_handle->Length(); j++) {
Handle<Value> arg(arr_handle->Get(Integer::New(j)));
GLint aux = (GLint)arg->IntegerValue();
pixels[j] = aux;
}
glTexSubImage2D((GLenum)target,
(GLint)level,
(GLint)xoffset,
(GLint)yoffset,
(GLsizei)width,
(GLsizei)height,
(GLenum)format,
(GLenum)type,
(const void*)pixels);
delete[] pixels;
return v8::Undefined();
}
case GL_FLOAT:
{
GLfloat* pixels = new GLfloat[arr_handle->Length()];
for (unsigned j = 0; j < arr_handle->Length(); j++) {
Handle<Value> arg(arr_handle->Get(Integer::New(j)));
GLfloat aux = (GLfloat)arg->NumberValue();
pixels[j] = aux;
}
glTexSubImage2D((GLenum)target,
(GLint)level,
(GLint)xoffset,
(GLint)yoffset,
(GLsizei)width,
(GLsizei)height,
(GLenum)format,
(GLenum)type,
(const void*)pixels);
delete[] pixels;
return v8::Undefined();
}
}
}
return ThrowException(String::New("Bad arguments"));
}
Handle<Value> GLESglGetRenderbufferParameterCallback(const Arguments& args) {
//if less that nbr of formal parameters then do nothing
if (args.Length() != 2) return ThrowException(String::New("Bad arguments"));
//get arguments
unsigned target = args[0]->Uint32Value();
unsigned pname = args[1]->Uint32Value();
switch(pname) {
//1 int value
case GL_RENDERBUFFER_WIDTH:
case GL_RENDERBUFFER_HEIGHT:
case GL_RENDERBUFFER_INTERNAL_FORMAT:
case GL_RENDERBUFFER_RED_SIZE:
case GL_RENDERBUFFER_GREEN_SIZE:
case GL_RENDERBUFFER_BLUE_SIZE:
case GL_RENDERBUFFER_ALPHA_SIZE:
case GL_RENDERBUFFER_DEPTH_SIZE:
case GL_RENDERBUFFER_STENCIL_SIZE:
{
int ans = 0;
glGetRenderbufferParameteriv((GLenum)target, (GLenum)pname, (GLint*)&ans);
return Integer::New(ans);
}
}
return ThrowException(String::New("Bad arguments"));
}
Handle<Value> GLESglGetFramebufferAttachmentParameterCallback(const Arguments& args) {
//if less that nbr of formal parameters then do nothing
if (args.Length() != 2) return ThrowException(String::New("Bad arguments"));
//get arguments
unsigned target = args[0]->Uint32Value();
unsigned attachment = args[1]->Uint32Value();
unsigned pname = args[2]->Uint32Value();
// switch(pname) {
// case FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE:
// case FRAMEBUFFER_ATTACHMENT_OBJECT_NAME:
// case FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL:
// case FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE:
// {
int ans = 0;
glGetFramebufferAttachmentParameteriv((GLenum)target,
(GLenum)attachment,
(GLenum)pname,
(GLint*)&ans);
return Integer::New(ans);
// }
// }
return ThrowException(String::New("Bad arguments"));
}
Handle<Value> GLESglGetShaderInfoLogCallback(const Arguments& args) {
if (args.Length() != 1) return ThrowException(String::New("Bad arguments"));
//get arguments
unsigned shader = args[0]->Uint32Value();
//query string length
int len = 0;
glGetShaderiv((GLuint)shader, GL_INFO_LOG_LENGTH, &len);
char* log = new char[len];
glGetShaderInfoLog((GLuint)shader, (GLsizei)len, NULL, log);
return String::New(log);
}
Handle<Value> GLESglGetShaderSourceCallback(const Arguments& args) {
if (args.Length() != 1) return ThrowException(String::New("Bad arguments"));
//get arguments
unsigned shader = args[0]->Uint32Value();
//query string length
int len = 0;
glGetShaderiv((GLuint)shader, GL_SHADER_SOURCE_LENGTH, &len);
char* log = new char[len];
glGetShaderSource((GLuint)shader, (GLsizei)len, NULL, log);
return String::New(log);
}
// We expect to be called with a shader id and a single string.
Handle<Value> GLESglShaderSourceFileCallback(const Arguments& args) {
if (args.Length() != 2)
return ThrowException(String::New("Bad arguments"));
GLuint shader_id = args[0]->Uint32Value();
// GLSL source is defined as an ASCII subset.
v8::String::AsciiValue filepath_ascii(args[1]);
if (!*filepath_ascii)
return v8::Undefined();
char* filepath_str = *filepath_ascii;
char* filename = V8GLUtils::getRealPath(filepath_str);
std::ifstream in_file(filename);
if(!in_file.is_open()) return v8::Undefined();
std::string line, full_text = "";
while (! in_file.eof() ) {
std::getline (in_file, line);
full_text += line + "\n";
}
char* ans = new char[full_text.length() +1];
strcpy(ans, full_text.c_str());
GLsizei code_len = full_text.length();
glShaderSource(shader_id, 1, (const GLchar**) &ans, &code_len);
delete[] ans;
delete[] filename;
Handle<Object> res(GlesFactory::self_);
return res;
}
Handle<Value> GLESglActiveTextureCallback(const Arguments& args) {
//if less that nbr of formal parameters then throw exception
if (args.Length() != 1 || !args[0]->IsUint32())
return ThrowException(String::New("Bad arguments"));
//get arguments
unsigned int arg0 = args[0]->Uint32Value();
//make call
glActiveTexture((GLenum) arg0);
Handle<Object> res(GlesFactory::self_);
return res;
}
Handle<Value> GLESglAttachShaderCallback(const Arguments& args) {
//if less that nbr of formal parameters then do nothing
if (args.Length() < 2) return ThrowException(String::New("Bad arguments"));
//get arguments
unsigned int arg0 = args[0]->Uint32Value();
unsigned int arg1 = args[1]->Uint32Value();
//make call
glAttachShader((GLuint) arg0, (GLuint) arg1);
Handle<Object> res(GlesFactory::self_);
return res;
}
Handle<Value> GLESglBindAttribLocationCallback(const Arguments& args) {
//if less that nbr of formal parameters then do nothing
if (args.Length() < 3) return ThrowException(String::New("Bad arguments"));
//get arguments
unsigned int arg0 = args[0]->Uint32Value();
unsigned int arg1 = args[1]->Uint32Value();
String::Utf8Value value2(args[2]);
char* arg2 = *value2;
//make call
glBindAttribLocation((GLuint) arg0, (GLuint) arg1, (const char*) arg2);
Handle<Object> res(GlesFactory::self_);
return res;
}
Handle<Value> GLESglBindBufferCallback(const Arguments& args) {
//if less that nbr of formal parameters then do nothing
if (args.Length() < 2) return ThrowException(String::New("Bad arguments"));
//get arguments
unsigned int arg0 = args[0]->Uint32Value();
unsigned int arg1 = args[1]->Uint32Value();
//make call
glBindBuffer((GLenum) arg0, (GLuint) arg1);
Handle<Object> res(GlesFactory::self_);
return res;
}
Handle<Value> GLESglBindFramebufferCallback(const Arguments& args) {
//if less that nbr of formal parameters then do nothing
if (args.Length() < 2) return ThrowException(String::New("Bad arguments"));
//get arguments
unsigned int arg0 = args[0]->Uint32Value();
unsigned int arg1 = args[1]->Uint32Value();
//make call
glBindFramebuffer((GLenum) arg0, (GLuint) arg1);
Handle<Object> res(GlesFactory::self_);
return res;
}
Handle<Value> GLESglBindRenderbufferCallback(const Arguments& args) {
//if less that nbr of formal parameters then do nothing
if (args.Length() < 2) return ThrowException(String::New("Bad arguments"));
//get arguments
unsigned int arg0 = args[0]->Uint32Value();
unsigned int arg1 = args[1]->Uint32Value();
//make call
glBindRenderbuffer((GLenum) arg0, (GLuint) arg1);
Handle<Object> res(GlesFactory::self_);
return res;
}
Handle<Value> GLESglBindTextureCallback(const Arguments& args) {
//if less that nbr of formal parameters then do nothing
if (args.Length() < 2) return ThrowException(String::New("Bad arguments"));
//get arguments
unsigned int arg0 = args[0]->Uint32Value();
unsigned int arg1 = args[1]->Uint32Value();
//make call
glBindTexture((GLenum) arg0, (GLuint) arg1);
Handle<Object> res(GlesFactory::self_);
return res;
}
Handle<Value> GLESglBlendColorCallback(const Arguments& args) {
//if less that nbr of formal parameters then do nothing
if (args.Length() < 4) return ThrowException(String::New("Bad arguments"));
//get arguments
double arg0 = args[0]->NumberValue();
double arg1 = args[1]->NumberValue();
double arg2 = args[2]->NumberValue();
double arg3 = args[3]->NumberValue();
//make call
glBlendColor((GLclampf) arg0, (GLclampf) arg1, (GLclampf) arg2, (GLclampf) arg3);
Handle<Object> res(GlesFactory::self_);
return res;
}
Handle<Value> GLESglBlendEquationCallback(const Arguments& args) {
//if less that nbr of formal parameters then throw exception
if (args.Length() != 1 || !args[0]->IsUint32())
return ThrowException(String::New("Bad arguments"));
//get arguments
unsigned int arg0 = args[0]->Uint32Value();
//make call
glBlendEquation((GLenum) arg0);
Handle<Object> res(GlesFactory::self_);
return res;
}
Handle<Value> GLESglBlendEquationSeparateCallback(const Arguments& args) {
//if less that nbr of formal parameters then do nothing
if (args.Length() < 2) return ThrowException(String::New("Bad arguments"));
//get arguments
unsigned int arg0 = args[0]->Uint32Value();
unsigned int arg1 = args[1]->Uint32Value();
//make call
glBlendEquationSeparate((GLenum) arg0, (GLenum) arg1);
Handle<Object> res(GlesFactory::self_);
return res;
}
Handle<Value> GLESglBlendFuncCallback(const Arguments& args) {
//if less that nbr of formal parameters then do nothing
if (args.Length() < 2) return ThrowException(String::New("Bad arguments"));
//get arguments
unsigned int arg0 = args[0]->Uint32Value();
unsigned int arg1 = args[1]->Uint32Value();
//make call
glBlendFunc((GLenum) arg0, (GLenum) arg1);
Handle<Object> res(GlesFactory::self_);
return res;
}
Handle<Value> GLESglBlendFuncSeparateCallback(const Arguments& args) {
//if less that nbr of formal parameters then do nothing
if (args.Length() < 4) return ThrowException(String::New("Bad arguments"));
//get arguments
unsigned int arg0 = args[0]->Uint32Value();
unsigned int arg1 = args[1]->Uint32Value();
unsigned int arg2 = args[2]->Uint32Value();
unsigned int arg3 = args[3]->Uint32Value();
//make call
glBlendFuncSeparate((GLenum) arg0, (GLenum) arg1, (GLenum) arg2, (GLenum) arg3);
Handle<Object> res(GlesFactory::self_);
return res;
}
Handle<Value> GLESglCheckFramebufferStatusCallback(const Arguments& args) {
//if less that nbr of formal parameters then throw exception
if (args.Length() != 1 || !args[0]->IsUint32())
return ThrowException(String::New("Bad arguments"));
//get arguments
unsigned int arg0 = args[0]->Uint32Value();
//make call
return Uint32::New(glCheckFramebufferStatus((GLenum) arg0));
}
Handle<Value> GLESglClearCallback(const Arguments& args) {
//if less that nbr of formal parameters then throw exception
if (args.Length() != 1 || !args[0]->IsUint32())
return ThrowException(String::New("Bad arguments"));
//get arguments
unsigned int arg0 = args[0]->Uint32Value();
//make call
glClear((GLbitfield) arg0);
Handle<Object> res(GlesFactory::self_);
return res;
}
Handle<Value> GLESglClearColorCallback(const Arguments& args) {
//if less that nbr of formal parameters then do nothing
if (args.Length() < 4 || !args[0]->IsNumber() || !args[1]->IsNumber() ||
!args[2]->IsNumber() || !args[3]->IsNumber())
return ThrowException(String::New("Bad arguments"));
//get arguments
double arg0 = args[0]->NumberValue();
double arg1 = args[1]->NumberValue();
double arg2 = args[2]->NumberValue();
double arg3 = args[3]->NumberValue();
//make call
glClearColor((GLclampf) arg0, (GLclampf) arg1, (GLclampf) arg2, (GLclampf) arg3);
Handle<Object> res(GlesFactory::self_);
return res;
}
Handle<Value> GLESglClearDepthCallback(const Arguments& args) {
//if less that nbr of formal parameters then do nothing
if (args.Length() < 1 || !args[0]->IsNumber())
return ThrowException(String::New("Bad arguments"));
//get arguments
double arg0 = args[0]->NumberValue();
if (arg0 < 0) arg0 = 0;
if (arg0 > 1) arg0 = 1;
//make call
glClearDepthf((GLclampf) arg0);
Handle<Object> res(GlesFactory::self_);
return res;
}
Handle<Value> GLESglClearStencilCallback(const Arguments& args) {
//if less that nbr of formal parameters then do nothing
if (args.Length() < 1 || !args[0]->IsNumber())
return ThrowException(String::New("Bad arguments"));
//get arguments
int arg0 = args[0]->IntegerValue();
//make call
glClearStencil((GLint) arg0);
Handle<Object> res(GlesFactory::self_);
return res;
}
Handle<Value> GLESglColorMaskCallback(const Arguments& args) {
//if less that nbr of formal parameters then do nothing
if (args.Length() < 4) return ThrowException(String::New("Bad arguments"));
//get arguments
unsigned int arg0 = args[0]->Uint32Value();
unsigned int arg1 = args[1]->Uint32Value();
unsigned int arg2 = args[2]->Uint32Value();
unsigned int arg3 = args[3]->Uint32Value();
//make call
glColorMask((GLboolean) arg0, (GLboolean) arg1, (GLboolean) arg2, (GLboolean) arg3);
Handle<Object> res(GlesFactory::self_);
return res;
}
Handle<Value> GLESglCompileShaderCallback(const Arguments& args) {
//if less that nbr of formal parameters then throw exception
if (args.Length() != 1 || !args[0]->IsUint32())
return ThrowException(String::New("Bad arguments"));
//get arguments
unsigned int arg0 = args[0]->Uint32Value();
//make call
glCompileShader((GLuint) arg0);
Handle<Object> res(GlesFactory::self_);
return res;
}
Handle<Value> GLESglCopyTexImage2DCallback(const Arguments& args) {
//if less that nbr of formal parameters then do nothing
if (args.Length() < 8) return ThrowException(String::New("Bad arguments"));
//get arguments
unsigned int arg0 = args[0]->Uint32Value();
int arg1 = args[1]->IntegerValue();
unsigned int arg2 = args[2]->Uint32Value();
int arg3 = args[3]->IntegerValue();
int arg4 = args[4]->IntegerValue();
int arg5 = args[5]->IntegerValue();
int arg6 = args[6]->IntegerValue();
int arg7 = args[7]->IntegerValue();
//make call
glCopyTexImage2D((GLenum) arg0, (GLint) arg1, (GLenum) arg2, (GLint) arg3, (GLint) arg4, (GLsizei) arg5, (GLsizei) arg6, (GLint) arg7);
Handle<Object> res(GlesFactory::self_);
return res;
}
Handle<Value> GLESglCopyTexSubImage2DCallback(const Arguments& args) {
//if less that nbr of formal parameters then do nothing
if (args.Length() < 8) return ThrowException(String::New("Bad arguments"));
//get arguments
unsigned int arg0 = args[0]->Uint32Value();
int arg1 = args[1]->IntegerValue();
int arg2 = args[2]->IntegerValue();
int arg3 = args[3]->IntegerValue();
int arg4 = args[4]->IntegerValue();
int arg5 = args[5]->IntegerValue();
int arg6 = args[6]->IntegerValue();
int arg7 = args[7]->IntegerValue();
//make call
glCopyTexSubImage2D((GLenum) arg0, (GLint) arg1, (GLint) arg2, (GLint) arg3, (GLint) arg4, (GLint) arg5, (GLsizei) arg6, (GLsizei) arg7);
Handle<Object> res(GlesFactory::self_);
return res;
}
Handle<Value> GLESglCreateProgramCallback(const Arguments& args) {
//if less that nbr of formal parameters then do nothing
if (args.Length() != 0) return ThrowException(String::New("Bad arguments"));
//get arguments
//make call
return Uint32::New(glCreateProgram());
}
Handle<Value> GLESglCreateShaderCallback(const Arguments& args) {
//if less that nbr of formal parameters then throw exception
if (args.Length() != 1 || !args[0]->IsUint32())
return ThrowException(String::New("Bad arguments"));
//get arguments
unsigned int arg0 = args[0]->Uint32Value();
//make call
return Uint32::New(glCreateShader((GLenum) arg0));
}
Handle<Value> GLESglCullFaceCallback(const Arguments& args) {
//if less that nbr of formal parameters then throw exception
if (args.Length() != 1 || !args[0]->IsUint32())
return ThrowException(String::New("Bad arguments"));
//get arguments
unsigned int arg0 = args[0]->Uint32Value();
//make call
glCullFace((GLenum) arg0);
Handle<Object> res(GlesFactory::self_);
return res;
}
Handle<Value> GLESglDeleteBuffersCallback(const Arguments& args) {
//if less that nbr of formal parameters then do nothing
if (args.Length() < 2) return ThrowException(String::New("Bad arguments"));
//get arguments
int arg0 = args[0]->IntegerValue();
Handle<Array> arrHandle1 = Handle<Array>::Cast(args[1]);
GLuint* arg1 = new GLuint[arrHandle1->Length()];
for (unsigned j = 0; j < arrHandle1->Length(); j++) {
Handle<Value> arg(arrHandle1->Get(Integer::New(j)));
GLuint aux = ( GLuint)arg->Uint32Value();
arg1[j] = aux;
}
//make call
glDeleteBuffers((GLsizei) arg0, (const GLuint*) arg1);
Handle<Object> res(GlesFactory::self_);
return res;
}
Handle<Value> GLESglDeleteFramebuffersCallback(const Arguments& args) {
//if less that nbr of formal parameters then do nothing
if (args.Length() < 2) return ThrowException(String::New("Bad arguments"));
//get arguments
int arg0 = args[0]->IntegerValue();
Handle<Array> arrHandle1 = Handle<Array>::Cast(args[1]);
GLuint* arg1 = new GLuint[arrHandle1->Length()];
for (unsigned j = 0; j < arrHandle1->Length(); j++) {
Handle<Value> arg(arrHandle1->Get(Integer::New(j)));
GLuint aux = ( GLuint)arg->Uint32Value();
arg1[j] = aux;
}
//make call
glDeleteFramebuffers((GLsizei) arg0, (const GLuint*) arg1);
Handle<Object> res(GlesFactory::self_);
return res;
}
Handle<Value> GLESglDeleteProgramCallback(const Arguments& args) {
//if less that nbr of formal parameters then throw exception
if (args.Length() != 1 || !args[0]->IsUint32())
return ThrowException(String::New("Bad arguments"));
//get arguments
unsigned int arg0 = args[0]->Uint32Value();
//make call
glDeleteProgram((GLuint) arg0);
Handle<Object> res(GlesFactory::self_);
return res;
}
Handle<Value> GLESglDeleteRenderbuffersCallback(const Arguments& args) {
//if less that nbr of formal parameters then do nothing
if (args.Length() < 2) return ThrowException(String::New("Bad arguments"));
//get arguments
int arg0 = args[0]->IntegerValue();
Handle<Array> arrHandle1 = Handle<Array>::Cast(args[1]);
GLuint* arg1 = new GLuint[arrHandle1->Length()];
for (unsigned j = 0; j < arrHandle1->Length(); j++) {
Handle<Value> arg(arrHandle1->Get(Integer::New(j)));
GLuint aux = ( GLuint)arg->Uint32Value();
arg1[j] = aux;
}
//make call
glDeleteRenderbuffers((GLsizei) arg0, (const GLuint*) arg1);
Handle<Object> res(GlesFactory::self_);
return res;
}
Handle<Value> GLESglDeleteShaderCallback(const Arguments& args) {
//if less that nbr of formal parameters then throw exception
if (args.Length() != 1 || !args[0]->IsUint32())
return ThrowException(String::New("Bad arguments"));
//get arguments
unsigned int arg0 = args[0]->Uint32Value();
//make call
glDeleteShader((GLuint) arg0);
Handle<Object> res(GlesFactory::self_);
return res;
}
Handle<Value> GLESglDeleteTexturesCallback(const Arguments& args) {
//if less that nbr of formal parameters then do nothing
if (args.Length() < 2) return ThrowException(String::New("Bad arguments"));
//get arguments
int arg0 = args[0]->IntegerValue();
Handle<Array> arrHandle1 = Handle<Array>::Cast(args[1]);
GLuint* arg1 = new GLuint[arrHandle1->Length()];
for (unsigned j = 0; j < arrHandle1->Length(); j++) {
Handle<Value> arg(arrHandle1->Get(Integer::New(j)));
GLuint aux = ( GLuint)arg->Uint32Value();
arg1[j] = aux;
}
//make call
glDeleteTextures((GLsizei) arg0, (const GLuint*) arg1);
Handle<Object> res(GlesFactory::self_);
return res;
}
Handle<Value> GLESglDepthFuncCallback(const Arguments& args) {
//if less that nbr of formal parameters then throw exception
if (args.Length() != 1 || !args[0]->IsUint32())
return ThrowException(String::New("Bad arguments"));
//get arguments
unsigned int arg0 = args[0]->Uint32Value();
//make call
glDepthFunc((GLenum) arg0);
Handle<Object> res(GlesFactory::self_);
return res;
}
Handle<Value> GLESglDepthMaskCallback(const Arguments& args) {
//if less that nbr of formal parameters then throw exception
if (args.Length() != 1 || !(args[0]->IsUint32() || args[0]->IsBoolean()))
return ThrowException(String::New("Bad arguments"));
//get arguments
bool arg0 = args[0]->BooleanValue();
//make call
glDepthMask((GLboolean) arg0);
Handle<Object> res(GlesFactory::self_);
return res;
}
Handle<Value> GLESglDepthRangefCallback(const Arguments& args) {
//if less that nbr of formal parameters then do nothing
if (args.Length() < 2 || !args[0]->IsNumber() || !args[1]->IsNumber())
return ThrowException(String::New("Bad arguments"));
//get arguments
double arg0 = args[0]->NumberValue();
double arg1 = args[1]->NumberValue();
//make call
glDepthRangef((GLclampf) arg0, (GLclampf) arg1);
Handle<Object> res(GlesFactory::self_);
return res;
}
Handle<Value> GLESglDetachShaderCallback(const Arguments& args) {
//if less that nbr of formal parameters then do nothing
if (args.Length() != 2 || !args[0]->IsUint32() || !args[1]->IsUint32())
return ThrowException(String::New("Bad arguments"));
//get arguments
unsigned int arg0 = args[0]->Uint32Value();
unsigned int arg1 = args[1]->Uint32Value();
//make call
glDetachShader((GLuint) arg0, (GLuint) arg1);
Handle<Object> res(GlesFactory::self_);
return res;
}
Handle<Value> GLESglDisableCallback(const Arguments& args) {
//if less that nbr of formal parameters then throw exception
if (args.Length() != 1 || !args[0]->IsUint32())
return ThrowException(String::New("Bad arguments"));
//get arguments
unsigned int arg0 = args[0]->Uint32Value();
//make call
glDisable((GLenum) arg0);
Handle<Object> res(GlesFactory::self_);
return res;
}
Handle<Value> GLESglDisableVertexAttribArrayCallback(const Arguments& args) {
//if less that nbr of formal parameters then throw exception
if (args.Length() != 1 || !args[0]->IsUint32())
return ThrowException(String::New("Bad arguments"));
//get arguments
unsigned int arg0 = args[0]->Uint32Value();
//make call
glDisableVertexAttribArray((GLuint) arg0);
Handle<Object> res(GlesFactory::self_);
return res;
}
Handle<Value> GLESglDrawArraysCallback(const Arguments& args) {
//if less that nbr of formal parameters then throw exception
if (args.Length() != 3 || !args[0]->IsUint32() || !args[1]->IsNumber() ||
!args[2]->IsNumber())
return ThrowException(String::New("Bad arguments"));
//get arguments
unsigned int arg0 = args[0]->Uint32Value();
int arg1 = args[1]->IntegerValue();
int arg2 = args[2]->IntegerValue();
//make call
glDrawArrays((GLenum) arg0, (GLint) arg1, (GLsizei) arg2);
Handle<Object> res(GlesFactory::self_);
return res;
}
Handle<Value> GLESglEnableCallback(const Arguments& args) {
//if less that nbr of formal parameters then throw exception
if (args.Length() != 1 || !args[0]->IsUint32())
return ThrowException(String::New("Bad arguments"));
//get arguments
unsigned int arg0 = args[0]->Uint32Value();
//make call
glEnable((GLenum) arg0);
Handle<Object> res(GlesFactory::self_);
return res;
}
Handle<Value> GLESglEnableVertexAttribArrayCallback(const Arguments& args) {
//if less that nbr of formal parameters then throw exception
if (args.Length() != 1 || !args[0]->IsUint32())
return ThrowException(String::New("Bad arguments"));
//get arguments
unsigned int arg0 = args[0]->Uint32Value();
//make call
glEnableVertexAttribArray((GLuint) arg0);
Handle<Object> res(GlesFactory::self_);
return res;
}
Handle<Value> GLESglFinishCallback(const Arguments& args) {
if (args.Length() != 0)
return ThrowException(String::New("Extra arguments to finish"));
//get arguments
//make call
glFinish();
Handle<Object> res(GlesFactory::self_);
return res;
}
Handle<Value> GLESglFlushCallback(const Arguments& args) {
if (args.Length() != 0)
return ThrowException(String::New("Bad arguments"));
//get arguments
//make call
glFlush();
Handle<Object> res(GlesFactory::self_);
return res;
}
Handle<Value> GLESglFramebufferRenderbufferCallback(const Arguments& args) {
//if less that nbr of formal parameters then throw exception
if (args.Length() < 4 || !args[0]->IsUint32() || !args[1]->IsUint32() ||
!args[2]->IsUint32() || !args[3]->IsUint32())
return ThrowException(String::New("Bad arguments"));
//get arguments
unsigned int arg0 = args[0]->Uint32Value();
unsigned int arg1 = args[1]->Uint32Value();
unsigned int arg2 = args[2]->Uint32Value();
unsigned int arg3 = args[3]->Uint32Value();
//make call
glFramebufferRenderbuffer((GLenum) arg0, (GLenum) arg1, (GLenum) arg2, (GLuint) arg3);
Handle<Object> res(GlesFactory::self_);
return res;
}
Handle<Value> GLESglFramebufferTexture2DCallback(const Arguments& args) {
//if less that nbr of formal parameters then throw exception
if (args.Length() < 5 || !args[0]->IsUint32() || !args[1]->IsUint32() ||
!args[2]->IsUint32() || !args[3]->IsUint32() || !args[4]->IsNumber())
return ThrowException(String::New("Bad arguments"));
//get arguments
unsigned int arg0 = args[0]->Uint32Value();
unsigned int arg1 = args[1]->Uint32Value();
unsigned int arg2 = args[2]->Uint32Value();
unsigned int arg3 = args[3]->Uint32Value();
int arg4 = args[4]->IntegerValue();
//make call
glFramebufferTexture2D((GLenum) arg0, (GLenum) arg1, (GLenum) arg2, (GLuint) arg3, (GLint) arg4);
Handle<Object> res(GlesFactory::self_);
return res;
}
Handle<Value> GLESglFrontFaceCallback(const Arguments& args) {
//if less that nbr of formal parameters then throw exception
if (args.Length() != 1 || !args[0]->IsUint32())
return ThrowException(String::New("Bad arguments"));
//get arguments
unsigned int arg0 = args[0]->Uint32Value();
//make call
glFrontFace((GLenum) arg0);
Handle<Object> res(GlesFactory::self_);
return res;
}
Handle<Value> GLESglGenerateMipmapCallback(const Arguments& args) {
//if less that nbr of formal parameters then throw exception
if (args.Length() != 1 || !args[0]->IsUint32())
return ThrowException(String::New("Bad arguments"));
//get arguments
unsigned int arg0 = args[0]->Uint32Value();
//make call
glGenerateMipmap((GLenum) arg0);
Handle<Object> res(GlesFactory::self_);
return res;
}
Handle<Value> GLESglGetAttribLocationCallback(const Arguments& args) {
//if less that nbr of formal parameters then throw exception
if (args.Length() != 2 || !args[0]->IsUint32())
return ThrowException(String::New("Bad arguments"));
//get arguments
unsigned int arg0 = args[0]->Uint32Value();
String::Utf8Value value1(args[1]);
char* arg1 = *value1;
//make call
return Integer::New(glGetAttribLocation((GLuint) arg0, (const char*) arg1));
}
Handle<Value> GLESglGetBooleanvCallback(const Arguments& args) {
//if less that nbr of formal parameters then throw exception
if (args.Length() != 2 || !args[0]->IsUint32() || !args[1]->IsArray())
return ThrowException(String::New("Bad arguments"));
//get arguments
unsigned int arg0 = args[0]->Uint32Value();
Handle<Array> arrHandle1 = Handle<Array>::Cast(args[1]);
GLboolean* arg1 = new GLboolean[arrHandle1->Length()];
for (unsigned j = 0; j < arrHandle1->Length(); j++) {
Handle<Value> arg(arrHandle1->Get(Integer::New(j)));
GLboolean aux = (GLboolean)arg->Uint32Value();
arg1[j] = aux;
}
//make call
glGetBooleanv((GLenum) arg0, (GLboolean*) arg1);
Handle<Object> res(GlesFactory::self_);
return res;
}
Handle<Value> GLESglGetErrorCallback(const Arguments& args) {
//if less that nbr of formal parameters then do nothing
if (args.Length() != 0) return ThrowException(String::New("Bad arguments"));
//get arguments
//make call
return Uint32::New(glGetError());
}
Handle<Value> GLESglGetFloatvCallback(const Arguments& args) {
//if less that nbr of formal parameters then do nothing
if (args.Length() < 2) return ThrowException(String::New("Bad arguments"));
//get arguments
unsigned int arg0 = args[0]->Uint32Value();
Handle<Array> arrHandle1 = Handle<Array>::Cast(args[1]);
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();
arg1[j] = aux;
}
//make call
glGetFloatv((GLenum) arg0, (GLfloat*) arg1);
Handle<Object> res(GlesFactory::self_);
return res;
}
Handle<Value> GLESglGetFramebufferAttachmentParameterivCallback(const Arguments& args) {
//if less that nbr of formal parameters then do nothing
if (args.Length() < 4) return ThrowException(String::New("Bad arguments"));
//get arguments
unsigned int arg0 = args[0]->Uint32Value();
unsigned int arg1 = args[1]->Uint32Value();
unsigned int arg2 = args[2]->Uint32Value();
Handle<Array> arrHandle3 = Handle<Array>::Cast(args[3]);
GLint* arg3 = new GLint[arrHandle3->Length()];
for (unsigned j = 0; j < arrHandle3->Length(); j++) {
Handle<Value> arg(arrHandle3->Get(Integer::New(j)));
GLint aux = (GLint)arg->IntegerValue();
arg3[j] = aux;
}
//make call
glGetFramebufferAttachmentParameteriv((GLenum) arg0, (GLenum) arg1, (GLenum) arg2, (GLint*) arg3);
Handle<Object> res(GlesFactory::self_);
return res;
}
Handle<Value> GLESglGetIntegervCallback(const Arguments& args) {
//if less that nbr of formal parameters then do nothing
if (args.Length() < 2) return ThrowException(String::New("Bad arguments"));
//get arguments
unsigned int arg0 = args[0]->Uint32Value();
Handle<Array> arrHandle1 = Handle<Array>::Cast(args[1]);
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();
arg1[j] = aux;
}
//make call
glGetIntegerv((GLenum) arg0, (GLint*) arg1);
Handle<Object> res(GlesFactory::self_);
return res;
}
Handle<Value> GLESglGetUniformivCallback(const Arguments& args) {
//if less that nbr of formal parameters then do nothing
if (args.Length() < 3) return ThrowException(String::New("Bad arguments"));
//get arguments
unsigned int arg0 = args[0]->Uint32Value();
int arg1 = args[1]->IntegerValue();
Handle<Array> arrHandle2 = Handle<Array>::Cast(args[2]);
GLint* arg2 = new GLint[arrHandle2->Length()];
for (unsigned j = 0; j < arrHandle2->Length(); j++) {
Handle<Value> arg(arrHandle2->Get(Integer::New(j)));
GLint aux = (GLint)arg->IntegerValue();
arg2[j] = aux;
}
//make call
glGetUniformiv((GLuint) arg0, (GLint) arg1, (GLint*) arg2);
Handle<Object> res(GlesFactory::self_);
return res;
}
Handle<Value> GLESglGetUniformLocationCallback(const Arguments& args) {
//if less that nbr of formal parameters then do nothing
if (args.Length() < 2 || !args[0]->IsUint32())
return ThrowException(String::New("Bad arguments"));
//get arguments
unsigned int arg0 = args[0]->Uint32Value();
String::Utf8Value value1(args[1]);
char* arg1 = *value1;
//make call
return Integer::New(glGetUniformLocation((GLuint) arg0, (const char*) arg1));
}
Handle<Value> GLESglHintCallback(const Arguments& args) {
//if less that nbr of formal parameters then do nothing
if (args.Length() < 2 || !args[0]->IsUint32() || !args[1]->IsUint32())
return ThrowException(String::New("Bad arguments"));
//get arguments
unsigned int arg0 = args[0]->Uint32Value();
unsigned int arg1 = args[1]->Uint32Value();
//make call
glHint((GLenum) arg0, (GLenum) arg1);
Handle<Object> res(GlesFactory::self_);
return res;
}
Handle<Value> GLESglIsBufferCallback(const Arguments& args) {
//if less that nbr of formal parameters then throw exception
if (args.Length() != 1 || !args[0]->IsUint32())
return ThrowException(String::New("Bad arguments"));
//get arguments
unsigned int arg0 = args[0]->Uint32Value();
//make call
return Uint32::New(glIsBuffer((GLuint) arg0));
}
Handle<Value> GLESglIsEnabledCallback(const Arguments& args) {
//if less that nbr of formal parameters then throw exception
if (args.Length() != 1 || !args[0]->IsUint32())
return ThrowException(String::New("Bad arguments"));
//get arguments
unsigned int arg0 = args[0]->Uint32Value();
//make call
return Uint32::New(glIsEnabled((GLenum) arg0));
}
Handle<Value> GLESglIsFramebufferCallback(const Arguments& args) {
//if less that nbr of formal parameters then throw exception
if (args.Length() != 1 || !args[0]->IsUint32())
return ThrowException(String::New("Bad arguments"));
//get arguments
unsigned int arg0 = args[0]->Uint32Value();
//make call
return Uint32::New(glIsFramebuffer((GLuint) arg0));
}
Handle<Value> GLESglIsProgramCallback(const Arguments& args) {
//if less that nbr of formal parameters then throw exception
if (args.Length() != 1 || !args[0]->IsUint32())
return ThrowException(String::New("Bad arguments"));
//get arguments
unsigned int arg0 = args[0]->Uint32Value();
//make call
return Uint32::New(glIsProgram((GLuint) arg0));
}
Handle<Value> GLESglIsRenderbufferCallback(const Arguments& args) {
//if less that nbr of formal parameters then throw exception
if (args.Length() != 1 || !args[0]->IsUint32())
return ThrowException(String::New("Bad arguments"));
//get arguments
unsigned int arg0 = args[0]->Uint32Value();
//make call
return Uint32::New(glIsRenderbuffer((GLuint) arg0));
}
Handle<Value> GLESglIsShaderCallback(const Arguments& args) {
//if less that nbr of formal parameters then throw exception
if (args.Length() != 1 || !args[0]->IsUint32())
return ThrowException(String::New("Bad arguments"));
//get arguments
unsigned int arg0 = args[0]->Uint32Value();
//make call
return Uint32::New(glIsShader((GLuint) arg0));
}
Handle<Value> GLESglIsTextureCallback(const Arguments& args) {
//if less that nbr of formal parameters then throw exception
if (args.Length() != 1 || !args[0]->IsUint32())
return ThrowException(String::New("Bad arguments"));
//get arguments
unsigned int arg0 = args[0]->Uint32Value();
//make call
return Uint32::New(glIsTexture((GLuint) arg0));
}
Handle<Value> GLESglLineWidthCallback(const Arguments& args) {
//if less that nbr of formal parameters then do nothing
if (args.Length() < 1) return ThrowException(String::New("Bad arguments"));
//get arguments
double arg0 = args[0]->NumberValue();
//make call
glLineWidth((GLfloat) arg0);
Handle<Object> res(GlesFactory::self_);
return res;
}
Handle<Value> GLESglLinkProgramCallback(const Arguments& args) {
//if less that nbr of formal parameters then throw exception
if (args.Length() != 1 || !args[0]->IsUint32())
return ThrowException(String::New("Bad arguments"));
//get arguments
unsigned int arg0 = args[0]->Uint32Value();
//make call
glLinkProgram((GLuint) arg0);
Handle<Object> res(GlesFactory::self_);
return res;
}
Handle<Value> GLESglPixelStoreiCallback(const Arguments& args) {
//if less that nbr of formal parameters then do nothing
if (args.Length() < 2) return ThrowException(String::New("Bad arguments"));
//get arguments
unsigned int arg0 = args[0]->Uint32Value();
int arg1 = args[1]->IntegerValue();
//make call
glPixelStorei((GLenum) arg0, (GLint) arg1);
Handle<Object> res(GlesFactory::self_);
return res;
}
Handle<Value> GLESglPolygonOffsetCallback(const Arguments& args) {
//if less that nbr of formal parameters then do nothing
if (args.Length() < 2) return ThrowException(String::New("Bad arguments"));
//get arguments
double arg0 = args[0]->NumberValue();
double arg1 = args[1]->NumberValue();
//make call
glPolygonOffset((GLfloat) arg0, (GLfloat) arg1);
Handle<Object> res(GlesFactory::self_);
return res;
}
Handle<Value> GLESglRenderbufferStorageCallback(const Arguments& args) {
//if less that nbr of formal parameters then do nothing
if (args.Length() < 4) return ThrowException(String::New("Bad arguments"));
//get arguments
unsigned int arg0 = args[0]->Uint32Value();
unsigned int arg1 = args[1]->Uint32Value();
int arg2 = args[2]->IntegerValue();
int arg3 = args[3]->IntegerValue();
//make call
glRenderbufferStorage((GLenum) arg0, (GLenum) arg1, (GLsizei) arg2, (GLsizei) arg3);
Handle<Object> res(GlesFactory::self_);
return res;
}
Handle<Value> GLESglSampleCoverageCallback(const Arguments& args) {
//if less that nbr of formal parameters then do nothing
if (args.Length() < 2) return ThrowException(String::New("Bad arguments"));
//get arguments
double arg0 = args[0]->NumberValue();
unsigned int arg1 = args[1]->Uint32Value();
//make call
glSampleCoverage((GLclampf) arg0, (GLboolean) arg1);
Handle<Object> res(GlesFactory::self_);
return res;
}
Handle<Value> GLESglScissorCallback(const Arguments& args) {
//if less that nbr of formal parameters then do nothing
if (args.Length() < 4) return ThrowException(String::New("Bad arguments"));
//get arguments
int arg0 = args[0]->IntegerValue();
int arg1 = args[1]->IntegerValue();
int arg2 = args[2]->IntegerValue();
int arg3 = args[3]->IntegerValue();
//make call
glScissor((GLint) arg0, (GLint) arg1, (GLsizei) arg2, (GLsizei) arg3);
Handle<Object> res(GlesFactory::self_);
return res;
}
Handle<Value> GLESglStencilFuncCallback(const Arguments& args) {
//if less that nbr of formal parameters then do nothing
if (args.Length() < 3) return ThrowException(String::New("Bad arguments"));
//get arguments
unsigned int arg0 = args[0]->Uint32Value();
int arg1 = args[1]->IntegerValue();
unsigned int arg2 = args[2]->Uint32Value();
//make call
glStencilFunc((GLenum) arg0, (GLint) arg1, (GLuint) arg2);
Handle<Object> res(GlesFactory::self_);
return res;
}
Handle<Value> GLESglStencilFuncSeparateCallback(const Arguments& args) {
//if less that nbr of formal parameters then do nothing
if (args.Length() < 4) return ThrowException(String::New("Bad arguments"));
//get arguments
unsigned int arg0 = args[0]->Uint32Value();
unsigned int arg1 = args[1]->Uint32Value();
int arg2 = args[2]->IntegerValue();
unsigned int arg3 = args[3]->Uint32Value();
//make call
glStencilFuncSeparate((GLenum) arg0, (GLenum) arg1, (GLint) arg2, (GLuint) arg3);
Handle<Object> res(GlesFactory::self_);
return res;
}
Handle<Value> GLESglStencilMaskCallback(const Arguments& args) {
//if less that nbr of formal parameters then throw exception
if (args.Length() != 1 || !args[0]->IsNumber())
return ThrowException(String::New("Bad arguments"));
//get arguments
unsigned int arg0 = args[0]->Uint32Value();
//make call
glStencilMask((GLuint) arg0);
Handle<Object> res(GlesFactory::self_);
return res;
}
Handle<Value> GLESglStencilMaskSeparateCallback(const Arguments& args) {
//if less that nbr of formal parameters then do nothing
if (args.Length() < 2) return ThrowException(String::New("Bad arguments"));
//get arguments
unsigned int arg0 = args[0]->Uint32Value();
unsigned int arg1 = args[1]->Uint32Value();
//make call
glStencilMaskSeparate((GLenum) arg0, (GLuint) arg1);
Handle<Object> res(GlesFactory::self_);
return res;
}
Handle<Value> GLESglStencilOpCallback(const Arguments& args) {
//if less that nbr of formal parameters then do nothing
if (args.Length() < 3) return ThrowException(String::New("Bad arguments"));
//get arguments
unsigned int arg0 = args[0]->Uint32Value();
unsigned int arg1 = args[1]->Uint32Value();
unsigned int arg2 = args[2]->Uint32Value();
//make call
glStencilOp((GLenum) arg0, (GLenum) arg1, (GLenum) arg2);
Handle<Object> res(GlesFactory::self_);
return res;
}
Handle<Value> GLESglStencilOpSeparateCallback(const Arguments& args) {
//if less that nbr of formal parameters then do nothing
if (args.Length() < 4) return ThrowException(String::New("Bad arguments"));
//get arguments
unsigned int arg0 = args[0]->Uint32Value();
unsigned int arg1 = args[1]->Uint32Value();
unsigned int arg2 = args[2]->Uint32Value();
unsigned int arg3 = args[3]->Uint32Value();
//make call
glStencilOpSeparate((GLenum) arg0, (GLenum) arg1, (GLenum) arg2, (GLenum) arg3);
Handle<Object> res(GlesFactory::self_);
return res;
}
Handle<Value> GLESglTexParameterfCallback(const Arguments& args) {
//if less that nbr of formal parameters then do nothing
if (args.Length() < 3) return ThrowException(String::New("Bad arguments"));
//get arguments
unsigned int arg0 = args[0]->Uint32Value();
unsigned int arg1 = args[1]->Uint32Value();
double arg2 = args[2]->NumberValue();
//make call
glTexParameterf((GLenum) arg0, (GLenum) arg1, (GLfloat) arg2);
Handle<Object> res(GlesFactory::self_);
return res;
}
Handle<Value> GLESglTexParameterfvCallback(const Arguments& args) {
//if less that nbr of formal parameters then do nothing
if (args.Length() < 3) return ThrowException(String::New("Bad arguments"));
//get arguments
unsigned int arg0 = args[0]->Uint32Value();
unsigned int arg1 = args[1]->Uint32Value();
Handle<Array> arrHandle2 = Handle<Array>::Cast(args[2]);
GLfloat* arg2 = new GLfloat[arrHandle2->Length()];
for (unsigned j = 0; j < arrHandle2->Length(); j++) {
Handle<Value> arg(arrHandle2->Get(Integer::New(j)));
GLfloat aux = ( GLfloat)arg->NumberValue();
arg2[j] = aux;
}
//make call
glTexParameterfv((GLenum) arg0, (GLenum) arg1, (const GLfloat*) arg2);
Handle<Object> res(GlesFactory::self_);
return res;
}
Handle<Value> GLESglTexParameteriCallback(const Arguments& args) {
//if less that nbr of formal parameters then do nothing
if (args.Length() < 3) return ThrowException(String::New("Bad arguments"));
//get arguments
unsigned int arg0 = args[0]->Uint32Value();
unsigned int arg1 = args[1]->Uint32Value();
int arg2 = args[2]->IntegerValue();
//make call
glTexParameteri((GLenum) arg0, (GLenum) arg1, (GLint) arg2);
Handle<Object> res(GlesFactory::self_);
return res;
}
Handle<Value> GLESglTexParameterivCallback(const Arguments& args) {
//if less that nbr of formal parameters then do nothing
if (args.Length() < 3) return ThrowException(String::New("Bad arguments"));
//get arguments
unsigned int arg0 = args[0]->Uint32Value();
unsigned int arg1 = args[1]->Uint32Value();
Handle<Array> arrHandle2 = Handle<Array>::Cast(args[2]);
GLint* arg2 = new GLint[arrHandle2->Length()];
for (unsigned j = 0; j < arrHandle2->Length(); j++) {
Handle<Value> arg(arrHandle2->Get(Integer::New(j)));
GLint aux = ( GLint)arg->IntegerValue();
arg2[j] = aux;
}
//make call
glTexParameteriv((GLenum) arg0, (GLenum) arg1, (const GLint*) arg2);
Handle<Object> res(GlesFactory::self_);
return res;
}
Handle<Value> GLESglUniform1fCallback(const Arguments& args) {
//if less that nbr of formal parameters then do nothing
if (args.Length() < 2) return ThrowException(String::New("Bad arguments"));
//get arguments
int arg0 = args[0]->IntegerValue();
double arg1 = args[1]->NumberValue();
//make call
glUniform1f((GLint) arg0, (GLfloat) arg1);
Handle<Object> res(GlesFactory::self_);
return res;
}
Handle<Value> GLESglUniform1fvCallback(const Arguments& args) {
//if less that nbr of formal parameters then do nothing
if (args.Length() < 2 || !args[0]->IsUint32() || !args[1]->IsObject())
return ThrowException(String::New("Bad arguments"));
//get arguments
unsigned int location = args[0]->Uint32Value();
Handle<Object> value = Handle<Object>::Cast(args[1]);
const unsigned VECTOR_SIZE = 1;
GLfloat *data;
unsigned count;
if (value->IsArray()) {
Handle<Array> arrHandle = Handle<Array>::Cast(value);
count = arrHandle->Length() / VECTOR_SIZE;
if ((count * VECTOR_SIZE) != arrHandle->Length())
return ThrowException(String::New("Value array is wrong size"));
data = new GLfloat[count * VECTOR_SIZE];
for (unsigned j = 0; j < (count * VECTOR_SIZE); j++) {
Handle<Value> arg(arrHandle->Get(Integer::New(j)));
GLfloat aux = ( GLfloat)arg->NumberValue();
data[j] = aux;
}
} else if (value->HasIndexedPropertiesInExternalArrayData() &&
value->GetIndexedPropertiesExternalArrayDataType() ==
kExternalFloatArray) {
data = (GLfloat *) value->GetIndexedPropertiesExternalArrayData();
count = value->GetIndexedPropertiesExternalArrayDataLength() / VECTOR_SIZE;
if ((count * VECTOR_SIZE) !=
value->GetIndexedPropertiesExternalArrayDataLength())
return ThrowException(String::New("Value array is wrong size"));
} else {
return ThrowException(String::New("Bad type for value argument"));
}
//make call
glUniform1fv((GLint) location, (GLsizei) count,
(const GLfloat*) data);
Handle<Object> res(GlesFactory::self_);
return res;
}
Handle<Value> GLESglUniform1iCallback(const Arguments& args) {
//if less that nbr of formal parameters then do nothing
if (args.Length() < 2) return ThrowException(String::New("Bad arguments"));
//get arguments
int arg0 = args[0]->IntegerValue();
int arg1 = args[1]->IntegerValue();
//make call
glUniform1i((GLint) arg0, (GLint) arg1);
Handle<Object> res(GlesFactory::self_);
return res;
}
Handle<Value> GLESglUniform1ivCallback(const Arguments& args) {
//if less that nbr of formal parameters then do nothing
if (args.Length() < 3) return ThrowException(String::New("Bad arguments"));
//get arguments
int arg0 = args[0]->IntegerValue();
int arg1 = args[1]->IntegerValue();
Handle<Array> arrHandle2 = Handle<Array>::Cast(args[2]);
GLint* arg2 = new GLint[arrHandle2->Length()];
for (unsigned j = 0; j < arrHandle2->Length(); j++) {
Handle<Value> arg(arrHandle2->Get(Integer::New(j)));
GLint aux = ( GLint)arg->IntegerValue();
arg2[j] = aux;
}
//make call
glUniform1iv((GLint) arg0, (GLsizei) arg1, (const GLint*) arg2);
Handle<Object> res(GlesFactory::self_);
return res;
}
Handle<Value> GLESglUniform2fCallback(const Arguments& args) {
//if less that nbr of formal parameters then do nothing
if (args.Length() < 3) return ThrowException(String::New("Bad arguments"));
//get arguments
int arg0 = args[0]->IntegerValue();
double arg1 = args[1]->NumberValue();
double arg2 = args[2]->NumberValue();
//make call
glUniform2f((GLint) arg0, (GLfloat) arg1, (GLfloat) arg2);
Handle<Object> res(GlesFactory::self_);
return res;
}
Handle<Value> GLESglUniform2fvCallback(const Arguments& args) {
//if less that nbr of formal parameters then do nothing
if (args.Length() < 2 || !args[0]->IsUint32() || !args[1]->IsObject())
return ThrowException(String::New("Bad arguments"));
//get arguments
unsigned int location = args[0]->Uint32Value();
Handle<Object> value = Handle<Object>::Cast(args[1]);
const unsigned VECTOR_SIZE = 2;
GLfloat *data;
unsigned count;
if (value->IsArray()) {
Handle<Array> arrHandle = Handle<Array>::Cast(value);
count = arrHandle->Length() / VECTOR_SIZE;
if ((count * VECTOR_SIZE) != arrHandle->Length())
return ThrowException(String::New("Value array is wrong size"));
data = new GLfloat[count * VECTOR_SIZE];
for (unsigned j = 0; j < (count * VECTOR_SIZE); j++) {
Handle<Value> arg(arrHandle->Get(Integer::New(j)));
GLfloat aux = ( GLfloat)arg->NumberValue();
data[j] = aux;
}
} else if (value->HasIndexedPropertiesInExternalArrayData() &&
value->GetIndexedPropertiesExternalArrayDataType() ==
kExternalFloatArray) {
data = (GLfloat *) value->GetIndexedPropertiesExternalArrayData();
count = value->GetIndexedPropertiesExternalArrayDataLength() / VECTOR_SIZE;
if ((count * VECTOR_SIZE) !=
value->GetIndexedPropertiesExternalArrayDataLength())
return ThrowException(String::New("Value array is wrong size"));
} else {
return ThrowException(String::New("Bad type for value argument"));
}
//make call
glUniform2fv((GLint) location, (GLsizei) count,
(const GLfloat*) data);
Handle<Object> res(GlesFactory::self_);
return res;
}
Handle<Value> GLESglUniform2iCallback(const Arguments& args) {
//if less that nbr of formal parameters then do nothing
if (args.Length() < 3) return ThrowException(String::New("Bad arguments"));
//get arguments
int arg0 = args[0]->IntegerValue();
int arg1 = args[1]->IntegerValue();
int arg2 = args[2]->IntegerValue();
//make call
glUniform2i((GLint) arg0, (GLint) arg1, (GLint) arg2);
Handle<Object> res(GlesFactory::self_);
return res;
}
Handle<Value> GLESglUniform2ivCallback(const Arguments& args) {
//if less that nbr of formal parameters then do nothing
if (args.Length() < 3) return ThrowException(String::New("Bad arguments"));
//get arguments
int arg0 = args[0]->IntegerValue();
int arg1 = args[1]->IntegerValue();
Handle<Array> arrHandle2 = Handle<Array>::Cast(args[2]);
GLint* arg2 = new GLint[arrHandle2->Length()];
for (unsigned j = 0; j < arrHandle2->Length(); j++) {
Handle<Value> arg(arrHandle2->Get(Integer::New(j)));
GLint aux = ( GLint)arg->IntegerValue();
arg2[j] = aux;
}
//make call
glUniform2iv((GLint) arg0, (GLsizei) arg1, (const GLint*) arg2);
Handle<Object> res(GlesFactory::self_);
return res;
}
Handle<Value> GLESglUniform3fCallback(const Arguments& args) {
//if less that nbr of formal parameters then do nothing
if (args.Length() < 4) return ThrowException(String::New("Bad arguments"));
//get arguments
int arg0 = args[0]->IntegerValue();
double arg1 = args[1]->NumberValue();
double arg2 = args[2]->NumberValue();
double arg3 = args[3]->NumberValue();
//make call
glUniform3f((GLint) arg0, (GLfloat) arg1, (GLfloat) arg2, (GLfloat) arg3);
Handle<Object> res(GlesFactory::self_);
return res;
}
Handle<Value> GLESglUniform3fvCallback(const Arguments& args) {
//if less that nbr of formal parameters then do nothing
if (args.Length() < 2 || !args[0]->IsUint32() || !args[1]->IsObject())
return ThrowException(String::New("Bad arguments"));
//get arguments
unsigned int location = args[0]->Uint32Value();
Handle<Object> value = Handle<Object>::Cast(args[1]);
const unsigned VECTOR_SIZE = 3;
GLfloat *data;
unsigned count;
if (value->IsArray()) {
Handle<Array> arrHandle = Handle<Array>::Cast(value);
count = arrHandle->Length() / VECTOR_SIZE;
if ((count * VECTOR_SIZE) != arrHandle->Length())
return ThrowException(String::New("Value array is wrong size"));
data = new GLfloat[count * VECTOR_SIZE];
for (unsigned j = 0; j < (count * VECTOR_SIZE); j++) {
Handle<Value> arg(arrHandle->Get(Integer::New(j)));
GLfloat aux = ( GLfloat)arg->NumberValue();
data[j] = aux;
}
} else if (value->HasIndexedPropertiesInExternalArrayData() &&
value->GetIndexedPropertiesExternalArrayDataType() ==
kExternalFloatArray) {
data = (GLfloat *) value->GetIndexedPropertiesExternalArrayData();
count = value->GetIndexedPropertiesExternalArrayDataLength() / VECTOR_SIZE;
if ((count * VECTOR_SIZE) !=
value->GetIndexedPropertiesExternalArrayDataLength())
return ThrowException(String::New("Value array is wrong size"));
} else {
return ThrowException(String::New("Bad type for value argument"));
}
//make call
glUniform3fv((GLint) location, (GLsizei) count,
(const GLfloat*) data);
Handle<Object> res(GlesFactory::self_);
return res;
}
Handle<Value> GLESglUniform3iCallback(const Arguments& args) {
//if less that nbr of formal parameters then do nothing
if (args.Length() < 4) return ThrowException(String::New("Bad arguments"));
//get arguments
int arg0 = args[0]->IntegerValue();
int arg1 = args[1]->IntegerValue();
int arg2 = args[2]->IntegerValue();
int arg3 = args[3]->IntegerValue();
//make call
glUniform3i((GLint) arg0, (GLint) arg1, (GLint) arg2, (GLint) arg3);
Handle<Object> res(GlesFactory::self_);
return res;
}
Handle<Value> GLESglUniform3ivCallback(const Arguments& args) {
//if less that nbr of formal parameters then do nothing
if (args.Length() < 3) return ThrowException(String::New("Bad arguments"));
//get arguments
int arg0 = args[0]->IntegerValue();
int arg1 = args[1]->IntegerValue();
Handle<Array> arrHandle2 = Handle<Array>::Cast(args[2]);
GLint* arg2 = new GLint[arrHandle2->Length()];
for (unsigned j = 0; j < arrHandle2->Length(); j++) {
Handle<Value> arg(arrHandle2->Get(Integer::New(j)));
GLint aux = ( GLint)arg->IntegerValue();
arg2[j] = aux;
}
//make call
glUniform3iv((GLint) arg0, (GLsizei) arg1, (const GLint*) arg2);
Handle<Object> res(GlesFactory::self_);
return res;
}
Handle<Value> GLESglUniform4fCallback(const Arguments& args) {
//if less that nbr of formal parameters then do nothing
if (args.Length() < 5) return ThrowException(String::New("Bad arguments"));
//get arguments
int arg0 = args[0]->IntegerValue();
double arg1 = args[1]->NumberValue();
double arg2 = args[2]->NumberValue();
double arg3 = args[3]->NumberValue();
double arg4 = args[4]->NumberValue();
//make call
glUniform4f((GLint) arg0, (GLfloat) arg1, (GLfloat) arg2, (GLfloat) arg3, (GLfloat) arg4);
Handle<Object> res(GlesFactory::self_);
return res;
}
Handle<Value> GLESglUniform4fvCallback(const Arguments& args) {
//if less that nbr of formal parameters then do nothing
if (args.Length() < 2 || !args[0]->IsUint32() || !args[1]->IsObject())
return ThrowException(String::New("Bad arguments"));
//get arguments
unsigned int location = args[0]->Uint32Value();
Handle<Object> value = Handle<Object>::Cast(args[1]);
const unsigned VECTOR_SIZE = 4;
GLfloat *data;
unsigned count;
if (value->IsArray()) {
Handle<Array> arrHandle = Handle<Array>::Cast(value);
count = arrHandle->Length() / VECTOR_SIZE;
if ((count * VECTOR_SIZE) != arrHandle->Length())
return ThrowException(String::New("Value array is wrong size"));
data = new GLfloat[count * VECTOR_SIZE];
for (unsigned j = 0; j < (count * VECTOR_SIZE); j++) {
Handle<Value> arg(arrHandle->Get(Integer::New(j)));
GLfloat aux = ( GLfloat)arg->NumberValue();
data[j] = aux;
}
} else if (value->HasIndexedPropertiesInExternalArrayData() &&
value->GetIndexedPropertiesExternalArrayDataType() ==
kExternalFloatArray) {
data = (GLfloat *) value->GetIndexedPropertiesExternalArrayData();
count = value->GetIndexedPropertiesExternalArrayDataLength() / VECTOR_SIZE;
if ((count * VECTOR_SIZE) !=
value->GetIndexedPropertiesExternalArrayDataLength())
return ThrowException(String::New("Value array is wrong size"));
} else {
return ThrowException(String::New("Bad type for value argument"));
}
//make call
glUniform4fv((GLint) location, (GLsizei) count,
(const GLfloat*) data);
Handle<Object> res(GlesFactory::self_);
return res;
}
Handle<Value> GLESglUniform4iCallback(const Arguments& args) {
//if less that nbr of formal parameters then do nothing
if (args.Length() < 5) return ThrowException(String::New("Bad arguments"));
//get arguments
int arg0 = args[0]->IntegerValue();
int arg1 = args[1]->IntegerValue();
int arg2 = args[2]->IntegerValue();
int arg3 = args[3]->IntegerValue();
int arg4 = args[4]->IntegerValue();
//make call
glUniform4i((GLint) arg0, (GLint) arg1, (GLint) arg2, (GLint) arg3, (GLint) arg4);
Handle<Object> res(GlesFactory::self_);
return res;
}
Handle<Value> GLESglUniform4ivCallback(const Arguments& args) {
//if less that nbr of formal parameters then do nothing
if (args.Length() < 3) return ThrowException(String::New("Bad arguments"));
//get arguments
int arg0 = args[0]->IntegerValue();
int arg1 = args[1]->IntegerValue();
Handle<Array> arrHandle2 = Handle<Array>::Cast(args[2]);
GLint* arg2 = new GLint[arrHandle2->Length()];
for (unsigned j = 0; j < arrHandle2->Length(); j++) {
Handle<Value> arg(arrHandle2->Get(Integer::New(j)));
GLint aux = ( GLint)arg->IntegerValue();
arg2[j] = aux;
}
//make call
glUniform4iv((GLint) arg0, (GLsizei) arg1, (const GLint*) arg2);
Handle<Object> res(GlesFactory::self_);
return res;
}
Handle<Value> GLESglUniformMatrix2fvCallback(const Arguments& args) {
//if less that nbr of formal parameters then do nothing
if (args.Length() < 3 || !args[0]->IsUint32() ||
!(args[1]->IsBoolean() || args[1]->IsUint32()) ||
!args[2]->IsObject())
return ThrowException(String::New("Bad arguments"));
//get arguments
unsigned int location = args[0]->Uint32Value();
bool transpose = args[1]->BooleanValue();
Handle<Object> value = Handle<Object>::Cast(args[2]);
const unsigned MATRIX_SIZE = 4; // 2x2 matrix
GLfloat *data;
unsigned count;
if (value->IsArray()) {
Handle<Array> arrHandle = Handle<Array>::Cast(value);
count = arrHandle->Length() / MATRIX_SIZE;
if ((count * MATRIX_SIZE) != arrHandle->Length())
return ThrowException(String::New("Value array is wrong size"));
data = new GLfloat[count * MATRIX_SIZE];
for (unsigned j = 0; j < (count * MATRIX_SIZE); j++) {
Handle<Value> arg(arrHandle->Get(Integer::New(j)));
GLfloat aux = ( GLfloat)arg->NumberValue();
data[j] = aux;
}
} else if (value->HasIndexedPropertiesInExternalArrayData() &&
value->GetIndexedPropertiesExternalArrayDataType() ==
kExternalFloatArray) {
data = (GLfloat *) value->GetIndexedPropertiesExternalArrayData();
count = value->GetIndexedPropertiesExternalArrayDataLength() / MATRIX_SIZE;
if ((count * MATRIX_SIZE) !=
value->GetIndexedPropertiesExternalArrayDataLength())
return ThrowException(String::New("Value array is wrong size"));
} else {
return ThrowException(String::New("Bad type for value argument"));
}
//make call
glUniformMatrix2fv((GLint) location, (GLsizei) count,
(GLboolean) transpose, (const GLfloat*) data);
Handle<Object> res(GlesFactory::self_);
return res;
}
Handle<Value> GLESglUniformMatrix3fvCallback(const Arguments& args) {
//if less that nbr of formal parameters then do nothing
if (args.Length() < 3 || !args[0]->IsUint32() ||
!(args[1]->IsBoolean() || args[1]->IsUint32()) ||
!args[2]->IsObject())
return ThrowException(String::New("Bad arguments"));
//get arguments
unsigned int location = args[0]->Uint32Value();
bool transpose = args[1]->BooleanValue();
Handle<Object> value = Handle<Object>::Cast(args[2]);
const unsigned MATRIX_SIZE = 9; // 3x3 matrix
GLfloat *data;
unsigned count;
if (value->IsArray()) {
Handle<Array> arrHandle = Handle<Array>::Cast(value);
count = arrHandle->Length() / MATRIX_SIZE;
if ((count * MATRIX_SIZE) != arrHandle->Length())
return ThrowException(String::New("Value array is wrong size"));
data = new GLfloat[count * MATRIX_SIZE];
for (unsigned j = 0; j < (count * MATRIX_SIZE); j++) {
Handle<Value> arg(arrHandle->Get(Integer::New(j)));
GLfloat aux = ( GLfloat)arg->NumberValue();
data[j] = aux;
}
} else if (value->HasIndexedPropertiesInExternalArrayData() &&
value->GetIndexedPropertiesExternalArrayDataType() ==
kExternalFloatArray) {
data = (GLfloat *) value->GetIndexedPropertiesExternalArrayData();
count = value->GetIndexedPropertiesExternalArrayDataLength() / MATRIX_SIZE;
if ((count * MATRIX_SIZE) !=
value->GetIndexedPropertiesExternalArrayDataLength())
return ThrowException(String::New("Value array is wrong size"));
} else {
return ThrowException(String::New("Bad type for value argument"));
}
//make call
glUniformMatrix3fv((GLint) location, (GLsizei) count,
(GLboolean) transpose, (const GLfloat*) data);
Handle<Object> res(GlesFactory::self_);
return res;
}
Handle<Value> GLESglUniformMatrix4fvCallback(const Arguments& args) {
//if less that nbr of formal parameters then do nothing
if (args.Length() < 3 || !args[0]->IsUint32() ||
!(args[1]->IsBoolean() || args[1]->IsUint32()) ||
!args[2]->IsObject())
return ThrowException(String::New("Bad arguments"));
//get arguments
unsigned int location = args[0]->Uint32Value();
bool transpose = args[1]->BooleanValue();
Handle<Object> value = Handle<Object>::Cast(args[2]);
const unsigned MATRIX_SIZE = 16; // 4x4 matrix
GLfloat *data;
unsigned count;
if (value->IsArray()) {
Handle<Array> arrHandle = Handle<Array>::Cast(value);
count = arrHandle->Length() / MATRIX_SIZE;
if ((count * MATRIX_SIZE) != arrHandle->Length())
return ThrowException(String::New("Value array is wrong size"));
data = new GLfloat[count * MATRIX_SIZE];
for (unsigned j = 0; j < (count * MATRIX_SIZE); j++) {
Handle<Value> arg(arrHandle->Get(Integer::New(j)));
GLfloat aux = ( GLfloat)arg->NumberValue();
data[j] = aux;
}
} else if (value->HasIndexedPropertiesInExternalArrayData() &&
value->GetIndexedPropertiesExternalArrayDataType() ==
kExternalFloatArray) {
data = (GLfloat *) value->GetIndexedPropertiesExternalArrayData();
count = value->GetIndexedPropertiesExternalArrayDataLength() / MATRIX_SIZE;
if ((count * MATRIX_SIZE) !=
value->GetIndexedPropertiesExternalArrayDataLength())
return ThrowException(String::New("Value array is wrong size"));
} else {
return ThrowException(String::New("Bad type for value argument"));
}
//make call
glUniformMatrix4fv((GLint) location, (GLsizei) count,
(GLboolean) transpose, (const GLfloat*) data);
Handle<Object> res(GlesFactory::self_);
return res;
}
Handle<Value> GLESglUseProgramCallback(const Arguments& args) {
//if less that nbr of formal parameters then throw exception
if (args.Length() != 1 || !args[0]->IsUint32())
return ThrowException(String::New("Bad arguments"));
//get arguments
unsigned int arg0 = args[0]->Uint32Value();
//make call
glUseProgram((GLuint) arg0);
Handle<Object> res(GlesFactory::self_);
return res;
}
Handle<Value> GLESglValidateProgramCallback(const Arguments& args) {
//if less that nbr of formal parameters then throw exception
if (args.Length() != 1 || !args[0]->IsUint32())
return ThrowException(String::New("Bad arguments"));
//get arguments
unsigned int arg0 = args[0]->Uint32Value();
//make call
glValidateProgram((GLuint) arg0);
Handle<Object> res(GlesFactory::self_);
return res;
}
Handle<Value> GLESglVertexAttrib1fCallback(const Arguments& args) {
//if less that nbr of formal parameters then do nothing
if (args.Length() < 2) return ThrowException(String::New("Bad arguments"));
//get arguments
unsigned int arg0 = args[0]->Uint32Value();
double arg1 = args[1]->NumberValue();
//make call
glVertexAttrib1f((GLuint) arg0, (GLfloat) arg1);
Handle<Object> res(GlesFactory::self_);
return res;
}
Handle<Value> GLESglVertexAttrib1fvCallback(const Arguments& args) {
//if less that nbr of formal parameters then do nothing
if (args.Length() < 2) return ThrowException(String::New("Bad arguments"));
//get arguments
unsigned int arg0 = args[0]->Uint32Value();
Handle<Array> arrHandle1 = Handle<Array>::Cast(args[1]);
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();
arg1[j] = aux;
}
//make call
glVertexAttrib1fv((GLuint) arg0, (const GLfloat*) arg1);
Handle<Object> res(GlesFactory::self_);
return res;
}
Handle<Value> GLESglVertexAttrib2fCallback(const Arguments& args) {
//if less that nbr of formal parameters then do nothing
if (args.Length() < 3) return ThrowException(String::New("Bad arguments"));
//get arguments
unsigned int arg0 = args[0]->Uint32Value();
double arg1 = args[1]->NumberValue();
double arg2 = args[2]->NumberValue();
//make call
glVertexAttrib2f((GLuint) arg0, (GLfloat) arg1, (GLfloat) arg2);
Handle<Object> res(GlesFactory::self_);
return res;
}
Handle<Value> GLESglVertexAttrib2fvCallback(const Arguments& args) {
//if less that nbr of formal parameters then do nothing
if (args.Length() < 2) return ThrowException(String::New("Bad arguments"));
//get arguments
unsigned int arg0 = args[0]->Uint32Value();
Handle<Array> arrHandle1 = Handle<Array>::Cast(args[1]);
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();
arg1[j] = aux;
}
//make call
glVertexAttrib2fv((GLuint) arg0, (const GLfloat*) arg1);
Handle<Object> res(GlesFactory::self_);
return res;
}
Handle<Value> GLESglVertexAttrib3fCallback(const Arguments& args) {
//if less that nbr of formal parameters then do nothing
if (args.Length() < 4) return ThrowException(String::New("Bad arguments"));
//get arguments
unsigned int arg0 = args[0]->Uint32Value();
double arg1 = args[1]->NumberValue();
double arg2 = args[2]->NumberValue();
double arg3 = args[3]->NumberValue();
//make call
glVertexAttrib3f((GLuint) arg0, (GLfloat) arg1, (GLfloat) arg2, (GLfloat) arg3);
Handle<Object> res(GlesFactory::self_);
return res;
}
Handle<Value> GLESglVertexAttrib3fvCallback(const Arguments& args) {
//if less that nbr of formal parameters then do nothing
if (args.Length() != 2 || !args[0]->IsUint32() || !args[1]->IsArray())
return ThrowException(String::New("Bad arguments"));
//get arguments
unsigned int arg0 = args[0]->Uint32Value();
Handle<Array> arrHandle1 = Handle<Array>::Cast(args[1]);
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();
arg1[j] = aux;
}
//make call
glVertexAttrib3fv((GLuint) arg0, (const GLfloat*) arg1);
Handle<Object> res(GlesFactory::self_);
return res;
}
Handle<Value> GLESglVertexAttrib4fCallback(const Arguments& args) {
//if less that nbr of formal parameters then do nothing
if (args.Length() < 5) return ThrowException(String::New("Bad arguments"));
//get arguments
unsigned int arg0 = args[0]->Uint32Value();
double arg1 = args[1]->NumberValue();
double arg2 = args[2]->NumberValue();
double arg3 = args[3]->NumberValue();
double arg4 = args[4]->NumberValue();
//make call
glVertexAttrib4f((GLuint) arg0, (GLfloat) arg1, (GLfloat) arg2, (GLfloat) arg3, (GLfloat) arg4);
Handle<Object> res(GlesFactory::self_);
return res;
}
Handle<Value> GLESglVertexAttrib4fvCallback(const Arguments& args) {
//if less that nbr of formal parameters then do nothing
if (args.Length() != 2 || !args[0]->IsUint32() || !args[1]->IsArray())
return ThrowException(String::New("Bad arguments"));
//get arguments
unsigned int arg0 = args[0]->Uint32Value();
Handle<Array> arrHandle1 = Handle<Array>::Cast(args[1]);
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();
arg1[j] = aux;
}
//make call
glVertexAttrib4fv((GLuint) arg0, (const GLfloat*) arg1);
Handle<Object> res(GlesFactory::self_);
return res;
}
Handle<Value> GLESglViewportCallback(const Arguments& args) {
//if less that nbr of formal parameters then do nothing
if (args.Length() < 4) return ThrowException(String::New("Bad arguments"));
//get arguments
int arg0 = args[0]->IntegerValue();
int arg1 = args[1]->IntegerValue();
int arg2 = args[2]->IntegerValue();
int arg3 = args[3]->IntegerValue();
//make call
glViewport((GLint) arg0, (GLint) arg1, (GLsizei) arg2, (GLsizei) arg3);
Handle<Object> res(GlesFactory::self_);
return res;
}
Handle<ObjectTemplate> GlesFactory::createGles(void) {
HandleScope handle_scope;
Handle<ObjectTemplate> Gles = ObjectTemplate::New();
Gles->SetInternalFieldCount(1);
Gles->Set(String::NewSymbol("ES_VERSION_2_0"), Uint32::New(GL_ES_VERSION_2_0), ReadOnly);
Gles->Set(String::NewSymbol("DEPTH_BUFFER_BIT"), Uint32::New(GL_DEPTH_BUFFER_BIT), ReadOnly);
Gles->Set(String::NewSymbol("STENCIL_BUFFER_BIT"), Uint32::New(GL_STENCIL_BUFFER_BIT), ReadOnly);
Gles->Set(String::NewSymbol("COLOR_BUFFER_BIT"), Uint32::New(GL_COLOR_BUFFER_BIT), ReadOnly);
Gles->Set(String::NewSymbol("FALSE"), Uint32::New(GL_FALSE), ReadOnly);
Gles->Set(String::NewSymbol("TRUE"), Uint32::New(GL_TRUE), ReadOnly);
Gles->Set(String::NewSymbol("POINTS"), Uint32::New(GL_POINTS), ReadOnly);
Gles->Set(String::NewSymbol("LINES"), Uint32::New(GL_LINES), ReadOnly);
Gles->Set(String::NewSymbol("LINE_LOOP"), Uint32::New(GL_LINE_LOOP), ReadOnly);
Gles->Set(String::NewSymbol("LINE_STRIP"), Uint32::New(GL_LINE_STRIP), ReadOnly);
Gles->Set(String::NewSymbol("TRIANGLES"), Uint32::New(GL_TRIANGLES), ReadOnly);
Gles->Set(String::NewSymbol("TRIANGLE_STRIP"), Uint32::New(GL_TRIANGLE_STRIP), ReadOnly);
Gles->Set(String::NewSymbol("TRIANGLE_FAN"), Uint32::New(GL_TRIANGLE_FAN), ReadOnly);
Gles->Set(String::NewSymbol("ZERO"), Uint32::New(GL_ZERO), ReadOnly);
Gles->Set(String::NewSymbol("ONE"), Uint32::New(GL_ONE), ReadOnly);
Gles->Set(String::NewSymbol("SRC_COLOR"), Uint32::New(GL_SRC_COLOR), ReadOnly);
Gles->Set(String::NewSymbol("ONE_MINUS_SRC_COLOR"), Uint32::New(GL_ONE_MINUS_SRC_COLOR), ReadOnly);
Gles->Set(String::NewSymbol("SRC_ALPHA"), Uint32::New(GL_SRC_ALPHA), ReadOnly);
Gles->Set(String::NewSymbol("ONE_MINUS_SRC_ALPHA"), Uint32::New(GL_ONE_MINUS_SRC_ALPHA), ReadOnly);
Gles->Set(String::NewSymbol("DST_ALPHA"), Uint32::New(GL_DST_ALPHA), ReadOnly);
Gles->Set(String::NewSymbol("ONE_MINUS_DST_ALPHA"), Uint32::New(GL_ONE_MINUS_DST_ALPHA), ReadOnly);
Gles->Set(String::NewSymbol("DST_COLOR"), Uint32::New(GL_DST_COLOR), ReadOnly);
Gles->Set(String::NewSymbol("ONE_MINUS_DST_COLOR"), Uint32::New(GL_ONE_MINUS_DST_COLOR), ReadOnly);
Gles->Set(String::NewSymbol("SRC_ALPHA_SATURATE"), Uint32::New(GL_SRC_ALPHA_SATURATE), ReadOnly);
Gles->Set(String::NewSymbol("FUNC_ADD"), Uint32::New(GL_FUNC_ADD), ReadOnly);
Gles->Set(String::NewSymbol("BLEND_EQUATION"), Uint32::New(GL_BLEND_EQUATION), ReadOnly);
Gles->Set(String::NewSymbol("BLEND_EQUATION_RGB"), Uint32::New(GL_BLEND_EQUATION_RGB), ReadOnly);
Gles->Set(String::NewSymbol("BLEND_EQUATION_ALPHA"), Uint32::New(GL_BLEND_EQUATION_ALPHA), ReadOnly);
Gles->Set(String::NewSymbol("FUNC_SUBTRACT"), Uint32::New(GL_FUNC_SUBTRACT), ReadOnly);
Gles->Set(String::NewSymbol("FUNC_REVERSE_SUBTRACT"), Uint32::New(GL_FUNC_REVERSE_SUBTRACT), ReadOnly);
Gles->Set(String::NewSymbol("BLEND_DST_RGB"), Uint32::New(GL_BLEND_DST_RGB), ReadOnly);
Gles->Set(String::NewSymbol("BLEND_SRC_RGB"), Uint32::New(GL_BLEND_SRC_RGB), ReadOnly);
Gles->Set(String::NewSymbol("BLEND_DST_ALPHA"), Uint32::New(GL_BLEND_DST_ALPHA), ReadOnly);
Gles->Set(String::NewSymbol("BLEND_SRC_ALPHA"), Uint32::New(GL_BLEND_SRC_ALPHA), ReadOnly);
Gles->Set(String::NewSymbol("CONSTANT_COLOR"), Uint32::New(GL_CONSTANT_COLOR), ReadOnly);
Gles->Set(String::NewSymbol("ONE_MINUS_CONSTANT_COLOR"), Uint32::New(GL_ONE_MINUS_CONSTANT_COLOR), ReadOnly);
Gles->Set(String::NewSymbol("CONSTANT_ALPHA"), Uint32::New(GL_CONSTANT_ALPHA), ReadOnly);
Gles->Set(String::NewSymbol("ONE_MINUS_CONSTANT_ALPHA"), Uint32::New(GL_ONE_MINUS_CONSTANT_ALPHA), ReadOnly);
Gles->S