From 5b56f1e513a9de16cf14e2f5b446c903588b028f Mon Sep 17 00:00:00 2001 From: Julien Gouesse Date: Sat, 4 Apr 2015 16:37:36 +0200 Subject: [PATCH 1/2] Updates the JogAmp backend, uses JOGL 2.3.1 --- jme3-jogl/build.gradle | 6 ++-- .../com/jme3/input/jogl/NewtMouseInput.java | 10 +++---- .../com/jme3/renderer/jogl/JoglRenderer.java | 22 +++++++-------- .../com/jme3/renderer/jogl/TextureUtil.java | 19 +++++++------ .../jme3/system/jogl/JoglAbstractDisplay.java | 28 +++++++++---------- .../java/com/jme3/system/jogl/JoglCanvas.java | 2 +- .../com/jme3/system/jogl/JoglContext.java | 6 ++-- .../com/jme3/system/jogl/JoglDisplay.java | 2 +- .../system/jogl/JoglNewtAbstractDisplay.java | 26 ++++++++--------- .../com/jme3/system/jogl/JoglNewtCanvas.java | 2 +- .../com/jme3/system/jogl/JoglNewtDisplay.java | 4 +-- .../jme3/system/jogl/JoglOffscreenBuffer.java | 12 ++++---- 12 files changed, 71 insertions(+), 68 deletions(-) diff --git a/jme3-jogl/build.gradle b/jme3-jogl/build.gradle index 135656ee6..e82139729 100644 --- a/jme3-jogl/build.gradle +++ b/jme3-jogl/build.gradle @@ -5,7 +5,7 @@ if (!hasProperty('mainClass')) { dependencies { compile project(':jme3-core') compile project(':jme3-desktop') - compile 'org.jogamp.gluegen:gluegen-rt-main:2.2.0' - compile 'org.jogamp.jogl:jogl-all-main:2.2.0' - compile 'org.jogamp.joal:joal-main:2.2.0' + compile 'org.jogamp.gluegen:gluegen-rt-main:2.3.1' + compile 'org.jogamp.jogl:jogl-all-main:2.3.1' + compile 'org.jogamp.joal:joal-main:2.3.1' } diff --git a/jme3-jogl/src/main/java/com/jme3/input/jogl/NewtMouseInput.java b/jme3-jogl/src/main/java/com/jme3/input/jogl/NewtMouseInput.java index d50017ccc..773f62b8a 100644 --- a/jme3-jogl/src/main/java/com/jme3/input/jogl/NewtMouseInput.java +++ b/jme3-jogl/src/main/java/com/jme3/input/jogl/NewtMouseInput.java @@ -45,11 +45,11 @@ import com.jogamp.newt.opengl.GLWindow; import java.nio.ByteBuffer; import java.util.ArrayList; import java.util.logging.Logger; -import javax.media.nativewindow.util.Dimension; -import javax.media.nativewindow.util.DimensionImmutable; -import javax.media.nativewindow.util.PixelFormat; -import javax.media.nativewindow.util.PixelRectangle; -import javax.media.nativewindow.util.Point; +import com.jogamp.nativewindow.util.Dimension; +import com.jogamp.nativewindow.util.DimensionImmutable; +import com.jogamp.nativewindow.util.PixelFormat; +import com.jogamp.nativewindow.util.PixelRectangle; +import com.jogamp.nativewindow.util.Point; public class NewtMouseInput implements MouseInput, MouseListener { diff --git a/jme3-jogl/src/main/java/com/jme3/renderer/jogl/JoglRenderer.java b/jme3-jogl/src/main/java/com/jme3/renderer/jogl/JoglRenderer.java index 85e5c7102..111719265 100644 --- a/jme3-jogl/src/main/java/com/jme3/renderer/jogl/JoglRenderer.java +++ b/jme3-jogl/src/main/java/com/jme3/renderer/jogl/JoglRenderer.java @@ -70,15 +70,15 @@ import java.util.EnumSet; import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; -import javax.media.nativewindow.NativeWindowFactory; -import javax.media.opengl.GL; -import javax.media.opengl.GL2; -import javax.media.opengl.GL2ES1; -import javax.media.opengl.GL2ES2; -import javax.media.opengl.GL2ES3; -import javax.media.opengl.GL2GL3; -import javax.media.opengl.GL3; -import javax.media.opengl.GLContext; +import com.jogamp.nativewindow.NativeWindowFactory; +import com.jogamp.opengl.GL; +import com.jogamp.opengl.GL2; +import com.jogamp.opengl.GL2ES1; +import com.jogamp.opengl.GL2ES2; +import com.jogamp.opengl.GL2ES3; +import com.jogamp.opengl.GL2GL3; +import com.jogamp.opengl.GL3; +import com.jogamp.opengl.GLContext; import jme3tools.converters.MipMapGenerator; import jme3tools.shader.ShaderDebug; @@ -1800,7 +1800,7 @@ public class JoglRenderer implements Renderer { if (samples > 1) { return GL3.GL_TEXTURE_2D_MULTISAMPLE_ARRAY; } else { - return GL.GL_TEXTURE_2D_ARRAY; + return GL2ES3.GL_TEXTURE_2D_ARRAY; } case ThreeDimensional: return GL2ES2.GL_TEXTURE_3D; @@ -2014,7 +2014,7 @@ public class JoglRenderer implements Renderer { for (int i = 0; i < 6; i++) { TextureUtil.uploadTexture(img, GL.GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, i, 0, linearizeSrgbImages); } - } else if (target == GL.GL_TEXTURE_2D_ARRAY) { + } else if (target == GL2ES3.GL_TEXTURE_2D_ARRAY) { if (!caps.contains(Caps.TextureArray)) { throw new RendererException("Texture arrays not supported by graphics hardware"); } diff --git a/jme3-jogl/src/main/java/com/jme3/renderer/jogl/TextureUtil.java b/jme3-jogl/src/main/java/com/jme3/renderer/jogl/TextureUtil.java index 9bdc0ca2d..8f3c5b156 100644 --- a/jme3-jogl/src/main/java/com/jme3/renderer/jogl/TextureUtil.java +++ b/jme3-jogl/src/main/java/com/jme3/renderer/jogl/TextureUtil.java @@ -36,14 +36,17 @@ import com.jme3.renderer.RendererException; import com.jme3.texture.Image; import com.jme3.texture.Image.Format; import com.jme3.texture.image.ColorSpace; + import java.nio.ByteBuffer; import java.util.logging.Level; import java.util.logging.Logger; -import javax.media.opengl.GL; -import javax.media.opengl.GL2; -import javax.media.opengl.GL2ES2; -import javax.media.opengl.GL2GL3; -import javax.media.opengl.GLContext; + +import com.jogamp.opengl.GL; +import com.jogamp.opengl.GL2; +import com.jogamp.opengl.GL2ES2; +import com.jogamp.opengl.GL2ES3; +import com.jogamp.opengl.GL2GL3; +import com.jogamp.opengl.GLContext; public class TextureUtil { @@ -124,9 +127,9 @@ public class TextureUtil { setFormat(Format.RGB32F, GL.GL_RGB32F, GL.GL_RGB, GL.GL_FLOAT, false); // Special RGB formats - setFormat(Format.RGB111110F, GL.GL_R11F_G11F_B10F, GL.GL_RGB, GL.GL_UNSIGNED_INT_10F_11F_11F_REV, false); + setFormat(Format.RGB111110F, GL2ES3.GL_R11F_G11F_B10F, GL.GL_RGB, GL.GL_UNSIGNED_INT_10F_11F_11F_REV, false); setFormat(Format.RGB9E5, GL2GL3.GL_RGB9_E5, GL.GL_RGB, GL2GL3.GL_UNSIGNED_INT_5_9_9_9_REV, false); - setFormat(Format.RGB16F_to_RGB111110F, GL.GL_R11F_G11F_B10F, GL.GL_RGB, GL.GL_HALF_FLOAT, false); + setFormat(Format.RGB16F_to_RGB111110F, GL2ES3.GL_R11F_G11F_B10F, GL.GL_RGB, GL.GL_HALF_FLOAT, false); setFormat(Format.RGB16F_to_RGB9E5, GL2.GL_RGB9_E5, GL.GL_RGB, GL.GL_HALF_FLOAT, false); // RGBA formats @@ -346,7 +349,7 @@ public class TextureUtil { glFmt.format, glFmt.dataType, data); - }else if (target == GL.GL_TEXTURE_2D_ARRAY){ + }else if (target == GL2ES3.GL_TEXTURE_2D_ARRAY){ // prepare data for 2D array // or upload slice if (index == -1){ diff --git a/jme3-jogl/src/main/java/com/jme3/system/jogl/JoglAbstractDisplay.java b/jme3-jogl/src/main/java/com/jme3/system/jogl/JoglAbstractDisplay.java index 8c6ec6e55..a7f7fbfd7 100644 --- a/jme3-jogl/src/main/java/com/jme3/system/jogl/JoglAbstractDisplay.java +++ b/jme3-jogl/src/main/java/com/jme3/system/jogl/JoglAbstractDisplay.java @@ -45,20 +45,20 @@ import java.awt.GraphicsDevice; import java.awt.GraphicsEnvironment; import java.util.concurrent.atomic.AtomicBoolean; import java.util.logging.Logger; -import javax.media.opengl.DebugGL2; -import javax.media.opengl.DebugGL3; -import javax.media.opengl.DebugGL3bc; -import javax.media.opengl.DebugGL4; -import javax.media.opengl.DebugGL4bc; -import javax.media.opengl.DebugGLES1; -import javax.media.opengl.DebugGLES2; -import javax.media.opengl.GL; -import javax.media.opengl.GLAutoDrawable; -import javax.media.opengl.GLCapabilities; -import javax.media.opengl.GLEventListener; -import javax.media.opengl.GLProfile; -import javax.media.opengl.GLRunnable; -import javax.media.opengl.awt.GLCanvas; +import com.jogamp.opengl.DebugGL2; +import com.jogamp.opengl.DebugGL3; +import com.jogamp.opengl.DebugGL3bc; +import com.jogamp.opengl.DebugGL4; +import com.jogamp.opengl.DebugGL4bc; +import com.jogamp.opengl.DebugGLES1; +import com.jogamp.opengl.DebugGLES2; +import com.jogamp.opengl.GL; +import com.jogamp.opengl.GLAutoDrawable; +import com.jogamp.opengl.GLCapabilities; +import com.jogamp.opengl.GLEventListener; +import com.jogamp.opengl.GLProfile; +import com.jogamp.opengl.GLRunnable; +import com.jogamp.opengl.awt.GLCanvas; public abstract class JoglAbstractDisplay extends JoglContext implements GLEventListener { diff --git a/jme3-jogl/src/main/java/com/jme3/system/jogl/JoglCanvas.java b/jme3-jogl/src/main/java/com/jme3/system/jogl/JoglCanvas.java index c4e97570e..9a409b85e 100644 --- a/jme3-jogl/src/main/java/com/jme3/system/jogl/JoglCanvas.java +++ b/jme3-jogl/src/main/java/com/jme3/system/jogl/JoglCanvas.java @@ -35,7 +35,7 @@ package com.jme3.system.jogl; import com.jme3.system.JmeCanvasContext; import java.awt.Canvas; import java.util.logging.Logger; -import javax.media.opengl.GLAutoDrawable; +import com.jogamp.opengl.GLAutoDrawable; public class JoglCanvas extends JoglAbstractDisplay implements JmeCanvasContext { diff --git a/jme3-jogl/src/main/java/com/jme3/system/jogl/JoglContext.java b/jme3-jogl/src/main/java/com/jme3/system/jogl/JoglContext.java index 8861904b8..5d687af8d 100644 --- a/jme3-jogl/src/main/java/com/jme3/system/jogl/JoglContext.java +++ b/jme3-jogl/src/main/java/com/jme3/system/jogl/JoglContext.java @@ -47,9 +47,9 @@ import java.nio.IntBuffer; import java.util.concurrent.atomic.AtomicBoolean; import java.util.logging.Level; import java.util.logging.Logger; -import javax.media.opengl.GL; -import javax.media.opengl.GL2GL3; -import javax.media.opengl.GLContext; +import com.jogamp.opengl.GL; +import com.jogamp.opengl.GL2GL3; +import com.jogamp.opengl.GLContext; public abstract class JoglContext implements JmeContext { diff --git a/jme3-jogl/src/main/java/com/jme3/system/jogl/JoglDisplay.java b/jme3-jogl/src/main/java/com/jme3/system/jogl/JoglDisplay.java index 363ccd096..3bac0ab53 100644 --- a/jme3-jogl/src/main/java/com/jme3/system/jogl/JoglDisplay.java +++ b/jme3-jogl/src/main/java/com/jme3/system/jogl/JoglDisplay.java @@ -45,7 +45,7 @@ import java.lang.reflect.InvocationTargetException; import java.util.concurrent.atomic.AtomicBoolean; import java.util.logging.Level; import java.util.logging.Logger; -import javax.media.opengl.GLAutoDrawable; +import com.jogamp.opengl.GLAutoDrawable; import javax.swing.JFrame; import javax.swing.SwingUtilities; diff --git a/jme3-jogl/src/main/java/com/jme3/system/jogl/JoglNewtAbstractDisplay.java b/jme3-jogl/src/main/java/com/jme3/system/jogl/JoglNewtAbstractDisplay.java index 4899c9c39..cb75d5d37 100644 --- a/jme3-jogl/src/main/java/com/jme3/system/jogl/JoglNewtAbstractDisplay.java +++ b/jme3-jogl/src/main/java/com/jme3/system/jogl/JoglNewtAbstractDisplay.java @@ -44,19 +44,19 @@ import com.jogamp.opengl.util.AnimatorBase; import com.jogamp.opengl.util.FPSAnimator; import java.util.concurrent.atomic.AtomicBoolean; import java.util.logging.Logger; -import javax.media.opengl.DebugGL2; -import javax.media.opengl.DebugGL3; -import javax.media.opengl.DebugGL3bc; -import javax.media.opengl.DebugGL4; -import javax.media.opengl.DebugGL4bc; -import javax.media.opengl.DebugGLES1; -import javax.media.opengl.DebugGLES2; -import javax.media.opengl.GL; -import javax.media.opengl.GLAutoDrawable; -import javax.media.opengl.GLCapabilities; -import javax.media.opengl.GLEventListener; -import javax.media.opengl.GLProfile; -import javax.media.opengl.GLRunnable; +import com.jogamp.opengl.DebugGL2; +import com.jogamp.opengl.DebugGL3; +import com.jogamp.opengl.DebugGL3bc; +import com.jogamp.opengl.DebugGL4; +import com.jogamp.opengl.DebugGL4bc; +import com.jogamp.opengl.DebugGLES1; +import com.jogamp.opengl.DebugGLES2; +import com.jogamp.opengl.GL; +import com.jogamp.opengl.GLAutoDrawable; +import com.jogamp.opengl.GLCapabilities; +import com.jogamp.opengl.GLEventListener; +import com.jogamp.opengl.GLProfile; +import com.jogamp.opengl.GLRunnable; public abstract class JoglNewtAbstractDisplay extends JoglContext implements GLEventListener { diff --git a/jme3-jogl/src/main/java/com/jme3/system/jogl/JoglNewtCanvas.java b/jme3-jogl/src/main/java/com/jme3/system/jogl/JoglNewtCanvas.java index e4f46d8fb..3ed501580 100644 --- a/jme3-jogl/src/main/java/com/jme3/system/jogl/JoglNewtCanvas.java +++ b/jme3-jogl/src/main/java/com/jme3/system/jogl/JoglNewtCanvas.java @@ -35,7 +35,7 @@ package com.jme3.system.jogl; import com.jme3.system.JmeCanvasContext; import com.jogamp.newt.awt.NewtCanvasAWT; import java.util.logging.Logger; -import javax.media.opengl.GLAutoDrawable; +import com.jogamp.opengl.GLAutoDrawable; public class JoglNewtCanvas extends JoglNewtAbstractDisplay implements JmeCanvasContext { diff --git a/jme3-jogl/src/main/java/com/jme3/system/jogl/JoglNewtDisplay.java b/jme3-jogl/src/main/java/com/jme3/system/jogl/JoglNewtDisplay.java index 011002aff..84a99e8d2 100644 --- a/jme3-jogl/src/main/java/com/jme3/system/jogl/JoglNewtDisplay.java +++ b/jme3-jogl/src/main/java/com/jme3/system/jogl/JoglNewtDisplay.java @@ -42,8 +42,8 @@ import java.util.List; import java.util.concurrent.atomic.AtomicBoolean; import java.util.logging.Level; import java.util.logging.Logger; -import javax.media.nativewindow.util.Dimension; -import javax.media.opengl.GLAutoDrawable; +import com.jogamp.nativewindow.util.Dimension; +import com.jogamp.opengl.GLAutoDrawable; public class JoglNewtDisplay extends JoglNewtAbstractDisplay { diff --git a/jme3-jogl/src/main/java/com/jme3/system/jogl/JoglOffscreenBuffer.java b/jme3-jogl/src/main/java/com/jme3/system/jogl/JoglOffscreenBuffer.java index e2ad1f79a..cd2b84f73 100644 --- a/jme3-jogl/src/main/java/com/jme3/system/jogl/JoglOffscreenBuffer.java +++ b/jme3-jogl/src/main/java/com/jme3/system/jogl/JoglOffscreenBuffer.java @@ -41,12 +41,12 @@ import com.jogamp.newt.NewtVersion; import java.util.concurrent.atomic.AtomicBoolean; import java.util.logging.Level; import java.util.logging.Logger; -import javax.media.opengl.GL; -import javax.media.opengl.GLCapabilities; -import javax.media.opengl.GLContext; -import javax.media.opengl.GLDrawableFactory; -import javax.media.opengl.GLOffscreenAutoDrawable; -import javax.media.opengl.GLProfile; +import com.jogamp.opengl.GL; +import com.jogamp.opengl.GLCapabilities; +import com.jogamp.opengl.GLContext; +import com.jogamp.opengl.GLDrawableFactory; +import com.jogamp.opengl.GLOffscreenAutoDrawable; +import com.jogamp.opengl.GLProfile; public class JoglOffscreenBuffer extends JoglContext implements Runnable { From 9f32bcf7bb116afcfcc8bcacd3bdfbdc18fb2bf0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kai=20B=C3=B6rnert?= Date: Tue, 7 Apr 2015 01:26:13 +0200 Subject: [PATCH 2/2] Hack fix for blenderloader. The optimisation disabled would result in null TextureKeys. -> This would then result in textures being embedded into the j3o file, seriously bloating the assets. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Kai Börnert --- .../scene/plugins/blender/textures/TextureHelper.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/jme3-blender/src/main/java/com/jme3/scene/plugins/blender/textures/TextureHelper.java b/jme3-blender/src/main/java/com/jme3/scene/plugins/blender/textures/TextureHelper.java index f6ed89ce7..f1c1c64fc 100644 --- a/jme3-blender/src/main/java/com/jme3/scene/plugins/blender/textures/TextureHelper.java +++ b/jme3-blender/src/main/java/com/jme3/scene/plugins/blender/textures/TextureHelper.java @@ -232,7 +232,7 @@ public class TextureHelper extends AbstractBlenderHelper { LOGGER.log(Level.FINE, "Fetching texture with OMA = {0}", imageStructure.getOldMemoryAddress()); Texture result = null; Image im = (Image) blenderContext.getLoadedFeature(imageStructure.getOldMemoryAddress(), LoadedDataType.FEATURE); - if (im == null) { + // if (im == null) { HACK force reaload always, as constructor in else case is destroying the TextureKeys! if ("ID".equals(imageStructure.getType())) { LOGGER.fine("Loading texture from external blend file."); result = (Texture) this.loadLibrary(imageStructure); @@ -253,9 +253,9 @@ public class TextureHelper extends AbstractBlenderHelper { result = new Texture2D(new ImageLoader().loadImage(blenderContext.getInputStream(), dataFileBlock.getBlockPosition(), true)); } } - } else { - result = new Texture2D(im); - } + //} else { + // result = new Texture2D(im); + // } if (result != null) {// render result is not being loaded blenderContext.addLoadedFeatures(imageStructure.getOldMemoryAddress(), LoadedDataType.STRUCTURE, imageStructure);