From 15e05b22afe910582a7ea55e2faad25501412349 Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 13 Aug 2014 13:59:54 -0600 Subject: [PATCH 1/2] Add OSMesaCreateContextExt wrapper method. --- src/bindings.cc | 1 + src/webgl.cc | 15 +++++++++++++++ src/webgl.h | 1 + 3 files changed, 17 insertions(+) diff --git a/src/bindings.cc b/src/bindings.cc index f4f983f..4de2220 100644 --- a/src/bindings.cc +++ b/src/bindings.cc @@ -17,6 +17,7 @@ void init(Handle target) atexit(webgl::AtExit); NODE_SET_METHOD(target, "CreateContext", webgl::CreateContext); + NODE_SET_METHOD(target, "CreateContextExt", webgl::CreateContextExt); NODE_SET_METHOD(target, "DestroyContext", webgl::DestroyContext); NODE_SET_METHOD(target, "MakeCurrent", webgl::MakeCurrent); diff --git a/src/webgl.cc b/src/webgl.cc index b173978..c6c237f 100644 --- a/src/webgl.cc +++ b/src/webgl.cc @@ -112,6 +112,21 @@ NAN_METHOD(CreateContext) { NanReturnValue(JS_INT((intptr_t)context)); } +NAN_METHOD(CreateContextExt) { + NanScope(); + + GLenum format = args[0]->Int32Value(); + GLint depthBits = args[1]->Int32Value(); + GLint stencilBits = args[2]->Int32Value(); + GLint accumBits = args[3]->Int32Value(); + OSMesaContext shareList = getOSMesaContext(args[4]); + + OSMesaContext context = OSMesaCreateContextExt(format, depthBits, stencilBits, accumBits, shareList); + std::cout << "CreateContextExt: " << context << std::endl; + + NanReturnValue(JS_INT((intptr_t)context)); +} + NAN_METHOD(DestroyContext) { NanScope(); diff --git a/src/webgl.h b/src/webgl.h index 8c09d23..a696aea 100644 --- a/src/webgl.h +++ b/src/webgl.h @@ -17,6 +17,7 @@ namespace webgl { void AtExit(); NAN_METHOD(CreateContext); +NAN_METHOD(CreateContextExt); NAN_METHOD(DestroyContext); NAN_METHOD(MakeCurrent); From 577aa8d5d6fbfea07c662d3bf9b064b1b30b7385 Mon Sep 17 00:00:00 2001 From: dan Date: Thu, 14 Aug 2014 01:43:52 -0600 Subject: [PATCH 2/2] Check for NULL shareList parameter. --- src/webgl.cc | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/webgl.cc b/src/webgl.cc index c6c237f..420ed1b 100644 --- a/src/webgl.cc +++ b/src/webgl.cc @@ -119,9 +119,15 @@ NAN_METHOD(CreateContextExt) { GLint depthBits = args[1]->Int32Value(); GLint stencilBits = args[2]->Int32Value(); GLint accumBits = args[3]->Int32Value(); - OSMesaContext shareList = getOSMesaContext(args[4]); - OSMesaContext context = OSMesaCreateContextExt(format, depthBits, stencilBits, accumBits, shareList); + OSMesaContext context; + if(args[4]->IsNull()) { + context = OSMesaCreateContextExt(format, depthBits, stencilBits, accumBits, NULL); + } else { + OSMesaContext shareList = getOSMesaContext(args[4]); + context = OSMesaCreateContextExt(format, depthBits, stencilBits, accumBits, shareList); + } + std::cout << "CreateContextExt: " << context << std::endl; NanReturnValue(JS_INT((intptr_t)context));