From d1dfb4a367b3fa2350122a9623e3f1b56210a86e Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 26 Mar 2010 20:00:46 +0100 Subject: Adapted JOGL TextureData API changes (138a5b057e39a4738a2e82f370424a9a21aceea9) --- src/demos/es2/perftst/PerfTextLoad.java | 2 +- src/demos/j2d/CustomText.java | 5 +++-- src/demos/j2d/FlyingText.java | 4 ++-- src/demos/proceduralTexturePhysics/Water.java | 11 +++++++---- src/demos/readbuffer/ReadBufferUtil.java | 1 + src/demos/texture/TestSubImage.java | 2 +- src/demos/texture/TextureConvert.java | 10 ++++++---- src/demos/util/Cubemap.java | 3 ++- 8 files changed, 23 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/demos/es2/perftst/PerfTextLoad.java b/src/demos/es2/perftst/PerfTextLoad.java index 55aad9a..b22266a 100755 --- a/src/demos/es2/perftst/PerfTextLoad.java +++ b/src/demos/es2/perftst/PerfTextLoad.java @@ -40,7 +40,7 @@ public class PerfTextLoad extends PerfModule { if(urlText==null) { throw new RuntimeException("couldn't fetch "+textName); } - textDatas[i] = TextureIO.newTextureData(urlText.openStream(), false, TextureIO.TGA); + textDatas[i] = TextureIO.newTextureData(gl.getGLProfile(), urlText.openStream(), false, TextureIO.TGA); System.out.println(textBaseName+": "+textDatas[i]); } diff --git a/src/demos/j2d/CustomText.java b/src/demos/j2d/CustomText.java index bfcbc79..c3194be 100755 --- a/src/demos/j2d/CustomText.java +++ b/src/demos/j2d/CustomText.java @@ -190,6 +190,8 @@ public class CustomText extends Demo { } public void init(GLAutoDrawable drawable) { + GL gl = drawable.getGL(); + // Create the background texture BufferedImage bgImage = new BufferedImage(2, 2, BufferedImage.TYPE_BYTE_GRAY); Graphics2D g = bgImage.createGraphics(); @@ -199,7 +201,7 @@ public class CustomText extends Demo { g.fillRect(0, 0, 1, 1); g.fillRect(1, 1, 1, 1); g.dispose(); - backgroundTexture = AWTTextureIO.newTexture(bgImage, false); + 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); @@ -231,7 +233,6 @@ public class CustomText extends Demo { ((SystemTime) time).rebase(); // Set up properties; note we don't need the depth buffer in this demo - GL gl = drawable.getGL(); gl.glDisable(GL.GL_DEPTH_TEST); // Turn off vsync if we can gl.setSwapInterval(0); diff --git a/src/demos/j2d/FlyingText.java b/src/demos/j2d/FlyingText.java index f46dac2..d8d156c 100755 --- a/src/demos/j2d/FlyingText.java +++ b/src/demos/j2d/FlyingText.java @@ -231,6 +231,7 @@ public class FlyingText extends Demo { } public void init(GLAutoDrawable drawable) { + GL gl = drawable.getGL(); // Create the background texture BufferedImage bgImage = new BufferedImage(2, 2, BufferedImage.TYPE_BYTE_GRAY); Graphics2D g = bgImage.createGraphics(); @@ -240,7 +241,7 @@ public class FlyingText extends Demo { g.fillRect(0, 0, 1, 1); g.fillRect(1, 1, 1, 1); g.dispose(); - backgroundTexture = AWTTextureIO.newTexture(bgImage, false); + 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); @@ -271,7 +272,6 @@ public class FlyingText extends Demo { ((SystemTime) time).rebase(); // Set up properties; note we don't need the depth buffer in this demo - GL gl = drawable.getGL(); gl.glDisable(GL2.GL_DEPTH_TEST); // Turn off vsync if we can gl.setSwapInterval(0); diff --git a/src/demos/proceduralTexturePhysics/Water.java b/src/demos/proceduralTexturePhysics/Water.java index 89c1495..3a5d1a8 100644 --- a/src/demos/proceduralTexturePhysics/Water.java +++ b/src/demos/proceduralTexturePhysics/Water.java @@ -45,6 +45,7 @@ import java.nio.ByteBuffer; import java.util.ArrayList; import java.util.Iterator; import java.util.List; +import javax.media.opengl.GLProfile; import javax.media.opengl.GL; import javax.media.opengl.GL2ES1; import javax.media.opengl.GL2; @@ -205,7 +206,9 @@ public class Water { String cubeMapFilenamePrefix, String cubeMapFilenameSuffix, GLAutoDrawable parentWindow) { - loadInitialTexture(initialMapFilename); + GLCapabilities caps = parentWindow.getChosenGLCapabilities(); + + loadInitialTexture(caps.getGLProfile(), initialMapFilename); tmpSpinFilename = spinFilename; tmpDropletFilename = dropletFilename; tmpCubeMapFilenamePrefix = cubeMapFilenamePrefix; @@ -213,7 +216,6 @@ public class Water { // create the pbuffer. Will use this as an offscreen rendering buffer. // it allows rendering a texture larger than our window. - GLCapabilities caps = parentWindow.getChosenGLCapabilities(); caps.setDoubleBuffered(false); if (!GLDrawableFactory.getFactory(caps.getGLProfile()).canCreateGLPbuffer()) { throw new GLException("Pbuffers not supported with this graphics card"); @@ -493,9 +495,10 @@ public class Water { // We need to load the initial texture file early to get the width // and height for the pbuffer - private void loadInitialTexture(String initialMapFilename) { + private void loadInitialTexture(GLProfile glp, String initialMapFilename) { try { - initialMapData = TextureIO.newTextureData(getClass().getClassLoader().getResourceAsStream(initialMapFilename), + initialMapData = TextureIO.newTextureData(glp, + getClass().getClassLoader().getResourceAsStream(initialMapFilename), false, FileUtil.getFileSuffix(initialMapFilename)); } catch (IOException e) { diff --git a/src/demos/readbuffer/ReadBufferUtil.java b/src/demos/readbuffer/ReadBufferUtil.java index 1e79915..bef8473 100755 --- a/src/demos/readbuffer/ReadBufferUtil.java +++ b/src/demos/readbuffer/ReadBufferUtil.java @@ -64,6 +64,7 @@ public class ReadBufferUtil { readPixelSizeLast = readPixelSize ; try { readTextureData = new TextureData( + gl.getGLProfile(), // gl.isGL2GL3()?gl.GL_RGBA:gl.GL_RGB, gl.GL_RGB, drawable.getWidth(), drawable.getHeight(), diff --git a/src/demos/texture/TestSubImage.java b/src/demos/texture/TestSubImage.java index 0024e50..bf1e936 100755 --- a/src/demos/texture/TestSubImage.java +++ b/src/demos/texture/TestSubImage.java @@ -139,7 +139,7 @@ public class TestSubImage { g.dispose(); // Create a TextureData and Texture from it - textureData = AWTTextureIO.newTextureData(convertedImage, false); + textureData = AWTTextureIO.newTextureData(gl.getGLProfile(), convertedImage, false); texture = TextureIO.newTexture(textureData); } diff --git a/src/demos/texture/TextureConvert.java b/src/demos/texture/TextureConvert.java index aaf75a2..df15fc2 100755 --- a/src/demos/texture/TextureConvert.java +++ b/src/demos/texture/TextureConvert.java @@ -49,6 +49,7 @@ import javax.media.opengl.GL; import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLDrawableFactory; import javax.media.opengl.GLPbuffer; +import javax.media.opengl.GLProfile; @@ -69,15 +70,16 @@ public class TextureConvert { String inputFile = args[0]; String outputFile = args[1]; - GLCapabilities caps = new GLCapabilities(null); + GLProfile glp = GLProfile.getDefault(); + GLCapabilities caps = new GLCapabilities(glp); caps.setDoubleBuffered(false); // Make a pbuffer to get an offscreen context - if (!GLDrawableFactory.getFactory(caps.getGLProfile()).canCreateGLPbuffer()) { + if (!GLDrawableFactory.getFactory(glp).canCreateGLPbuffer()) { System.out.println("Pbuffer support not available (required to run this demo)"); System.exit(1); } - GLPbuffer pbuffer = GLDrawableFactory.getFactory(caps.getGLProfile()).createGLPbuffer(caps, null, 2, 2, null); + GLPbuffer pbuffer = GLDrawableFactory.getFactory(glp).createGLPbuffer(caps, null, 2, 2, null); pbuffer.getContext().makeCurrent(); GL gl = pbuffer.getGL(); @@ -89,7 +91,7 @@ public class TextureConvert { } } - TextureData inputData = TextureIO.newTextureData(new File(inputFile), false, null); + TextureData inputData = TextureIO.newTextureData(glp, new File(inputFile), false, null); if (attemptCompression && !inputData.isDataCompressed()) { inputData.setInternalFormat(GL.GL_COMPRESSED_RGBA_S3TC_DXT3_EXT); } diff --git a/src/demos/util/Cubemap.java b/src/demos/util/Cubemap.java index 405fc38..6c1a332 100755 --- a/src/demos/util/Cubemap.java +++ b/src/demos/util/Cubemap.java @@ -46,6 +46,7 @@ import com.sun.opengl.util.texture.TextureIO; import java.io.IOException; import javax.media.opengl.GL; import javax.media.opengl.GLException; +import javax.media.opengl.GLContext; @@ -69,7 +70,7 @@ public class Cubemap { for (int i = 0; i < suffixes.length; i++) { String resourceName = basename + suffixes[i] + "." + suffix; - TextureData data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), + TextureData data = TextureIO.newTextureData(GLContext.getCurrentGL().getGLProfile(), scope.getResourceAsStream(resourceName), mipmapped, FileUtil.getFileSuffix(resourceName)); if (data == null) { -- cgit v1.2.3