Skip to content

Commit

Permalink
Add cpplint badge
Browse files Browse the repository at this point in the history
  • Loading branch information
raub committed Oct 11, 2023
1 parent fe4edae commit 25e89da
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 69 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ This is a part of [Node3D](https://github.com/node-3d) project.
[![NPM](https://badge.fury.io/js/webgl-raub.svg)](https://badge.fury.io/js/webgl-raub)
[![ESLint](https://github.com/node-3d/webgl-raub/actions/workflows/eslint.yml/badge.svg)](https://github.com/node-3d/webgl-raub/actions/workflows/eslint.yml)
[![Test](https://github.com/node-3d/webgl-raub/actions/workflows/test.yml/badge.svg)](https://github.com/node-3d/webgl-raub/actions/workflows/test.yml)
[![Cpplint](https://github.com/node-3d/webgl-raub/actions/workflows/cpplint.yml/badge.svg)](https://github.com/node-3d/webgl-raub/actions/workflows/cpplint.yml)

```
```console
npm i -s webgl-raub
```

Expand Down
96 changes: 28 additions & 68 deletions src/cpp/bindings.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "webgl.hpp"


#define JS_GL_SET_CONSTANT(name, constant) \
#define JS_CUSTOM_CONSTANT(name, constant) \
exports.Set(#name, static_cast<double>(constant));

#define JS_GL_CONSTANT(name) \
Expand All @@ -19,7 +19,7 @@
);


Napi::Object initModule(Napi::Env env, Napi::Object exports) {
static inline void initMethods(Napi::Env &env, Napi::Object &exports) {
JS_GL_SET_METHOD(init);

// Query
Expand Down Expand Up @@ -224,11 +224,11 @@ Napi::Object initModule(Napi::Env env, Napi::Object exports) {
JS_GL_SET_METHOD(sampleCoverage);
JS_GL_SET_METHOD(scissor);
JS_GL_SET_METHOD(viewport);
// OpenGL ES 2.1 constants
// ClearBufferMask
}


static inline void initConstants(Napi::Env &env, Napi::Object &exports) {
// ClearBufferMask
JS_GL_CONSTANT(DEPTH_BUFFER_BIT);
JS_GL_CONSTANT(STENCIL_BUFFER_BIT);
JS_GL_CONSTANT(COLOR_BUFFER_BIT);
Expand All @@ -246,16 +246,6 @@ Napi::Object initModule(Napi::Env env, Napi::Object exports) {
JS_GL_CONSTANT(TRIANGLE_STRIP);
JS_GL_CONSTANT(TRIANGLE_FAN);

/* AlphaFunction (not supported in ES20) */
/* GL_NEVER */
/* GL_LESS */
/* GL_EQUAL */
/* GL_LEQUAL */
/* GL_GREATER */
/* GL_NOTEQUAL */
/* GL_GEQUAL */
/* GL_ALWAYS */

// BlendingFactorDest
JS_GL_CONSTANT(ZERO);
JS_GL_CONSTANT(ONE);
Expand All @@ -267,20 +257,14 @@ Napi::Object initModule(Napi::Env env, Napi::Object exports) {
JS_GL_CONSTANT(ONE_MINUS_DST_ALPHA);

/* BlendingFactorSrc */
/* GL_ZERO */
/* GL_ONE */
JS_GL_CONSTANT(DST_COLOR);
JS_GL_CONSTANT(ONE_MINUS_DST_COLOR);
JS_GL_CONSTANT(SRC_ALPHA_SATURATE);
/* GL_SRC_ALPHA */
/* GL_ONE_MINUS_SRC_ALPHA */
/* GL_DST_ALPHA */
/* GL_ONE_MINUS_DST_ALPHA */

// BlendEquationSeparate
JS_GL_CONSTANT(FUNC_ADD);
JS_GL_CONSTANT(BLEND_EQUATION);
JS_GL_CONSTANT(BLEND_EQUATION_RGB); /* same as BLEND_EQUATION */
JS_GL_CONSTANT(BLEND_EQUATION_RGB);
JS_GL_CONSTANT(BLEND_EQUATION_ALPHA);

// BlendSubtract
Expand Down Expand Up @@ -318,16 +302,6 @@ Napi::Object initModule(Napi::Env env, Napi::Object exports) {
JS_GL_CONSTANT(BACK);
JS_GL_CONSTANT(FRONT_AND_BACK);

/* DepthFunction */
/* GL_NEVER */
/* GL_LESS */
/* GL_EQUAL */
/* GL_LEQUAL */
/* GL_GREATER */
/* GL_NOTEQUAL */
/* GL_GEQUAL */
/* GL_ALWAYS */

// EnableCap
JS_GL_CONSTANT(TEXTURE_2D);
JS_GL_CONSTANT(TEXTURE_2D_ARRAY);
Expand Down Expand Up @@ -381,7 +355,6 @@ Napi::Object initModule(Napi::Env env, Napi::Object exports) {
JS_GL_CONSTANT(STENCIL_BACK_WRITEMASK);
JS_GL_CONSTANT(VIEWPORT);
JS_GL_CONSTANT(SCISSOR_BOX);
/* GL_SCISSOR_TEST */
JS_GL_CONSTANT(COLOR_CLEAR_VALUE);
JS_GL_CONSTANT(COLOR_WRITEMASK);
JS_GL_CONSTANT(UNPACK_ALIGNMENT);
Expand All @@ -396,20 +369,13 @@ Napi::Object initModule(Napi::Env env, Napi::Object exports) {
JS_GL_CONSTANT(DEPTH_BITS);
JS_GL_CONSTANT(STENCIL_BITS);
JS_GL_CONSTANT(POLYGON_OFFSET_UNITS);
/* GL_POLYGON_OFFSET_FILL */
JS_GL_CONSTANT(POLYGON_OFFSET_FACTOR);
JS_GL_CONSTANT(TEXTURE_BINDING_2D);
JS_GL_CONSTANT(SAMPLE_BUFFERS);
JS_GL_CONSTANT(SAMPLES);
JS_GL_CONSTANT(SAMPLE_COVERAGE_VALUE);
JS_GL_CONSTANT(SAMPLE_COVERAGE_INVERT);

/* GetTextureParameter */
/* GL_TEXTURE_MAG_FILTER */
/* GL_TEXTURE_MIN_FILTER */
/* GL_TEXTURE_WRAP_S */
/* GL_TEXTURE_WRAP_T */

JS_GL_CONSTANT(NUM_COMPRESSED_TEXTURE_FORMATS);
JS_GL_CONSTANT(COMPRESSED_TEXTURE_FORMATS);

Expand All @@ -431,6 +397,9 @@ Napi::Object initModule(Napi::Env env, Napi::Object exports) {
JS_GL_CONSTANT(UNSIGNED_INT_24_8);
JS_GL_CONSTANT(FLOAT);
JS_GL_CONSTANT(FIXED);
JS_GL_CONSTANT(UNSIGNED_SHORT_4_4_4_4);
JS_GL_CONSTANT(UNSIGNED_SHORT_5_5_5_1);
JS_GL_CONSTANT(UNSIGNED_SHORT_5_6_5);

// PixelFormat
JS_GL_CONSTANT(DEPTH_COMPONENT);
Expand Down Expand Up @@ -463,12 +432,6 @@ Napi::Object initModule(Napi::Env env, Napi::Object exports) {
JS_GL_CONSTANT(RGBA8);
JS_GL_CONSTANT(SRGB8_ALPHA8);

// PixelType
/* GL_UNSIGNED_BYTE */
JS_GL_CONSTANT(UNSIGNED_SHORT_4_4_4_4);
JS_GL_CONSTANT(UNSIGNED_SHORT_5_5_5_1);
JS_GL_CONSTANT(UNSIGNED_SHORT_5_6_5);

// Shaders
JS_GL_CONSTANT(FRAGMENT_SHADER);
JS_GL_CONSTANT(VERTEX_SHADER);
Expand Down Expand Up @@ -507,7 +470,6 @@ Napi::Object initModule(Napi::Env env, Napi::Object exports) {
JS_GL_CONSTANT(ALWAYS);

// StencilOp
/* GL_ZERO */
JS_GL_CONSTANT(KEEP);
JS_GL_CONSTANT(REPLACE);
JS_GL_CONSTANT(INCR);
Expand All @@ -531,8 +493,6 @@ Napi::Object initModule(Napi::Env env, Napi::Object exports) {
JS_GL_CONSTANT(LINEAR);

// TextureMinFilter
/* GL_NEAREST */
/* GL_LINEAR */
JS_GL_CONSTANT(NEAREST_MIPMAP_NEAREST);
JS_GL_CONSTANT(LINEAR_MIPMAP_NEAREST);
JS_GL_CONSTANT(NEAREST_MIPMAP_LINEAR);
Expand Down Expand Up @@ -693,9 +653,6 @@ Napi::Object initModule(Napi::Env env, Napi::Object exports) {
JS_GL_CONSTANT(FRAMEBUFFER_COMPLETE);
JS_GL_CONSTANT(FRAMEBUFFER_INCOMPLETE_ATTACHMENT);
JS_GL_CONSTANT(FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT);

//JS_GL_CONSTANT(FRAMEBUFFER_INCOMPLETE_DIMENSIONS);

JS_GL_CONSTANT(FRAMEBUFFER_UNSUPPORTED);

JS_GL_CONSTANT(FRAMEBUFFER_BINDING);
Expand Down Expand Up @@ -735,28 +692,31 @@ Napi::Object initModule(Napi::Env env, Napi::Object exports) {
JS_GL_CONSTANT(COMPARE_REF_TO_TEXTURE);

// WebGL-specific enums
JS_GL_SET_CONSTANT(UNPACK_FLIP_Y_WEBGL, 0x9240);
JS_GL_SET_CONSTANT(UNPACK_PREMULTIPLY_ALPHA_WEBGL, 0x9241);
JS_GL_SET_CONSTANT(CONTEXT_LOST_WEBGL, 0x9242);
JS_GL_SET_CONSTANT(UNPACK_COLORSPACE_CONVERSION_WEBGL, 0x9243);
JS_GL_SET_CONSTANT(BROWSER_DEFAULT_WEBGL, 0x9244);
JS_GL_SET_CONSTANT(UNPACK_ROW_LENGTH, 0x0CF2);
JS_CUSTOM_CONSTANT(UNPACK_FLIP_Y_WEBGL, 0x9240);
JS_CUSTOM_CONSTANT(UNPACK_PREMULTIPLY_ALPHA_WEBGL, 0x9241);
JS_CUSTOM_CONSTANT(CONTEXT_LOST_WEBGL, 0x9242);
JS_CUSTOM_CONSTANT(UNPACK_COLORSPACE_CONVERSION_WEBGL, 0x9243);
JS_CUSTOM_CONSTANT(BROWSER_DEFAULT_WEBGL, 0x9244);
JS_CUSTOM_CONSTANT(UNPACK_ROW_LENGTH, 0x0CF2);

// WebGL 2
JS_GL_CONSTANT(MAX_SAMPLES);
JS_GL_CONSTANT(MAX_UNIFORM_BUFFER_BINDINGS);
JS_GL_CONSTANT(MAX);
JS_GL_CONSTANT(MIN);

//////////////////////////////
// NOT in WebGL spec
//////////////////////////////

// PBO
JS_GL_SET_CONSTANT(PIXEL_PACK_BUFFER, 0x88EB);
JS_GL_SET_CONSTANT(PIXEL_UNPACK_BUFFER, 0x88EC);
JS_GL_SET_CONSTANT(PIXEL_PACK_BUFFER_BINDING, 0x88ED);
JS_GL_SET_CONSTANT(PIXEL_UNPACK_BUFFER_BINDING, 0x88EF);
JS_CUSTOM_CONSTANT(PIXEL_PACK_BUFFER, 0x88EB);
JS_CUSTOM_CONSTANT(PIXEL_UNPACK_BUFFER, 0x88EC);
JS_CUSTOM_CONSTANT(PIXEL_PACK_BUFFER_BINDING, 0x88ED);
JS_CUSTOM_CONSTANT(PIXEL_UNPACK_BUFFER_BINDING, 0x88EF);

}


Napi::Object initModule(Napi::Env env, Napi::Object exports) {
initMethods(env, exports);
initConstants(env, exports);

return exports;
}
Expand Down

0 comments on commit 25e89da

Please sign in to comment.