Skip to content

Commit

Permalink
Fix issue causing missing buffer objects due to duplicate IDs
Browse files Browse the repository at this point in the history
  • Loading branch information
sriharshachilakapati committed Dec 29, 2015
1 parent 4578b75 commit 0e27eb5
Showing 1 changed file with 38 additions and 24 deletions.
62 changes: 38 additions & 24 deletions webgl4j/src/main/java/com/shc/webgl4j/client/WebGLObjectMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,20 @@ final class WebGLObjectMap
// Field to store the current program
int currentProgram = 0;

// Fields for last generated IDs of WebGL objects
private int lastShaderID = 0;
private int lastBufferID = 0;
private int lastProgramID = 0;
private int lastTextureID = 0;
private int lastFramebufferID = 0;
private int lastRenderbufferID = 0;
private int lastUniformID = 0;
private int lastQueryID = 0;
private int lastSamplerID = 0;
private int lastSyncID = 0;
private int lastTransformFeedbackID = 0;
private int lastVertexArrayObjectID = 0;

private WebGLObjectMap()
{
}
Expand Down Expand Up @@ -89,8 +103,8 @@ int createShader(JavaScriptObject shader)
return key;
}

shaders.put(shaders.size() + 1, shader);
return shaders.size();
shaders.put(++lastShaderID, shader);
return lastShaderID;
}

JavaScriptObject toShader(int shaderID)
Expand All @@ -110,8 +124,8 @@ int createBuffer(JavaScriptObject buffer)
return key;
}

buffers.put(buffers.size() + 1, buffer);
return buffers.size();
buffers.put(++lastBufferID, buffer);
return lastBufferID;
}

JavaScriptObject toBuffer(int bufferID)
Expand All @@ -131,8 +145,8 @@ int createProgram(JavaScriptObject program)
return key;
}

programs.put(programs.size() + 1, program);
return programs.size();
programs.put(++lastProgramID, program);
return lastProgramID;
}

JavaScriptObject toProgram(int programID)
Expand All @@ -152,8 +166,8 @@ int createTexture(JavaScriptObject texture)
return key;
}

textures.put(textures.size() + 1, texture);
return textures.size();
textures.put(++lastTextureID, texture);
return lastTextureID;
}

JavaScriptObject toTexture(int textureID)
Expand All @@ -173,8 +187,8 @@ int createFramebuffer(JavaScriptObject frameBuffer)
return key;
}

frameBuffers.put(frameBuffers.size() + 1, frameBuffer);
return frameBuffers.size();
frameBuffers.put(++lastFramebufferID, frameBuffer);
return lastFramebufferID;
}

JavaScriptObject toFramebuffer(int frameBuffer)
Expand All @@ -194,8 +208,8 @@ int createRenderBuffer(JavaScriptObject renderBuffer)
return key;
}

renderBuffers.put(renderBuffers.size() + 1, renderBuffer);
return renderBuffers.size();
renderBuffers.put(++lastRenderbufferID, renderBuffer);
return lastRenderbufferID;
}

JavaScriptObject toRenderBuffer(int renderBuffer)
Expand Down Expand Up @@ -223,8 +237,8 @@ int createUniform(JavaScriptObject uniform)
return key;
}

progUniforms.put(progUniforms.size() + 1, uniform);
return progUniforms.size();
progUniforms.put(++lastUniformID, uniform);
return lastUniformID;
}

JavaScriptObject toUniform(int programID, int uniform)
Expand Down Expand Up @@ -288,8 +302,8 @@ int createQuery(JavaScriptObject query)
return key;
}

queries.put(queries.size() + 1, query);
return queries.size();
queries.put(++lastQueryID, query);
return lastQueryID;
}

JavaScriptObject toQuery(int query)
Expand All @@ -309,8 +323,8 @@ int createSampler(JavaScriptObject sampler)
return key;
}

samplers.put(samplers.size() + 1, sampler);
return samplers.size();
samplers.put(++lastSamplerID, sampler);
return lastSamplerID;
}

JavaScriptObject toSampler(int sampler)
Expand All @@ -330,8 +344,8 @@ int createSync(JavaScriptObject sync)
return key;
}

syncs.put(syncs.size() + 1, sync);
return syncs.size();
syncs.put(++lastSyncID, sync);
return lastSyncID;
}

JavaScriptObject toSync(int sync)
Expand All @@ -351,8 +365,8 @@ int createTransformFeedback(JavaScriptObject transformFeedback)
return key;
}

transformFeedbacks.put(transformFeedbacks.size() + 1, transformFeedback);
return transformFeedbacks.size();
transformFeedbacks.put(++lastTransformFeedbackID, transformFeedback);
return lastTransformFeedbackID;
}

JavaScriptObject toTransformFeedback(int transformFeedback)
Expand All @@ -372,8 +386,8 @@ int createVertexArrayObject(JavaScriptObject vertexArrayObject)
return key;
}

vertexArrayObjects.put(vertexArrayObjects.size() + 1, vertexArrayObject);
return vertexArrayObjects.size();
vertexArrayObjects.put(++lastVertexArrayObjectID, vertexArrayObject);
return lastVertexArrayObjectID;
}

JavaScriptObject toVertexArrayObject(int vertexArrayObject)
Expand Down

0 comments on commit 0e27eb5

Please sign in to comment.