Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix restore vao bug bewteen js and native #109

Merged
merged 1 commit into from
Mar 6, 2024

Conversation

bliu96
Copy link

@bliu96 bliu96 commented Dec 8, 2023

GL object is managed by wasm js scipt, Each GL object created in native has an unique id generated in wasm.js.

wasm.js

var _glGenBuffers = (n, buffers) => {
  __glGenObject(n, buffers, 'createBuffer', GL.buffers
    );
};

var __glGenObject = (n, buffers, createFunction, objectTable) => {
  for (var i = 0; i < n; i++) {
    var buffer = GLctx[createFunction]();
    var id = buffer && GL.getNewId(objectTable);
    if (buffer) {
      buffer.name = id;
      objectTable[id] = buffer;
    } else {
      GL.recordError(0x502 /* GL_INVALID_OPERATION */);
    }
    HEAP32[(((buffers)+(i*4))>>2)] = id;
  }
 };


var _glGetIntegerv = (name_, p) => {
   emscriptenWebGLGet(name_, p, 0);
};

var emscriptenWebGLGet = (name_, p, type) => {
    ...
    var result = GLctx.getParameter(name_);
    ...
    ret = result.name | 0;
    ...
}

This explains why create and bind buffer in js but get 0 in native glGetIntegerv.

@durswd durswd merged commit cec5921 into effekseer:master Mar 6, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants