Skip to content
Merged
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
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,11 @@ backend.
| `EXT_color_buffer_float` / `WEBGL_color_buffer_float` | Exposed |
| `EXT_color_buffer_half_float` | Exposed |
| `EXT_frag_depth` | Exposed |
| `EXT_float_blend` | Exposed |
| `EXT_sRGB` | Exposed |
| `EXT_shader_texture_lod` | Exposed |
| `EXT_texture_filter_anisotropic` | Exposed |
| `EXT_texture_mirror_clamp_to_edge` | Exposed |
| `OES_element_index_uint` | Exposed |
| `OES_standard_derivatives` | Exposed |
| `OES_texture_float` / `OES_texture_float_linear` | Exposed |
Expand Down
2 changes: 2 additions & 0 deletions binding/binding.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,11 @@ static napi_value InitBinding(napi_env env, napi_value exports) {
EXTColorBufferFloatExtension::Register(env, exports);
EXTColorBufferHalfFloatExtension::Register(env, exports);
EXTFragDepthExtension::Register(env, exports);
EXTFloatBlendExtension::Register(env, exports);
EXTShaderTextureLodExtension::Register(env, exports);
EXTSRGBExtension::Register(env, exports);
EXTTextureFilterAnisotropicExtension::Register(env, exports);
EXTTextureMirrorClampToEdgeExtension::Register(env, exports);
OESElementIndexUintExtension::Register(env, exports);
OESStandardDerivativesExtension::Register(env, exports);
OESTextureFloatExtension::Register(env, exports);
Expand Down
108 changes: 108 additions & 0 deletions binding/webgl_extensions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,15 @@ namespace nodejsgl {
egl_context_wrapper->gl_extensions->HasExtension(ext_name);
#endif

static void RequestExtensionIfAvailable(EGLContextWrapper* egl_context_wrapper,
const char* ext_name) {
if (egl_context_wrapper->angle_requestable_extensions->HasExtension(
ext_name) ||
egl_context_wrapper->gl_extensions->HasExtension(ext_name)) {
egl_context_wrapper->glRequestExtensionANGLE(ext_name);
}
}

//==============================================================================
// GLExtensionBase

Expand Down Expand Up @@ -210,6 +219,7 @@ napi_status EXTColorBufferFloatExtension::NewInstance(
ENSURE_NAPI_OK_RETVAL(env, nstatus, nstatus);

egl_context_wrapper->glRequestExtensionANGLE("GL_EXT_color_buffer_float");
RequestExtensionIfAvailable(egl_context_wrapper, "GL_EXT_float_blend");
egl_context_wrapper->RefreshGLExtensions();

return napi_ok;
Expand Down Expand Up @@ -307,6 +317,51 @@ napi_status EXTFragDepthExtension::NewInstance(
return napi_ok;
}

//==============================================================================
// EXTFloatBlendExtension

napi_ref EXTFloatBlendExtension::constructor_ref_;

EXTFloatBlendExtension::EXTFloatBlendExtension(napi_env env)
: GLExtensionBase(env) {}

/* static */
bool EXTFloatBlendExtension::IsSupported(
EGLContextWrapper* egl_context_wrapper) {
IS_EXTENSION_NAME_AVAILABLE("GL_EXT_float_blend");
}

/* static */
napi_status EXTFloatBlendExtension::Register(napi_env env, napi_value exports) {
napi_status nstatus;

napi_value ctor_value;
nstatus = napi_define_class(env, "EXT_float_blend", NAPI_AUTO_LENGTH,
GLExtensionBase::InitStubClass, nullptr, 0,
nullptr, &ctor_value);
ENSURE_NAPI_OK_RETVAL(env, nstatus, nstatus);

nstatus = napi_create_reference(env, ctor_value, 1, &constructor_ref_);
ENSURE_NAPI_OK_RETVAL(env, nstatus, nstatus);

return napi_ok;
}

/* static */
napi_status EXTFloatBlendExtension::NewInstance(
napi_env env, napi_value* instance,
EGLContextWrapper* egl_context_wrapper) {
ENSURE_EXTENSION_IS_SUPPORTED

napi_status nstatus = NewInstanceBase(env, constructor_ref_, instance);
ENSURE_NAPI_OK_RETVAL(env, nstatus, nstatus);

egl_context_wrapper->glRequestExtensionANGLE("GL_EXT_float_blend");
egl_context_wrapper->RefreshGLExtensions();

return napi_ok;
}

//==============================================================================
// EXTShaderTextureLodExtension

Expand Down Expand Up @@ -460,6 +515,58 @@ napi_status EXTTextureFilterAnisotropicExtension::NewInstance(
return napi_ok;
}

//==============================================================================
// EXTTextureMirrorClampToEdgeExtension

napi_ref EXTTextureMirrorClampToEdgeExtension::constructor_ref_;

EXTTextureMirrorClampToEdgeExtension::EXTTextureMirrorClampToEdgeExtension(
napi_env env)
: GLExtensionBase(env) {}

/* static */
bool EXTTextureMirrorClampToEdgeExtension::IsSupported(
EGLContextWrapper* egl_context_wrapper) {
IS_EXTENSION_NAME_AVAILABLE("GL_EXT_texture_mirror_clamp_to_edge");
}

/* static */
napi_status EXTTextureMirrorClampToEdgeExtension::Register(napi_env env,
napi_value exports) {
napi_status nstatus;

napi_property_descriptor properties[] = {NapiDefineIntProperty(
env, GL_MIRROR_CLAMP_TO_EDGE_EXT, "MIRROR_CLAMP_TO_EDGE_EXT")};

napi_value ctor_value;
nstatus = napi_define_class(env, "EXT_texture_mirror_clamp_to_edge",
NAPI_AUTO_LENGTH, GLExtensionBase::InitStubClass,
nullptr, ARRAY_SIZE(properties), properties,
&ctor_value);
ENSURE_NAPI_OK_RETVAL(env, nstatus, nstatus);

nstatus = napi_create_reference(env, ctor_value, 1, &constructor_ref_);
ENSURE_NAPI_OK_RETVAL(env, nstatus, nstatus);

return napi_ok;
}

/* static */
napi_status EXTTextureMirrorClampToEdgeExtension::NewInstance(
napi_env env, napi_value* instance,
EGLContextWrapper* egl_context_wrapper) {
ENSURE_EXTENSION_IS_SUPPORTED

napi_status nstatus = NewInstanceBase(env, constructor_ref_, instance);
ENSURE_NAPI_OK_RETVAL(env, nstatus, nstatus);

egl_context_wrapper->glRequestExtensionANGLE(
"GL_EXT_texture_mirror_clamp_to_edge");
egl_context_wrapper->RefreshGLExtensions();

return napi_ok;
}

//==============================================================================
// OESElementIndexUintExtension

Expand Down Expand Up @@ -601,6 +708,7 @@ napi_status OESTextureFloatExtension::NewInstance(
"GL_CHROMIUM_color_buffer_float_rgba");
egl_context_wrapper->glRequestExtensionANGLE(
"GL_CHROMIUM_color_buffer_float_rgb");
RequestExtensionIfAvailable(egl_context_wrapper, "GL_EXT_float_blend");
egl_context_wrapper->RefreshGLExtensions();

return napi_ok;
Expand Down
20 changes: 20 additions & 0 deletions binding/webgl_extensions.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,16 @@ class EXTFragDepthExtension : public GLExtensionBase {
virtual ~EXTFragDepthExtension() {}
};

// Provides 'EXT_float_blend':
// https://registry.khronos.org/webgl/extensions/EXT_float_blend/
class EXTFloatBlendExtension : public GLExtensionBase {
NAPI_BOOTSTRAP_METHODS

protected:
EXTFloatBlendExtension(napi_env env);
virtual ~EXTFloatBlendExtension() {}
};

// Provides 'EXT_shader_texture_lod':
// https://www.khronos.org/registry/webgl/extensions/EXT_shader_texture_lod/
class EXTShaderTextureLodExtension : public GLExtensionBase {
Expand Down Expand Up @@ -141,6 +151,16 @@ class EXTTextureFilterAnisotropicExtension : public GLExtensionBase {
virtual ~EXTTextureFilterAnisotropicExtension() {}
};

// Provides 'EXT_texture_mirror_clamp_to_edge':
// https://registry.khronos.org/webgl/extensions/EXT_texture_mirror_clamp_to_edge/
class EXTTextureMirrorClampToEdgeExtension : public GLExtensionBase {
NAPI_BOOTSTRAP_METHODS

protected:
EXTTextureMirrorClampToEdgeExtension(napi_env env);
virtual ~EXTTextureMirrorClampToEdgeExtension() {}
};

// Provides 'OES_element_index_uint':
// https://www.khronos.org/registry/webgl/extensions/OES_element_index_uint/
class OESElementIndexUintExtension : public GLExtensionBase {
Expand Down
6 changes: 6 additions & 0 deletions binding/webgl_rendering_context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6229,11 +6229,14 @@ DEFINE_EXTENSION_DESCRIPTOR_HELPERS(EXTColorBufferFloat,
DEFINE_EXTENSION_DESCRIPTOR_HELPERS(EXTColorBufferHalfFloat,
EXTColorBufferHalfFloatExtension)
DEFINE_EXTENSION_DESCRIPTOR_HELPERS(EXTFragDepth, EXTFragDepthExtension)
DEFINE_EXTENSION_DESCRIPTOR_HELPERS(EXTFloatBlend, EXTFloatBlendExtension)
DEFINE_EXTENSION_DESCRIPTOR_HELPERS(EXTSRGB, EXTSRGBExtension)
DEFINE_EXTENSION_DESCRIPTOR_HELPERS(EXTShaderTextureLod,
EXTShaderTextureLodExtension)
DEFINE_EXTENSION_DESCRIPTOR_HELPERS(EXTTextureFilterAnisotropic,
EXTTextureFilterAnisotropicExtension)
DEFINE_EXTENSION_DESCRIPTOR_HELPERS(EXTTextureMirrorClampToEdge,
EXTTextureMirrorClampToEdgeExtension)
DEFINE_EXTENSION_DESCRIPTOR_HELPERS(OESElementIndexUint,
OESElementIndexUintExtension)
DEFINE_EXTENSION_DESCRIPTOR_HELPERS(OESStandardDerivatives,
Expand Down Expand Up @@ -6276,11 +6279,14 @@ static const WebGLExtensionDescriptor kKnownWebGLExtensions[] = {
{"EXT_color_buffer_half_float", SupportsEXTColorBufferHalfFloat,
NewEXTColorBufferHalfFloat},
{"EXT_frag_depth", SupportsEXTFragDepth, NewEXTFragDepth},
{"EXT_float_blend", SupportsEXTFloatBlend, NewEXTFloatBlend},
Comment thread
dsafdsaf132 marked this conversation as resolved.
{"EXT_sRGB", SupportsEXTSRGB, NewEXTSRGB},
{"EXT_shader_texture_lod", SupportsEXTShaderTextureLod,
NewEXTShaderTextureLod},
{"EXT_texture_filter_anisotropic", SupportsEXTTextureFilterAnisotropic,
NewEXTTextureFilterAnisotropic},
{"EXT_texture_mirror_clamp_to_edge", SupportsEXTTextureMirrorClampToEdge,
NewEXTTextureMirrorClampToEdge},
{"OES_element_index_uint", SupportsOESElementIndexUint,
NewOESElementIndexUint},
{"OES_standard_derivatives", SupportsOESStandardDerivatives,
Expand Down
10 changes: 10 additions & 0 deletions src/binding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@ export type NodeGlesWEBGLDrawBuffers = {
drawBuffersWEBGL(buffers: number[] | Uint32Array): void;
};

export type NodeGlesEXTFloatBlend = {};

export type NodeGlesEXTTextureMirrorClampToEdge = {
readonly MIRROR_CLAMP_TO_EDGE_EXT: number;
};

export type NodeGlesWebGL2RenderingContext = WebGL2RenderingContext & {
drawingBufferColorSpace: "srgb" | "display-p3";
readonly drawingBufferFormat: number;
Expand Down Expand Up @@ -183,6 +189,10 @@ export type NodeGlesWebGL2RenderingContext = WebGL2RenderingContext & {
srcOffsetOrOffset?: number, srcLengthOverride?: number): void;
getExtension(extensionName: "ANGLE_instanced_arrays"):
NodeGlesANGLEInstancedArrays | null;
getExtension(extensionName: "EXT_float_blend"):
NodeGlesEXTFloatBlend | null;
getExtension(extensionName: "EXT_texture_mirror_clamp_to_edge"):
NodeGlesEXTTextureMirrorClampToEdge | null;
getExtension(extensionName: "OES_vertex_array_object"):
NodeGlesOESVertexArrayObject | null;
getExtension(extensionName: "WEBGL_draw_buffers"):
Expand Down
Loading
Loading