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

TypeError: Cannot read property 'ARRAY_BUFFER' of undefined (gl.ARRAY_BUFFER) #12

Open
deathcap opened this issue Feb 9, 2016 · 1 comment
Labels

Comments

@deathcap
Copy link
Member

deathcap commented Feb 9, 2016

Sometimes the engine fails to init, crashing with a null gl:

// voxel-mesher
  // load combined porous mesh into GL
  var gl = this.shell.gl;
  var verticesBuf = createBuffer(gl, new Float32Array(vertices));


// gl-buffer
function createBuffer(gl, data, type, usage) {
  type = type || gl.ARRAY_BUFFER // gl is undefined

screen shot 2016-02-08 at 11 14 35 pm

WebGL not yet properly initialized? (race condition?)

@deathcap deathcap added the bug label Feb 9, 2016
@deathcap
Copy link
Member Author

deathcap commented Feb 9, 2016

Called from:

// voxel-engine-stackgl

Game.prototype.showChunk = function(chunk, optionalPosition) {
  if (optionalPosition) chunk.position = optionalPosition

  var chunkIndex = chunk.position.join('|')
  var bounds = this.voxels.getBounds.apply(this.voxels, chunk.position)
  //console.log('showChunk',chunkIndex,'density=',JSON.stringify(chunkDensity(chunk)))

  var voxelArray = isndarray(chunk) ? chunk : ndarray(chunk.voxels, chunk.dims)
  var mesh = this.mesherPlugin.createVoxelMesh(this.shell.gl, voxelArray, this.stitcher.voxelSideTextureIDs, this.stitcher.voxelSideTextureSizes, chunk.position, this.chunkPad)

gl comes from this.shell.gl = https://www.npmjs.com/package/game-shell, or more specifically the extension https://www.npmjs.com/package/gl-now. gl is supposed to be ready when gl-init is fired:

shell.on("gl-init", function() {
  var gl = shell.gl

is this code executed before gl-init, or gl-init is fired before gl is ready?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant