Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions binding/egl_context_wrapper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,11 @@

#include "egl_context_wrapper.h"

#include "utils.h"
#include <vector>

#include "angle/include/EGL/egl.h"
#include "angle/include/EGL/eglext.h"

#include <vector>
#include "utils.h"

namespace nodejsgl {

Expand Down Expand Up @@ -370,6 +369,8 @@ void EGLContextWrapper::BindProcAddresses() {
eglGetProcAddress("glStencilOpSeparate"));
glTexImage2D =
reinterpret_cast<PFNGLTEXIMAGE2DPROC>(eglGetProcAddress("glTexImage2D"));
glTexStorage2D = reinterpret_cast<PFNGLTEXSTORAGE2DPROC>(
eglGetProcAddress("glTexStorage2D"));
glTexParameteri = reinterpret_cast<PFNGLTEXPARAMETERIPROC>(
eglGetProcAddress("glTexParameteri"));
glTexParameterf = reinterpret_cast<PFNGLTEXPARAMETERFPROC>(
Expand Down
9 changes: 5 additions & 4 deletions binding/egl_context_wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@
// Use generated EGL includes from ANGLE:
#define EGL_EGL_PROTOTYPES 1

#include <iostream>
#include <memory>
#include <string>

#include "angle/include/EGL/egl.h"
#include "angle/include/GLES2/gl2.h"
#include "angle/include/GLES2/gl2ext.h"
#include "angle/include/GLES3/gl3.h"

#include <iostream>
#include <memory>
#include <string>

namespace nodejsgl {

// Provides initialization of EGL/GL context options.
Expand Down Expand Up @@ -193,6 +193,7 @@ class EGLContextWrapper {
PFNGLSTENCILMASKSEPARATEPROC glStencilMaskSeparate;
PFNGLSTENCILOPPROC glStencilOp;
PFNGLSTENCILOPSEPARATEPROC glStencilOpSeparate;
PFNGLTEXSTORAGE2DPROC glTexStorage2D;
PFNGLTEXIMAGE2DPROC glTexImage2D;
PFNGLTEXPARAMETERIPROC glTexParameteri;
PFNGLTEXPARAMETERFPROC glTexParameterf;
Expand Down
66 changes: 58 additions & 8 deletions binding/webgl_rendering_context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,18 @@

#include "webgl_rendering_context.h"

#include "utils.h"
#include "webgl_extensions.h"
#include "webgl_sync.h"

#include "angle/include/GLES2/gl2.h"
#include "angle/include/GLES3/gl3.h"
#include "angle/include/GLES3/gl32.h"

#include <cstring>
#include <iostream>
#include <string>
#include <vector>

#include "angle/include/GLES2/gl2.h"
#include "angle/include/GLES3/gl3.h"
#include "angle/include/GLES3/gl32.h"
#include "utils.h"
#include "webgl_extensions.h"
#include "webgl_sync.h"

namespace nodejsgl {

// Basic type to control what byte-width the ArrayLike buffer is for cleanup.
Expand Down Expand Up @@ -530,6 +529,7 @@ napi_status WebGLRenderingContext::Register(napi_env env, napi_value exports) {
NAPI_DEFINE_METHOD("stencilMaskSeparate", StencilMaskSeparate),
NAPI_DEFINE_METHOD("stencilOp", StencilOp),
NAPI_DEFINE_METHOD("stencilOpSeparate", StencilOpSeparate),
NAPI_DEFINE_METHOD("texStorage2D", TexStorage2D),
NAPI_DEFINE_METHOD("texImage2D", TexImage2D),
NAPI_DEFINE_METHOD("texParameteri", TexParameteri),
NAPI_DEFINE_METHOD("texParameterf", TexParameterf),
Expand Down Expand Up @@ -4004,6 +4004,56 @@ napi_value WebGLRenderingContext::Scissor(napi_env env,
return nullptr;
}

napi_value WebGLRenderingContext::TexStorage2D(napi_env env,
napi_callback_info info) {
LOG_CALL("TexStorage2D");

napi_status nstatus;

size_t argc = 5;
napi_value args[5];
napi_value js_this;
nstatus = napi_get_cb_info(env, info, &argc, args, &js_this, nullptr);
ENSURE_NAPI_OK_RETVAL(env, nstatus, nullptr);

ENSURE_VALUE_IS_NUMBER_RETVAL(env, args[0], nullptr);
ENSURE_VALUE_IS_NUMBER_RETVAL(env, args[1], nullptr);
ENSURE_VALUE_IS_NUMBER_RETVAL(env, args[2], nullptr);
ENSURE_VALUE_IS_NUMBER_RETVAL(env, args[3], nullptr);
ENSURE_VALUE_IS_NUMBER_RETVAL(env, args[4], nullptr);

GLenum target;
nstatus = napi_get_value_uint32(env, args[0], &target);
ENSURE_NAPI_OK_RETVAL(env, nstatus, nullptr);

GLsizei levels;
nstatus = napi_get_value_int32(env, args[1], &levels);
ENSURE_NAPI_OK_RETVAL(env, nstatus, nullptr);

GLenum internal_format;
nstatus = napi_get_value_uint32(env, args[2], &internal_format);
ENSURE_NAPI_OK_RETVAL(env, nstatus, nullptr);

GLsizei width;
nstatus = napi_get_value_int32(env, args[3], &width);
ENSURE_NAPI_OK_RETVAL(env, nstatus, nullptr);

GLsizei height;
nstatus = napi_get_value_int32(env, args[4], &height);
ENSURE_NAPI_OK_RETVAL(env, nstatus, nullptr);

WebGLRenderingContext *context = nullptr;
nstatus = UnwrapContext(env, js_this, &context);
ENSURE_NAPI_OK_RETVAL(env, nstatus, nullptr);

context->eglContextWrapper_->glTexStorage2D(target, levels, internal_format,
width, height);
#if DEBUG
context->CheckForErrors();
#endif
return nullptr;
}

/* static */
napi_value WebGLRenderingContext::TexImage2D(napi_env env,
napi_callback_info info) {
Expand Down
1 change: 1 addition & 0 deletions binding/webgl_rendering_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ class WebGLRenderingContext {
static napi_value StencilMaskSeparate(napi_env env, napi_callback_info info);
static napi_value StencilOp(napi_env env, napi_callback_info info);
static napi_value StencilOpSeparate(napi_env env, napi_callback_info info);
static napi_value TexStorage2D(napi_env env, napi_callback_info info);
static napi_value TexImage2D(napi_env env, napi_callback_info info);
static napi_value TexParameteri(napi_env env, napi_callback_info info);
static napi_value TexParameterf(napi_env env, napi_callback_info info);
Expand Down