summaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/jogamp/opengl
diff options
context:
space:
mode:
Diffstat (limited to 'src/jogl/classes/jogamp/opengl')
-rw-r--r--src/jogl/classes/jogamp/opengl/GLBufferObjectTracker.java44
-rw-r--r--src/jogl/classes/jogamp/opengl/util/glsl/GLSLArrayHandler.java12
2 files changed, 33 insertions, 23 deletions
diff --git a/src/jogl/classes/jogamp/opengl/GLBufferObjectTracker.java b/src/jogl/classes/jogamp/opengl/GLBufferObjectTracker.java
index 2351826cb..483b9b526 100644
--- a/src/jogl/classes/jogamp/opengl/GLBufferObjectTracker.java
+++ b/src/jogl/classes/jogamp/opengl/GLBufferObjectTracker.java
@@ -109,11 +109,11 @@ public class GLBufferObjectTracker {
GLBufferStorageImpl(final int name, final long size, final int mutableUsage, final int immutableFlags) {
super(name, size, mutableUsage, immutableFlags);
}
- final void setMappedBuffer(final ByteBuffer bb) {
- if (DEBUG) {
- System.err.printf("%s.GLBufferStorage.setMappedBuffer: %s: %s -> %s%n", msgClazzName, toString(true), mappedBuffer, bb);
- }
- mappedBuffer = bb;
+ protected final void reset(final long size, final int mutableUsage, final int immutableFlags) {
+ super.reset(size, mutableUsage, immutableFlags);
+ }
+ protected final void setMappedBuffer(final ByteBuffer buffer) {
+ super.setMappedBuffer(buffer);
}
}
@@ -169,13 +169,18 @@ public class GLBufferObjectTracker {
throw new GLException(String.format("GL-Error 0x%X while creating %s storage for target 0x%X -> buffer %d of size %d with data %s",
glerrPost, mutableBuffer ? "mutable" : "immutable", target, bufferName, size, data));
}
- final GLBufferStorageImpl objNew = new GLBufferStorageImpl(bufferName, size, mutableUsage, immutableFlags);
- final GLBufferStorageImpl objOld = (GLBufferStorageImpl) bufferName2StorageMap.put(bufferName, objNew);
- if (DEBUG) {
- System.err.printf("%s.%s target: 0x%X -> %d: %s -> %s%n", msgClazzName, msgCreateBound, target, bufferName, objOld, objNew);
- }
+ final GLBufferStorageImpl objOld = (GLBufferStorageImpl) bufferName2StorageMap.get(bufferName);
if( null != objOld ) {
- objOld.setMappedBuffer(null);
+ objOld.reset(size, mutableUsage, immutableFlags);
+ if (DEBUG) {
+ System.err.printf("%s.%s target: 0x%X -> reset %d: %s%n", msgClazzName, msgCreateBound, target, bufferName, objOld);
+ }
+ } else {
+ final GLBufferStorageImpl objNew = new GLBufferStorageImpl(bufferName, size, mutableUsage, immutableFlags);
+ bufferName2StorageMap.put(bufferName, objNew);
+ if (DEBUG) {
+ System.err.printf("%s.%s target: 0x%X -> new %d: %s%n", msgClazzName, msgCreateBound, target, bufferName, objNew);
+ }
}
}
@@ -209,13 +214,18 @@ public class GLBufferObjectTracker {
throw new GLException(String.format("GL-Error 0x%X while creating %s storage for buffer %d of size %d with data %s",
glerrPost, "mutable", bufferName, size, data));
}
- final GLBufferStorageImpl objNew = new GLBufferStorageImpl(bufferName, size, mutableUsage, 0 /* immutableFlags */);
- final GLBufferStorageImpl objOld = (GLBufferStorageImpl) bufferName2StorageMap.put(bufferName, objNew);
- if (DEBUG) {
- System.err.printf("%s.%s direct: %d: %s -> %s%n", msgClazzName, msgCreateNamed, bufferName, objOld, objNew);
- }
+ final GLBufferStorageImpl objOld = (GLBufferStorageImpl) bufferName2StorageMap.get(bufferName);
if( null != objOld ) {
- objOld.setMappedBuffer(null);
+ objOld.reset(size, mutableUsage, immutableFlags);
+ if (DEBUG) {
+ System.err.printf("%s.%s direct: reset %d: %s%n", msgClazzName, msgCreateNamed, bufferName, objOld);
+ }
+ } else {
+ final GLBufferStorageImpl objNew = new GLBufferStorageImpl(bufferName, size, mutableUsage, immutableFlags);
+ bufferName2StorageMap.put(bufferName, objNew);
+ if (DEBUG) {
+ System.err.printf("%s.%s direct: new %d: %s%n", msgClazzName, msgCreateNamed, bufferName, objNew);
+ }
}
}
diff --git a/src/jogl/classes/jogamp/opengl/util/glsl/GLSLArrayHandler.java b/src/jogl/classes/jogamp/opengl/util/glsl/GLSLArrayHandler.java
index 1f402f48b..e9fb91086 100644
--- a/src/jogl/classes/jogamp/opengl/util/glsl/GLSLArrayHandler.java
+++ b/src/jogl/classes/jogamp/opengl/util/glsl/GLSLArrayHandler.java
@@ -69,6 +69,8 @@ public class GLSLArrayHandler extends GLVBOArrayHandler {
}
}
+ private final int[] tempI = new int[1];
+
private final void enableShaderState(GL2ES2 glsl, boolean enable, ShaderState st) {
if(enable) {
/*
@@ -99,9 +101,8 @@ public class GLSLArrayHandler extends GLVBOArrayHandler {
} else if(st.getAttribLocation(glsl, ad) >= 0) {
// didn't experience a performance hit on this query ..
// (using ShaderState's location query above to validate the location)
- final int[] qi = new int[1];
- glsl.glGetVertexAttribiv(ad.getLocation(), GL2ES2.GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING, qi, 0);
- if(ad.getVBOName() != qi[0]) {
+ glsl.glGetVertexAttribiv(ad.getLocation(), GL2ES2.GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING, tempI, 0);
+ if(ad.getVBOName() != tempI[0]) {
glsl.glBindBuffer(ad.getVBOTarget(), ad.getVBOName());
st.vertexAttribPointer(glsl, ad);
glsl.glBindBuffer(ad.getVBOTarget(), 0);
@@ -151,9 +152,8 @@ public class GLSLArrayHandler extends GLVBOArrayHandler {
} else {
// didn't experience a performance hit on this query ..
// (using ShaderState's location query above to validate the location)
- final int[] qi = new int[1];
- glsl.glGetVertexAttribiv(location, GL2ES2.GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING, qi, 0);
- if(ad.getVBOName() != qi[0]) {
+ glsl.glGetVertexAttribiv(location, GL2ES2.GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING, tempI, 0);
+ if(ad.getVBOName() != tempI[0]) {
glsl.glBindBuffer(ad.getVBOTarget(), ad.getVBOName());
glsl.glVertexAttribPointer(ad);
glsl.glBindBuffer(ad.getVBOTarget(), 0);