Code Monkey home page Code Monkey logo

webgl-raub's People

Contributors

automatonsystems avatar aximili-dev avatar creationix avatar djulien avatar jiahansu avatar lmeyerov avatar lukaaash avatar maratyszcza avatar mikeseven avatar nicholasbishop avatar raub avatar samzanemesis avatar timknip2 avatar tmpvar avatar trxcllnt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

webgl-raub's Issues

context.drawImage is not a function

Hi Raub! Thank you so much for your great work here.
I'm reaching to you because i have noticed an error. When the texture is not Pow of 2, this error is being triggered:

THREE.WebGLRenderer 89
C:\Users\elmer\Repos\3d-core-raub\node_modules\node-threejs-raub\build\three.js:18538
                                context.drawImage( image, 0, 0, canvas.width, canvas.height );
                                        ^

TypeError: context.drawImage is not a function
    at makePowerOfTwo (C:\Users\elmer\Repos\3d-core-raub\node_modules\node-threejs-raub\build\three.js:18538:13)
    at uploadTexture (C:\Users\elmer\Repos\3d-core-raub\node_modules\node-threejs-raub\build\three.js:18917:13)
    at WebGLTextures.setTexture2D (C:\Users\elmer\Repos\3d-core-raub\node_modules\node-threejs-raub\build\three.js:18699:6)
    at WebGLRenderer.setTexture2D (C:\Users\elmer\Repos\3d-core-raub\node_modules\node-threejs-raub\build\three.js:23541:14)
    at SingleUniform.setValueT1 [as setValue] (C:\Users\elmer\Repos\3d-core-raub\node_modules\node-threejs-raub\build\three.js:4937:12)
    at Function.WebGLUniforms.upload (C:\Users\elmer\Repos\3d-core-raub\node_modules\node-threejs-raub\build\three.js:5278:7)
    at setProgram (C:\Users\elmer\Repos\3d-core-raub\node_modules\node-threejs-raub\build\three.js:23088:19)
    at WebGLRenderer.renderBufferDirect (C:\Users\elmer\Repos\3d-core-raub\node_modules\node-threejs-raub\build\three.js:21873:18)
    at renderObject (C:\Users\elmer\Repos\3d-core-raub\node_modules\node-threejs-raub\build\three.js:22632:11)
    at renderObjects (C:\Users\elmer\Repos\3d-core-raub\node_modules\node-threejs-raub\build\three.js:22603:6)

I was going to add this bug on the 3d-core-raub repo but after some debugging i noticed the error is on this package. Looks like the context (webgl) doesn't have the drawImage function, and after reviewing the code looks like its actually true. We can easily replicate this error by changing the dimensions of the crate.gif file and run the crate example.

Do you have a workaround for this issue?

Thanks, really appreciate the work.

Comparison with headless-gl

Hello! Thank you for this project!
We are using https://github.com/stackgl/headless-gl to render images on node js with pixijs.
It does not support webgl2, so we are trying to find a replacement.
Does your project allow to use webgl2?
Does it provide similar performance to https://github.com/stackgl/headless-gl ?

In order to utilize nvidia gpu we build headless-gl passing

'libraries': [
              '-lEGL',
              '-lGLESv2'
 ],

to linker and it utilizes egl provided by nvidia drivers.
stackgl/headless-gl@master...Lumen5:headless-gl:master

Is it possible to do the same with your library?

Thank you!

How to enable argument coercion like the browser's WebGL APIs?

JS_METHOD(vertexAttribPointer) { NAPI_ENV;
REQ_INT32_ARG(0, indx);
REQ_INT32_ARG(1, size);
REQ_INT32_ARG(2, type);
LET_BOOL_ARG(3, normalized);
REQ_INT32_ARG(4, stride);
REQ_OFFS_ARG(5, offset);
GLvoid *vertices = reinterpret_cast<GLvoid*>(offset);
glVertexAttribPointer(indx, size, type, normalized, stride, vertices);
RET_UNDEFINED;
}

I was trying to pass numbers for argument 3 normalized (f.e. 0 or 1) instead of booleans, and this causes the error:

vertexAttrib4fv error
Error: Argument 3 must be of type `Bool` or be `null`/`undefined`

So on the JS side I had to cast my values (which I don't have to do in a browser) like so:

gl.vertexAttribPointer(..., !!normalized, ...)

The browser automatically coerces values, so no need ton manually convert them.

Is there some way to fix this?

getExtension breaks with no output

const webgl = require('node-webgl-raub');
webgl.getExtension && webgl.getExtension('WEBGL_color_buffer_float');

const canvas = document.createElement('canvas'); // === doc
const gl = canvas.getContext('webgl'); 
console.log( gl.getExtension('WEBGL_color_buffer_float') );

Incorrect typescript definitions

The index.d.ts file has some semicolons which cause the following error to be throw when trying to compile a typescript project that uses this library:

node_modules/webgl-raub/index.d.ts:24:4 - error TS1036: Statements are not allowed in ambient contexts.

I've forked the repo and created a fix to be able to use it in my own projects, I've also submitted a pull request with the fix

darwin-arm64.zip: 404, not found

Hello. Thanks again for this excellent work! I'm on a MacBook Air M2 these days, and when I run npm install in https://github.com/lume/glas, I now get this error:

npm ERR! code 255
npm ERR! path /Users/trusktr/src/lume+lume/packages/glas/node_modules/deps-opengl-raub
npm ERR! command failed
npm ERR! command sh -c -- node install
npm ERR! https://github.com/node-3d/deps-opengl-raub/releases/download/4.1.0/darwin-arm64.zip
npm ERR! Response status was 404

I'm guessing this isn't compiled for MacBook Air M2 architecture yet?

I thought I was able to install successfully before though.

Headless rendering

Hi, this is really cool. Is there any way to render headless, without the use of a GUI? It would be nice to be able to get a frame buffers stream in JS.

Is all extension unavailable?

When I used webgl1 extension, there was an undefined method error and no method bindings in the source code. Is webgl extension not available?

  const ext = gl.getExtension("OES_vertex_array_object"),
    vao = ext.createVertexArrayOES();
  ext.bindVertexArrayOES(vao);

Error: Cannot find module './bin-linux/segfault'

Hello again. I must say, this package is pretty neat! I've gotten lume/glas (port of Three.js to AssemblyScript) to run inside unit tests ran with as-pect (a test runner for AssemblyScript). I polyfilled WebGL on the Node.js side with webgl-raub, then used ASWebGLue (WebGL bindings for AssemblyScript) to set up the JS WebGL glue code and for the WebGL API inside AssemblyScript code, and it works great in Linux (headlessly with xvfb-maybe for unit testing, but it will work great with a window for actual applications). Really awesome that webgl-raub exists to allow such things.

I'm trying to get this setup working in Windows now. First I'm trying in WSL Bash, and when I try to run unit tests I run into this error:

Error: Cannot find module './bin-linux/segfault'
Require stack:
- /mnt/d/src/lume+lume/packages/glas/node_modules/segfault-raub/index.js
- /mnt/d/src/lume+lume/packages/glas/node_modules/webgl-raub/core.js
- /mnt/d/src/lume+lume/packages/glas/node_modules/webgl-raub/js/webgl.js
- /mnt/d/src/lume+lume/packages/glas/node_modules/webgl-raub/index.js

When I check to see what is in the segfault-raub package, I see there is not bin-linux/ folder:

$ ls -l node_modules/segfault-raub/
total 12
-rwxrwxrwx 1 trusktr trusktr  260 Oct 26  1985 index.js
-rwxrwxrwx 1 trusktr trusktr  232 Oct 26  1985 install.js
-rwxrwxrwx 1 trusktr trusktr 1538 Oct 26  1985 LICENSE
-rwxrwxrwx 1 trusktr trusktr 1860 Mar 12 21:27 package.json
-rwxrwxrwx 1 trusktr trusktr 1857 Oct 26  1985 README.md

Any idea what is happening?

Missing props for WebGL needed for ThreeJS

Ok,

I am trying to write a React wrapper for glfw-raub and webgl-raub... so i can then use them in react-three-fiber.
I am using 3d-core-raub as a reference implementation

I am using threejs v0.128.x

Got an error that gl.canvas was undefined here.
https://github.com/mrdoob/three.js/blob/da14c33181a90419820c04b5201d66b1401c1581/src/renderers/webgl/WebGLState.js#L1117

^^^ WebGLRenderingContext is supposed to have a reference to the canvas that created it, i guess. i set this manually and got past this error.

ThreeJS expects a WebGLRenderingContext, but you use your WebGL class in all your examples. Its fine if it is the same object but for typescript maybe they could be masked behind getters that return that right context.

in your examples you set viewportWidth & Height, but those properties don't exist...
also tried to use drawingBufferWidth & height and they were null.

Just notes to help anyone else with this issue.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.