diff options
Diffstat (limited to 'src/demos')
35 files changed, 198 insertions, 197 deletions
diff --git a/src/demos/GLNewtRun.java b/src/demos/GLNewtRun.java index 5310a93..d02657c 100755 --- a/src/demos/GLNewtRun.java +++ b/src/demos/GLNewtRun.java @@ -233,11 +233,11 @@ public class GLNewtRun extends WindowAdapter implements KeyListener, MouseListen window.setFullscreen(fullscreen); // Size OpenGL to Video Surface window.setVisible(true); - window.enablePerfLog(true); + window.setUpdateFPSFrames(FPSCounter.DEFAULT_FRAMES_PER_INTERVAL, System.err); do { window.display(); - } while (!quit && window.getDuration() < 20000) ; + } while (!quit && window.getTotalFPSDuration() < 20000) ; window.destroy(); diff --git a/src/demos/applets/JOGLNewtAppletBase.java b/src/demos/applets/JOGLNewtAppletBase.java index 9fa1bdc..5f85715 100755 --- a/src/demos/applets/JOGLNewtAppletBase.java +++ b/src/demos/applets/JOGLNewtAppletBase.java @@ -124,7 +124,7 @@ public class JOGLNewtAppletBase extends WindowAdapter implements KeyListener, Mo } glWindow.addKeyListener(this); - glWindow.enablePerfLog(true); + glWindow.setUpdateFPSFrames(FPSCounter.DEFAULT_FRAMES_PER_INTERVAL, System.err); // glAnimator = new FPSAnimator(canvas, 60); glAnimator = new Animator(tg, glWindow); diff --git a/src/demos/es1/RedSquare.java b/src/demos/es1/RedSquare.java index 1049ee7..0a672e5 100755 --- a/src/demos/es1/RedSquare.java +++ b/src/demos/es1/RedSquare.java @@ -131,12 +131,12 @@ public class RedSquare extends Thread implements WindowListener, KeyListener, Mo window.addKeyListener(this); window.addGLEventListener(this); - window.enablePerfLog(true); + window.setUpdateFPSFrames(FPSCounter.DEFAULT_FRAMES_PER_INTERVAL, System.err); // Size OpenGL to Video Surface window.setSize(width, height); // window.setFullscreen(true); window.setVisible(true); - window.enablePerfLog(true); + window.setUpdateFPSFrames(FPSCounter.DEFAULT_FRAMES_PER_INTERVAL, System.err); if(!oneThread) { if(useAnimator) { @@ -152,7 +152,7 @@ public class RedSquare extends Thread implements WindowListener, KeyListener, Mo } else { do { display(); - } while (!quit && window.getDuration() < 11000) ; + } while (!quit && window.getTotalFPSDuration() < 11000) ; shutdown(); } } @@ -284,7 +284,7 @@ public class RedSquare extends Thread implements WindowListener, KeyListener, Mo gl.glMatrixMode(gl.GL_MODELVIEW); gl.glLoadIdentity(); gl.glTranslatef(0, 0, -10); - float ang = ((float) window.getDuration() * 360.0f) / 4000.0f; + float ang = ((float) window.getTotalFPSDuration() * 360.0f) / 4000.0f; gl.glRotatef(ang, 0, 0, 1); gl.glRotatef(ang, 0, 1, 0); diff --git a/src/demos/es1/angeles/AngelesGL.java b/src/demos/es1/angeles/AngelesGL.java index bc367d7..713cca7 100755 --- a/src/demos/es1/angeles/AngelesGL.java +++ b/src/demos/es1/angeles/AngelesGL.java @@ -298,14 +298,14 @@ public class GLSpatial { int[] tmp = new int[1]; gl.glGenBuffers(1, tmp, 0); vboName = tmp[0]; - - vArrayData = GLArrayDataWrapper.createFixed(gl, gl.GL_VERTEX_ARRAY, vComps, GL.GL_FLOAT, false, - 0, pBuffer, vboName, vOffset); - cArrayData = GLArrayDataWrapper.createFixed(gl, gl.GL_COLOR_ARRAY, cComps, GL.GL_FLOAT, false, - 0, pBuffer, vboName, cOffset); + + vArrayData = GLArrayDataWrapper.createFixed(gl.GL_VERTEX_ARRAY, vComps, GL.GL_FLOAT, false, + 0, pBuffer, vboName, vOffset, GL.GL_STATIC_DRAW); + cArrayData = GLArrayDataWrapper.createFixed(gl.GL_COLOR_ARRAY, cComps, GL.GL_FLOAT, false, + 0, pBuffer, vboName, cOffset, GL.GL_STATIC_DRAW); if(useNormalArray) { - nArrayData = GLArrayDataWrapper.createFixed(gl, gl.GL_NORMAL_ARRAY, nComps, GL.GL_FLOAT, false, - 0, pBuffer, vboName, nOffset); + nArrayData = GLArrayDataWrapper.createFixed(gl.GL_NORMAL_ARRAY, nComps, GL.GL_FLOAT, false, + 0, pBuffer, vboName, nOffset, GL.GL_STATIC_DRAW); } } diff --git a/src/demos/es1/angeles/AngelesGLil.java b/src/demos/es1/angeles/AngelesGLil.java index 92be109..fab211f 100755 --- a/src/demos/es1/angeles/AngelesGLil.java +++ b/src/demos/es1/angeles/AngelesGLil.java @@ -298,13 +298,13 @@ public class GLSpatial { interlArray.position(count*(vComps+cComps+nComps)); interlArray.flip(); - vArrayData = GLArrayDataWrapper.createFixed(gl, gl.GL_VERTEX_ARRAY, vComps, GL.GL_FLOAT, false, - bStride, pBuffer, vboName, vOffset); - cArrayData = GLArrayDataWrapper.createFixed(gl, gl.GL_COLOR_ARRAY, cComps, GL.GL_FLOAT, false, - bStride, pBuffer, vboName, cOffset); + vArrayData = GLArrayDataWrapper.createFixed(gl.GL_VERTEX_ARRAY, vComps, GL.GL_FLOAT, false, + bStride, pBuffer, vboName, vOffset, GL.GL_STATIC_DRAW); + cArrayData = GLArrayDataWrapper.createFixed(gl.GL_COLOR_ARRAY, cComps, GL.GL_FLOAT, false, + bStride, pBuffer, vboName, cOffset, GL.GL_STATIC_DRAW); if(useNormalArray) { - nArrayData = GLArrayDataWrapper.createFixed(gl, gl.GL_NORMAL_ARRAY, nComps, GL.GL_FLOAT, false, - bStride, pBuffer, vboName, nOffset); + nArrayData = GLArrayDataWrapper.createFixed(gl.GL_NORMAL_ARRAY, nComps, GL.GL_FLOAT, false, + bStride, pBuffer, vboName, nOffset, GL.GL_STATIC_DRAW); } } diff --git a/src/demos/es1/angeles/Main.java b/src/demos/es1/angeles/Main.java index 743f961..ad1a5b5 100755 --- a/src/demos/es1/angeles/Main.java +++ b/src/demos/es1/angeles/Main.java @@ -75,7 +75,7 @@ public class Main implements WindowListener, MouseListener { window.addWindowListener(this); window.addMouseListener(this); - window.enablePerfLog(true); + window.setUpdateFPSFrames(FPSCounter.DEFAULT_FRAMES_PER_INTERVAL, System.err); window.setSize(width, height); window.setFullscreen(true); window.setVisible(true); @@ -97,7 +97,7 @@ public class Main implements WindowListener, MouseListener { } } - while (!quit && window.getDuration() < 215000) { + while (!quit && window.getTotalFPSDuration() < 215000) { window.display(); } diff --git a/src/demos/es1/cube/Cube.java b/src/demos/es1/cube/Cube.java index fa88674..769bbe6 100644 --- a/src/demos/es1/cube/Cube.java +++ b/src/demos/es1/cube/Cube.java @@ -338,13 +338,13 @@ public class Cube implements GLEventListener { window.addGLEventListener(this); - window.enablePerfLog(true); + window.setUpdateFPSFrames(FPSCounter.DEFAULT_FRAMES_PER_INTERVAL, System.err); // Size OpenGL to Video Surface window.setSize(width, height); window.setFullscreen(true); window.setVisible(true); - while (!quit && window.getDuration() < 31000) { + while (!quit && window.getTotalFPSDuration() < 31000) { window.display(); } diff --git a/src/demos/es1/cube/CubeImmModeSink.java b/src/demos/es1/cube/CubeImmModeSink.java index a75b274..944cad0 100644 --- a/src/demos/es1/cube/CubeImmModeSink.java +++ b/src/demos/es1/cube/CubeImmModeSink.java @@ -403,7 +403,7 @@ public class CubeImmModeSink implements GLEventListener { window.addGLEventListener(this); - window.enablePerfLog(true); + window.setUpdateFPSFrames(FPSCounter.DEFAULT_FRAMES_PER_INTERVAL, System.err); // Size OpenGL to Video Surface window.setSize(width, height); window.setFullscreen(true); diff --git a/src/demos/es1/cubefbo/Main.java b/src/demos/es1/cubefbo/Main.java index cd26556..b2da7a5 100755 --- a/src/demos/es1/cubefbo/Main.java +++ b/src/demos/es1/cubefbo/Main.java @@ -76,7 +76,7 @@ public class Main implements WindowListener, MouseListener { window.addWindowListener(this); window.addMouseListener(this); - window.enablePerfLog(true); + window.setUpdateFPSFrames(FPSCounter.DEFAULT_FRAMES_PER_INTERVAL, System.err); window.setSize(width, height); window.setFullscreen(false); window.setVisible(true); @@ -85,7 +85,7 @@ public class Main implements WindowListener, MouseListener { FBCubes cubes = new FBCubes(); window.addGLEventListener(cubes); - while ( !quit && window.getDuration() < 31000) { + while ( !quit && window.getTotalFPSDuration() < 31000) { window.display(); } diff --git a/src/demos/es2/RedSquare.java b/src/demos/es2/RedSquare.java index 1d0bcad..c4817a8 100755 --- a/src/demos/es2/RedSquare.java +++ b/src/demos/es2/RedSquare.java @@ -118,12 +118,12 @@ public class RedSquare extends Thread implements WindowListener, KeyListener, Mo window.setSize(width, height); // window.setFullscreen(true); window.setVisible(true); - window.enablePerfLog(true); + window.setUpdateFPSFrames(FPSCounter.DEFAULT_FRAMES_PER_INTERVAL, System.err); if(!oneThread) { do { display(); - } while (!quit && window.getDuration() < 20000) ; + } while (!quit && window.getTotalFPSDuration() < 20000) ; shutdown(); } @@ -212,18 +212,18 @@ public class RedSquare extends Thread implements WindowListener, KeyListener, Mo initShader(gl); // Push the 1st uniform down the path - st.glUseProgram(gl, true); + st.useProgram(gl, true); pmvMatrix.glMatrixMode(pmvMatrix.GL_PROJECTION); pmvMatrix.glLoadIdentity(); pmvMatrix.glMatrixMode(pmvMatrix.GL_MODELVIEW); pmvMatrix.glLoadIdentity(); - if(!st.glUniform(gl, new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.glGetPMvMatrixf()))) { + if(!st.uniform(gl, new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.glGetPMvMatrixf()))) { throw new GLException("Error setting PMVMatrix in shader: "+st); } // Allocate vertex arrays - GLArrayDataClient vertices = GLArrayDataClient.createGLSL(gl, "mgl_Vertex", 3, gl.GL_FLOAT, false, 4); + GLArrayDataClient vertices = GLArrayDataClient.createGLSL(st, "mgl_Vertex", 3, gl.GL_FLOAT, false, 4); { // Fill them up FloatBuffer verticeb = (FloatBuffer)vertices.getBuffer(); @@ -234,7 +234,7 @@ public class RedSquare extends Thread implements WindowListener, KeyListener, Mo } vertices.seal(gl, true); - GLArrayDataClient colors = GLArrayDataClient.createGLSL(gl, "mgl_Color", 4, gl.GL_FLOAT, false, 4); + GLArrayDataClient colors = GLArrayDataClient.createGLSL(st, "mgl_Color", 4, gl.GL_FLOAT, false, 4); { // Fill them up FloatBuffer colorb = (FloatBuffer)colors.getBuffer(); @@ -249,7 +249,7 @@ public class RedSquare extends Thread implements WindowListener, KeyListener, Mo gl.glClearColor(0, 0, 0, 1); gl.glEnable(GL2ES2.GL_DEPTH_TEST); - st.glUseProgram(gl, false); + st.useProgram(gl, false); // Let's show the completed shader state .. System.out.println(Thread.currentThread()+" "+st); @@ -260,7 +260,7 @@ public class RedSquare extends Thread implements WindowListener, KeyListener, Mo GL2ES2 gl = drawable.getGL().getGL2ES2(); - st.glUseProgram(gl, true); + st.useProgram(gl, true); // Set location in front of camera pmvMatrix.glMatrixMode(pmvMatrix.GL_PROJECTION); @@ -271,10 +271,10 @@ public class RedSquare extends Thread implements WindowListener, KeyListener, Mo GLUniformData ud = st.getUniform("mgl_PMVMatrix"); if(null!=ud) { // same data object - st.glUniform(gl, ud); + st.uniform(gl, ud); } - st.glUseProgram(gl, false); + st.useProgram(gl, false); } public void dispose(GLAutoDrawable drawable) { @@ -295,7 +295,7 @@ public class RedSquare extends Thread implements WindowListener, KeyListener, Mo GL2ES2 gl = drawable.getGL().getGL2ES2(); - st.glUseProgram(gl, true); + st.useProgram(gl, true); gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT); @@ -303,20 +303,20 @@ public class RedSquare extends Thread implements WindowListener, KeyListener, Mo pmvMatrix.glMatrixMode(pmvMatrix.GL_MODELVIEW); pmvMatrix.glLoadIdentity(); pmvMatrix.glTranslatef(0, 0, -10); - float ang = ((float) window.getDuration() * 360.0f) / 4000.0f; + float ang = ((float) window.getTotalFPSDuration() * 360.0f) / 4000.0f; pmvMatrix.glRotatef(ang, 0, 0, 1); pmvMatrix.glRotatef(ang, 0, 1, 0); GLUniformData ud = st.getUniform("mgl_PMVMatrix"); if(null!=ud) { // same data object - st.glUniform(gl, ud); + st.uniform(gl, ud); } // Draw a square gl.glDrawArrays(gl.GL_TRIANGLE_STRIP, 0, 4); - st.glUseProgram(gl, false); + st.useProgram(gl, false); } public void displayChanged(GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged) { diff --git a/src/demos/es2/openmax/Cube.java b/src/demos/es2/openmax/Cube.java index 5d318cf..db09a06 100644 --- a/src/demos/es2/openmax/Cube.java +++ b/src/demos/es2/openmax/Cube.java @@ -330,13 +330,13 @@ public class Cube implements GLEventListener { window.addGLEventListener(this); - window.enablePerfLog(true); + window.setUpdateFPSFrames(FPSCounter.DEFAULT_FRAMES_PER_INTERVAL, System.err); // Size OpenGL to Video Surface window.setSize(width, height); window.setFullscreen(true); window.setVisible(true); - while (!quit && window.getDuration() < 31000) { + while (!quit && window.getTotalFPSDuration() < 31000) { window.display(); } diff --git a/src/demos/es2/openmax/MovieCube.java b/src/demos/es2/openmax/MovieCube.java index 6b53c6d..d992de1 100755 --- a/src/demos/es2/openmax/MovieCube.java +++ b/src/demos/es2/openmax/MovieCube.java @@ -185,13 +185,13 @@ public class MovieCube implements MouseListener, GLEventListener, OMXEventListen tex=movie.getNextTextureID(); if(null!=tex) { System.out.println("Use: "+tex); - tex.enable(); - tex.bind(); + tex.enable(gl); + tex.bind(gl); } } cube.display(drawable); if(null!=tex) { - tex.disable(); + tex.disable(gl); } } diff --git a/src/demos/es2/openmax/MovieSimple.java b/src/demos/es2/openmax/MovieSimple.java index 015d3b5..efcb59b 100755 --- a/src/demos/es2/openmax/MovieSimple.java +++ b/src/demos/es2/openmax/MovieSimple.java @@ -169,17 +169,17 @@ public class MovieSimple implements MouseListener, GLEventListener, OMXEventList initShader(gl); // Push the 1st uniform down the path - st.glUseProgram(gl, true); + st.useProgram(gl, true); pmvMatrix.glMatrixMode(pmvMatrix.GL_PROJECTION); pmvMatrix.glLoadIdentity(); pmvMatrix.glMatrixMode(pmvMatrix.GL_MODELVIEW); pmvMatrix.glLoadIdentity(); - if(!st.glUniform(gl, new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.glGetPMvMatrixf()))) { + if(!st.uniform(gl, new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.glGetPMvMatrixf()))) { throw new GLException("Error setting PMVMatrix in shader: "+st); } - if(!st.glUniform(gl, new GLUniformData("mgl_ActiveTexture", 0))) { + if(!st.uniform(gl, new GLUniformData("mgl_ActiveTexture", 0))) { throw new GLException("Error setting mgl_ActiveTexture in shader: "+st); } gl.glActiveTexture(GL.GL_TEXTURE0); @@ -197,7 +197,7 @@ public class MovieSimple implements MouseListener, GLEventListener, OMXEventList } // Allocate vertex array - GLArrayDataServer vertices = GLArrayDataServer.createGLSL(gl, "mgl_Vertex", 3, gl.GL_FLOAT, false, 4, GL.GL_STATIC_DRAW); + GLArrayDataServer vertices = GLArrayDataServer.createGLSL(st, "mgl_Vertex", 3, gl.GL_FLOAT, false, 4, GL.GL_STATIC_DRAW); { // Fill them up FloatBuffer verticeb = (FloatBuffer)vertices.getBuffer(); @@ -209,7 +209,7 @@ public class MovieSimple implements MouseListener, GLEventListener, OMXEventList vertices.seal(gl, true); // Allocate texcoord array - GLArrayDataServer texcoord = GLArrayDataServer.createGLSL(gl, "mgl_MultiTexCoord", 2, gl.GL_FLOAT, false, 4, GL.GL_STATIC_DRAW); + GLArrayDataServer texcoord = GLArrayDataServer.createGLSL(st, "mgl_MultiTexCoord", 2, gl.GL_FLOAT, false, 4, GL.GL_STATIC_DRAW); { // Fill them up FloatBuffer texcoordb = (FloatBuffer)texcoord.getBuffer(); @@ -220,7 +220,7 @@ public class MovieSimple implements MouseListener, GLEventListener, OMXEventList } texcoord.seal(gl, true); - GLArrayDataServer colors = GLArrayDataServer.createGLSL(gl, "mgl_Color", 4, gl.GL_FLOAT, false, 4, GL.GL_STATIC_DRAW); + GLArrayDataServer colors = GLArrayDataServer.createGLSL(st, "mgl_Color", 4, gl.GL_FLOAT, false, 4, GL.GL_STATIC_DRAW); { // Fill them up FloatBuffer colorb = (FloatBuffer)colors.getBuffer(); @@ -235,7 +235,7 @@ public class MovieSimple implements MouseListener, GLEventListener, OMXEventList gl.glClearColor(0.2f, 0.2f, 0.2f, 1); gl.glEnable(GL2ES2.GL_DEPTH_TEST); - st.glUseProgram(gl, false); + st.useProgram(gl, false); // Let's show the completed shader state .. System.out.println(st); @@ -257,7 +257,7 @@ public class MovieSimple implements MouseListener, GLEventListener, OMXEventList public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { GL2ES2 gl = drawable.getGL().getGL2ES2(); - st.glUseProgram(gl, true); + st.useProgram(gl, true); // Set location in front of camera pmvMatrix.glMatrixMode(pmvMatrix.GL_PROJECTION); @@ -272,10 +272,10 @@ public class MovieSimple implements MouseListener, GLEventListener, OMXEventList GLUniformData ud = st.getUniform("mgl_PMVMatrix"); if(null!=ud) { // same data object - st.glUniform(gl, ud); + st.uniform(gl, ud); } - st.glUseProgram(gl, false); + st.useProgram(gl, false); } public void dispose(GLAutoDrawable drawable) { @@ -293,7 +293,7 @@ public class MovieSimple implements MouseListener, GLEventListener, OMXEventList public void display(GLAutoDrawable drawable) { GL2ES2 gl = drawable.getGL().getGL2ES2(); - st.glUseProgram(gl, true); + st.useProgram(gl, true); gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT); @@ -312,7 +312,7 @@ public class MovieSimple implements MouseListener, GLEventListener, OMXEventList GLUniformData ud = st.getUniform("mgl_PMVMatrix"); if(null!=ud) { // same data object - st.glUniform(gl, ud); + st.uniform(gl, ud); } if(!rotate) { @@ -325,8 +325,8 @@ public class MovieSimple implements MouseListener, GLEventListener, OMXEventList if(null!=movie) { tex=movie.getNextTextureID(); if(null!=tex) { - tex.enable(); - tex.bind(); + tex.enable(gl); + tex.bind(gl); } } @@ -334,10 +334,10 @@ public class MovieSimple implements MouseListener, GLEventListener, OMXEventList gl.glDrawArrays(gl.GL_TRIANGLE_STRIP, 0, 4); if(null!=tex) { - tex.disable(); + tex.disable(gl); } - st.glUseProgram(gl, false); + st.useProgram(gl, false); } public void displayChanged(GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged) { diff --git a/src/demos/es2/perftst/PerfModule.java b/src/demos/es2/perftst/PerfModule.java index 69b9f1a..b472039 100644 --- a/src/demos/es2/perftst/PerfModule.java +++ b/src/demos/es2/perftst/PerfModule.java @@ -47,7 +47,7 @@ public abstract class PerfModule { // Let's manage all our states using ShaderState. st.attachShaderProgram(gl, sp); - st.glUseProgram(gl, true); + st.useProgram(gl, true); } public static final void put(Buffer buffer, int type, float v) { diff --git a/src/demos/es2/perftst/PerfTextLoad.java b/src/demos/es2/perftst/PerfTextLoad.java index 30f0ad7..e0a6e2e 100755 --- a/src/demos/es2/perftst/PerfTextLoad.java +++ b/src/demos/es2/perftst/PerfTextLoad.java @@ -57,9 +57,9 @@ public class PerfTextLoad extends PerfModule { // Vertices Data setup // - st.glUseProgram(gl, true); + st.useProgram(gl, true); - GLArrayDataServer vertices = GLArrayDataServer.createGLSL(gl, "mgl_Vertex", 2, GL.GL_FLOAT, true, 4, GL.GL_STATIC_DRAW); + GLArrayDataServer vertices = GLArrayDataServer.createGLSL(st, "mgl_Vertex", 2, GL.GL_FLOAT, true, 4, GL.GL_STATIC_DRAW); { FloatBuffer vb = (FloatBuffer)vertices.getBuffer(); vb.put(0f); vb.put(0f); @@ -69,7 +69,7 @@ public class PerfTextLoad extends PerfModule { } vertices.seal(gl, true); - GLArrayDataServer texCoords = GLArrayDataServer.createGLSL(gl, "mgl_MultiTexCoord0", 2, GL.GL_FLOAT, true, 4, GL.GL_STATIC_DRAW); + GLArrayDataServer texCoords = GLArrayDataServer.createGLSL(st, "mgl_MultiTexCoord0", 2, GL.GL_FLOAT, true, 4, GL.GL_STATIC_DRAW); { FloatBuffer cb = (FloatBuffer)texCoords.getBuffer(); cb.put(0f); cb.put(0f); @@ -86,12 +86,12 @@ public class PerfTextLoad extends PerfModule { tU[0] = System.currentTimeMillis(); for(int j=0; j<numTextures; j++) { gl.glActiveTexture(j); - textures[j].updateImage(textDatas[0]); + textures[j].updateImage(gl, textDatas[0]); tU[j+1] = System.currentTimeMillis(); } GLUniformData activeTexture = new GLUniformData("mgl_ActiveTexture", 0); - st.glUniform(gl, activeTexture); + st.uniform(gl, activeTexture); // // run loops @@ -116,14 +116,14 @@ public class PerfTextLoad extends PerfModule { for(int k=0; k<numTextures; k++) { gl.glActiveTexture(GL.GL_TEXTURE0+k); - textures[k].enable(); - textures[k].bind(); + textures[k].enable(gl); + textures[k].bind(gl); activeTexture.setData(k); - st.glUniform(gl, activeTexture); + st.uniform(gl, activeTexture); t1[i][j][k] = System.currentTimeMillis(); - textures[k].updateSubImage(textDatas[j], 0, 0, 0); + textures[k].updateSubImage(gl, textDatas[j], 0, 0, 0); t2[i][j][k] = System.currentTimeMillis(); @@ -189,11 +189,11 @@ public class PerfTextLoad extends PerfModule { } System.out.println("*****************************************************************"); - st.glUseProgram(gl, false); + st.useProgram(gl, false); for(int i=0; i<numTextures; i++) { - textures[i].disable(); - textures[i].dispose(); + textures[i].disable(gl); + textures[i].destroy(gl); textures[i]=null; } for(int i=0; i<numObjs; i++) { diff --git a/src/demos/es2/perftst/PerfUniLoad.java b/src/demos/es2/perftst/PerfUniLoad.java index 1c71253..99621ee 100755 --- a/src/demos/es2/perftst/PerfUniLoad.java +++ b/src/demos/es2/perftst/PerfUniLoad.java @@ -35,9 +35,9 @@ public class PerfUniLoad extends PerfModule { throw new GLException("numArrayElem must be within 0.."+MAX_ARRAY_ELEM); } - st.glUseProgram(gl, true); + st.useProgram(gl, true); - GLArrayDataServer vertices = GLArrayDataServer.createGLSL(gl, "mgl_Vertex", 3, GL.GL_FLOAT, true, 4, GL.GL_STATIC_DRAW); + GLArrayDataServer vertices = GLArrayDataServer.createGLSL(st, "mgl_Vertex", 3, GL.GL_FLOAT, true, 4, GL.GL_STATIC_DRAW); { FloatBuffer vb = (FloatBuffer)vertices.getBuffer(); vb.put(0f); vb.put(0f); vb.put(0f); @@ -47,7 +47,7 @@ public class PerfUniLoad extends PerfModule { } vertices.seal(gl, true); - GLArrayDataServer colors = GLArrayDataServer.createGLSL(gl, "mgl_Color", 4, GL.GL_FLOAT, true, 4, GL.GL_STATIC_DRAW); + GLArrayDataServer colors = GLArrayDataServer.createGLSL(st, "mgl_Color", 4, GL.GL_FLOAT, true, 4, GL.GL_STATIC_DRAW); { FloatBuffer cb = (FloatBuffer)colors.getBuffer(); cb.put(0f); cb.put(0f); cb.put(0f); cb.put(1f); @@ -103,7 +103,7 @@ public class PerfUniLoad extends PerfModule { t0[i] = System.currentTimeMillis(); for(int j=0; j<numObjs; j++) { - st.glUniform(gl, dummyUni[j]); + st.uniform(gl, dummyUni[j]); t1[i][j] = System.currentTimeMillis(); @@ -155,7 +155,7 @@ public class PerfUniLoad extends PerfModule { System.out.println("*****************************************************************"); - st.glUseProgram(gl, false); + st.useProgram(gl, false); try { Thread.sleep(100); diff --git a/src/demos/es2/perftst/PerfVBOLoad.java b/src/demos/es2/perftst/PerfVBOLoad.java index d0b4a1d..fcfaff0 100755 --- a/src/demos/es2/perftst/PerfVBOLoad.java +++ b/src/demos/es2/perftst/PerfVBOLoad.java @@ -28,8 +28,8 @@ public class PerfVBOLoad extends PerfModule { float r=1f, g=1f, b=1f; for(int i=0; i<numObjs; i++) { - vertices[i] = GLArrayDataServer.createGLSL(gl, "mgl_Vertex", 3, dataType, true, numVertices, GL.GL_STATIC_DRAW); - vertices[i].setVBOUsage(useVBO); + vertices[i] = GLArrayDataServer.createGLSL(st, "mgl_Vertex", 3, dataType, true, numVertices, GL.GL_STATIC_DRAW); + vertices[i].setVBOEnabled(useVBO); { Buffer verticeb = vertices[i].getBuffer(); for(int j=0; j<numVertices; j++) { @@ -42,8 +42,8 @@ public class PerfVBOLoad extends PerfModule { if(y>1f) { x=0f; y=0f; z+=0.01f; } } } - colors[i] = GLArrayDataServer.createGLSL(gl, "mgl_Color", 4, dataType, true, numVertices, GL.GL_STATIC_DRAW); - colors[i].setVBOUsage(useVBO); + colors[i] = GLArrayDataServer.createGLSL(st, "mgl_Color", 4, dataType, true, numVertices, GL.GL_STATIC_DRAW); + colors[i].setVBOEnabled(useVBO); { // Fill them up Buffer colorb = colors[i].getBuffer(); @@ -74,7 +74,7 @@ public class PerfVBOLoad extends PerfModule { long[] tS = new long[loops]; // Push the 1st uniform down the path - st.glUseProgram(gl, true); + st.useProgram(gl, true); for(int i=0; i<loops; i++) { tC[i] = System.currentTimeMillis(); @@ -164,7 +164,7 @@ public class PerfVBOLoad extends PerfModule { } System.out.println("*****************************************************************"); - st.glUseProgram(gl, false); + st.useProgram(gl, false); for(int i=0; i<numObjs; i++) { vertices[i].destroy(gl); diff --git a/src/demos/es2/perftst/Perftst.java b/src/demos/es2/perftst/Perftst.java index 4860e51..dba9e48 100755 --- a/src/demos/es2/perftst/Perftst.java +++ b/src/demos/es2/perftst/Perftst.java @@ -93,17 +93,17 @@ public class Perftst implements MouseListener, GLEventListener { pmvMatrix = new PMVMatrix(); pmod.initShaderState(gl); - st = ShaderState.getCurrent(); + st = ShaderState.getShaderState(gl); // Push the 1st uniform down the path - st.glUseProgram(gl, true); + st.useProgram(gl, true); pmvMatrix.glMatrixMode(pmvMatrix.GL_PROJECTION); pmvMatrix.glLoadIdentity(); pmvMatrix.glMatrixMode(pmvMatrix.GL_MODELVIEW); pmvMatrix.glLoadIdentity(); - if(!st.glUniform(gl, new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.glGetPMvMatrixf()))) { + if(!st.uniform(gl, new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.glGetPMvMatrixf()))) { throw new GLException("Error setting PMVMatrix in shader: "+st); } @@ -111,7 +111,7 @@ public class Perftst implements MouseListener, GLEventListener { gl.glClearColor(0, 0, 0, 1); gl.glEnable(GL2ES2.GL_DEPTH_TEST); - st.glUseProgram(gl, false); + st.useProgram(gl, false); // Let's show the completed shader state .. System.out.println(st); @@ -120,7 +120,7 @@ public class Perftst implements MouseListener, GLEventListener { public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { GL2ES2 gl = drawable.getGL().getGL2ES2(); - st.glUseProgram(gl, true); + st.useProgram(gl, true); // Set location in front of camera pmvMatrix.glMatrixMode(pmvMatrix.GL_PROJECTION); @@ -134,10 +134,10 @@ public class Perftst implements MouseListener, GLEventListener { GLUniformData ud = st.getUniform("mgl_PMVMatrix"); if(null!=ud) { // same data object - st.glUniform(gl, ud); + st.uniform(gl, ud); } - st.glUseProgram(gl, false); + st.useProgram(gl, false); } public void dispose(GLAutoDrawable drawable) { diff --git a/src/demos/hwShadowmapsSimple/HWShadowmapsSimple.java b/src/demos/hwShadowmapsSimple/HWShadowmapsSimple.java index 7afb354..e2af4b3 100644 --- a/src/demos/hwShadowmapsSimple/HWShadowmapsSimple.java +++ b/src/demos/hwShadowmapsSimple/HWShadowmapsSimple.java @@ -240,8 +240,8 @@ public class HWShadowmapsSimple extends Demo { decal = TextureIO.newTexture(getClass().getClassLoader().getResourceAsStream("demos/data/images/decal_image.png"), true, TextureIO.PNG); - decal.setTexParameteri(GL2.GL_TEXTURE_WRAP_S, GL2.GL_REPEAT); - decal.setTexParameteri(GL2.GL_TEXTURE_WRAP_T, GL2.GL_REPEAT); + decal.setTexParameteri(gl, GL2.GL_TEXTURE_WRAP_S, GL2.GL_REPEAT); + decal.setTexParameteri(gl, GL2.GL_TEXTURE_WRAP_T, GL2.GL_REPEAT); light_image = TextureIO.newTexture(getClass().getClassLoader().getResourceAsStream("demos/data/images/nvlogo_spot.png"), true, TextureIO.PNG); @@ -573,10 +573,10 @@ public class HWShadowmapsSimple extends Demo { gl.glMatrixMode(GL2.GL_MODELVIEW); gl.glDisable(GL2.GL_LIGHTING); - decal.bind(); - decal.enable(); + decal.bind(gl); + decal.enable(gl); gl.glCallList(quad); - decal.disable(); + decal.disable(gl); gl.glEnable(GL2.GL_LIGHTING); texgen(gl, false); @@ -647,8 +647,8 @@ public class HWShadowmapsSimple extends Demo { applyTransform(gl, spotlightInverseTransform); gl.glMatrixMode(GL2.GL_MODELVIEW); - light_image.bind(); - light_image.enable(); + light_image.bind(gl); + light_image.enable(gl); gl.glTexEnvi(GL2.GL_TEXTURE_ENV, GL2.GL_TEXTURE_ENV_MODE, GL2.GL_MODULATE); gl.glActiveTexture(GL2.GL_TEXTURE0); @@ -660,7 +660,7 @@ public class HWShadowmapsSimple extends Demo { render_scene(gl, cameraTransform, drawable, params); gl.glActiveTexture(GL2.GL_TEXTURE1); - light_image.disable(); + light_image.disable(gl); gl.glActiveTexture(GL2.GL_TEXTURE0); render_manipulators(gl, cameraTransform, drawable, params); @@ -694,8 +694,8 @@ public class HWShadowmapsSimple extends Demo { applyTransform(gl, spotlightInverseTransform); gl.glMatrixMode(GL2.GL_MODELVIEW); - light_image.bind(); - light_image.enable(); + light_image.bind(gl); + light_image.enable(gl); gl.glTexEnvi(GL2.GL_TEXTURE_ENV, GL2.GL_TEXTURE_ENV_MODE, GL2.GL_MODULATE); // depth compare @@ -729,7 +729,7 @@ public class HWShadowmapsSimple extends Demo { render_scene(gl, cameraTransform, drawable, params); gl.glActiveTexture(GL2.GL_TEXTURE1); - light_image.disable(); + light_image.disable(gl); gl.glActiveTexture(GL2.GL_TEXTURE2); gl.glDisable(GL2.GL_TEXTURE_2D); gl.glActiveTexture(GL2.GL_TEXTURE0); @@ -769,8 +769,8 @@ public class HWShadowmapsSimple extends Demo { glu.gluPerspective(lightshaper_fovy, 1, lightshaper_zNear, lightshaper_zFar); gl.glMatrixMode(GL2.GL_MODELVIEW); - light_image.bind(); - light_image.enable(); + light_image.bind(gl); + light_image.enable(gl); gl.glTexEnvi(GL2.GL_TEXTURE_ENV, GL2.GL_TEXTURE_ENV_MODE, GL2.GL_MODULATE); gl.glActiveTexture(GL2.GL_TEXTURE0); @@ -785,7 +785,7 @@ public class HWShadowmapsSimple extends Demo { render_scene(gl, spotlightTransform, null, null); gl.glActiveTexture(GL2.GL_TEXTURE1); - light_image.disable(); + light_image.disable(gl); gl.glActiveTexture(GL2.GL_TEXTURE0); } diff --git a/src/demos/j2d/CustomText.java b/src/demos/j2d/CustomText.java index 5918dc9..3a68761 100755 --- a/src/demos/j2d/CustomText.java +++ b/src/demos/j2d/CustomText.java @@ -210,11 +210,11 @@ public class CustomText extends Demo { g.fillRect(1, 1, 1, 1); g.dispose(); backgroundTexture = AWTTextureIO.newTexture(gl.getGLProfile(), bgImage, false); - backgroundTexture.bind(); - backgroundTexture.setTexParameteri(GL.GL_TEXTURE_MIN_FILTER, GL.GL_NEAREST); - backgroundTexture.setTexParameteri(GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); - backgroundTexture.setTexParameteri(GL.GL_TEXTURE_WRAP_S, GL.GL_REPEAT); - backgroundTexture.setTexParameteri(GL.GL_TEXTURE_WRAP_T, GL.GL_REPEAT); + backgroundTexture.bind(gl); + backgroundTexture.setTexParameteri(gl, GL.GL_TEXTURE_MIN_FILTER, GL.GL_NEAREST); + backgroundTexture.setTexParameteri(gl, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); + backgroundTexture.setTexParameteri(gl, GL.GL_TEXTURE_WRAP_S, GL.GL_REPEAT); + backgroundTexture.setTexParameteri(gl, GL.GL_TEXTURE_WRAP_T, GL.GL_REPEAT); // Create the text renderer renderer = new TextRenderer(new Font("Serif", Font.PLAIN, 72), true, true, @@ -299,8 +299,8 @@ public class CustomText extends Demo { gl.glLoadIdentity(); // Draw the background texture - backgroundTexture.enable(); - backgroundTexture.bind(); + backgroundTexture.enable(gl); + backgroundTexture.bind(gl); TextureCoords coords = backgroundTexture.getImageTexCoords(); int w = drawable.getWidth(); int h = drawable.getHeight(); @@ -317,7 +317,7 @@ public class CustomText extends Demo { gl.glTexCoord2f(fw * coords.left(), fh * coords.top()); gl.glVertex3f(0, h, 0); gl.glEnd(); - backgroundTexture.disable(); + backgroundTexture.disable(gl); // Render all text renderer.beginRendering(drawable.getWidth(), drawable.getHeight()); diff --git a/src/demos/j2d/FlyingText.java b/src/demos/j2d/FlyingText.java index 929803e..debb9c7 100755 --- a/src/demos/j2d/FlyingText.java +++ b/src/demos/j2d/FlyingText.java @@ -249,11 +249,11 @@ public class FlyingText extends Demo { g.fillRect(1, 1, 1, 1); g.dispose(); backgroundTexture = AWTTextureIO.newTexture(gl.getGLProfile(), bgImage, false); - backgroundTexture.bind(); - backgroundTexture.setTexParameteri(GL2.GL_TEXTURE_MIN_FILTER, GL2.GL_NEAREST); - backgroundTexture.setTexParameteri(GL2.GL_TEXTURE_MAG_FILTER, GL2.GL_NEAREST); - backgroundTexture.setTexParameteri(GL2.GL_TEXTURE_WRAP_S, GL2.GL_REPEAT); - backgroundTexture.setTexParameteri(GL2.GL_TEXTURE_WRAP_T, GL2.GL_REPEAT); + backgroundTexture.bind(gl); + backgroundTexture.setTexParameteri(gl, GL2.GL_TEXTURE_MIN_FILTER, GL2.GL_NEAREST); + backgroundTexture.setTexParameteri(gl, GL2.GL_TEXTURE_MAG_FILTER, GL2.GL_NEAREST); + backgroundTexture.setTexParameteri(gl, GL2.GL_TEXTURE_WRAP_S, GL2.GL_REPEAT); + backgroundTexture.setTexParameteri(gl, GL2.GL_TEXTURE_WRAP_T, GL2.GL_REPEAT); // Create the text renderer renderer = new TextRenderer(new Font("Serif", Font.PLAIN, 72), true, true); @@ -353,8 +353,8 @@ public class FlyingText extends Demo { gl.glLoadIdentity(); // Draw the background texture - backgroundTexture.enable(); - backgroundTexture.bind(); + backgroundTexture.enable(gl); + backgroundTexture.bind(gl); TextureCoords coords = backgroundTexture.getImageTexCoords(); int w = drawable.getWidth(); int h = drawable.getHeight(); @@ -371,7 +371,7 @@ public class FlyingText extends Demo { gl.glTexCoord2f(fw * coords.left(), fh * coords.top()); gl.glVertex3f(0, h, 0); gl.glEnd(); - backgroundTexture.disable(); + backgroundTexture.disable(gl); // Render all text renderer.beginRendering(drawable.getWidth(), drawable.getHeight()); diff --git a/src/demos/particles/engine/Engine.java b/src/demos/particles/engine/Engine.java index d769457..d443ac2 100755 --- a/src/demos/particles/engine/Engine.java +++ b/src/demos/particles/engine/Engine.java @@ -37,6 +37,7 @@ package demos.particles.engine; import javax.media.opengl.*; + import com.jogamp.opengl.util.texture.*; import java.net.*; import java.util.*; @@ -78,12 +79,12 @@ public class Engine { } } - public void init() { + public void init(GL gl) { try { ClassLoader c1 = this.getClass().getClassLoader(); URL url = c1.getResource(path); texture = TextureIO.newTexture(url, false, null); - texture.enable(); + texture.enable(gl); } catch(IOException e) { e.printStackTrace(); diff --git a/src/demos/particles/engine/GLComponent.java b/src/demos/particles/engine/GLComponent.java index 7194861..46a0940 100755 --- a/src/demos/particles/engine/GLComponent.java +++ b/src/demos/particles/engine/GLComponent.java @@ -106,7 +106,7 @@ public class GLComponent extends GLCanvas implements GLEventListener { animator.start(); - engine.init(); + engine.init(gl); } diff --git a/src/demos/particles/engine/Particle.java b/src/demos/particles/engine/Particle.java index d9858dd..81fbe25 100755 --- a/src/demos/particles/engine/Particle.java +++ b/src/demos/particles/engine/Particle.java @@ -58,7 +58,7 @@ public class Particle { public void draw(GL2 gl, Texture texture, RGBA tendToColor) { adjust(tendToColor); - texture.bind(); + texture.bind(gl); gl.glColor4f(rgba.r,rgba.g,rgba.b,rgba.a); gl.glBegin(GL2.GL_QUADS); diff --git a/src/demos/proceduralTexturePhysics/Water.java b/src/demos/proceduralTexturePhysics/Water.java index 3e4fad4..80de446 100644 --- a/src/demos/proceduralTexturePhysics/Water.java +++ b/src/demos/proceduralTexturePhysics/Water.java @@ -272,11 +272,11 @@ public class Water { // Draw quad over full display gl.glActiveTexture(GL2.GL_TEXTURE0); - dynamicTextures[CA_TEXTURE_NORMAL_MAP].bind(); - dynamicTextures[CA_TEXTURE_NORMAL_MAP].disable(); + dynamicTextures[CA_TEXTURE_NORMAL_MAP].bind(gl); + dynamicTextures[CA_TEXTURE_NORMAL_MAP].disable(gl); gl.glActiveTexture(GL2.GL_TEXTURE3); - cubemap.bind(); - cubemap.enable(); + cubemap.bind(gl); + cubemap.enable(gl); gl.glColor4f(1, 1, 1, 1); gl.glBegin(GL2.GL_QUADS); @@ -307,7 +307,7 @@ public class Water { gl.glEnd(); - cubemap.disable(); + cubemap.disable(gl); gl.glDisable(GL2.GL_FRAGMENT_PROGRAM_ARB); break; @@ -316,7 +316,7 @@ public class Water { case CA_FULLSCREEN_NORMALMAP: { // Draw quad over full display gl.glActiveTexture(GL2.GL_TEXTURE0); - dynamicTextures[CA_TEXTURE_NORMAL_MAP].bind(); + dynamicTextures[CA_TEXTURE_NORMAL_MAP].bind(gl); gl.glCallList(displayListIDs[CA_DRAW_SCREEN_QUAD]); break; @@ -334,7 +334,7 @@ public class Water { case CA_FULLSCREEN_FORCE: { // Draw quad over full display gl.glActiveTexture(GL2.GL_TEXTURE0); - dynamicTextures[CA_TEXTURE_FORCE_TARGET].bind(); + dynamicTextures[CA_TEXTURE_FORCE_TARGET].bind(gl); gl.glCallList(displayListIDs[CA_DRAW_SCREEN_QUAD]); break; @@ -344,7 +344,7 @@ public class Water { // Draw quad over full display // lower left gl.glActiveTexture(GL2.GL_TEXTURE0); - dynamicTextures[CA_TEXTURE_FORCE_TARGET].bind(); + dynamicTextures[CA_TEXTURE_FORCE_TARGET].bind(gl); gl.glMatrixMode(GL2.GL_MODELVIEW); gl.glPushMatrix(); @@ -363,7 +363,7 @@ public class Water { gl.glPopMatrix(); // upper left - dynamicTextures[CA_TEXTURE_NORMAL_MAP].bind(); + dynamicTextures[CA_TEXTURE_NORMAL_MAP].bind(gl); gl.glMatrixMode(GL2.GL_MODELVIEW); gl.glPushMatrix(); @@ -694,11 +694,11 @@ public class Water { switch (flipState) { case 0: - texHeightInput = dynamicTextures[CA_TEXTURE_HEIGHT_SOURCE].getTextureObject(); // initial height map. - texHeightOutput = dynamicTextures[CA_TEXTURE_HEIGHT_TARGET].getTextureObject(); // next height map. + texHeightInput = dynamicTextures[CA_TEXTURE_HEIGHT_SOURCE].getTextureObject(gl); // initial height map. + texHeightOutput = dynamicTextures[CA_TEXTURE_HEIGHT_TARGET].getTextureObject(gl); // next height map. - texVelocityInput = dynamicTextures[CA_TEXTURE_VELOCITY_SOURCE].getTextureObject(); // initial velocity. - texVelocityOutput = dynamicTextures[CA_TEXTURE_VELOCITY_TARGET].getTextureObject(); // next velocity. + texVelocityInput = dynamicTextures[CA_TEXTURE_VELOCITY_SOURCE].getTextureObject(gl); // initial velocity. + texVelocityOutput = dynamicTextures[CA_TEXTURE_VELOCITY_TARGET].getTextureObject(gl); // next velocity. // Clear initial velocity texture to 0x80 == gray gl.glClearColor(0.5f, 0.5f, 0.5f, 1.0f); @@ -776,7 +776,7 @@ public class Water { // Now we need to copy the resulting pixels into the intermediate force field texture gl.glActiveTexture(GL2.GL_TEXTURE2); - dynamicTextures[CA_TEXTURE_FORCE_INTERMEDIATE].bind(); + dynamicTextures[CA_TEXTURE_FORCE_INTERMEDIATE].bind(gl); // use CopyTexSubImage for speed (even though we copy all of it) since we pre-allocated the texture gl.glCopyTexSubImage2D(GL2.GL_TEXTURE_2D, 0, 0, 0, 0, 0, initialMapDimensions[0], initialMapDimensions[1]); @@ -818,7 +818,7 @@ public class Water { // Now we need to copy the resulting pixels into the intermediate force field texture gl.glActiveTexture(GL2.GL_TEXTURE1); - dynamicTextures[CA_TEXTURE_FORCE_TARGET].bind(); + dynamicTextures[CA_TEXTURE_FORCE_TARGET].bind(gl); // use CopyTexSubImage for speed (even though we copy all of it) since we pre-allocated the texture gl.glCopyTexSubImage2D(GL2.GL_TEXTURE_2D, 0, 0, 0, 0, 0, initialMapDimensions[0], initialMapDimensions[1]); @@ -837,7 +837,7 @@ public class Water { gl.glActiveTexture(GL2.GL_TEXTURE0); gl.glBindTexture(GL2.GL_TEXTURE_2D, texVelocityInput); gl.glActiveTexture(GL2.GL_TEXTURE1); - dynamicTextures[CA_TEXTURE_FORCE_TARGET].bind(); + dynamicTextures[CA_TEXTURE_FORCE_TARGET].bind(gl); gl.glActiveTexture(GL2.GL_TEXTURE2); gl.glDisable(GL2.GL_TEXTURE_2D); gl.glActiveTexture(GL2.GL_TEXTURE3); @@ -985,7 +985,7 @@ public class Water { // Now we need to copy the resulting pixels into the normal map gl.glActiveTexture(GL2.GL_TEXTURE0); - dynamicTextures[CA_TEXTURE_NORMAL_MAP].bind(); + dynamicTextures[CA_TEXTURE_NORMAL_MAP].bind(gl); // use CopyTexSubImage for speed (even though we copy all of it) since we pre-allocated the texture gl.glCopyTexSubImage2D(GL2.GL_TEXTURE_2D, 0, 0, 0, 0, 0, initialMapDimensions[0], initialMapDimensions[1]); @@ -994,8 +994,8 @@ public class Water { private void drawInteriorBoundaryObjects(GL2 gl) { gl.glActiveTexture(GL2.GL_TEXTURE0); - initialMapTex.bind(); - initialMapTex.enable(); + initialMapTex.bind(gl); + initialMapTex.enable(gl); gl.glEnable(GL2.GL_ALPHA_TEST); @@ -1012,7 +1012,7 @@ public class Water { if (spinLogo) { gl.glActiveTexture(GL2.GL_TEXTURE0); - spinTex.bind(); + spinTex.bind(gl); gl.glMatrixMode(GL2.GL_MODELVIEW); gl.glPushMatrix(); gl.glRotatef(angle, 0, 0, 1); @@ -1043,10 +1043,10 @@ public class Water { FileUtil.getFileSuffix(dropletFilename)); // load the cubemap texture - cubemap = Cubemap.loadFromStreams(getClass().getClassLoader(), + cubemap = Cubemap.loadFromStreams(gl, + getClass().getClassLoader(), cubeMapFilenamePrefix, - cubeMapFilenameSuffix, - true); + cubeMapFilenameSuffix, true); // now create dummy intermediate textures from the initial map texture for (int i = 0; i < CA_NUM_DYNAMIC_TEXTURES; i++) { @@ -1055,11 +1055,11 @@ public class Water { initialMapData = null; - texHeightInput = initialMapTex.getTextureObject(); // initial height map. - texHeightOutput = dynamicTextures[CA_TEXTURE_HEIGHT_TARGET].getTextureObject(); // next height map. + texHeightInput = initialMapTex.getTextureObject(gl); // initial height map. + texHeightOutput = dynamicTextures[CA_TEXTURE_HEIGHT_TARGET].getTextureObject(gl); // next height map. - texVelocityInput = dynamicTextures[CA_TEXTURE_VELOCITY_SOURCE].getTextureObject(); // initial velocity. - texVelocityOutput = dynamicTextures[CA_TEXTURE_VELOCITY_TARGET].getTextureObject(); // next velocity. + texVelocityInput = dynamicTextures[CA_TEXTURE_VELOCITY_SOURCE].getTextureObject(gl); // initial velocity. + texVelocityOutput = dynamicTextures[CA_TEXTURE_VELOCITY_TARGET].getTextureObject(gl); // next velocity. } private void createAndWriteUVOffsets(GL2 gl, int width, int height) { @@ -1154,8 +1154,8 @@ public class Water { gl.glDisable(GL2.GL_VERTEX_PROGRAM_ARB); gl.glActiveTexture(GL2.GL_TEXTURE0); - dropletTex.bind(); - dropletTex.enable(); + dropletTex.bind(gl); + dropletTex.enable(gl); gl.glActiveTexture(GL2.GL_TEXTURE1); gl.glDisable(GL2.GL_TEXTURE_2D); diff --git a/src/demos/readbuffer/Main.java b/src/demos/readbuffer/Main.java index 426bdd7..d0ce55b 100755 --- a/src/demos/readbuffer/Main.java +++ b/src/demos/readbuffer/Main.java @@ -68,7 +68,7 @@ public class Main implements WindowListener, MouseListener, SurfaceUpdatedListen Window nWindow = NewtFactory.createWindow(nScreen, capsOffscreen); GLWindow windowOffscreen = GLWindow.create(nWindow); - windowOffscreen.enablePerfLog(true); + windowOffscreen.setUpdateFPSFrames(FPSCounter.DEFAULT_FRAMES_PER_INTERVAL, System.err); windowOffscreen.setSize(w, h); windowOffscreen.setVisible(true); return windowOffscreen; @@ -139,11 +139,11 @@ public class Main implements WindowListener, MouseListener, SurfaceUpdatedListen // System.out.println("..............................."); windowOffscreen.display(); if ( TEST_READBUFFER2SCREEN == typeTest ) { - if ( windowOffscreen.getDuration() >= 10000) { + if ( windowOffscreen.getTotalFPSDuration() >= 10000) { break; } } else { - if ( windowOffscreen.getTotalFrames() >= 10) { + if ( windowOffscreen.getTotalFPSFrames() >= 10) { break; } } diff --git a/src/demos/readbuffer/ReadBuffer2Screen.java b/src/demos/readbuffer/ReadBuffer2Screen.java index 13e6508..cc120f2 100755 --- a/src/demos/readbuffer/ReadBuffer2Screen.java +++ b/src/demos/readbuffer/ReadBuffer2Screen.java @@ -66,10 +66,10 @@ 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", + readTextureVertices = GLArrayDataServer.createFixed(GLPointerFunc.GL_VERTEX_ARRAY, "mgl_Vertex", 2, GL.GL_FLOAT, true, 4, GL.GL_STATIC_DRAW); readTextureVertices.setEnableAlways(enableBufferAlways); - readTextureVertices.setVBOUsage(enableBufferVBO); + readTextureVertices.setVBOEnabled(enableBufferVBO); { FloatBuffer vb = (FloatBuffer)readTextureVertices.getBuffer(); vb.put(-f_edge); vb.put(-f_edge); @@ -130,8 +130,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); @@ -151,15 +151,15 @@ 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", + readTextureCoords = GLArrayDataServer.createFixed(GLPointerFunc.GL_TEXTURE_COORD_ARRAY, "mgl_MultiTexCoord0", 2, GL.GL_FLOAT, true, 4, GL.GL_STATIC_DRAW); readTextureCoords.setEnableAlways(enableBufferAlways); - readTextureCoords.setVBOUsage(enableBufferVBO); + readTextureCoords.setVBOEnabled(enableBufferVBO); { TextureCoords coords = readBufferUtil.getTexture().getImageTexCoords(); FloatBuffer cb = (FloatBuffer)readTextureCoords.getBuffer(); diff --git a/src/demos/readbuffer/ReadBufferBase.java b/src/demos/readbuffer/ReadBufferBase.java index 6922f02..d392d1c 100755 --- a/src/demos/readbuffer/ReadBufferBase.java +++ b/src/demos/readbuffer/ReadBufferBase.java @@ -80,7 +80,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/demos/readbuffer/ReadBufferUtil.java b/src/demos/readbuffer/ReadBufferUtil.java index 85680c7..e271767 100755 --- a/src/demos/readbuffer/ReadBufferUtil.java +++ b/src/demos/readbuffer/ReadBufferUtil.java @@ -88,9 +88,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()); @@ -99,8 +99,8 @@ public class ReadBufferUtil { } } - public void dispose() { - readTexture.dispose(); + public void dispose(GL gl) { + readTexture.destroy(gl); readTextureData = null; readPixelBuffer.clear(); readPixelBuffer = null; diff --git a/src/demos/readbuffer/Surface2File.java b/src/demos/readbuffer/Surface2File.java index 2303a1c..051094c 100755 --- a/src/demos/readbuffer/Surface2File.java +++ b/src/demos/readbuffer/Surface2File.java @@ -47,8 +47,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 surface, long when) { diff --git a/src/demos/texture/TestSubImage.java b/src/demos/texture/TestSubImage.java index 377a910..05cbb59 100755 --- a/src/demos/texture/TestSubImage.java +++ b/src/demos/texture/TestSubImage.java @@ -120,7 +120,7 @@ public class TestSubImage { if (convertedImage == null) { // Get rid of any previously allocated texture if (texture != null) { - texture.dispose(); + texture.destroy(gl); texture = null; } @@ -183,15 +183,15 @@ public class TestSubImage { yOrigin = texture.getHeight() - yOrigin; } - texture.updateSubImage(textureData, 0, + texture.updateSubImage(gl, textureData, 0, union.x, yOrigin, union.x, yOrigin, union.width, union.height); } // Now draw one quad with the 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); @@ -204,7 +204,7 @@ public class TestSubImage { gl.glTexCoord2f(coords.left(), coords.top()); gl.glVertex3f(0, 1, 0); gl.glEnd(); - texture.disable(); + texture.disable(gl); } public void displayChanged(GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged) {} diff --git a/src/demos/texture/TestTexture.java b/src/demos/texture/TestTexture.java index 057e957..224c247 100755 --- a/src/demos/texture/TestTexture.java +++ b/src/demos/texture/TestTexture.java @@ -184,7 +184,7 @@ public class TestTexture implements GLEventListener { if (flushTexture) { flushTexture = false; if (texture != null) { - texture.dispose(); + texture.destroy(gl); texture = null; } } @@ -193,7 +193,7 @@ public class TestTexture implements GLEventListener { newTexture = false; if (texture != null) { - texture.dispose(); + texture.destroy(gl); texture = null; } @@ -214,8 +214,8 @@ public class TestTexture implements GLEventListener { } if (texture != null) { - texture.enable(); - texture.bind(); + texture.enable(gl); + texture.bind(gl); gl.glTexEnvi(GL2.GL_TEXTURE_ENV, GL2.GL_TEXTURE_ENV_MODE, GL.GL_REPLACE); TextureCoords coords = texture.getImageTexCoords(); @@ -229,7 +229,7 @@ public class TestTexture implements GLEventListener { gl.glTexCoord2f(coords.left(), coords.top()); gl.glVertex3f(0, 1, 0); gl.glEnd(); - texture.disable(); + texture.disable(gl); } } diff --git a/src/demos/util/Cubemap.java b/src/demos/util/Cubemap.java index 9f31b9a..5ceab82 100755 --- a/src/demos/util/Cubemap.java +++ b/src/demos/util/Cubemap.java @@ -62,10 +62,10 @@ public class Cubemap { GL.GL_TEXTURE_CUBE_MAP_POSITIVE_Z, GL.GL_TEXTURE_CUBE_MAP_NEGATIVE_Z }; - public static Texture loadFromStreams(ClassLoader scope, + public static Texture loadFromStreams(GL gl, + ClassLoader scope, String basename, - String suffix, - boolean mipmapped) throws IOException, GLException { + String suffix, boolean mipmapped) throws IOException, GLException { Texture cubemap = TextureIO.newTexture(GL.GL_TEXTURE_CUBE_MAP); for (int i = 0; i < suffixes.length; i++) { @@ -76,7 +76,7 @@ public class Cubemap { if (data == null) { throw new IOException("Unable to load texture " + resourceName); } - cubemap.updateImage(data, targets[i]); + cubemap.updateImage(gl, data, targets[i]); } return cubemap; diff --git a/src/demos/util/DurationTimer.java b/src/demos/util/DurationTimer.java index c0f88e7..18a7f40 100644 --- a/src/demos/util/DurationTimer.java +++ b/src/demos/util/DurationTimer.java @@ -58,7 +58,7 @@ public class DurationTimer { accumulatedTime += (curTime - startTime); } - public long getDuration() { + public long getTotalFPSDuration() { return accumulatedTime; } diff --git a/src/demos/vertexProgRefract/VertexProgRefract.java b/src/demos/vertexProgRefract/VertexProgRefract.java index cac8d5a..9915fae 100644 --- a/src/demos/vertexProgRefract/VertexProgRefract.java +++ b/src/demos/vertexProgRefract/VertexProgRefract.java @@ -299,10 +299,10 @@ public class VertexProgRefract extends Demo { gl.glProgramEnvParameter4fARB(GL2.GL_VERTEX_PROGRAM_ARB, 3, 0.0f, 1.0f, 2.0f, 3.0f); // misc constants try { - cubemap = Cubemap.loadFromStreams(getClass().getClassLoader(), + cubemap = Cubemap.loadFromStreams(gl, + getClass().getClassLoader(), "demos/data/cubemaps/uffizi_", - "png", - true); + "png", true); } catch (IOException e) { shutdownDemo(); throw new RuntimeException(e); @@ -403,15 +403,15 @@ public class VertexProgRefract extends Demo { // set texture transforms gl.glActiveTexture(GL.GL_TEXTURE0); - cubemap.bind(); - cubemap.enable(); + cubemap.bind(gl); + cubemap.enable(gl); gl.glMatrixMode(GL.GL_TEXTURE); gl.glLoadIdentity(); viewer.updateInverseRotation(gl); gl.glActiveTexture(GL.GL_TEXTURE1); - cubemap.bind(); - cubemap.enable(); + cubemap.bind(gl); + cubemap.enable(gl); gl.glMatrixMode(GL.GL_TEXTURE); gl.glLoadIdentity(); viewer.updateInverseRotation(gl); @@ -617,8 +617,8 @@ public class VertexProgRefract extends Demo { gl.glDisable(GL.GL_TEXTURE_CUBE_MAP); gl.glActiveTexture(GL.GL_TEXTURE0); - cubemap.bind(); - cubemap.enable(); + cubemap.bind(gl); + cubemap.enable(gl); // This is a workaround for a driver bug on Mac OS X where the // normals are not being sent down to the hardware in |