diff options
author | Sven Gothel <[email protected]> | 2011-04-22 05:28:00 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2011-04-22 05:28:00 +0200 |
commit | 31d948b5f5432837c3a52e9891f60d9189011c91 (patch) | |
tree | 386d404ca30851aef7d6c1ffe99f1b698ec60df1 /src/test | |
parent | 0ad2f3f0b54ef0088cfbfef30c35144491effe30 (diff) |
Texture: Change method signatures: Pass GL context object if required (remove GLContext.getCurrentGL() usage.
Using function signatures explicitly require the GL [current] instance clarifies
that the context must be current.
Removing GLContext.getCurrentGL() reduces TLS access of current thread
and hence possible performance hits.
The Texture class has been chosen for this conversion [not TextureIO yet],
since the enable/bind methods maybe used within a rendering loop.
User already 'complained' about lack of current GLContext clarity as well.
Diffstat (limited to 'src/test')
7 files changed, 24 insertions, 26 deletions
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/ReadBufferUtil.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/ReadBufferUtil.java index 172eef4fc..dc1ea2da3 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/demos/ReadBufferUtil.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/ReadBufferUtil.java @@ -83,9 +83,9 @@ public class ReadBufferUtil { gl.glReadPixels(0, 0, drawable.getWidth(), drawable.getHeight(), GL.GL_RGB, GL.GL_UNSIGNED_BYTE, readPixelBuffer); readPixelBuffer.rewind(); if(newData) { - readTexture.updateImage(readTextureData); + readTexture.updateImage(gl, readTextureData); } else { - readTexture.updateSubImage(readTextureData, 0, + readTexture.updateSubImage(gl, readTextureData, 0, 0, 0, // src offset 0, 0, // dst offset drawable.getWidth(), drawable.getHeight()); @@ -94,9 +94,8 @@ public class ReadBufferUtil { } } - @SuppressWarnings("deprecation") - public void dispose() { - readTexture.dispose(); + public void dispose(GL gl) { + readTexture.destroy(gl); readTextureData = null; if(null != readPixelBuffer) { readPixelBuffer.clear(); diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/Screenshot.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/Screenshot.java index e0c304e49..f4b6f6dd9 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/demos/Screenshot.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/Screenshot.java @@ -12,8 +12,8 @@ public class Screenshot { ReadBufferUtil readBufferUtil = new ReadBufferUtil(); - public void dispose() { - readBufferUtil.dispose(); + public void dispose(GL gl) { + readBufferUtil.dispose(gl); } public void surface2File(GLAutoDrawable drawable, String filename) { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/ReadBuffer2Screen.java b/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/ReadBuffer2Screen.java index 67e400f29..23271dde2 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/ReadBuffer2Screen.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/ReadBuffer2Screen.java @@ -62,8 +62,8 @@ public class ReadBuffer2Screen extends ReadBufferBase { if(null==readTextureVertices) { //readTextureVertices = GLArrayDataClient.createFixed(gl, GLPointerFunc.GL_VERTEX_ARRAY, "mgl_Vertex", // 2, GL.GL_FLOAT, true, 4); - readTextureVertices = GLArrayDataServer.createFixed(gl, GLPointerFunc.GL_VERTEX_ARRAY, "mgl_Vertex", - 2, GL.GL_FLOAT, true, 4, GL.GL_STATIC_DRAW, GL.GL_ARRAY_BUFFER); + readTextureVertices = GLArrayDataServer.createFixed(GLPointerFunc.GL_VERTEX_ARRAY, "mgl_Vertex", 2, + GL.GL_FLOAT, true, 4, GL.GL_STATIC_DRAW); readTextureVertices.setEnableAlways(enableBufferAlways); readTextureVertices.setVBOEnabled(enableBufferVBO); { @@ -128,8 +128,8 @@ public class ReadBuffer2Screen extends ReadBufferBase { if(!readBufferUtil.isValid()) return; // Now draw one quad with the texture - readBufferUtil.getTexture().enable(); - readBufferUtil.getTexture().bind(); + readBufferUtil.getTexture().enable(gl); + readBufferUtil.getTexture().bind(gl); if(gl.isGL2ES1()) { // gl.getGL2ES1().glTexEnvi(GL2ES1.GL_TEXTURE_ENV, GL2ES1.GL_TEXTURE_ENV_MODE, GL2ES1.GL_REPLACE); @@ -149,13 +149,13 @@ public class ReadBuffer2Screen extends ReadBufferBase { } readTextureVertices.enableBuffer(gl, false); */ - readBufferUtil.getTexture().disable(); + readBufferUtil.getTexture().disable(gl); } void updateTextureCoords(GL gl, boolean force) { if(force || null==readTextureCoords) { - readTextureCoords = GLArrayDataServer.createFixed(gl, GLPointerFunc.GL_TEXTURE_COORD_ARRAY, "mgl_MultiTexCoord0", - 2, GL.GL_FLOAT, true, 4, GL.GL_STATIC_DRAW, GL.GL_ARRAY_BUFFER); + readTextureCoords = GLArrayDataServer.createFixed(GLPointerFunc.GL_TEXTURE_COORD_ARRAY, "mgl_MultiTexCoord0", 2, + GL.GL_FLOAT, true, 4, GL.GL_STATIC_DRAW); readTextureCoords.setEnableAlways(enableBufferAlways); readTextureCoords.setVBOEnabled(enableBufferVBO); { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/ReadBufferBase.java b/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/ReadBufferBase.java index 71a73a7e1..53675bc31 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/ReadBufferBase.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/ReadBufferBase.java @@ -78,7 +78,7 @@ public class ReadBufferBase implements GLEventListener { } public void dispose(GLAutoDrawable drawable) { - readBufferUtil.dispose(); + readBufferUtil.dispose(drawable.getGL()); } public void display(GLAutoDrawable drawable) { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/ReadBufferUtil.java b/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/ReadBufferUtil.java index d4fa0d654..5a2c73cf4 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/ReadBufferUtil.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/ReadBufferUtil.java @@ -83,9 +83,9 @@ public class ReadBufferUtil { gl.glReadPixels(0, 0, drawable.getWidth(), drawable.getHeight(), GL.GL_RGB, GL.GL_UNSIGNED_BYTE, readPixelBuffer); readPixelBuffer.rewind(); if(newData) { - readTexture.updateImage(readTextureData); + readTexture.updateImage(gl, readTextureData); } else { - readTexture.updateSubImage(readTextureData, 0, + readTexture.updateSubImage(gl, readTextureData, 0, 0, 0, // src offset 0, 0, // dst offset drawable.getWidth(), drawable.getHeight()); @@ -94,9 +94,8 @@ public class ReadBufferUtil { } } - @SuppressWarnings("deprecation") - public void dispose() { - readTexture.dispose(); + public void dispose(GL gl) { + readTexture.destroy(gl); readTextureData = null; readPixelBuffer.clear(); readPixelBuffer = null; diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/Surface2File.java b/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/Surface2File.java index 3ad2c4213..77fd40181 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/Surface2File.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/Surface2File.java @@ -42,8 +42,8 @@ public class Surface2File implements SurfaceUpdatedListener { ReadBufferUtil readBufferUtil = new ReadBufferUtil(); int shotNum = 0; - public void dispose() { - readBufferUtil.dispose(); + public void dispose(GL gl) { + readBufferUtil.dispose(gl); } public void surfaceUpdated(Object updater, NativeSurface ns, long when) { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/gl2/TextureGL2ListenerDraw1.java b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/gl2/TextureGL2ListenerDraw1.java index 649a3b19a..084caa682 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/gl2/TextureGL2ListenerDraw1.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/gl2/TextureGL2ListenerDraw1.java @@ -69,7 +69,7 @@ public class TextureGL2ListenerDraw1 implements GLEventListener { public void dispose(GLAutoDrawable drawable) { GL2 gl = drawable.getGL().getGL2(); if(null!=texture) { - texture.disable(); + texture.disable(gl); texture.destroy(gl); } if(null!=textureData) { @@ -91,8 +91,8 @@ public class TextureGL2ListenerDraw1 implements GLEventListener { // Now draw one quad with the texture if(null!=texture) { - texture.enable(); - texture.bind(); + texture.enable(gl); + texture.bind(gl); gl.glTexEnvi(GL2.GL_TEXTURE_ENV, GL2.GL_TEXTURE_ENV_MODE, GL2.GL_REPLACE); TextureCoords coords = texture.getImageTexCoords(); gl.glBegin(GL2.GL_QUADS); @@ -105,7 +105,7 @@ public class TextureGL2ListenerDraw1 implements GLEventListener { gl.glTexCoord2f(coords.left(), coords.top()); gl.glVertex3f(0, 1, 0); gl.glEnd(); - texture.disable(); + texture.disable(gl); } } } |