diff options
Diffstat (limited to 'ardor3d-jogl/src/main/java')
50 files changed, 1611 insertions, 1541 deletions
diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/CapsUtil.java b/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/CapsUtil.java index 5a5fb95..93bd55c 100644 --- a/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/CapsUtil.java +++ b/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/CapsUtil.java @@ -1,23 +1,31 @@ /** - * Copyright (c) 2008-2010 Ardor Labs, Inc. + * Copyright (c) 2008-2014 Ardor Labs, Inc. * * This file is part of Ardor3D. * - * Ardor3D is free software: you can redistribute it and/or modify it + * Ardor3D is free software: you can redistribute it and/or modify it * under the terms of its license which may be found in the accompanying * LICENSE file or at <http://www.ardor3d.com/LICENSE>. */ package com.ardor3d.framework.jogl; -import javax.media.opengl.GLCapabilities; -import javax.media.opengl.GLProfile; - +import com.ardor3d.framework.CanvasRenderer; import com.ardor3d.framework.DisplaySettings; import com.ardor3d.util.Ardor3dException; +import com.jogamp.newt.MonitorMode; +import com.jogamp.opengl.GLCapabilities; +import com.jogamp.opengl.GLCapabilitiesImmutable; +import com.jogamp.opengl.GLProfile; public class CapsUtil { + static { + // The GLSL mode of GLJPanel used in JoglSwingCanvas seems to cause a lot of troubles when using our own GLSL + // shaders and with the wireframe state. Therefore, it is disabled as early as possible + System.setProperty("jogl.gljpanel.noglsl", "true"); + } + public GLProfile getProfile() { // tries to get the most capable profile, programmable or fixed, desktop or embedded, forward or backward // compatible @@ -27,6 +35,13 @@ public class CapsUtil { if (isForwardCompatible) { // Ardor3D doesn't support forward compatible yet profile = GLProfile.getMaxFixedFunc(true); + } else { + final boolean isES2orES3 = profile.isGLES2() || profile.isGLES3(); + // Ardor3D doesn't fully support ES 2.0 and later yet, favors ES 1 if possible + // FIXME remove this kludge when Ardor3D gets some VAO support + if (isES2orES3 && GLProfile.isAvailable(GLProfile.GLES1)) { + profile = GLProfile.get(GLProfile.GLES1); + } } return profile; } @@ -35,6 +50,29 @@ public class CapsUtil { return getCapsForSettings(settings, true, false, false, false); } + /** + * for internal use only, tolerates artificial display settings containing hints + * + * @param settings + * @param onscreen + * @param bitmapRequested + * @param pbufferRequested + * @param fboRequested + * @return + */ + GLCapabilities getCapsForSettingsWithHints(final DisplaySettings settings, final boolean onscreen, + final boolean bitmapRequested, final boolean pbufferRequested, final boolean fboRequested) { + final DisplaySettings realSettings; + if (settings.isFullScreen() && (settings.getWidth() == 0 || settings.getHeight() == 0)) { + realSettings = new DisplaySettings(1, 1, settings.getColorDepth(), settings.getFrequency(), + settings.getAlphaBits(), settings.getDepthBits(), settings.getStencilBits(), settings.getSamples(), + true, settings.isStereo(), settings.getShareContext(), settings.getRotation()); + } else { + realSettings = settings; + } + return getCapsForSettings(realSettings, onscreen, bitmapRequested, pbufferRequested, fboRequested); + } + public GLCapabilities getCapsForSettings(final DisplaySettings settings, final boolean onscreen, final boolean bitmapRequested, final boolean pbufferRequested, final boolean fboRequested) { @@ -45,10 +83,16 @@ public class CapsUtil { // Validate bit depth. if ((settings.getColorDepth() != 32) && (settings.getColorDepth() != 16) && (settings.getColorDepth() != 24) - && (settings.getColorDepth() != -1)) { + && (settings.getColorDepth() != 0) && (settings.getColorDepth() != -1)) { throw new Ardor3dException("Invalid pixel depth: " + settings.getColorDepth()); } + // Validate rotation + if (settings.getRotation() != MonitorMode.ROTATE_0 && settings.getRotation() != MonitorMode.ROTATE_90 + && settings.getRotation() != MonitorMode.ROTATE_180 && settings.getRotation() != MonitorMode.ROTATE_270) { + throw new Ardor3dException("Invalid rotation: " + settings.getRotation()); + } + final GLCapabilities caps = new GLCapabilities(getProfile()); caps.setHardwareAccelerated(true); caps.setDoubleBuffered(true); @@ -80,4 +124,12 @@ public class CapsUtil { return caps; } + public DisplaySettings getSettingsForCaps(final GLCapabilitiesImmutable glCaps, final int width, final int height, + final int frequency, final boolean fullscreen, final CanvasRenderer shareContext, final int rotation) { + final int colorDepth = glCaps.getRedBits() + glCaps.getGreenBits() + glCaps.getBlueBits(); + final DisplaySettings settings = new DisplaySettings(width, height, colorDepth, frequency, + glCaps.getAlphaBits(), glCaps.getDepthBits(), glCaps.getStencilBits(), glCaps.getNumSamples(), + fullscreen, glCaps.getStereo(), shareContext, rotation); + return settings; + } } diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglAwtCanvas.java b/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglAwtCanvas.java deleted file mode 100644 index cc233c8..0000000 --- a/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglAwtCanvas.java +++ /dev/null @@ -1,116 +0,0 @@ -/** - * Copyright (c) 2008-2010 Ardor Labs, Inc. - * - * This file is part of Ardor3D. - * - * Ardor3D is free software: you can redistribute it and/or modify it - * under the terms of its license which may be found in the accompanying - * LICENSE file or at <http://www.ardor3d.com/LICENSE>. - */ - -package com.ardor3d.framework.jogl; - -import java.lang.reflect.InvocationTargetException; -import java.util.concurrent.CountDownLatch; - -import javax.media.opengl.GLAutoDrawable; -import javax.media.opengl.GLRunnable; -import javax.media.opengl.awt.GLCanvas; -import javax.swing.SwingUtilities; - -import com.ardor3d.annotation.MainThread; -import com.ardor3d.framework.Canvas; -import com.ardor3d.framework.DisplaySettings; - -/** - * Ardor3D JOGL AWT heavyweight canvas, AWT component for the OpenGL rendering of Ardor3D with JOGL that supports the - * AWT input system directly and its abstraction in Ardor3D (com.ardor3d.input.awt) - * - * FIXME there is still a deadlock when using several instances of this class in the same container, see JOGL bug 572 - * Rather use JoglNewtAwtCanvas in this case. - * - */ -public class JoglAwtCanvas extends GLCanvas implements Canvas { - - private static final long serialVersionUID = 1L; - - private final JoglCanvasRenderer _canvasRenderer; - private boolean _inited = false; - - private final DisplaySettings _settings; - - private final JoglDrawerRunnable _drawerGLRunnable; - - private final JoglAwtInitializerRunnable _initializerRunnable; - - public JoglAwtCanvas(final DisplaySettings settings, final JoglCanvasRenderer canvasRenderer) { - this(settings, canvasRenderer, new CapsUtil()); - } - - public JoglAwtCanvas(final DisplaySettings settings, final JoglCanvasRenderer canvasRenderer, - final CapsUtil capsUtil) { - super(capsUtil.getCapsForSettings(settings)); - _drawerGLRunnable = new JoglDrawerRunnable(canvasRenderer); - _initializerRunnable = new JoglAwtInitializerRunnable(this, settings); - _settings = settings; - _canvasRenderer = canvasRenderer; - - setFocusable(true); - requestFocus(); - setSize(_settings.getWidth(), _settings.getHeight()); - setIgnoreRepaint(true); - setAutoSwapBufferMode(false); - } - - @Override - @MainThread - public void init() { - if (_inited) { - return; - } - - // Calling setVisible(true) on the GLCanvas not from the AWT-EDT can freeze the Intel GPU under Windows - if (!SwingUtilities.isEventDispatchThread()) { - try { - SwingUtilities.invokeAndWait(_initializerRunnable); - } catch (final InterruptedException ex) { - ex.printStackTrace(); - } catch (final InvocationTargetException ex) { - ex.printStackTrace(); - } - } else { - _initializerRunnable.run(); - } - - _inited = isRealized(); - } - - @Override - public void draw(final CountDownLatch latch) { - if (!_inited) { - init(); - } - - if (isShowing()) { - invoke(true, _drawerGLRunnable); - } - if (latch != null) { - latch.countDown(); - } - } - - @Override - public JoglCanvasRenderer getCanvasRenderer() { - return _canvasRenderer; - } - - public void setVSyncEnabled(final boolean enabled) { - invoke(true, new GLRunnable() { - @Override - public boolean run(final GLAutoDrawable glAutoDrawable) { - glAutoDrawable.getGL().setSwapInterval(enabled ? 1 : 0); - return false; - } - }); - } -} diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglAwtInitializerRunnable.java b/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglAwtInitializerRunnable.java deleted file mode 100644 index 3a7153d..0000000 --- a/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglAwtInitializerRunnable.java +++ /dev/null @@ -1,41 +0,0 @@ -/** - * Copyright (c) 2008-2014 Ardor Labs, Inc. - * - * This file is part of Ardor3D. - * - * Ardor3D is free software: you can redistribute it and/or modify it - * under the terms of its license which may be found in the accompanying - * LICENSE file or at <http://www.ardor3d.com/LICENSE>. - */ - -package com.ardor3d.framework.jogl; - -import com.ardor3d.framework.DisplaySettings; - -public class JoglAwtInitializerRunnable implements Runnable { - - private final JoglAwtCanvas _joglAwtCanvas; - - private final DisplaySettings _settings; - - public JoglAwtInitializerRunnable(final JoglAwtCanvas joglAwtCanvas, final DisplaySettings settings) { - _joglAwtCanvas = joglAwtCanvas; - _settings = settings; - } - - @Override - public void run() { - // Make the window visible to realize the OpenGL surface. - _joglAwtCanvas.setVisible(true); - // Force the realization - _joglAwtCanvas.display(); - if (_joglAwtCanvas.getDelegatedDrawable().isRealized()) { - // Request the focus here as it cannot work when the window is not visible - _joglAwtCanvas.requestFocus(); - // The OpenGL context has been created after the realization of the surface - _joglAwtCanvas.getCanvasRenderer().setContext(_joglAwtCanvas.getContext()); - // As the canvas renderer knows the OpenGL context, it can be initialized - _joglAwtCanvas.getCanvasRenderer().init(_settings, true); - } - } -}
\ No newline at end of file diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglCanvas.java b/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglCanvas.java deleted file mode 100644 index 9ca4c89..0000000 --- a/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglCanvas.java +++ /dev/null @@ -1,285 +0,0 @@ -/** - * Copyright (c) 2008-2010 Ardor Labs, Inc. - * - * This file is part of Ardor3D. - * - * Ardor3D is free software: you can redistribute it and/or modify it - * under the terms of its license which may be found in the accompanying - * LICENSE file or at <http://www.ardor3d.com/LICENSE>. - */ - -package com.ardor3d.framework.jogl; - -import java.awt.Dimension; -import java.awt.DisplayMode; -import java.awt.Frame; -import java.awt.GraphicsDevice; -import java.awt.GraphicsEnvironment; -import java.awt.Toolkit; -import java.awt.event.FocusListener; -import java.awt.event.KeyListener; -import java.awt.event.MouseListener; -import java.awt.event.MouseMotionListener; -import java.awt.event.MouseWheelListener; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; -import java.util.concurrent.CountDownLatch; -import java.util.logging.Level; -import java.util.logging.Logger; - -import javax.media.opengl.GLContext; -import javax.media.opengl.GLException; - -import com.ardor3d.annotation.MainThread; -import com.ardor3d.framework.CanvasRenderer; -import com.ardor3d.framework.DisplaySettings; -import com.ardor3d.framework.NativeCanvas; -import com.ardor3d.image.Image; -import com.ardor3d.renderer.jogl.JoglPbufferTextureRenderer; - -/** - * A canvas implementation for use with native JOGL windows. - */ -public class JoglCanvas extends Frame implements NativeCanvas { - - private static final long serialVersionUID = 1L; - - private static final Logger logger = Logger.getLogger(JoglCanvas.class.getName()); - - private final DisplaySettings _settings; - private boolean _inited = false; - private boolean _isClosing = false; - - private JoglAwtCanvas _glCanvas; - - public JoglCanvas(final JoglCanvasRenderer canvasRenderer, final DisplaySettings settings) { - _settings = settings; - - // Create the OpenGL canvas - _glCanvas = new JoglAwtCanvas(_settings, canvasRenderer); - - // Default is not-resizeable. If you turn on resizeable, know what you are doing. - setResizable(false); - } - - @Override - public synchronized void addKeyListener(final KeyListener l) { - _glCanvas.addKeyListener(l); - } - - @Override - public synchronized void addMouseListener(final MouseListener l) { - _glCanvas.addMouseListener(l); - } - - @Override - public synchronized void addMouseMotionListener(final MouseMotionListener l) { - _glCanvas.addMouseMotionListener(l); - } - - @Override - public synchronized void addMouseWheelListener(final MouseWheelListener l) { - _glCanvas.addMouseWheelListener(l); - } - - @Override - public synchronized void addFocusListener(final FocusListener l) { - _glCanvas.addFocusListener(l); - } - - @Override - @MainThread - public void init() { - privateInit(); - } - - @MainThread - protected void privateInit() { - if (_inited) { - return; - } - - // FIXME: remove need for directly setting _parentContext. - JoglPbufferTextureRenderer._parentContext = _glCanvas.getContext(); - - this.add(_glCanvas); - - final boolean isDisplayModeModified; - final GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice(); - // Get the current display mode - final DisplayMode previousDisplayMode = gd.getDisplayMode(); - // Handle full screen mode if requested. - if (_settings.isFullScreen()) { - setUndecorated(true); - // Check if the full-screen mode is supported by the OS - boolean isFullScreenSupported = gd.isFullScreenSupported(); - if (isFullScreenSupported) { - gd.setFullScreenWindow(this); - // Check if display mode changes are supported by the OS - if (gd.isDisplayChangeSupported()) { - // Get all available display modes - final DisplayMode[] displayModes = gd.getDisplayModes(); - DisplayMode multiBitsDepthSupportedDisplayMode = null; - DisplayMode refreshRateUnknownDisplayMode = null; - DisplayMode multiBitsDepthSupportedAndRefreshRateUnknownDisplayMode = null; - DisplayMode matchingDisplayMode = null; - DisplayMode currentDisplayMode; - // Look for the display mode that matches with our parameters - // Look for some display modes that are close to these parameters - // and that could be used as substitutes - // On some machines, the refresh rate is unknown and/or multi bit - // depths are supported. If you try to force a particular refresh - // rate or a bit depth, you might find no available display mode - // that matches exactly with your parameters - for (int i = 0; i < displayModes.length && matchingDisplayMode == null; i++) { - currentDisplayMode = displayModes[i]; - if (currentDisplayMode.getWidth() == _settings.getWidth() - && currentDisplayMode.getHeight() == _settings.getHeight()) { - if (currentDisplayMode.getBitDepth() == _settings.getColorDepth()) { - if (currentDisplayMode.getRefreshRate() == _settings.getFrequency()) { - matchingDisplayMode = currentDisplayMode; - } else if (currentDisplayMode.getRefreshRate() == DisplayMode.REFRESH_RATE_UNKNOWN) { - refreshRateUnknownDisplayMode = currentDisplayMode; - } - } else if (currentDisplayMode.getBitDepth() == DisplayMode.BIT_DEPTH_MULTI) { - if (currentDisplayMode.getRefreshRate() == _settings.getFrequency()) { - multiBitsDepthSupportedDisplayMode = currentDisplayMode; - } else if (currentDisplayMode.getRefreshRate() == DisplayMode.REFRESH_RATE_UNKNOWN) { - multiBitsDepthSupportedAndRefreshRateUnknownDisplayMode = currentDisplayMode; - } - } - } - } - DisplayMode nextDisplayMode = null; - if (matchingDisplayMode != null) { - nextDisplayMode = matchingDisplayMode; - } else if (multiBitsDepthSupportedDisplayMode != null) { - nextDisplayMode = multiBitsDepthSupportedDisplayMode; - } else if (refreshRateUnknownDisplayMode != null) { - nextDisplayMode = refreshRateUnknownDisplayMode; - } else if (multiBitsDepthSupportedAndRefreshRateUnknownDisplayMode != null) { - nextDisplayMode = multiBitsDepthSupportedAndRefreshRateUnknownDisplayMode; - } else { - isFullScreenSupported = false; - } - // If we have found a display mode that approximatively matches - // with the input parameters, use it - if (nextDisplayMode != null) { - gd.setDisplayMode(nextDisplayMode); - isDisplayModeModified = true; - } else { - isDisplayModeModified = false; - } - } else { - isDisplayModeModified = false; - // Resize the canvas if the display mode cannot be changed - // and the screen size is not equal to the canvas size - final Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); - if (screenSize.width != _settings.getWidth() || screenSize.height != _settings.getHeight()) { - _glCanvas.setSize(screenSize); - } - } - } else { - isDisplayModeModified = false; - } - - // Software windowed full-screen mode - if (!isFullScreenSupported) { - final Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); - // Resize the canvas - _glCanvas.setSize(screenSize); - // Resize the frame so that it occupies the whole screen - this.setSize(screenSize); - // Set its location at the top left corner - this.setLocation(0, 0); - } - } - // Otherwise, center the window on the screen. - else { - isDisplayModeModified = false; - pack(); - - int x, y; - x = (Toolkit.getDefaultToolkit().getScreenSize().width - _settings.getWidth()) / 2; - y = (Toolkit.getDefaultToolkit().getScreenSize().height - _settings.getHeight()) / 2; - this.setLocation(x, y); - } - - addWindowListener(new WindowAdapter() { - @Override - public void windowClosing(final WindowEvent e) { - _isClosing = true; - // If required, restore the previous display mode - if (isDisplayModeModified) { - gd.setDisplayMode(previousDisplayMode); - } - // If required, get back to the windowed mode - if (gd.getFullScreenWindow() == JoglCanvas.this) { - gd.setFullScreenWindow(null); - } - } - }); - - // Make the window visible to realize the OpenGL surface. - setVisible(true); - - _glCanvas.init(); // true - do swap in renderer. - _inited = true; - } - - @Override - public void draw(final CountDownLatch latch) { - if (!_inited) { - privateInit(); - } - - _glCanvas.draw(latch); - } - - @Override - public CanvasRenderer getCanvasRenderer() { - return _glCanvas.getCanvasRenderer(); - } - - @Override - public void close() { - try { - if (GLContext.getCurrent() != null) { - // Release the OpenGL resources. - GLContext.getCurrent().release(); - } - } catch (final GLException releaseFailure) { - logger.log(Level.WARNING, "Failed to release OpenGL Context: " + _glCanvas, releaseFailure); - } finally { - _glCanvas = null; - } - - // Dispose of any window resources. - dispose(); - } - - @Override - public boolean isActive() { - return hasFocus(); - } - - @Override - public boolean isClosing() { - return _isClosing; - } - - @Override - public void moveWindowTo(final int locX, final int locY) { - setLocation(locX, locY); - } - - @Override - public void setIcon(final Image[] iconImages) { - // not implemented, not supported by AWT anyway - } - - @Override - public void setVSyncEnabled(final boolean enabled) { - _glCanvas.setVSyncEnabled(enabled); - } -} diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglCanvasRenderer.java b/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglCanvasRenderer.java index a86e3bc..ca92de2 100644 --- a/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglCanvasRenderer.java +++ b/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglCanvasRenderer.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2008-2010 Ardor Labs, Inc. + * Copyright (c) 2008-2014 Ardor Labs, Inc. * * This file is part of Ardor3D. * @@ -12,18 +12,6 @@ package com.ardor3d.framework.jogl; 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.GLContext; -import javax.media.opengl.GLDrawableFactory; -import javax.media.opengl.GLException; - import com.ardor3d.annotation.MainThread; import com.ardor3d.framework.CanvasRenderer; import com.ardor3d.framework.DisplaySettings; @@ -41,6 +29,11 @@ import com.ardor3d.renderer.jogl.JoglRenderContext; import com.ardor3d.renderer.jogl.JoglRenderer; import com.ardor3d.util.Ardor3dException; import com.ardor3d.util.geom.jogl.DirectNioBuffersSet; +import com.jogamp.opengl.GL; +import com.jogamp.opengl.GLContext; +import com.jogamp.opengl.GLDrawableFactory; +import com.jogamp.opengl.GLException; +import com.jogamp.opengl.GLPipelineFactory; public class JoglCanvasRenderer implements CanvasRenderer { @@ -65,42 +58,75 @@ public class JoglCanvasRenderer implements CanvasRenderer { */ private boolean _debugEnabled = false; + /** + * <code>true</code> if we try to drop and reclaim the context on each frame. + */ + private final boolean _contextDropAndReclaimOnDrawEnabled; + protected CapsUtil _capsUtil; protected DirectNioBuffersSet _directNioBuffersSet; + /** + * Default constructor, with debug disabled, using the default utility for the capabilities and with context drop + * and reclaim on draw disabled + * + * @param scene + * data related to the scene (cannot be null) + */ public JoglCanvasRenderer(final Scene scene) { - this(scene, false, new CapsUtil()); + this(scene, false, new CapsUtil(), false); } - public JoglCanvasRenderer(final Scene scene, final boolean useDebug, final CapsUtil capsUtil) { + /** + * Main constructor + * + * @param scene + * data related to the scene + * @param useDebug + * <code>true</code> if debugging is currently enabled for this GLContext + * @param capsUtil + * utility to manage the capabilities (cannot be null) + * @param contextDropAndReclaimOnDrawEnabled + * <code>true</code> if we try to drop and reclaim the context on each frame. It should be set to + * <code>false</code> for better performance in the general case. It should be set to <code>true</code> + * if and only if the OpenGL context is made current on a thread which is not the default rendering + * thread of the canvas. + */ + public JoglCanvasRenderer(final Scene scene, final boolean useDebug, final CapsUtil capsUtil, + final boolean contextDropAndReclaimOnDrawEnabled) { _scene = scene; _useDebug = useDebug; _capsUtil = capsUtil; + _contextDropAndReclaimOnDrawEnabled = contextDropAndReclaimOnDrawEnabled; } @Override public void makeCurrentContext() throws Ardor3dException { int value = GLContext.CONTEXT_NOT_CURRENT; - int attempt = 0; - do { + for (int attempt = 0;;) { try { value = _context.makeCurrent(); } catch (final GLException gle) { gle.printStackTrace(); } finally { attempt++; + } + if (value == GLContext.CONTEXT_NOT_CURRENT) { if (attempt == MAX_CONTEXT_GRAB_ATTEMPTS) { // failed, throw exception throw new Ardor3dException("Failed to claim OpenGL context."); + } else { + try { + Thread.sleep(5); + } catch (final InterruptedException e1) { + e1.printStackTrace(); + } } + } else { + break; } - try { - Thread.sleep(5); - } catch (final InterruptedException e1) { - e1.printStackTrace(); - } - } while (value == GLContext.CONTEXT_NOT_CURRENT); + } if (ContextManager.getCurrentContext() != null) { if (value == GLContext.CONTEXT_CURRENT_NEW) { ContextManager.getCurrentContext().contextLost(); @@ -177,9 +203,9 @@ public class JoglCanvasRenderer implements CanvasRenderer { if (_camera == null) { /** Set up how our camera sees. */ - _camera = new Camera(settings.getWidth(), settings.getHeight()); - _camera.setFrustumPerspective(45.0f, (float) settings.getWidth() / (float) settings.getHeight(), 1, - 1000); + _camera = new Camera(settings.getRotatedWidth(), settings.getRotatedHeight()); + _camera.setFrustumPerspective(45.0f, + (float) settings.getRotatedWidth() / (float) settings.getRotatedHeight(), 1, 1000); _camera.setProjectionMode(ProjectionMode.Perspective); final Vector3 loc = new Vector3(0.0f, 0.0f, 10.0f); @@ -191,8 +217,8 @@ public class JoglCanvasRenderer implements CanvasRenderer { } else { // use new width and height to set ratio. _camera.setFrustumPerspective(_camera.getFovY(), - (float) settings.getWidth() / (float) settings.getHeight(), _camera.getFrustumNear(), - _camera.getFrustumFar()); + (float) settings.getRotatedWidth() / (float) settings.getRotatedHeight(), + _camera.getFrustumNear(), _camera.getFrustumFar()); } } finally { releaseCurrentContext(); @@ -214,41 +240,13 @@ public class JoglCanvasRenderer implements CanvasRenderer { public boolean draw() { // set up context for rendering this canvas - makeCurrentContext(); + if (_contextDropAndReclaimOnDrawEnabled) { + makeCurrentContext(); + } // Enable Debugging if requested. if (_useDebug != _debugEnabled) { - if (_context.getGL().isGLES()) { - if (_context.getGL().isGLES1()) { - _context.setGL(new DebugGLES1(_context.getGL().getGLES1())); - } else { - if (_context.getGL().isGLES2()) { - _context.setGL(new DebugGLES2(_context.getGL().getGLES2())); - } else { - // TODO ES3 - } - } - } else { - if (_context.getGL().isGL4bc()) { - _context.setGL(new DebugGL4bc(_context.getGL().getGL4bc())); - } else { - if (_context.getGL().isGL4()) { - _context.setGL(new DebugGL4(_context.getGL().getGL4())); - } else { - if (_context.getGL().isGL3bc()) { - _context.setGL(new DebugGL3bc(_context.getGL().getGL3bc())); - } else { - if (_context.getGL().isGL3()) { - _context.setGL(new DebugGL3(_context.getGL().getGL3())); - } else { - if (_context.getGL().isGL2()) { - _context.setGL(new DebugGL2(_context.getGL().getGL2())); - } - } - } - } - } - } + _context.setGL(GLPipelineFactory.create("javax.media.opengl.Debug", null, _context.getGL(), null)); _debugEnabled = true; LOGGER.info("DebugGL Enabled"); @@ -268,7 +266,9 @@ public class JoglCanvasRenderer implements CanvasRenderer { // release the context if we're done (swapped and all) if (_doSwap) { - releaseCurrentContext(); + if (_contextDropAndReclaimOnDrawEnabled) { + releaseCurrentContext(); + } } return drew; diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglDrawerRunnable.java b/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglDrawerRunnable.java index a3c00e8..d6a5544 100644 --- a/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglDrawerRunnable.java +++ b/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglDrawerRunnable.java @@ -1,7 +1,7 @@ package com.ardor3d.framework.jogl; -import javax.media.opengl.GLAutoDrawable; -import javax.media.opengl.GLRunnable; +import com.jogamp.opengl.GLAutoDrawable; +import com.jogamp.opengl.GLRunnable; public class JoglDrawerRunnable implements GLRunnable { diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglNewtAwtCanvas.java b/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglNewtAwtCanvas.java deleted file mode 100644 index b56e6c1..0000000 --- a/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglNewtAwtCanvas.java +++ /dev/null @@ -1,114 +0,0 @@ -/** - * Copyright (c) 2008-2012 Ardor Labs, Inc. - * - * This file is part of Ardor3D. - * - * Ardor3D is free software: you can redistribute it and/or modify it - * under the terms of its license which may be found in the accompanying - * LICENSE file or at <http://www.ardor3d.com/LICENSE>. - */ - -package com.ardor3d.framework.jogl; - -import java.util.concurrent.CountDownLatch; - -import javax.media.opengl.GLAutoDrawable; -import javax.media.opengl.GLRunnable; - -import com.ardor3d.annotation.MainThread; -import com.ardor3d.framework.Canvas; -import com.ardor3d.framework.DisplaySettings; -import com.jogamp.newt.awt.NewtCanvasAWT; -import com.jogamp.newt.opengl.GLWindow; - -public class JoglNewtAwtCanvas extends NewtCanvasAWT implements Canvas, NewtWindowContainer { - - private static final long serialVersionUID = 1L; - - private final JoglCanvasRenderer _canvasRenderer; - private boolean _inited = false; - - private final DisplaySettings _settings; - - private final JoglDrawerRunnable _drawerGLRunnable; - - public JoglNewtAwtCanvas(final DisplaySettings settings, final JoglCanvasRenderer canvasRenderer) { - this(settings, canvasRenderer, new CapsUtil()); - } - - public JoglNewtAwtCanvas(final DisplaySettings settings, final JoglCanvasRenderer canvasRenderer, - final CapsUtil capsUtil) { - super(GLWindow.create(capsUtil.getCapsForSettings(settings))); - _drawerGLRunnable = new JoglDrawerRunnable(canvasRenderer); - getNewtWindow().setUndecorated(true); - _settings = settings; - _canvasRenderer = canvasRenderer; - - setFocusable(true); - setSize(_settings.getWidth(), _settings.getHeight()); - setIgnoreRepaint(true); - getNewtWindow().setAutoSwapBufferMode(false); - } - - @Override - @MainThread - public void init() { - if (_inited) { - return; - } - - // Make the window visible to realize the OpenGL surface. - setVisible(true); - if (getNewtWindow().isRealized()) { - // Request the focus here as it cannot work when the window is not visible - requestFocus(); - /** - * I do not understand why I cannot get the context earlier, I failed in getting it from addNotify() and - * setVisible(true) - * */ - _canvasRenderer.setContext(getNewtWindow().getContext()); - getNewtWindow().invoke(true, new GLRunnable() { - @Override - public boolean run(final GLAutoDrawable glAutoDrawable) { - _canvasRenderer.init(_settings, true);// true - do swap in renderer. - return true; - } - }); - _inited = true; - } - } - - @Override - public void draw(final CountDownLatch latch) { - if (!_inited) { - init(); - } - - if (isShowing()) { - getNewtWindow().invoke(true, _drawerGLRunnable); - } - if (latch != null) { - latch.countDown(); - } - } - - @Override - public JoglCanvasRenderer getCanvasRenderer() { - return _canvasRenderer; - } - - @Override - public GLWindow getNewtWindow() { - return (GLWindow) getNEWTChild(); - } - - public void setVSyncEnabled(final boolean enabled) { - getNewtWindow().invoke(true, new GLRunnable() { - @Override - public boolean run(final GLAutoDrawable glAutoDrawable) { - glAutoDrawable.getGL().setSwapInterval(enabled ? 1 : 0); - return false; - } - }); - } -} diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglNewtSwtCanvas.java b/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglNewtSwtCanvas.java deleted file mode 100644 index 66436d3..0000000 --- a/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglNewtSwtCanvas.java +++ /dev/null @@ -1,113 +0,0 @@ -/** - * Copyright (c) 2008-2010 Ardor Labs, Inc. - * - * This file is part of Ardor3D. - * - * Ardor3D is free software: you can redistribute it and/or modify it - * under the terms of its license which may be found in the accompanying - * LICENSE file or at <http://www.ardor3d.com/LICENSE>. - */ - -package com.ardor3d.framework.jogl; - -import java.util.concurrent.CountDownLatch; - -import javax.media.opengl.GLAutoDrawable; -import javax.media.opengl.GLRunnable; - -import org.eclipse.swt.widgets.Composite; - -import com.ardor3d.annotation.MainThread; -import com.ardor3d.framework.Canvas; -import com.ardor3d.framework.DisplaySettings; -import com.jogamp.newt.opengl.GLWindow; -import com.jogamp.newt.swt.NewtCanvasSWT; - -/** - * Ardor3D JOGL SWT lightweight canvas, SWT control for the OpenGL rendering of Ardor3D with JOGL that supports both - * NEWT and SWT input systems directly and their abstractions in Ardor3D (com.ardor3d.input.jogl and - * com.ardor3d.input.swt) - */ -public class JoglNewtSwtCanvas extends NewtCanvasSWT implements Canvas, NewtWindowContainer { - - private final JoglCanvasRenderer _canvasRenderer; - private boolean _inited = false; - - private final DisplaySettings _settings; - - private final JoglDrawerRunnable _drawerGLRunnable; - - public JoglNewtSwtCanvas(final DisplaySettings settings, final JoglCanvasRenderer canvasRenderer, - final Composite composite, final int style) { - this(settings, canvasRenderer, new CapsUtil(), composite, style); - } - - public JoglNewtSwtCanvas(final DisplaySettings settings, final JoglCanvasRenderer canvasRenderer, - final CapsUtil capsUtil, final Composite composite, final int style) { - super(composite, style, GLWindow.create(capsUtil.getCapsForSettings(settings))); - _drawerGLRunnable = new JoglDrawerRunnable(canvasRenderer); - getNewtWindow().setUndecorated(true); - _settings = settings; - _canvasRenderer = canvasRenderer; - - setSize(_settings.getWidth(), _settings.getHeight()); - getNewtWindow().setAutoSwapBufferMode(false); - } - - @Override - @MainThread - public void init() { - if (_inited) { - return; - } - - // Make the window visible to realize the OpenGL surface. - setVisible(true); - if (getNewtWindow().isRealized()) { - _canvasRenderer.setContext(getNewtWindow().getContext()); - getNewtWindow().invoke(true, new GLRunnable() { - @Override - public boolean run(final GLAutoDrawable glAutoDrawable) { - _canvasRenderer.init(_settings, true);// true - do swap in renderer. - return true; - } - }); - _inited = true; - } - } - - @Override - public void draw(final CountDownLatch latch) { - if (!_inited) { - init(); - } - - if (isVisible()) { - getNewtWindow().invoke(true, _drawerGLRunnable); - } - if (latch != null) { - latch.countDown(); - } - } - - @Override - public JoglCanvasRenderer getCanvasRenderer() { - return _canvasRenderer; - } - - @Override - public GLWindow getNewtWindow() { - return (GLWindow) getNEWTChild(); - } - - public void setVSyncEnabled(final boolean enabled) { - getNewtWindow().invoke(true, new GLRunnable() { - @Override - public boolean run(final GLAutoDrawable glAutoDrawable) { - glAutoDrawable.getGL().setSwapInterval(enabled ? 1 : 0); - return false; - } - }); - } - -} diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglNewtWindow.java b/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglNewtWindow.java index 938a53e..e72f593 100644 --- a/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglNewtWindow.java +++ b/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglNewtWindow.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2008-2012 Ardor Labs, Inc. + * Copyright (c) 2008-2014 Ardor Labs, Inc. * * This file is part of Ardor3D. * @@ -10,18 +10,18 @@ package com.ardor3d.framework.jogl; +import java.util.ArrayList; +import java.util.Collections; import java.util.List; import java.util.concurrent.CountDownLatch; -import javax.media.nativewindow.util.Dimension; -import javax.media.opengl.GLAutoDrawable; -import javax.media.opengl.GLContext; -import javax.media.opengl.GLRunnable; - import com.ardor3d.annotation.MainThread; import com.ardor3d.framework.DisplaySettings; import com.ardor3d.framework.NativeCanvas; import com.ardor3d.image.Image; +import com.jogamp.nativewindow.ScalableSurface; +import com.jogamp.nativewindow.util.Dimension; +import com.jogamp.nativewindow.util.DimensionImmutable; import com.jogamp.newt.MonitorDevice; import com.jogamp.newt.MonitorMode; import com.jogamp.newt.event.KeyListener; @@ -31,6 +31,10 @@ import com.jogamp.newt.event.WindowEvent; import com.jogamp.newt.event.WindowListener; import com.jogamp.newt.opengl.GLWindow; import com.jogamp.newt.util.MonitorModeUtil; +import com.jogamp.opengl.GLAutoDrawable; +import com.jogamp.opengl.GLCapabilitiesImmutable; +import com.jogamp.opengl.GLContext; +import com.jogamp.opengl.GLRunnable; /** * Ardor3D NEWT lightweight window, NEWT "top level" component for the OpenGL rendering of Ardor3D with JOGL that @@ -42,13 +46,18 @@ public class JoglNewtWindow implements NativeCanvas, NewtWindowContainer { private final JoglCanvasRenderer _canvasRenderer; private boolean _inited = false; private boolean _isClosing = false; - - private final DisplaySettings _settings; + /** chosen display settings. Note that they may differ from the requested display settings */ + private DisplaySettings _settings; private final JoglDrawerRunnable _drawerGLRunnable; private final GLWindow _newtWindow; + /** list of monitor devices used in fullscreen mode, ignored in windowed mode */ + private List<MonitorDevice> _monitorDevices; + + private final CapsUtil _capsUtil; + public JoglNewtWindow(final JoglCanvasRenderer canvasRenderer, final DisplaySettings settings) { this(canvasRenderer, settings, true, false, false, false); } @@ -62,38 +71,114 @@ public class JoglNewtWindow implements NativeCanvas, NewtWindowContainer { public JoglNewtWindow(final JoglCanvasRenderer canvasRenderer, final DisplaySettings settings, final boolean onscreen, final boolean bitmapRequested, final boolean pbufferRequested, final boolean fboRequested, final CapsUtil capsUtil) { - _newtWindow = GLWindow.create(capsUtil.getCapsForSettings(settings, onscreen, bitmapRequested, + _capsUtil = capsUtil; + // FIXME rather pass the monitor(s) to the constructor, create a screen to get the primary monitor + _newtWindow = GLWindow.create(capsUtil.getCapsForSettingsWithHints(settings, onscreen, bitmapRequested, pbufferRequested, fboRequested)); + _monitorDevices = new ArrayList<>(); + // uses the primary monitor by default + _newtWindow.getScreen().createNative(); + final MonitorDevice primaryMonitor = _newtWindow.getScreen().getPrimaryMonitor(); + _monitorDevices.add(primaryMonitor); + // disables HiDPI, see https://github.com/gouessej/Ardor3D/issues/14 + _newtWindow.setSurfaceScale(new float[] { ScalableSurface.IDENTITY_PIXELSCALE, + ScalableSurface.IDENTITY_PIXELSCALE }); _drawerGLRunnable = new JoglDrawerRunnable(canvasRenderer); - _settings = settings; + final int width, height; + if (settings.isFullScreen() && settings.getWidth() == 0 || settings.getHeight() == 0) { + // FIXME use all available monitor devices to compute the size + final DimensionImmutable currentResolution = primaryMonitor.queryCurrentMode().getSurfaceSize() + .getResolution(); + width = currentResolution.getWidth(); + height = currentResolution.getHeight(); + } else { + width = settings.getWidth(); + height = settings.getHeight(); + } + _settings = new DisplaySettings(width, height, settings.getColorDepth(), settings.getFrequency(), + settings.getAlphaBits(), settings.getDepthBits(), settings.getStencilBits(), settings.getSamples(), + settings.isFullScreen(), settings.isStereo(), settings.getShareContext(), settings.getRotation()); _canvasRenderer = canvasRenderer; - setAutoSwapBufferMode(false); + _canvasRenderer._doSwap = true;// true - do swap in renderer. + setAutoSwapBufferMode(false);// false - doesn't swap automatically in JOGL itself } /** * Applies all settings not related to OpenGL (screen resolution, screen size, etc...) * */ - private void applySettings() { + protected void applySettings() { _newtWindow.setUndecorated(_settings.isFullScreen()); - _newtWindow.setFullscreen(_settings.isFullScreen()); - // FIXME Ardor3D does not allow to change the resolution - /** - * uses the filtering relying on resolution with the size to fetch only the screen mode matching with the - * current resolution - */ if (_settings.isFullScreen()) { - final MonitorDevice monitor = _newtWindow.getMainMonitor(); - List<MonitorMode> monitorModes = monitor.getSupportedModes(); - // the resolution is provided by the user - final Dimension dimension = new Dimension(_settings.getWidth(), _settings.getHeight()); - monitorModes = MonitorModeUtil.filterByResolution(monitorModes, dimension); - monitorModes = MonitorModeUtil.getHighestAvailableBpp(monitorModes); - if (_settings.getFrequency() > 0) { - monitorModes = MonitorModeUtil.filterByRate(monitorModes, _settings.getFrequency()); - } else { - monitorModes = MonitorModeUtil.getHighestAvailableRate(monitorModes); + _newtWindow.setFullscreen(_monitorDevices); + for (final MonitorDevice monitorDevice : _monitorDevices) { + List<MonitorMode> monitorModes = monitorDevice.getSupportedModes(); + final MonitorMode currentMode = monitorDevice.getCurrentMode(); + if (monitorDevice == _monitorDevices.get(0)) { + final Dimension dimension; + // the resolution is taken into account only if it is valid + if (_settings.getWidth() > 0 && _settings.getHeight() > 0) { + dimension = new Dimension(_settings.getWidth(), _settings.getHeight()); + } else { + final DimensionImmutable currentResolution = currentMode.getSurfaceSize().getResolution(); + dimension = new Dimension(currentResolution.getWidth(), currentResolution.getHeight()); + } + monitorModes = MonitorModeUtil.filterByResolution(monitorModes, dimension); + } else { + // FIXME the display settings should store the size of the other monitors + } + // if the frequency may be valid (greater than zero), it tries to use it + final List<MonitorMode> byRateMonitorModes; + if (_settings.getFrequency() > 0) { + byRateMonitorModes = MonitorModeUtil.filterByRate(monitorModes, _settings.getFrequency()); + } else { + // if the frequency is set to zero, it tries to preserve the refresh rate + if (_settings.getFrequency() == 0) { + byRateMonitorModes = MonitorModeUtil.filterByRate(monitorModes, currentMode.getRefreshRate()); + } else { + // otherwise it picks the highest available rate + byRateMonitorModes = MonitorModeUtil.getHighestAvailableRate(monitorModes); + } + } + if (!byRateMonitorModes.isEmpty()) { + monitorModes = byRateMonitorModes; + } + final List<MonitorMode> byBppMonitorModes; + switch (_settings.getColorDepth()) { + case 16: + case 24: + case 32: { + byBppMonitorModes = MonitorModeUtil.filterByBpp(monitorModes, _settings.getColorDepth()); + break; + } + case 0: { + byBppMonitorModes = MonitorModeUtil.filterByBpp(monitorModes, currentMode.getSurfaceSize() + .getBitsPerPixel()); + break; + } + case -1: { + byBppMonitorModes = MonitorModeUtil.getHighestAvailableBpp(monitorModes); + break; + } + default: { + byBppMonitorModes = monitorModes; + } + } + if (!byBppMonitorModes.isEmpty()) { + monitorModes = byBppMonitorModes; + } + if (_settings.getRotation() == MonitorMode.ROTATE_0 || _settings.getRotation() == MonitorMode.ROTATE_90 + || _settings.getRotation() == MonitorMode.ROTATE_180 + || _settings.getRotation() == MonitorMode.ROTATE_270) { + final List<MonitorMode> rotatedMonitorModes = MonitorModeUtil.filterByRotation(monitorModes, + _settings.getRotation()); + if (!rotatedMonitorModes.isEmpty()) { + monitorModes = rotatedMonitorModes; + } + } + monitorDevice.setCurrentMode(monitorModes.get(0)); } - monitor.setCurrentMode(monitorModes.get(0)); + } else { + _newtWindow.setFullscreen(false); } } @@ -113,14 +198,79 @@ public class JoglNewtWindow implements NativeCanvas, NewtWindowContainer { return _newtWindow.getContext(); } + /** + * Returns the width of the client area including insets (window decorations) in window units. + * + * @return width of the client area including insets (window decorations) in window units + */ public int getWidth() { + return _newtWindow.getWidth() + (_newtWindow.getInsets() == null ? 0 : _newtWindow.getInsets().getTotalWidth()); + } + + /** + * Returns the width of the client area including insets (window decorations) in pixel units. + * + * @return width of the client area including insets (window decorations) in pixel units + */ + public int getWidthInPixelUnits() { + return _newtWindow.convertToPixelUnits(new int[] { getWidth(), 0 })[0]; + } + + /** + * Returns the width of the client area excluding insets (window decorations) in window units. + * + * @return width of the client area excluding insets (window decorations) in window units + */ + public int getSurfaceWidthInWindowUnits() { return _newtWindow.getWidth(); } + /** + * Returns the width of the client area excluding insets (window decorations) in pixel units. + * + * @return width of the client area excluding insets (window decorations) in pixel units + */ + public int getSurfaceWidth() { + return _newtWindow.getSurfaceWidth(); + } + + /** + * Returns the height of the client area including insets (window decorations) in window units. + * + * @return height of the client area including insets (window decorations) in window units + */ public int getHeight() { + return _newtWindow.getHeight() + + (_newtWindow.getInsets() == null ? 0 : _newtWindow.getInsets().getTotalHeight()); + } + + /** + * Returns the height of the client area including insets (window decorations) in pixel units. + * + * @return height of the client area including insets (window decorations) in pixel units + */ + public int getHeightInPixelUnits() { + return _newtWindow.convertToPixelUnits(new int[] { 0, getHeight() })[1]; + } + + /** + * Returns the height of the client area excluding insets (window decorations) in window units. + * + * @return height of the client area excluding insets (window decorations) in window units + */ + public int getSurfaceHeightInWindowUnits() { return _newtWindow.getHeight(); } + /** + * Returns the height of the client area excluding insets (window decorations) in pixel units. + * + * @return height of the client area excluding insets (window decorations) in pixel units + */ + public int getSurfaceHeight() { + return _newtWindow.getSurfaceHeight(); + } + public int getX() { return _newtWindow.getX(); } @@ -141,6 +291,11 @@ public class JoglNewtWindow implements NativeCanvas, NewtWindowContainer { _newtWindow.setVisible(visible); } + /** + * Enables or disables automatic buffer swapping for this JoglNewtWindow. By default this property is set to false + * + * @param autoSwapBufferModeEnabled + */ public void setAutoSwapBufferMode(final boolean autoSwapBufferModeEnabled) { _newtWindow.setAutoSwapBufferMode(autoSwapBufferModeEnabled); } @@ -157,6 +312,10 @@ public class JoglNewtWindow implements NativeCanvas, NewtWindowContainer { // Make the window visible to realize the OpenGL surface. setVisible(true); if (_newtWindow.isRealized()) { + final GLCapabilitiesImmutable glCaps = _newtWindow.getChosenGLCapabilities(); + _settings = _capsUtil.getSettingsForCaps(glCaps, _settings.getWidth(), _settings.getHeight(), + _settings.getFrequency(), _settings.isFullScreen(), _settings.getShareContext(), + _settings.getRotation()); _newtWindow.addWindowListener(new WindowAdapter() { @Override public void windowDestroyNotify(final WindowEvent e) { @@ -188,7 +347,7 @@ public class JoglNewtWindow implements NativeCanvas, NewtWindowContainer { _newtWindow.invoke(true, new GLRunnable() { @Override public boolean run(final GLAutoDrawable glAutoDrawable) { - _canvasRenderer.init(_settings, true);// true - do swap in renderer. + _canvasRenderer.init(_settings, _canvasRenderer._doSwap); return true; } }); @@ -254,9 +413,69 @@ public class JoglNewtWindow implements NativeCanvas, NewtWindowContainer { @Override public void moveWindowTo(final int locX, final int locY) { - _newtWindow.setPosition(locX, locY); + _newtWindow.setTopLevelPosition(locX, locY); + } + + public boolean isResizable() { + return _newtWindow.isResizable(); + } + + public void setResizable(final boolean resizable) { + _newtWindow.setResizable(resizable); + } + + public boolean isDecorated() { + return !_newtWindow.isUndecorated(); + } + + public void setDecorated(final boolean decorated) { + _newtWindow.setUndecorated(!decorated); + } + + public boolean isSticky() { + return _newtWindow.isSticky(); + } + + public void setSticky(final boolean sticky) { + _newtWindow.setSticky(sticky); + } + + public boolean isAlwaysOnTop() { + return _newtWindow.isAlwaysOnTop(); + } + + public void setAlwaysOnTop(final boolean alwaysOnTop) { + _newtWindow.setAlwaysOnTop(alwaysOnTop); + } + + public boolean isAlwaysOnBottom() { + return _newtWindow.isAlwaysOnBottom(); + } + + public void setAlwaysOnBottom(final boolean alwaysOnBottom) { + _newtWindow.setAlwaysOnBottom(alwaysOnBottom); } + /** + * Returns a list of monitor devices used in fullscreen mode, ignored in windowed mode + * + * @return list of monitor devices used in fullscreen mode, ignored in windowed mode + */ + public List<MonitorDevice> getMonitorDevices() { + return Collections.unmodifiableList(_monitorDevices); + } + + public void setMonitorDevices(final List<MonitorDevice> monitorDevices) { + if (_monitorDevices == null || _monitorDevices.isEmpty()) { + throw new IllegalArgumentException("The list of monitor devices cannot be null or empty"); + } + + _monitorDevices = monitorDevices; + // FIXME recompute the width and the height of the settings, apply the settings anew + } + + // TODO return all available monitor modes + @Override public GLWindow getNewtWindow() { return _newtWindow; diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglSwtCanvas.java b/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglSwtCanvas.java deleted file mode 100644 index a659d49..0000000 --- a/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglSwtCanvas.java +++ /dev/null @@ -1,105 +0,0 @@ -/** - * Copyright (c) 2008-2014 Ardor Labs, Inc. - * - * This file is part of Ardor3D. - * - * Ardor3D is free software: you can redistribute it and/or modify it - * under the terms of its license which may be found in the accompanying - * LICENSE file or at <http://www.ardor3d.com/LICENSE>. - */ - -package com.ardor3d.framework.jogl; - -import java.util.concurrent.CountDownLatch; - -import javax.media.opengl.GLAutoDrawable; -import javax.media.opengl.GLRunnable; - -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Display; - -import com.ardor3d.annotation.MainThread; -import com.ardor3d.framework.Canvas; -import com.ardor3d.framework.DisplaySettings; -import com.jogamp.opengl.swt.GLCanvas; - -/** - * Ardor3D JOGL SWT heavyweight canvas, SWT control for the OpenGL rendering of Ardor3D with JOGL that supports the SWT - * input system directly and its abstraction in Ardor3D (com.ardor3d.input.swt) - */ -public class JoglSwtCanvas extends GLCanvas implements Canvas { - - private final JoglCanvasRenderer _canvasRenderer; - private boolean _inited = false; - - private final DisplaySettings _settings; - - private final JoglDrawerRunnable _drawerGLRunnable; - - private final JoglSwtInitializerRunnable _initializerRunnable; - - public JoglSwtCanvas(final DisplaySettings settings, final JoglCanvasRenderer canvasRenderer, - final Composite composite, final int style) { - this(settings, canvasRenderer, new CapsUtil(), composite, style); - } - - public JoglSwtCanvas(final DisplaySettings settings, final JoglCanvasRenderer canvasRenderer, - final CapsUtil capsUtil, final Composite composite, final int style) { - super(composite, style, capsUtil.getCapsForSettings(settings), null); - _drawerGLRunnable = new JoglDrawerRunnable(canvasRenderer); - _initializerRunnable = new JoglSwtInitializerRunnable(this, settings); - _settings = settings; - _canvasRenderer = canvasRenderer; - - setFocus(); - setSize(_settings.getWidth(), _settings.getHeight()); - setAutoSwapBufferMode(false); - } - - @Override - @MainThread - public void init() { - if (_inited) { - return; - } - - // if we aren't on SWT user interface thread - if (Display.getCurrent() == null) { - Display.getDefault().syncExec(_initializerRunnable); - } else { - _initializerRunnable.run(); - } - - _inited = isRealized(); - } - - @Override - public void draw(final CountDownLatch latch) { - if (!_inited) { - init(); - } - - if (isVisible()) { - invoke(true, _drawerGLRunnable); - } - if (latch != null) { - latch.countDown(); - } - } - - @Override - public JoglCanvasRenderer getCanvasRenderer() { - return _canvasRenderer; - } - - public void setVSyncEnabled(final boolean enabled) { - invoke(true, new GLRunnable() { - @Override - public boolean run(final GLAutoDrawable glAutoDrawable) { - glAutoDrawable.getGL().setSwapInterval(enabled ? 1 : 0); - return false; - } - }); - } - -} diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglSwtInitializerRunnable.java b/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglSwtInitializerRunnable.java deleted file mode 100644 index f580221..0000000 --- a/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/JoglSwtInitializerRunnable.java +++ /dev/null @@ -1,42 +0,0 @@ -/** - * Copyright (c) 2008-2010 Ardor Labs, Inc. - * - * This file is part of Ardor3D. - * - * Ardor3D is free software: you can redistribute it and/or modify it - * under the terms of its license which may be found in the accompanying - * LICENSE file or at <http://www.ardor3d.com/LICENSE>. - */ - -package com.ardor3d.framework.jogl; - -import com.ardor3d.framework.DisplaySettings; - -public class JoglSwtInitializerRunnable implements Runnable { - - private final JoglSwtCanvas _joglSwtCanvas; - - private final DisplaySettings _settings; - - public JoglSwtInitializerRunnable(final JoglSwtCanvas joglSwtCanvas, final DisplaySettings settings) { - _joglSwtCanvas = joglSwtCanvas; - _settings = settings; - } - - @Override - public void run() { - // Make the window visible to realize the OpenGL surface. - _joglSwtCanvas.setVisible(true); - // Force the realization - _joglSwtCanvas.display(); - if (_joglSwtCanvas.getDelegatedDrawable().isRealized()) { - // Request the focus here as it cannot work when the window is not visible - _joglSwtCanvas.setFocus(); - // The OpenGL context has been created after the realization of the surface - _joglSwtCanvas.getCanvasRenderer().setContext(_joglSwtCanvas.getContext()); - // As the canvas renderer knows the OpenGL context, it can be initialized - _joglSwtCanvas.getCanvasRenderer().init(_settings, true); - } - } - -} diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/NewtWindowContainer.java b/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/NewtWindowContainer.java index 5470a36..09e2058 100644 --- a/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/NewtWindowContainer.java +++ b/ardor3d-jogl/src/main/java/com/ardor3d/framework/jogl/NewtWindowContainer.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2008-2012 Ardor Labs, Inc. + * Copyright (c) 2008-2014 Ardor Labs, Inc. * * This file is part of Ardor3D. * diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/image/util/jogl/JoglImageLoader.java b/ardor3d-jogl/src/main/java/com/ardor3d/image/util/jogl/JoglImageLoader.java index 15164a9..42af78a 100644 --- a/ardor3d-jogl/src/main/java/com/ardor3d/image/util/jogl/JoglImageLoader.java +++ b/ardor3d-jogl/src/main/java/com/ardor3d/image/util/jogl/JoglImageLoader.java @@ -1,9 +1,9 @@ /** - * Copyright (c) 2008-2010 Ardor Labs, Inc. + * Copyright (c) 2008-2014 Ardor Labs, Inc. * * This file is part of Ardor3D. * - * Ardor3D is free software: you can redistribute it and/or modify it + * Ardor3D is free software: you can redistribute it and/or modify it * under the terms of its license which may be found in the accompanying * LICENSE file or at <http://www.ardor3d.com/LICENSE>. */ @@ -20,6 +20,8 @@ import java.nio.FloatBuffer; import java.nio.IntBuffer; import java.nio.LongBuffer; import java.nio.ShortBuffer; +import java.util.ArrayList; +import java.util.List; import com.ardor3d.framework.jogl.CapsUtil; import com.ardor3d.image.Image; @@ -29,6 +31,7 @@ import com.ardor3d.image.util.ImageLoaderUtil; import com.ardor3d.scene.state.jogl.util.JoglTextureUtil; import com.ardor3d.util.geom.BufferUtils; import com.jogamp.common.nio.Buffers; +import com.jogamp.common.os.Platform; import com.jogamp.opengl.util.texture.TextureData; import com.jogamp.opengl.util.texture.TextureIO; @@ -38,6 +41,11 @@ public class JoglImageLoader implements ImageLoader { protected final CapsUtil _capsUtil; + /** + * Flag indicating whether the mipmaps are produced by JOGL (retrieved from the file or generated) + */ + private boolean _mipmapsProductionEnabled; + private enum TYPE { BYTE(ByteBuffer.class), SHORT(ShortBuffer.class), CHAR(CharBuffer.class), INT(IntBuffer.class), FLOAT( FloatBuffer.class), LONG(LongBuffer.class), DOUBLE(DoubleBuffer.class); @@ -49,10 +57,20 @@ public class JoglImageLoader implements ImageLoader { } }; - private static final String[] _supportedFormats = new String[] { "." + TextureIO.DDS.toUpperCase(), - "." + TextureIO.GIF.toUpperCase(), "." + TextureIO.JPG.toUpperCase(), "." + TextureIO.PAM.toUpperCase(), - "." + TextureIO.PNG.toUpperCase(), "." + TextureIO.PPM.toUpperCase(), "." + TextureIO.SGI.toUpperCase(), - "." + TextureIO.TGA.toUpperCase(), "." + TextureIO.TIFF.toUpperCase() }; + private static final String[] _supportedFormats = computeSupportedFormats(); + + private static final String[] computeSupportedFormats() { + final List<String> supportedFormatsList = new ArrayList<>(); + if (Platform.AWT_AVAILABLE) { + supportedFormatsList.add("." + TextureIO.GIF.toUpperCase()); + } + supportedFormatsList.add("." + TextureIO.DDS.toUpperCase()); + supportedFormatsList.add("." + TextureIO.JPG.toUpperCase()); + supportedFormatsList.add("." + TextureIO.PNG.toUpperCase()); + supportedFormatsList.add("." + TextureIO.SGI.toUpperCase()); + supportedFormatsList.add("." + TextureIO.SGI_RGB.toUpperCase()); + return supportedFormatsList.toArray(new String[supportedFormatsList.size()]); + } public static String[] getSupportedFormats() { return _supportedFormats; @@ -60,6 +78,7 @@ public class JoglImageLoader implements ImageLoader { public static void registerLoader() { registerLoader(new JoglImageLoader(), _supportedFormats); + registerLoader(new JoglTgaImageLoader(), JoglTgaImageLoader.getSupportedFormats()); } public static void registerLoader(final JoglImageLoader joglImageLoader, final String[] supportedFormats) { @@ -74,17 +93,17 @@ public class JoglImageLoader implements ImageLoader { _capsUtil = capsUtil; } - public Image makeArdor3dImage(final TextureData textureData, final boolean flipped) { + public Image makeArdor3dImage(final TextureData textureData, final boolean verticalFlipNeeded) { final Buffer textureDataBuffer = textureData.getBuffer(); final Image ardorImage = new Image(); - final TYPE bufferDataType = getBufferDataType(textureDataBuffer); + TYPE bufferDataType = getBufferDataType(textureDataBuffer); if (bufferDataType == null) { throw new UnsupportedOperationException("Unknown buffer type " + textureDataBuffer.getClass().getName()); } else { - final int dataSizeInBytes = textureDataBuffer.capacity() * Buffers.sizeOfBufferElem(textureDataBuffer); - final ByteBuffer scratch = createOnHeap ? BufferUtils.createByteBufferOnHeap(dataSizeInBytes) : Buffers + int dataSizeInBytes = textureDataBuffer.capacity() * Buffers.sizeOfBufferElem(textureDataBuffer); + ByteBuffer scratch = createOnHeap ? BufferUtils.createByteBufferOnHeap(dataSizeInBytes) : Buffers .newDirectByteBuffer(dataSizeInBytes); - if (flipped) { + if (verticalFlipNeeded) { flipImageData(textureDataBuffer, scratch, dataSizeInBytes, bufferDataType, textureData.getWidth(), textureData.getHeight()); } else { @@ -94,19 +113,45 @@ public class JoglImageLoader implements ImageLoader { ardorImage.setHeight(textureData.getHeight()); ardorImage.setData(scratch); ardorImage.setDataFormat(JoglTextureUtil.getImageDataFormat(textureData.getPixelFormat())); - // ardorImage.setDataType(JoglTextureUtil.getPixelDataType(textureData.getPixelType())); + /** + * A ByteBuffer is always used to store the image data, otherwise we should call + * JoglTextureUtil.getPixelDataType(textureData.getPixelType()) + */ ardorImage.setDataType(PixelDataType.UnsignedByte); + if (textureData.getMipmapData() != null) { + for (final Buffer mipmapData : textureData.getMipmapData()) { + dataSizeInBytes = mipmapData.capacity() * Buffers.sizeOfBufferElem(mipmapData); + scratch = createOnHeap ? BufferUtils.createByteBufferOnHeap(dataSizeInBytes) : Buffers + .newDirectByteBuffer(dataSizeInBytes); + bufferDataType = getBufferDataType(mipmapData); + if (verticalFlipNeeded) { + flipImageData(mipmapData, scratch, dataSizeInBytes, bufferDataType, textureData.getWidth(), + textureData.getHeight()); + } else { + copyImageData(mipmapData, scratch, bufferDataType); + } + ardorImage.addData(scratch); + } + final int[] mipMapSizes = new int[ardorImage.getDataSize()]; + int imageDataIndex = 0; + for (final Buffer imageData : ardorImage.getData()) { + mipMapSizes[imageDataIndex] = imageData.capacity(); + imageDataIndex++; + } + ardorImage.setMipMapByteSizes(mipMapSizes); + } return ardorImage; } } @Override - public Image load(final InputStream is, final boolean flipped) throws IOException { - final TextureData textureData = TextureIO.newTextureData(_capsUtil.getProfile(), is, true, null); + public Image load(final InputStream is, final boolean verticalFlipNeeded) throws IOException { + final TextureData textureData = TextureIO.newTextureData(_capsUtil.getProfile(), is, _mipmapsProductionEnabled, + null /* JOGL >= 2.3.2 is able to guess the file suffix */); if (textureData == null) { return null; } - return makeArdor3dImage(textureData, flipped); + return makeArdor3dImage(textureData, textureData.getMustFlipVertically() == verticalFlipNeeded); } private TYPE getBufferDataType(final Buffer buffer) { @@ -196,7 +241,7 @@ public class JoglImageLoader implements ImageLoader { final int srcFirstPixelIndex = dest.position() / bytesPerPixel; final int srcFirstPixelComponentOffset = dest.position() - (srcFirstPixelIndex * bytesPerPixel); final int srcFirstColumnIndex = srcFirstPixelIndex % width; - final int scrFirstRowIndex = (srcFirstPixelIndex - srcFirstColumnIndex) / height; + final int scrFirstRowIndex = (srcFirstPixelIndex - srcFirstColumnIndex) / width; final int dstFirstColumnIndex = srcFirstColumnIndex; final int dstFirstRowIndex = (height - 1) - scrFirstRowIndex; final int dstFirstPixelIndex = dstFirstRowIndex * width + dstFirstColumnIndex; @@ -251,4 +296,12 @@ public class JoglImageLoader implements ImageLoader { src.position(srcPos); dest.position(destPos); } + + public boolean isMipmapsProductionEnabled() { + return _mipmapsProductionEnabled; + } + + public void setMipmapsProductionEnabled(final boolean mipmapsProductionEnabled) { + _mipmapsProductionEnabled = mipmapsProductionEnabled; + } } diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/image/util/jogl/JoglImageUtil.java b/ardor3d-jogl/src/main/java/com/ardor3d/image/util/jogl/JoglImageUtil.java index 0e9a2de..f964d59 100644 --- a/ardor3d-jogl/src/main/java/com/ardor3d/image/util/jogl/JoglImageUtil.java +++ b/ardor3d-jogl/src/main/java/com/ardor3d/image/util/jogl/JoglImageUtil.java @@ -1,9 +1,9 @@ /** - * Copyright (c) 2008-2010 Ardor Labs, Inc. + * Copyright (c) 2008-2014 Ardor Labs, Inc. * * This file is part of Ardor3D. * - * Ardor3D is free software: you can redistribute it and/or modify it + * Ardor3D is free software: you can redistribute it and/or modify it * under the terms of its license which may be found in the accompanying * LICENSE file or at <http://www.ardor3d.com/LICENSE>. */ @@ -11,15 +11,14 @@ package com.ardor3d.image.util.jogl; import java.nio.ByteBuffer; +import java.util.ArrayList; import java.util.List; -import javax.media.nativewindow.util.PixelFormat; - import com.ardor3d.framework.jogl.CapsUtil; import com.ardor3d.image.Image; import com.ardor3d.scene.state.jogl.util.JoglTextureUtil; -import com.google.common.collect.Lists; import com.jogamp.common.nio.Buffers; +import com.jogamp.nativewindow.util.PixelFormat; import com.jogamp.opengl.util.GLPixelBuffer.GLPixelAttributes; import com.jogamp.opengl.util.texture.TextureData; @@ -31,7 +30,7 @@ public class JoglImageUtil { /** * Convert the given Ardor3D Image to a List of TextureData instances. It is a List because Ardor3D Images may * contain multiple layers (for example, in the case of cube maps or 3D textures). - * + * * @param input * the Ardor3D Image to convert * @return the TextureData instance(s) created in the conversion @@ -43,7 +42,7 @@ public class JoglImageUtil { /** * Convert the given Ardor3D Image to a List of TextureData instances. It is a List because Ardor3D Images may * contain multiple layers (for example, in the case of cube maps or 3D textures). - * + * * @param capsUtil * @param input * the Ardor3D Image to convert @@ -57,7 +56,7 @@ public class JoglImageUtil { final int width = input.getWidth(), height = input.getHeight(); // create our return list - final List<TextureData> rVal = Lists.newArrayList(); + final List<TextureData> rVal = new ArrayList<>(); // go through each layer for (int i = 0; i < size; i++) { @@ -88,7 +87,7 @@ public class JoglImageUtil { default: pixelFormat = null; } - final GLPixelAttributes pixelAtt = GLPixelAttributes.convert(pixelFormat, capsUtil.getProfile()); + final GLPixelAttributes pixelAtt = GLPixelAttributes.convert(capsUtil.getProfile(), pixelFormat, false); // pixel data type = internal format? final TextureData image = new TextureData(capsUtil.getProfile(), pixDataType, width, height, border, pixelAtt, false, false, false, dest, null); diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/image/util/jogl/JoglTgaImageLoader.java b/ardor3d-jogl/src/main/java/com/ardor3d/image/util/jogl/JoglTgaImageLoader.java new file mode 100644 index 0000000..84ae044 --- /dev/null +++ b/ardor3d-jogl/src/main/java/com/ardor3d/image/util/jogl/JoglTgaImageLoader.java @@ -0,0 +1,50 @@ +/** + * Copyright (c) 2008-2014 Ardor Labs, Inc. + * + * This file is part of Ardor3D. + * + * Ardor3D is free software: you can redistribute it and/or modify it + * under the terms of its license which may be found in the accompanying + * LICENSE file or at <http://www.ardor3d.com/LICENSE>. + */ + +package com.ardor3d.image.util.jogl; + +import java.io.IOException; +import java.io.InputStream; + +import com.ardor3d.image.Image; +import com.ardor3d.image.util.ImageLoaderUtil; +import com.jogamp.opengl.util.texture.TextureData; +import com.jogamp.opengl.util.texture.TextureIO; + +/** + * Ardor3D loader using the build-in JOGL TGA loader. As this format has no magic number, it cannot use the detection + * mechanism implemented in JoglImageLoader + */ +public class JoglTgaImageLoader extends JoglImageLoader { + + private static final String[] _supportedFormats = new String[] { "." + TextureIO.TGA.toUpperCase() }; + + @Override + public Image load(final InputStream is, final boolean verticalFlipNeeded) throws IOException { + final TextureData textureData = TextureIO.newTextureData(_capsUtil.getProfile(), is, + isMipmapsProductionEnabled(), TextureIO.TGA); + if (textureData == null) { + return null; + } + return makeArdor3dImage(textureData, textureData.getMustFlipVertically() == verticalFlipNeeded); + } + + public static String[] getSupportedFormats() { + return _supportedFormats; + } + + public static void registerLoader() { + registerLoader(new JoglTgaImageLoader(), _supportedFormats); + } + + public static void registerLoader(final JoglTgaImageLoader joglTgaImageLoader, final String[] supportedFormats) { + ImageLoaderUtil.registerHandler(joglTgaImageLoader, supportedFormats); + } +} diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/input/jogl/JoglNewtFocusWrapper.java b/ardor3d-jogl/src/main/java/com/ardor3d/input/jogl/JoglNewtFocusWrapper.java index 5068e6c..b7845e7 100644 --- a/ardor3d-jogl/src/main/java/com/ardor3d/input/jogl/JoglNewtFocusWrapper.java +++ b/ardor3d-jogl/src/main/java/com/ardor3d/input/jogl/JoglNewtFocusWrapper.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2008-2012 Ardor Labs, Inc. + * Copyright (c) 2008-2014 Ardor Labs, Inc. * * This file is part of Ardor3D. * diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/input/jogl/JoglNewtKey.java b/ardor3d-jogl/src/main/java/com/ardor3d/input/jogl/JoglNewtKey.java index 45babf1..73a65dc 100644 --- a/ardor3d-jogl/src/main/java/com/ardor3d/input/jogl/JoglNewtKey.java +++ b/ardor3d-jogl/src/main/java/com/ardor3d/input/jogl/JoglNewtKey.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2008-2012 Ardor Labs, Inc. + * Copyright (c) 2008-2014 Ardor Labs, Inc. * * This file is part of Ardor3D. * diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/input/jogl/JoglNewtKeyboardWrapper.java b/ardor3d-jogl/src/main/java/com/ardor3d/input/jogl/JoglNewtKeyboardWrapper.java index bce6810..119820d 100644 --- a/ardor3d-jogl/src/main/java/com/ardor3d/input/jogl/JoglNewtKeyboardWrapper.java +++ b/ardor3d-jogl/src/main/java/com/ardor3d/input/jogl/JoglNewtKeyboardWrapper.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2008-2012 Ardor Labs, Inc. + * Copyright (c) 2008-2014 Ardor Labs, Inc. * * This file is part of Ardor3D. * @@ -31,7 +31,7 @@ import com.jogamp.newt.opengl.GLWindow; public class JoglNewtKeyboardWrapper extends KeyAdapter implements KeyboardWrapper { @GuardedBy("this") - protected final LinkedList<KeyEvent> _upcomingEvents = new LinkedList<KeyEvent>(); + protected final LinkedList<KeyEvent> _upcomingEvents = new LinkedList<>(); @GuardedBy("this") protected JoglNewtKeyboardIterator _currentIterator = null; diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/input/jogl/JoglNewtMouseManager.java b/ardor3d-jogl/src/main/java/com/ardor3d/input/jogl/JoglNewtMouseManager.java index 10ca249..72c31d5 100644 --- a/ardor3d-jogl/src/main/java/com/ardor3d/input/jogl/JoglNewtMouseManager.java +++ b/ardor3d-jogl/src/main/java/com/ardor3d/input/jogl/JoglNewtMouseManager.java @@ -1,9 +1,9 @@ /** - * Copyright (c) 2008-2012 Ardor Labs, Inc. + * Copyright (c) 2008-2014 Ardor Labs, Inc. * * This file is part of Ardor3D. * - * Ardor3D is free software: you can redistribute it and/or modify it + * Ardor3D is free software: you can redistribute it and/or modify it * under the terms of its license which may be found in the accompanying * LICENSE file or at <http://www.ardor3d.com/LICENSE>. */ @@ -12,16 +12,15 @@ package com.ardor3d.input.jogl; import java.nio.ByteBuffer; -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 com.ardor3d.framework.jogl.NewtWindowContainer; import com.ardor3d.image.Image; import com.ardor3d.input.GrabbedState; import com.ardor3d.input.MouseCursor; import com.ardor3d.input.MouseManager; +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.newt.Display.PointerIcon; import com.jogamp.newt.opengl.GLWindow; @@ -51,8 +50,8 @@ public class JoglNewtMouseManager implements MouseManager { PixelFormat pixFormat = null; for (final PixelFormat pf : PixelFormat.values()) { - if (pf.componentCount == image.getDataFormat().getComponents() - && pf.bytesPerPixel() == image.getDataType().getBytesPerPixel(pf.componentCount)) { + if (pf.comp.componentCount() == image.getDataFormat().getComponents() + && pf.comp.bytesPerPixel() == image.getDataType().getBytesPerPixel(pf.comp.componentCount())) { pixFormat = pf; break; } diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/input/jogl/JoglNewtMouseWrapper.java b/ardor3d-jogl/src/main/java/com/ardor3d/input/jogl/JoglNewtMouseWrapper.java index a82bb1a..426d9b4 100644 --- a/ardor3d-jogl/src/main/java/com/ardor3d/input/jogl/JoglNewtMouseWrapper.java +++ b/ardor3d-jogl/src/main/java/com/ardor3d/input/jogl/JoglNewtMouseWrapper.java @@ -1,9 +1,9 @@ /** - * Copyright (c) 2008-2012 Ardor Labs, Inc. + * Copyright (c) 2008-2014 Ardor Labs, Inc. * * This file is part of Ardor3D. * - * Ardor3D is free software: you can redistribute it and/or modify it + * Ardor3D is free software: you can redistribute it and/or modify it * under the terms of its license which may be found in the accompanying * LICENSE file or at <http://www.ardor3d.com/LICENSE>. */ @@ -26,8 +26,6 @@ import com.ardor3d.input.MouseState; import com.ardor3d.input.MouseWrapper; import com.google.common.collect.AbstractIterator; import com.google.common.collect.EnumMultiset; -import com.google.common.collect.Lists; -import com.google.common.collect.Maps; import com.google.common.collect.Multiset; import com.google.common.collect.PeekingIterator; import com.jogamp.newt.event.MouseEvent; @@ -38,7 +36,7 @@ import com.jogamp.newt.opengl.GLWindow; public class JoglNewtMouseWrapper implements MouseWrapper, MouseListener { @GuardedBy("this") - protected final LinkedList<MouseState> _upcomingEvents = Lists.newLinkedList(); + protected final LinkedList<MouseState> _upcomingEvents = new LinkedList<>(); @GuardedBy("this") protected JoglNewtMouseIterator _currentIterator = null; @@ -55,7 +53,7 @@ public class JoglNewtMouseWrapper implements MouseWrapper, MouseListener { protected boolean _skipAutoRepeatEvents = false; protected final Multiset<MouseButton> _clicks = EnumMultiset.create(MouseButton.class); - protected final EnumMap<MouseButton, Long> _lastClickTime = Maps.newEnumMap(MouseButton.class); + protected final EnumMap<MouseButton, Long> _lastClickTime = new EnumMap<>(MouseButton.class); protected final EnumSet<MouseButton> _clickArmed = EnumSet.noneOf(MouseButton.class); protected int _ignoreX = Integer.MAX_VALUE; @@ -226,8 +224,9 @@ public class JoglNewtMouseWrapper implements MouseWrapper, MouseListener { private void addNewState(final MouseEvent mouseEvent, final EnumMap<MouseButton, ButtonState> enumMap, final Multiset<MouseButton> clicks) { final MouseState newState = new MouseState(mouseEvent.getX(), getArdor3DY(mouseEvent), getDX(mouseEvent), - getDY(mouseEvent), (int) (mouseEvent.isShiftDown() ? mouseEvent.getRotation()[0] - : mouseEvent.getRotation()[1]), enumMap, clicks); + getDY(mouseEvent), + (int) (mouseEvent.isShiftDown() ? mouseEvent.getRotation()[0] : mouseEvent.getRotation()[1]), enumMap, + clicks); synchronized (JoglNewtMouseWrapper.this) { _upcomingEvents.add(newState); @@ -244,7 +243,7 @@ public class JoglNewtMouseWrapper implements MouseWrapper, MouseListener { } /** - * @param e + * @param me * our mouseEvent * @return the Y coordinate of the event, flipped relative to the component since we expect an origin in the lower * left corner. diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/renderer/jogl/JoglContextCapabilities.java b/ardor3d-jogl/src/main/java/com/ardor3d/renderer/jogl/JoglContextCapabilities.java index 5ee1cb8..2459c9b 100644 --- a/ardor3d-jogl/src/main/java/com/ardor3d/renderer/jogl/JoglContextCapabilities.java +++ b/ardor3d-jogl/src/main/java/com/ardor3d/renderer/jogl/JoglContextCapabilities.java @@ -1,9 +1,9 @@ /** - * Copyright (c) 2008-2010 Ardor Labs, Inc. + * Copyright (c) 2008-2014 Ardor Labs, Inc. * * This file is part of Ardor3D. * - * Ardor3D is free software: you can redistribute it and/or modify it + * Ardor3D is free software: you can redistribute it and/or modify it * under the terms of its license which may be found in the accompanying * LICENSE file or at <http://www.ardor3d.com/LICENSE>. */ @@ -13,15 +13,14 @@ package com.ardor3d.renderer.jogl; import java.nio.FloatBuffer; import java.nio.IntBuffer; -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.GLAutoDrawable; - import com.ardor3d.renderer.ContextCapabilities; import com.ardor3d.util.geom.jogl.DirectNioBuffersSet; +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.GLAutoDrawable; public class JoglContextCapabilities extends ContextCapabilities { @@ -67,8 +66,10 @@ public class JoglContextCapabilities extends ContextCapabilities { _maxTextureLodBias = 0f; } - gl.glGetIntegerv(GL2ES1.GL_MAX_CLIP_PLANES, buf); - _maxUserClipPlanes = buf.get(0); + if (gl.isGL2ES1()) { + gl.glGetIntegerv(GL2ES1.GL_MAX_CLIP_PLANES, buf); + _maxUserClipPlanes = buf.get(0); + } _glslSupported = gl.isExtensionAvailable("GL_ARB_shader_objects") && gl.isExtensionAvailable("GL_ARB_fragment_shader") && gl.isExtensionAvailable("GL_ARB_vertex_shader") @@ -81,9 +82,15 @@ public class JoglContextCapabilities extends ContextCapabilities { _tessellationShadersSupported = gl.isExtensionAvailable("GL_ARB_tessellation_shader") && _glslSupported; + _computeShaderSupported = gl.isExtensionAvailable("GL_ARB_compute_shader") && _glslSupported; + if (_glslSupported) { - gl.glGetIntegerv(GL2.GL_MAX_VERTEX_ATTRIBS_ARB, buf); - _maxGLSLVertexAttribs = buf.get(0); + if (gl.isGL2()) { + gl.glGetIntegerv(GL2.GL_MAX_VERTEX_ATTRIBS_ARB, buf); + _maxGLSLVertexAttribs = buf.get(0); + } else { + // FIXME use a reasonable value + } } // Pbuffer @@ -96,7 +103,7 @@ public class JoglContextCapabilities extends ContextCapabilities { _supportsFBOMultisample = gl.isExtensionAvailable("GL_EXT_framebuffer_multisample"); _supportsFBOBlit = gl.isExtensionAvailable("GL_EXT_framebuffer_blit"); - if (gl.isExtensionAvailable("GL_ARB_draw_buffers")) { + if (gl.isExtensionAvailable("GL_ARB_draw_buffers") && gl.isGL2ES2()) { gl.glGetIntegerv(GL2ES2.GL_MAX_COLOR_ATTACHMENTS, buf); _maxFBOColorAttachments = buf.get(0); } else { @@ -105,8 +112,8 @@ public class JoglContextCapabilities extends ContextCapabilities { // Max multisample samples. if (gl.isExtensionAvailable("GL_EXT_framebuffer_multisample") - && gl.isExtensionAvailable("GL_EXT_framebuffer_blit")) { - gl.glGetIntegerv(GL2ES3.GL_MAX_SAMPLES, buf); + && gl.isExtensionAvailable("GL_EXT_framebuffer_blit") && gl.isGL2ES3()) { + gl.glGetIntegerv(GL.GL_MAX_SAMPLES, buf); _maxFBOSamples = buf.get(0); } else { _maxFBOSamples = 0; @@ -119,8 +126,10 @@ public class JoglContextCapabilities extends ContextCapabilities { _stencilWrapSupport = gl.isExtensionAvailable("GL_EXT_stencil_wrap"); // number of available auxiliary draw buffers - gl.glGetIntegerv(GL2.GL_AUX_BUFFERS, buf); - _numAuxDrawBuffers = buf.get(0); + if (gl.isGL2()) { + gl.glGetIntegerv(GL2.GL_AUX_BUFFERS, buf); + _numAuxDrawBuffers = buf.get(0); + } // max texture size. gl.glGetIntegerv(GL.GL_MAX_TEXTURE_SIZE, buf); @@ -148,9 +157,10 @@ public class JoglContextCapabilities extends ContextCapabilities { // If we do support multitexturing, find out how many textures we // can handle. - if (_supportsMultiTexture) { + if (_supportsMultiTexture && gl.isGL2ES1()) { gl.glGetIntegerv(GL2ES1.GL_MAX_TEXTURE_UNITS, buf); _numFixedTexUnits = buf.get(0); + // FIXME use a reasonable value when ES2 & 3 are detected } else { _numFixedTexUnits = 1; } @@ -241,14 +251,18 @@ public class JoglContextCapabilities extends ContextCapabilities { _displayVersion = "Unable to retrieve API version."; } - if (_glslSupported) { - try { - _shadingLanguageVersion = gl.glGetString(GL2ES2.GL_SHADING_LANGUAGE_VERSION); - } catch (final Exception e) { - _shadingLanguageVersion = "Unable to retrieve shading language version."; - } - } else { + if (gl.isGLES1()) { _shadingLanguageVersion = "Not supported."; + } else { + if (_glslSupported) { + try { + _shadingLanguageVersion = gl.glGetString(GL2ES2.GL_SHADING_LANGUAGE_VERSION); + } catch (final Exception e) { + _shadingLanguageVersion = "Unable to retrieve shading language version."; + } + } else { + _shadingLanguageVersion = "Not supported."; + } } } } diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/renderer/jogl/JoglPbufferTextureRenderer.java b/ardor3d-jogl/src/main/java/com/ardor3d/renderer/jogl/JoglPbufferTextureRenderer.java index 1a74c24..0bd3f1b 100644 --- a/ardor3d-jogl/src/main/java/com/ardor3d/renderer/jogl/JoglPbufferTextureRenderer.java +++ b/ardor3d-jogl/src/main/java/com/ardor3d/renderer/jogl/JoglPbufferTextureRenderer.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2008-2010 Ardor Labs, Inc. + * Copyright (c) 2008-2014 Ardor Labs, Inc. * * This file is part of Ardor3D. * @@ -15,12 +15,12 @@ import java.util.List; 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; import com.ardor3d.framework.DisplaySettings; import com.ardor3d.framework.Scene; @@ -299,6 +299,8 @@ public class JoglPbufferTextureRenderer extends AbstractPbufferTextureRenderer { caps.setOnscreen(false); caps.setPBuffer(true); _offscreenDrawable = fac.createOffscreenAutoDrawable(null, caps, null, _width, _height); + // FIXME is this hack still useful? + _offscreenDrawable.setSharedContext(_parentContext); _context = _offscreenDrawable.getContext(); _context.makeCurrent(); @@ -331,8 +333,8 @@ public class JoglPbufferTextureRenderer extends AbstractPbufferTextureRenderer { try { activate(); - _width = _offscreenDrawable.getWidth(); - _height = _offscreenDrawable.getHeight(); + _width = _offscreenDrawable.getSurfaceWidth(); + _height = _offscreenDrawable.getSurfaceHeight(); deactivate(); } catch (final Exception e) { diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/renderer/jogl/JoglRenderContext.java b/ardor3d-jogl/src/main/java/com/ardor3d/renderer/jogl/JoglRenderContext.java index 6dbd1d6..b361021 100644 --- a/ardor3d-jogl/src/main/java/com/ardor3d/renderer/jogl/JoglRenderContext.java +++ b/ardor3d-jogl/src/main/java/com/ardor3d/renderer/jogl/JoglRenderContext.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2008-2010 Ardor Labs, Inc. + * Copyright (c) 2008-2014 Ardor Labs, Inc. * * This file is part of Ardor3D. * diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/renderer/jogl/JoglRenderer.java b/ardor3d-jogl/src/main/java/com/ardor3d/renderer/jogl/JoglRenderer.java index 1e15e65..70dfe2d 100644 --- a/ardor3d-jogl/src/main/java/com/ardor3d/renderer/jogl/JoglRenderer.java +++ b/ardor3d-jogl/src/main/java/com/ardor3d/renderer/jogl/JoglRenderer.java @@ -1,9 +1,9 @@ /** - * Copyright (c) 2008-2010 Ardor Labs, Inc. + * Copyright (c) 2008-2014 Ardor Labs, Inc. * * This file is part of Ardor3D. * - * Ardor3D is free software: you can redistribute it and/or modify it + * Ardor3D is free software: you can redistribute it and/or modify it * under the terms of its license which may be found in the accompanying * LICENSE file or at <http://www.ardor3d.com/LICENSE>. */ @@ -19,19 +19,6 @@ import java.util.Collection; import java.util.List; import java.util.logging.Logger; -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.GLContext; -import javax.media.opengl.GLException; -import javax.media.opengl.fixedfunc.GLLightingFunc; -import javax.media.opengl.fixedfunc.GLMatrixFunc; -import javax.media.opengl.fixedfunc.GLPointerFunc; -import javax.media.opengl.glu.GLU; - import com.ardor3d.image.ImageDataFormat; import com.ardor3d.image.PixelDataType; import com.ardor3d.image.Texture; @@ -105,11 +92,23 @@ import com.ardor3d.util.Constants; import com.ardor3d.util.geom.BufferUtils; import com.ardor3d.util.stat.StatCollector; import com.ardor3d.util.stat.StatType; +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.GLContext; +import com.jogamp.opengl.GLException; +import com.jogamp.opengl.fixedfunc.GLLightingFunc; +import com.jogamp.opengl.fixedfunc.GLMatrixFunc; +import com.jogamp.opengl.fixedfunc.GLPointerFunc; +import com.jogamp.opengl.glu.GLU; import com.jogamp.opengl.util.GLBuffers; /** * <code>JoglRenderer</code> provides an implementation of the <code>Renderer</code> interface using the JOGL API. - * + * * @see com.ardor3d.renderer.Renderer */ public class JoglRenderer extends AbstractRenderer { @@ -117,11 +116,13 @@ public class JoglRenderer extends AbstractRenderer { private FloatBuffer _transformBuffer; private final Matrix4 _transformMatrix = new Matrix4(); + private final GLU _glu = new GLU();// only used to get error strings /** * Constructor instantiates a new <code>JoglRenderer</code> object. */ public JoglRenderer() { + super(); logger.fine("JoglRenderer created."); } @@ -223,11 +224,8 @@ public class JoglRenderer extends AbstractRenderer { @Override public void flushFrame(final boolean doSwap) { - final GL gl = GLContext.getCurrentGL(); - renderBuckets(); - gl.glFlush(); if (doSwap) { doApplyState(defaultStateList.get(RenderState.StateType.ColorMask)); @@ -241,6 +239,11 @@ public class JoglRenderer extends AbstractRenderer { if (Constants.stats) { StatCollector.endStat(StatType.STAT_DISPLAYSWAP_TIMER); } + } else { + // this call is not necessary just before swapBuffers(), see: + // http://www.opengl.org/wiki/Common_Mistakes#glFinish_and_glFlush + final GL gl = GLContext.getCurrentGL(); + gl.glFlush(); } if (Constants.stats) { @@ -454,7 +457,7 @@ public class JoglRenderer extends AbstractRenderer { if (!vboIdsBuffer.hasRemaining()) { vboIdsBuffer.flip(); if (vboIdsBuffer.remaining() > 0) { - gl.glDeleteTextures(vboIdsBuffer.remaining(), vboIdsBuffer); + gl.glDeleteBuffers(vboIdsBuffer.remaining(), vboIdsBuffer); } vboIdsBuffer.clear(); } @@ -464,7 +467,7 @@ public class JoglRenderer extends AbstractRenderer { } vboIdsBuffer.flip(); if (vboIdsBuffer.remaining() > 0) { - gl.glDeleteTextures(vboIdsBuffer.remaining(), vboIdsBuffer); + gl.glDeleteBuffers(vboIdsBuffer.remaining(), vboIdsBuffer); } vboIdsBuffer.clear(); } @@ -626,12 +629,16 @@ public class JoglRenderer extends AbstractRenderer { GL.GL_UNSIGNED_BYTE, source); break; case OneDimensional: - gl.getGL2GL3().glTexSubImage1D(GL2GL3.GL_TEXTURE_1D, 0, dstOffsetX, dstWidth, pixelFormat, - GL.GL_UNSIGNED_BYTE, source); + if (gl.isGL2GL3()) { + gl.getGL2GL3().glTexSubImage1D(GL2GL3.GL_TEXTURE_1D, 0, dstOffsetX, dstWidth, pixelFormat, + GL.GL_UNSIGNED_BYTE, source); + } break; case ThreeDimensional: - gl.getGL2ES2().glTexSubImage3D(GL2ES2.GL_TEXTURE_3D, 0, dstOffsetX, dstOffsetY, dstOffsetZ, - dstWidth, dstHeight, dstDepth, pixelFormat, GL.GL_UNSIGNED_BYTE, source); + if (gl.isGL2ES2()) { + gl.getGL2ES2().glTexSubImage3D(GL2ES2.GL_TEXTURE_3D, 0, dstOffsetX, dstOffsetY, dstOffsetZ, + dstWidth, dstHeight, dstDepth, pixelFormat, GL.GL_UNSIGNED_BYTE, source); + } break; case CubeMap: gl.glTexSubImage2D(JoglTextureStateUtil.getGLCubeMapFace(dstFace), 0, dstOffsetX, dstOffsetY, @@ -672,12 +679,11 @@ public class JoglRenderer extends AbstractRenderer { @Override public void checkCardError() throws Ardor3dException { final GL gl = GLContext.getCurrentGL(); - final GLU glu = new GLU(); try { final int errorCode = gl.glGetError(); if (errorCode != GL.GL_NO_ERROR) { - throw new GLException(glu.gluErrorString(errorCode)); + throw new GLException(_glu.gluErrorString(errorCode)); } } catch (final GLException exception) { throw new Ardor3dException("Error in opengl: " + exception.getMessage(), exception); @@ -741,8 +747,10 @@ public class JoglRenderer extends AbstractRenderer { gl.getGL2GL3().glEnableClientState(GLPointerFunc.GL_VERTEX_ARRAY); } vertexBuffer.rewind(); - if (gl.isGL2ES1() && vertexBufferData != null) { - gl.getGL2ES1().glVertexPointer(vertexBufferData.getValuesPerTuple(), GL.GL_FLOAT, 0, vertexBuffer); + if (vertexBufferData != null) { + if (gl.isGL2ES1()) { + gl.getGL2ES1().glVertexPointer(vertexBufferData.getValuesPerTuple(), GL.GL_FLOAT, 0, vertexBuffer); + } } } } @@ -783,8 +791,10 @@ public class JoglRenderer extends AbstractRenderer { gl.getGL2GL3().glEnableClientState(GLPointerFunc.GL_COLOR_ARRAY); } colorBuffer.rewind(); - if (gl.isGL2ES1() && colorBufferData != null) { - gl.getGL2ES1().glColorPointer(colorBufferData.getValuesPerTuple(), GL.GL_FLOAT, 0, colorBuffer); + if (colorBufferData != null) { + if (gl.isGL2ES1()) { + gl.getGL2ES1().glColorPointer(colorBufferData.getValuesPerTuple(), GL.GL_FLOAT, 0, colorBuffer); + } } } } @@ -1084,6 +1094,10 @@ public class JoglRenderer extends AbstractRenderer { JoglRendererUtil.setBoundVBO(rendRecord, vboID); if (gl.isGL2ES1()) { gl.getGL2ES1().glColorPointer(data.getValuesPerTuple(), GL.GL_FLOAT, 0, 0); + } else { + if (gl.isGL2ES2()) { + // TODO use VAO + } } } else { if (gl.isGL2GL3()) { @@ -1738,18 +1752,24 @@ public class JoglRenderer extends AbstractRenderer { if (stipplePattern != (short) 0xFFFF) { if (!lineRecord.isValid() || !lineRecord.stippled) { - gl.glEnable(GL2.GL_LINE_STIPPLE); + if (gl.isGL2()) { + gl.glEnable(GL2.GL_LINE_STIPPLE); + } lineRecord.stippled = true; } if (!lineRecord.isValid() || stippleFactor != lineRecord.stippleFactor || stipplePattern != lineRecord.stipplePattern) { - gl.getGL2().glLineStipple(stippleFactor, stipplePattern); + if (gl.isGL2()) { + gl.getGL2().glLineStipple(stippleFactor, stipplePattern); + } lineRecord.stippleFactor = stippleFactor; lineRecord.stipplePattern = stipplePattern; } } else if (!lineRecord.isValid() || lineRecord.stippled) { - gl.glDisable(GL2.GL_LINE_STIPPLE); + if (gl.isGL2()) { + gl.glDisable(GL2.GL_LINE_STIPPLE); + } lineRecord.stippled = false; } @@ -1879,7 +1899,7 @@ public class JoglRenderer extends AbstractRenderer { /** * Start a new display list. All further renderer commands that can be stored in a display list are part of this new * list until {@link #endDisplayList()} is called. - * + * * @return id of new display list */ @Override diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/renderer/jogl/JoglTextureRenderer.java b/ardor3d-jogl/src/main/java/com/ardor3d/renderer/jogl/JoglTextureRenderer.java index 4b24580..6a18ddb 100644 --- a/ardor3d-jogl/src/main/java/com/ardor3d/renderer/jogl/JoglTextureRenderer.java +++ b/ardor3d-jogl/src/main/java/com/ardor3d/renderer/jogl/JoglTextureRenderer.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2008-2010 Ardor Labs, Inc. + * Copyright (c) 2008-2014 Ardor Labs, Inc. * * This file is part of Ardor3D. * @@ -15,11 +15,11 @@ import java.util.LinkedList; import java.util.List; import java.util.logging.Logger; -import javax.media.opengl.GL; -import javax.media.opengl.GL2ES2; -import javax.media.opengl.GL2ES3; -import javax.media.opengl.GL2GL3; -import javax.media.opengl.GLContext; +import com.jogamp.opengl.GL; +import com.jogamp.opengl.GL2ES2; +import com.jogamp.opengl.GL2ES3; +import com.jogamp.opengl.GL2GL3; +import com.jogamp.opengl.GLContext; import com.ardor3d.framework.Scene; import com.ardor3d.image.Texture; @@ -106,7 +106,10 @@ public class JoglTextureRenderer extends AbstractFBOTextureRenderer { // Initialize mipmapping for this texture, if requested if (tex.getMinificationFilter().usesMipMapLevels()) { - gl.glGenerateMipmap(JoglTextureStateUtil.getGLType(tex.getType())); + final int glType = JoglTextureStateUtil.getGLType(tex.getType()); + if (glType != GL.GL_INVALID_ENUM) { + gl.glGenerateMipmap(glType); + } } // Setup filtering and wrap @@ -176,8 +179,8 @@ public class JoglTextureRenderer extends AbstractFBOTextureRenderer { // Otherwise, we can streamline this by rendering to multiple textures at once. // first determine how many groups we need - final LinkedList<Texture> depths = new LinkedList<Texture>(); - final LinkedList<Texture> colors = new LinkedList<Texture>(); + final LinkedList<Texture> depths = new LinkedList<>(); + final LinkedList<Texture> colors = new LinkedList<>(); for (int i = 0; i < texs.size(); i++) { final Texture tex = texs.get(i); if (tex.getTextureStoreFormat().isDepthFormat()) { @@ -252,7 +255,10 @@ public class JoglTextureRenderer extends AbstractFBOTextureRenderer { final Texture tex = texs.get(x); if (tex.getMinificationFilter().usesMipMapLevels()) { JoglTextureStateUtil.doTextureBind(tex, 0, true); - gl.glGenerateMipmap(JoglTextureStateUtil.getGLType(tex.getType())); + final int glType = JoglTextureStateUtil.getGLType(tex.getType()); + if (glType != GL.GL_INVALID_ENUM) { + gl.glGenerateMipmap(glType); + } } } } finally { @@ -351,7 +357,10 @@ public class JoglTextureRenderer extends AbstractFBOTextureRenderer { // automatically generate mipmaps for our texture. if (tex.getMinificationFilter().usesMipMapLevels()) { JoglTextureStateUtil.doTextureBind(tex, 0, true); - gl.glGenerateMipmap(JoglTextureStateUtil.getGLType(tex.getType())); + final int glType = JoglTextureStateUtil.getGLType(tex.getType()); + if (glType != GL.GL_INVALID_ENUM) { + gl.glGenerateMipmap(JoglTextureStateUtil.getGLType(tex.getType())); + } } } diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/renderer/jogl/JoglTextureRendererProvider.java b/ardor3d-jogl/src/main/java/com/ardor3d/renderer/jogl/JoglTextureRendererProvider.java index 57117f8..858b1ae 100644 --- a/ardor3d-jogl/src/main/java/com/ardor3d/renderer/jogl/JoglTextureRendererProvider.java +++ b/ardor3d-jogl/src/main/java/com/ardor3d/renderer/jogl/JoglTextureRendererProvider.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2008-2010 Ardor Labs, Inc. + * Copyright (c) 2008-2014 Ardor Labs, Inc. * * This file is part of Ardor3D. * diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/renderer/jogl/state/record/JoglMatrixBackend.java b/ardor3d-jogl/src/main/java/com/ardor3d/renderer/jogl/state/record/JoglMatrixBackend.java index e70bd71..fe76591 100644 --- a/ardor3d-jogl/src/main/java/com/ardor3d/renderer/jogl/state/record/JoglMatrixBackend.java +++ b/ardor3d-jogl/src/main/java/com/ardor3d/renderer/jogl/state/record/JoglMatrixBackend.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2008-2010 Ardor Labs, Inc. + * Copyright (c) 2008-2014 Ardor Labs, Inc. * * This file is part of Ardor3D. * diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/renderer/jogl/state/record/JoglRealMatrixBackend.java b/ardor3d-jogl/src/main/java/com/ardor3d/renderer/jogl/state/record/JoglRealMatrixBackend.java index 386f7fc..49e99ce 100644 --- a/ardor3d-jogl/src/main/java/com/ardor3d/renderer/jogl/state/record/JoglRealMatrixBackend.java +++ b/ardor3d-jogl/src/main/java/com/ardor3d/renderer/jogl/state/record/JoglRealMatrixBackend.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2008-2010 Ardor Labs, Inc. + * Copyright (c) 2008-2014 Ardor Labs, Inc. * * This file is part of Ardor3D. * @@ -12,8 +12,8 @@ package com.ardor3d.renderer.jogl.state.record; import java.nio.FloatBuffer; -import javax.media.opengl.GL2ES1; -import javax.media.opengl.GLContext; +import com.jogamp.opengl.GL2ES1; +import com.jogamp.opengl.GLContext; public class JoglRealMatrixBackend implements JoglMatrixBackend { diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/renderer/jogl/state/record/JoglRendererRecord.java b/ardor3d-jogl/src/main/java/com/ardor3d/renderer/jogl/state/record/JoglRendererRecord.java index 56a151c..4d5d61f 100644 --- a/ardor3d-jogl/src/main/java/com/ardor3d/renderer/jogl/state/record/JoglRendererRecord.java +++ b/ardor3d-jogl/src/main/java/com/ardor3d/renderer/jogl/state/record/JoglRendererRecord.java @@ -1,19 +1,20 @@ /** - * Copyright (c) 2008-2010 Ardor Labs, Inc. + * Copyright (c) 2008-2014 Ardor Labs, Inc. * * This file is part of Ardor3D. * - * Ardor3D is free software: you can redistribute it and/or modify it + * Ardor3D is free software: you can redistribute it and/or modify it * under the terms of its license which may be found in the accompanying * LICENSE file or at <http://www.ardor3d.com/LICENSE>. */ package com.ardor3d.renderer.jogl.state.record; -import javax.media.opengl.GL; -import javax.media.opengl.GLContext; - import com.ardor3d.renderer.state.record.RendererRecord; +import com.jogamp.opengl.GL; +import com.jogamp.opengl.GLContext; +import com.jogamp.opengl.util.glsl.fixedfunc.FixedFuncUtil; +import com.jogamp.opengl.util.glsl.fixedfunc.ShaderSelectionMode; public class JoglRendererRecord extends RendererRecord { @@ -25,6 +26,8 @@ public class JoglRendererRecord extends RendererRecord { _matrixBackend = new JoglRealMatrixBackend(); } else { _matrixBackend = new JoglSimulatedMatrixBackend(); + FixedFuncUtil.wrapFixedFuncEmul(gl, ShaderSelectionMode.AUTO, + ((JoglSimulatedMatrixBackend) _matrixBackend)._matrix); } } diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/renderer/jogl/state/record/JoglSimulatedMatrixBackend.java b/ardor3d-jogl/src/main/java/com/ardor3d/renderer/jogl/state/record/JoglSimulatedMatrixBackend.java index 441f786..3617ae5 100644 --- a/ardor3d-jogl/src/main/java/com/ardor3d/renderer/jogl/state/record/JoglSimulatedMatrixBackend.java +++ b/ardor3d-jogl/src/main/java/com/ardor3d/renderer/jogl/state/record/JoglSimulatedMatrixBackend.java @@ -1,9 +1,9 @@ /** - * Copyright (c) 2008-2010 Ardor Labs, Inc. + * Copyright (c) 2008-2014 Ardor Labs, Inc. * * This file is part of Ardor3D. * - * Ardor3D is free software: you can redistribute it and/or modify it + * Ardor3D is free software: you can redistribute it and/or modify it * under the terms of its license which may be found in the accompanying * LICENSE file or at <http://www.ardor3d.com/LICENSE>. */ @@ -16,7 +16,7 @@ import com.jogamp.opengl.util.PMVMatrix; public class JoglSimulatedMatrixBackend implements JoglMatrixBackend { - private final PMVMatrix _matrix; + final PMVMatrix _matrix; public JoglSimulatedMatrixBackend() { super(); diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglBlendStateUtil.java b/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglBlendStateUtil.java index 4d7f834..097ffd5 100644 --- a/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglBlendStateUtil.java +++ b/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglBlendStateUtil.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2008-2010 Ardor Labs, Inc. + * Copyright (c) 2008-2014 Ardor Labs, Inc. * * This file is part of Ardor3D. * @@ -10,11 +10,11 @@ package com.ardor3d.scene.state.jogl; -import javax.media.opengl.GL; -import javax.media.opengl.GL2ES1; -import javax.media.opengl.GL2ES2; -import javax.media.opengl.GL2GL3; -import javax.media.opengl.GLContext; +import com.jogamp.opengl.GL; +import com.jogamp.opengl.GL2ES1; +import com.jogamp.opengl.GL2ES2; +import com.jogamp.opengl.GL2GL3; +import com.jogamp.opengl.GLContext; import com.ardor3d.math.type.ReadOnlyColorRGBA; import com.ardor3d.renderer.ContextCapabilities; diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglClipStateUtil.java b/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglClipStateUtil.java index dfd3c9c..56a5d34 100644 --- a/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglClipStateUtil.java +++ b/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglClipStateUtil.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2008-2010 Ardor Labs, Inc. + * Copyright (c) 2008-2014 Ardor Labs, Inc. * * This file is part of Ardor3D. * @@ -13,9 +13,9 @@ package com.ardor3d.scene.state.jogl; import java.nio.DoubleBuffer; import java.nio.FloatBuffer; -import javax.media.opengl.GL; -import javax.media.opengl.GL2ES1; -import javax.media.opengl.GLContext; +import com.jogamp.opengl.GL; +import com.jogamp.opengl.GL2ES1; +import com.jogamp.opengl.GLContext; import com.ardor3d.renderer.ContextCapabilities; import com.ardor3d.renderer.ContextManager; @@ -73,7 +73,9 @@ public abstract class JoglClipStateUtil { } else { ((DoubleBuffer) record.buf).put(state.getPlaneEquations(planeIndex)); record.buf.flip(); - gl.getGL2().glClipPlane(GL2ES1.GL_CLIP_PLANE0 + planeIndex, (DoubleBuffer) record.buf); + if (gl.isGL2()) { + gl.getGL2().glClipPlane(GL2ES1.GL_CLIP_PLANE0 + planeIndex, (DoubleBuffer) record.buf); + } } } else { // TODO use this suggestion but take into account the good reference frame: diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglColorMaskStateUtil.java b/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglColorMaskStateUtil.java index ca685a8..1d87696 100644 --- a/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglColorMaskStateUtil.java +++ b/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglColorMaskStateUtil.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2008-2010 Ardor Labs, Inc. + * Copyright (c) 2008-2014 Ardor Labs, Inc. * * This file is part of Ardor3D. * @@ -10,8 +10,8 @@ package com.ardor3d.scene.state.jogl; -import javax.media.opengl.GL; -import javax.media.opengl.GLContext; +import com.jogamp.opengl.GL; +import com.jogamp.opengl.GLContext; import com.ardor3d.renderer.ContextManager; import com.ardor3d.renderer.RenderContext; diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglCullStateUtil.java b/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglCullStateUtil.java index a2f3fd8..d2aa7cf 100644 --- a/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglCullStateUtil.java +++ b/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglCullStateUtil.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2008-2010 Ardor Labs, Inc. + * Copyright (c) 2008-2014 Ardor Labs, Inc. * * This file is part of Ardor3D. * @@ -10,8 +10,8 @@ package com.ardor3d.scene.state.jogl; -import javax.media.opengl.GL; -import javax.media.opengl.GLContext; +import com.jogamp.opengl.GL; +import com.jogamp.opengl.GLContext; import com.ardor3d.renderer.ContextManager; import com.ardor3d.renderer.RenderContext; diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglFogStateUtil.java b/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglFogStateUtil.java index a36649a..e19ffa0 100644 --- a/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglFogStateUtil.java +++ b/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglFogStateUtil.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2008-2010 Ardor Labs, Inc. + * Copyright (c) 2008-2014 Ardor Labs, Inc. * * This file is part of Ardor3D. * @@ -10,10 +10,10 @@ package com.ardor3d.scene.state.jogl; -import javax.media.opengl.GL; -import javax.media.opengl.GL2; -import javax.media.opengl.GL2ES1; -import javax.media.opengl.GLContext; +import com.jogamp.opengl.GL; +import com.jogamp.opengl.GL2; +import com.jogamp.opengl.GL2ES1; +import com.jogamp.opengl.GLContext; import com.ardor3d.math.type.ReadOnlyColorRGBA; import com.ardor3d.renderer.ContextCapabilities; @@ -43,23 +43,35 @@ public abstract class JoglFogStateUtil { if (record.isValid()) { if (record.fogStart != state.getStart()) { - gl.getGL2ES1().glFogf(GL2ES1.GL_FOG_START, state.getStart()); + if (gl.isGL2ES1()) { + gl.getGL2ES1().glFogf(GL2ES1.GL_FOG_START, state.getStart()); + } record.fogStart = state.getStart(); } if (record.fogEnd != state.getEnd()) { - gl.getGL2ES1().glFogf(GL2ES1.GL_FOG_END, state.getEnd()); + if (gl.isGL2ES1()) { + gl.getGL2ES1().glFogf(GL2ES1.GL_FOG_END, state.getEnd()); + } record.fogEnd = state.getEnd(); } if (record.density != state.getDensity()) { - gl.getGL2ES1().glFogf(GL2ES1.GL_FOG_DENSITY, state.getDensity()); + if (gl.isGL2ES1()) { + gl.getGL2ES1().glFogf(GL2ES1.GL_FOG_DENSITY, state.getDensity()); + } record.density = state.getDensity(); } } else { - gl.getGL2ES1().glFogf(GL2ES1.GL_FOG_START, state.getStart()); + if (gl.isGL2ES1()) { + gl.getGL2ES1().glFogf(GL2ES1.GL_FOG_START, state.getStart()); + } record.fogStart = state.getStart(); - gl.getGL2ES1().glFogf(GL2ES1.GL_FOG_END, state.getEnd()); + if (gl.isGL2ES1()) { + gl.getGL2ES1().glFogf(GL2ES1.GL_FOG_END, state.getEnd()); + } record.fogEnd = state.getEnd(); - gl.getGL2ES1().glFogf(GL2ES1.GL_FOG_DENSITY, state.getDensity()); + if (gl.isGL2ES1()) { + gl.getGL2ES1().glFogf(GL2ES1.GL_FOG_DENSITY, state.getDensity()); + } record.density = state.getDensity(); } @@ -82,17 +94,25 @@ public abstract class JoglFogStateUtil { if (record.isValid()) { if (enable && !record.enabled) { - gl.glEnable(GL2ES1.GL_FOG); + if (gl.isGL2ES1()) { + gl.glEnable(GL2ES1.GL_FOG); + } record.enabled = true; } else if (!enable && record.enabled) { - gl.glDisable(GL2ES1.GL_FOG); + if (gl.isGL2ES1()) { + gl.glDisable(GL2ES1.GL_FOG); + } record.enabled = false; } } else { if (enable) { - gl.glEnable(GL2ES1.GL_FOG); + if (gl.isGL2ES1()) { + gl.glEnable(GL2ES1.GL_FOG); + } } else { - gl.glDisable(GL2ES1.GL_FOG); + if (gl.isGL2ES1()) { + gl.glDisable(GL2ES1.GL_FOG); + } } record.enabled = enable; } @@ -107,7 +127,9 @@ public abstract class JoglFogStateUtil { record.colorBuff.put(record.fogColor.getRed()).put(record.fogColor.getGreen()) .put(record.fogColor.getBlue()).put(record.fogColor.getAlpha()); record.colorBuff.flip(); - gl.getGL2ES1().glFogfv(GL2ES1.GL_FOG_COLOR, record.colorBuff); + if (gl.isGL2ES1()) { + gl.getGL2ES1().glFogfv(GL2ES1.GL_FOG_COLOR, record.colorBuff); + } } } @@ -118,9 +140,13 @@ public abstract class JoglFogStateUtil { if (caps.isFogCoordinatesSupported()) { if (!record.isValid() || !source.equals(record.source)) { if (source == CoordinateSource.Depth) { - gl.getGL2().glFogi(GL2.GL_FOG_COORDINATE_SOURCE, GL2.GL_FRAGMENT_DEPTH); + if (gl.isGL2()) { + gl.getGL2().glFogi(GL2.GL_FOG_COORDINATE_SOURCE, GL2.GL_FRAGMENT_DEPTH); + } } else { - gl.getGL2().glFogi(GL2.GL_FOG_COORDINATE_SOURCE, GL2.GL_FOG_COORDINATE); + if (gl.isGL2()) { + gl.getGL2().glFogi(GL2.GL_FOG_COORDINATE_SOURCE, GL2.GL_FOG_COORDINATE); + } } } } @@ -143,7 +169,9 @@ public abstract class JoglFogStateUtil { } if (!record.isValid() || record.fogMode != glMode) { - gl.getGL2().glFogi(GL2ES1.GL_FOG_MODE, glMode); + if (gl.isGL2()) { + gl.getGL2().glFogi(GL2ES1.GL_FOG_MODE, glMode); + } record.fogMode = glMode; } } @@ -162,7 +190,9 @@ public abstract class JoglFogStateUtil { } if (!record.isValid() || record.fogHint != glHint) { - gl.glHint(GL2ES1.GL_FOG_HINT, glHint); + if (gl.isGL2ES1()) { + gl.glHint(GL2ES1.GL_FOG_HINT, glHint); + } record.fogHint = glHint; } } diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglFragmentProgramStateUtil.java b/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglFragmentProgramStateUtil.java index b227ae4..6d4210c 100644 --- a/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglFragmentProgramStateUtil.java +++ b/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglFragmentProgramStateUtil.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2008-2010 Ardor Labs, Inc. + * Copyright (c) 2008-2014 Ardor Labs, Inc. * * This file is part of Ardor3D. * @@ -14,9 +14,9 @@ import java.nio.ByteBuffer; import java.nio.IntBuffer; import java.util.logging.Logger; -import javax.media.opengl.GL; -import javax.media.opengl.GL2; -import javax.media.opengl.GLContext; +import com.jogamp.opengl.GL; +import com.jogamp.opengl.GL2; +import com.jogamp.opengl.GLContext; import com.ardor3d.renderer.ContextCapabilities; import com.ardor3d.renderer.ContextManager; diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglLightStateUtil.java b/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglLightStateUtil.java index 489fdd4..5c0bfb6 100644 --- a/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglLightStateUtil.java +++ b/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglLightStateUtil.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2008-2010 Ardor Labs, Inc. + * Copyright (c) 2008-2014 Ardor Labs, Inc. * * This file is part of Ardor3D. * @@ -10,11 +10,11 @@ package com.ardor3d.scene.state.jogl; -import javax.media.opengl.GL; -import javax.media.opengl.GL2; -import javax.media.opengl.GL2ES1; -import javax.media.opengl.GLContext; -import javax.media.opengl.fixedfunc.GLLightingFunc; +import com.jogamp.opengl.GL; +import com.jogamp.opengl.GL2; +import com.jogamp.opengl.GL2ES1; +import com.jogamp.opengl.GLContext; +import com.jogamp.opengl.fixedfunc.GLLightingFunc; import com.ardor3d.light.DirectionalLight; import com.ardor3d.light.Light; @@ -167,9 +167,13 @@ public abstract class JoglLightStateUtil { if (!record.isValid() || lr.isEnabled() != enable) { if (enable) { - gl.glEnable(GLLightingFunc.GL_LIGHT0 + index); + if (gl.isGL2ES1()) { + gl.glEnable(GLLightingFunc.GL_LIGHT0 + index); + } } else { - gl.glDisable(GLLightingFunc.GL_LIGHT0 + index); + if (gl.isGL2ES1()) { + gl.glDisable(GLLightingFunc.GL_LIGHT0 + index); + } } lr.setEnabled(enable); @@ -181,9 +185,13 @@ public abstract class JoglLightStateUtil { if (!record.isValid() || record.isEnabled() != enable) { if (enable) { - gl.glEnable(GLLightingFunc.GL_LIGHTING); + if (gl.isGL2ES1()) { + gl.glEnable(GLLightingFunc.GL_LIGHTING); + } } else { - gl.glDisable(GLLightingFunc.GL_LIGHTING); + if (gl.isGL2ES1()) { + gl.glDisable(GLLightingFunc.GL_LIGHTING); + } } record.setEnabled(enable); } @@ -194,9 +202,21 @@ public abstract class JoglLightStateUtil { if (!record.isValid() || record.isTwoSidedOn() != twoSided) { if (twoSided) { - gl.getGL2().glLightModeli(GL2ES1.GL_LIGHT_MODEL_TWO_SIDE, GL.GL_TRUE); + if (gl.isGL2()) { + gl.getGL2().glLightModeli(GL2ES1.GL_LIGHT_MODEL_TWO_SIDE, GL.GL_TRUE); + } else { + if (gl.isGLES1()) { + gl.getGLES1().glLightModelx(GL2ES1.GL_LIGHT_MODEL_TWO_SIDE, GL.GL_TRUE); + } + } } else { - gl.getGL2().glLightModeli(GL2ES1.GL_LIGHT_MODEL_TWO_SIDE, GL.GL_FALSE); + if (gl.isGL2()) { + gl.getGL2().glLightModeli(GL2ES1.GL_LIGHT_MODEL_TWO_SIDE, GL.GL_FALSE); + } else { + if (gl.isGLES1()) { + gl.getGLES1().glLightModelx(GL2ES1.GL_LIGHT_MODEL_TWO_SIDE, GL.GL_FALSE); + } + } } record.setTwoSidedOn(twoSided); } @@ -207,9 +227,21 @@ public abstract class JoglLightStateUtil { if (!record.isValid() || record.isLocalViewer() != localViewer) { if (localViewer) { - gl.getGL2().glLightModeli(GL2.GL_LIGHT_MODEL_LOCAL_VIEWER, GL.GL_TRUE); + if (gl.isGL2()) { + gl.getGL2().glLightModeli(GL2.GL_LIGHT_MODEL_LOCAL_VIEWER, GL.GL_TRUE); + } else { + if (gl.isGLES1()) { + gl.getGLES1().glLightModelx(GL2.GL_LIGHT_MODEL_LOCAL_VIEWER, GL.GL_TRUE); + } + } } else { - gl.getGL2().glLightModeli(GL2.GL_LIGHT_MODEL_LOCAL_VIEWER, GL.GL_FALSE); + if (gl.isGL2()) { + gl.getGL2().glLightModeli(GL2.GL_LIGHT_MODEL_LOCAL_VIEWER, GL.GL_FALSE); + } else { + if (gl.isGLES1()) { + gl.getGLES1().glLightModelx(GL2.GL_LIGHT_MODEL_LOCAL_VIEWER, GL.GL_FALSE); + } + } } record.setLocalViewer(localViewer); } @@ -220,9 +252,21 @@ public abstract class JoglLightStateUtil { if (!record.isValid() || record.isSeparateSpecular() != separateSpecularOn) { if (separateSpecularOn) { - gl.getGL2().glLightModeli(GL2.GL_LIGHT_MODEL_COLOR_CONTROL, GL2.GL_SEPARATE_SPECULAR_COLOR); + if (gl.isGL2()) { + gl.getGL2().glLightModeli(GL2.GL_LIGHT_MODEL_COLOR_CONTROL, GL2.GL_SEPARATE_SPECULAR_COLOR); + } else { + if (gl.isGLES1()) { + gl.getGLES1().glLightModelx(GL2.GL_LIGHT_MODEL_COLOR_CONTROL, GL2.GL_SEPARATE_SPECULAR_COLOR); + } + } } else { - gl.getGL2().glLightModeli(GL2.GL_LIGHT_MODEL_COLOR_CONTROL, GL2.GL_SINGLE_COLOR); + if (gl.isGL2()) { + gl.getGL2().glLightModeli(GL2.GL_LIGHT_MODEL_COLOR_CONTROL, GL2.GL_SINGLE_COLOR); + } else { + if (gl.isGLES1()) { + gl.getGLES1().glLightModelx(GL2.GL_LIGHT_MODEL_COLOR_CONTROL, GL2.GL_SINGLE_COLOR); + } + } } record.setSeparateSpecular(separateSpecularOn); } @@ -238,7 +282,10 @@ public abstract class JoglLightStateUtil { record.lightBuffer.put(globalAmbient.getBlue()); record.lightBuffer.put(globalAmbient.getAlpha()); record.lightBuffer.flip(); - gl.getGL2().glLightModelfv(GL2ES1.GL_LIGHT_MODEL_AMBIENT, record.lightBuffer); // TODO Check for float + if (gl.isGL2ES1()) { + gl.getGL2ES1().glLightModelfv(GL2ES1.GL_LIGHT_MODEL_AMBIENT, record.lightBuffer); // TODO Check for + // float + } record.globalAmbient.set(globalAmbient); } } @@ -254,10 +301,10 @@ public abstract class JoglLightStateUtil { record.lightBuffer.put(ambient.getBlue()); record.lightBuffer.put(ambient.getAlpha()); record.lightBuffer.flip(); - gl.getGL2().glLightfv(GLLightingFunc.GL_LIGHT0 + index, GLLightingFunc.GL_AMBIENT, record.lightBuffer); // TODO - // Check - // for - // float + if (gl.isGL2ES1()) { + gl.getGL2ES1().glLightfv(GLLightingFunc.GL_LIGHT0 + index, GLLightingFunc.GL_AMBIENT, + record.lightBuffer); // TODO Check for float + } lr.ambient.set(ambient); } } @@ -273,10 +320,13 @@ public abstract class JoglLightStateUtil { record.lightBuffer.put(diffuse.getBlue()); record.lightBuffer.put(diffuse.getAlpha()); record.lightBuffer.flip(); - gl.getGL2().glLightfv(GLLightingFunc.GL_LIGHT0 + index, GLLightingFunc.GL_DIFFUSE, record.lightBuffer); // TODO - // Check - // for - // float + if (gl.isGL2ES1()) { + gl.getGL2ES1().glLightfv(GLLightingFunc.GL_LIGHT0 + index, GLLightingFunc.GL_DIFFUSE, + record.lightBuffer); // TODO + } + // Check + // for + // float lr.diffuse.set(diffuse); } } @@ -292,10 +342,13 @@ public abstract class JoglLightStateUtil { record.lightBuffer.put(specular.getBlue()); record.lightBuffer.put(specular.getAlpha()); record.lightBuffer.flip(); - gl.getGL2().glLightfv(GLLightingFunc.GL_LIGHT0 + index, GLLightingFunc.GL_SPECULAR, record.lightBuffer); // TODO - // Check - // for - // float + if (gl.isGL2ES1()) { + gl.getGL2ES1().glLightfv(GLLightingFunc.GL_LIGHT0 + index, GLLightingFunc.GL_SPECULAR, + record.lightBuffer); // TODO + } + // Check + // for + // float lr.specular.set(specular); } } @@ -327,7 +380,10 @@ public abstract class JoglLightStateUtil { record.lightBuffer.put(positionZ); record.lightBuffer.put(positionW); record.lightBuffer.flip(); - gl.getGL2().glLightfv(GLLightingFunc.GL_LIGHT0 + index, GLLightingFunc.GL_POSITION, record.lightBuffer); + if (gl.isGL2ES1()) { + gl.getGL2ES1().glLightfv(GLLightingFunc.GL_LIGHT0 + index, GLLightingFunc.GL_POSITION, + record.lightBuffer); + } lr.position.set(positionX, positionY, positionZ, positionW); if (!Camera.getCurrentCamera().isFrameDirty()) { @@ -355,17 +411,23 @@ public abstract class JoglLightStateUtil { record.lightBuffer.put(directionZ); record.lightBuffer.put(value); record.lightBuffer.flip(); - gl.getGL2().glLightfv(GLLightingFunc.GL_LIGHT0 + index, GLLightingFunc.GL_SPOT_DIRECTION, record.lightBuffer); // TODO - // Check - // for - // float + if (gl.isGL2ES1()) { + gl.getGL2ES1().glLightfv(GLLightingFunc.GL_LIGHT0 + index, GLLightingFunc.GL_SPOT_DIRECTION, + record.lightBuffer); // TODO + // Check + // for + // float + } } private static void setConstant(final int index, final float constant, final LightRecord lr, final boolean force) { final GL gl = GLContext.getCurrentGL(); if (force || constant != lr.getConstant()) { - gl.getGL2().glLightf(GLLightingFunc.GL_LIGHT0 + index, GLLightingFunc.GL_CONSTANT_ATTENUATION, constant); + if (gl.isGL2ES1()) { + gl.getGL2ES1().glLightf(GLLightingFunc.GL_LIGHT0 + index, GLLightingFunc.GL_CONSTANT_ATTENUATION, + constant); + } lr.setConstant(constant); } } @@ -374,7 +436,9 @@ public abstract class JoglLightStateUtil { final GL gl = GLContext.getCurrentGL(); if (force || linear != lr.getLinear()) { - gl.getGL2().glLightf(GLLightingFunc.GL_LIGHT0 + index, GLLightingFunc.GL_LINEAR_ATTENUATION, linear); + if (gl.isGL2ES1()) { + gl.getGL2ES1().glLightf(GLLightingFunc.GL_LIGHT0 + index, GLLightingFunc.GL_LINEAR_ATTENUATION, linear); + } lr.setLinear(linear); } } @@ -383,7 +447,10 @@ public abstract class JoglLightStateUtil { final GL gl = GLContext.getCurrentGL(); if (force || quad != lr.getQuadratic()) { - gl.getGL2().glLightf(GLLightingFunc.GL_LIGHT0 + index, GLLightingFunc.GL_QUADRATIC_ATTENUATION, quad); + if (gl.isGL2ES1()) { + gl.getGL2ES1() + .glLightf(GLLightingFunc.GL_LIGHT0 + index, GLLightingFunc.GL_QUADRATIC_ATTENUATION, quad); + } lr.setQuadratic(quad); } } @@ -407,7 +474,9 @@ public abstract class JoglLightStateUtil { final GL gl = GLContext.getCurrentGL(); if (!record.isValid() || lr.getSpotExponent() != exponent) { - gl.getGL2().glLightf(GLLightingFunc.GL_LIGHT0 + index, GLLightingFunc.GL_SPOT_EXPONENT, exponent); + if (gl.isGL2ES1()) { + gl.getGL2ES1().glLightf(GLLightingFunc.GL_LIGHT0 + index, GLLightingFunc.GL_SPOT_EXPONENT, exponent); + } lr.setSpotExponent(exponent); } } @@ -417,7 +486,9 @@ public abstract class JoglLightStateUtil { final GL gl = GLContext.getCurrentGL(); if (!record.isValid() || lr.getSpotCutoff() != cutoff) { - gl.getGL2().glLightf(GLLightingFunc.GL_LIGHT0 + index, GLLightingFunc.GL_SPOT_CUTOFF, cutoff); + if (gl.isGL2ES1()) { + gl.getGL2ES1().glLightf(GLLightingFunc.GL_LIGHT0 + index, GLLightingFunc.GL_SPOT_CUTOFF, cutoff); + } lr.setSpotCutoff(cutoff); } } diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglMaterialStateUtil.java b/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglMaterialStateUtil.java index 9fc3490..58e659f 100644 --- a/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglMaterialStateUtil.java +++ b/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglMaterialStateUtil.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2008-2010 Ardor Labs, Inc. + * Copyright (c) 2008-2014 Ardor Labs, Inc. * * This file is part of Ardor3D. * @@ -10,9 +10,9 @@ package com.ardor3d.scene.state.jogl; -import javax.media.opengl.GL; -import javax.media.opengl.GLContext; -import javax.media.opengl.fixedfunc.GLLightingFunc; +import com.jogamp.opengl.GL; +import com.jogamp.opengl.GLContext; +import com.jogamp.opengl.fixedfunc.GLLightingFunc; import com.ardor3d.math.type.ReadOnlyColorRGBA; import com.ardor3d.renderer.ContextManager; @@ -74,7 +74,10 @@ public abstract class JoglMaterialStateUtil { record.tempColorBuff.put(frontColor.getRed()).put(frontColor.getGreen()).put(frontColor.getBlue()) .put(frontColor.getAlpha()); record.tempColorBuff.flip(); - gl.getGL2().glMaterialfv(getGLMaterialFace(MaterialFace.FrontAndBack), glMat, record.tempColorBuff); + if (gl.isGL2()) { + gl.getGL2().glMaterialfv(getGLMaterialFace(MaterialFace.FrontAndBack), glMat, + record.tempColorBuff); + } record.setColor(MaterialFace.FrontAndBack, glMatColor, frontColor); } } @@ -85,7 +88,9 @@ public abstract class JoglMaterialStateUtil { record.tempColorBuff.put(frontColor.getRed()).put(frontColor.getGreen()).put(frontColor.getBlue()) .put(frontColor.getAlpha()); record.tempColorBuff.flip(); - gl.getGL2().glMaterialfv(getGLMaterialFace(MaterialFace.Front), glMat, record.tempColorBuff); + if (gl.isGL2()) { + gl.getGL2().glMaterialfv(getGLMaterialFace(MaterialFace.Front), glMat, record.tempColorBuff); + } record.setColor(MaterialFace.Front, glMatColor, frontColor); } } @@ -96,7 +101,9 @@ public abstract class JoglMaterialStateUtil { record.tempColorBuff.put(backColor.getRed()).put(backColor.getGreen()).put(backColor.getBlue()) .put(backColor.getAlpha()); record.tempColorBuff.flip(); - gl.getGL2().glMaterialfv(getGLMaterialFace(MaterialFace.Back), glMat, record.tempColorBuff); + if (gl.isGL2()) { + gl.getGL2().glMaterialfv(getGLMaterialFace(MaterialFace.Back), glMat, record.tempColorBuff); + } record.setColor(MaterialFace.Back, glMatColor, backColor); } } @@ -135,13 +142,18 @@ public abstract class JoglMaterialStateUtil { final GL gl = GLContext.getCurrentGL(); if (colorMaterial == ColorMaterial.None) { - gl.glDisable(GLLightingFunc.GL_COLOR_MATERIAL); + if (gl.isGL2()) { + gl.glDisable(GLLightingFunc.GL_COLOR_MATERIAL); + } } else { final int glMat = getGLColorMaterial(colorMaterial); final int glFace = getGLMaterialFace(face); - - gl.getGL2().glColorMaterial(glFace, glMat); - gl.glEnable(GLLightingFunc.GL_COLOR_MATERIAL); + if (gl.isGL2()) { + gl.getGL2().glColorMaterial(glFace, glMat); + } + if (gl.isGL2()) { + gl.glEnable(GLLightingFunc.GL_COLOR_MATERIAL); + } record.resetColorsForCM(face, colorMaterial); } record.colorMaterial = colorMaterial; @@ -156,20 +168,26 @@ public abstract class JoglMaterialStateUtil { if (frontShininess == backShininess) { // consolidate to one call if (!record.isValid() || frontShininess != record.frontShininess || record.backShininess != backShininess) { - gl.getGL2().glMaterialf(getGLMaterialFace(MaterialFace.FrontAndBack), GLLightingFunc.GL_SHININESS, - frontShininess); + if (gl.isGL2()) { + gl.getGL2().glMaterialf(getGLMaterialFace(MaterialFace.FrontAndBack), GLLightingFunc.GL_SHININESS, + frontShininess); + } record.backShininess = record.frontShininess = frontShininess; } } else { if (!record.isValid() || frontShininess != record.frontShininess) { - gl.getGL2().glMaterialf(getGLMaterialFace(MaterialFace.Front), GLLightingFunc.GL_SHININESS, - frontShininess); + if (gl.isGL2()) { + gl.getGL2().glMaterialf(getGLMaterialFace(MaterialFace.Front), GLLightingFunc.GL_SHININESS, + frontShininess); + } record.frontShininess = frontShininess; } if (!record.isValid() || backShininess != record.backShininess) { - gl.getGL2().glMaterialf(getGLMaterialFace(MaterialFace.Back), GLLightingFunc.GL_SHININESS, - backShininess); + if (gl.isGL2()) { + gl.getGL2().glMaterialf(getGLMaterialFace(MaterialFace.Back), GLLightingFunc.GL_SHININESS, + backShininess); + } record.backShininess = backShininess; } } diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglOffsetStateUtil.java b/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglOffsetStateUtil.java index ec48484..6fe1c12 100644 --- a/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglOffsetStateUtil.java +++ b/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglOffsetStateUtil.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2008-2010 Ardor Labs, Inc. + * Copyright (c) 2008-2014 Ardor Labs, Inc. * * This file is part of Ardor3D. * @@ -10,9 +10,9 @@ package com.ardor3d.scene.state.jogl; -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; import com.ardor3d.renderer.ContextManager; import com.ardor3d.renderer.RenderContext; @@ -59,10 +59,12 @@ public abstract class JoglOffsetStateUtil { final int glType = getGLType(type); if (!record.isValid() || typeEnabled != record.enabledOffsets.contains(type)) { - if (typeEnabled) { - gl.glEnable(glType); - } else { - gl.glDisable(glType); + if (!gl.isGLES()) { + if (typeEnabled) { + gl.glEnable(glType); + } else { + gl.glDisable(glType); + } } } } diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglShaderObjectsStateUtil.java b/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglShaderObjectsStateUtil.java index ebb53a8..3788548 100644 --- a/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglShaderObjectsStateUtil.java +++ b/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglShaderObjectsStateUtil.java @@ -1,9 +1,9 @@ /** - * Copyright (c) 2008-2012 Ardor Labs, Inc. + * Copyright (c) 2008-2014 Ardor Labs, Inc. * * This file is part of Ardor3D. * - * Ardor3D is free software: you can redistribute it and/or modify it + * Ardor3D is free software: you can redistribute it and/or modify it * under the terms of its license which may be found in the accompanying * LICENSE file or at <http://www.ardor3d.com/LICENSE>. */ @@ -15,13 +15,6 @@ import java.nio.IntBuffer; import java.util.List; import java.util.logging.Logger; -import javax.media.opengl.GL; -import javax.media.opengl.GL2; -import javax.media.opengl.GL2ES2; -import javax.media.opengl.GL3; -import javax.media.opengl.GL4; -import javax.media.opengl.GLContext; - import com.ardor3d.renderer.ContextCapabilities; import com.ardor3d.renderer.ContextManager; import com.ardor3d.renderer.RenderContext; @@ -34,6 +27,12 @@ import com.ardor3d.scene.state.jogl.shader.JoglShaderUtil; import com.ardor3d.util.Ardor3dException; import com.ardor3d.util.geom.BufferUtils; import com.ardor3d.util.shader.ShaderVariable; +import com.jogamp.opengl.GL; +import com.jogamp.opengl.GL2; +import com.jogamp.opengl.GL2ES2; +import com.jogamp.opengl.GL3; +import com.jogamp.opengl.GL3ES3; +import com.jogamp.opengl.GLContext; public abstract class JoglShaderObjectsStateUtil { private static final Logger logger = Logger.getLogger(JoglShaderObjectsStateUtil.class.getName()); @@ -49,7 +48,7 @@ public abstract class JoglShaderObjectsStateUtil { if (state._programID == -1) { if (gl.isGL2()) { - state._programID = gl.getGL2().glCreateProgramObjectARB(); + state._programID = (int) gl.getGL2().glCreateProgramObjectARB(); } else { if (gl.isGL2ES2()) { state._programID = gl.getGL2ES2().glCreateProgram(); @@ -62,7 +61,7 @@ public abstract class JoglShaderObjectsStateUtil { removeVertShader(state); } if (gl.isGL2()) { - state._vertexShaderID = gl.getGL2().glCreateShaderObjectARB(GL2ES2.GL_VERTEX_SHADER); + state._vertexShaderID = (int) gl.getGL2().glCreateShaderObjectARB(GL2ES2.GL_VERTEX_SHADER); } else { if (gl.isGL2ES2()) { state._vertexShaderID = gl.getGL2ES2().glCreateShader(GL2ES2.GL_VERTEX_SHADER); @@ -97,7 +96,7 @@ public abstract class JoglShaderObjectsStateUtil { gl.getGL2ES2().glGetShaderiv(state._vertexShaderID, GL2ES2.GL_COMPILE_STATUS, compiled); } } - checkProgramError(compiled.get(0), state._vertexShaderID, state._vertexShaderName); + checkShaderError(compiled.get(0), state._vertexShaderID, state._vertexShaderName); // Attach the program if (gl.isGL2()) { @@ -118,7 +117,7 @@ public abstract class JoglShaderObjectsStateUtil { } if (gl.isGL2()) { - state._fragmentShaderID = gl.getGL2().glCreateShaderObjectARB(GL2ES2.GL_FRAGMENT_SHADER); + state._fragmentShaderID = (int) gl.getGL2().glCreateShaderObjectARB(GL2ES2.GL_FRAGMENT_SHADER); } else { if (gl.isGL2ES2()) { state._fragmentShaderID = gl.getGL2ES2().glCreateShader(GL2ES2.GL_FRAGMENT_SHADER); @@ -153,7 +152,7 @@ public abstract class JoglShaderObjectsStateUtil { gl.getGL2ES2().glGetShaderiv(state._fragmentShaderID, GL2ES2.GL_COMPILE_STATUS, compiled); } } - checkProgramError(compiled.get(0), state._fragmentShaderID, state._vertexShaderName); + checkShaderError(compiled.get(0), state._fragmentShaderID, state._vertexShaderName); // Attach the program if (gl.isGL2()) { @@ -175,7 +174,7 @@ public abstract class JoglShaderObjectsStateUtil { } if (gl.isGL2()) { - state._geometryShaderID = gl.getGL2().glCreateShaderObjectARB(GL3.GL_GEOMETRY_SHADER); + state._geometryShaderID = (int) gl.getGL2().glCreateShaderObjectARB(GL3.GL_GEOMETRY_SHADER); } else { if (gl.isGL2ES2()) { state._geometryShaderID = gl.getGL2ES2().glCreateShader(GL3.GL_GEOMETRY_SHADER); @@ -210,7 +209,7 @@ public abstract class JoglShaderObjectsStateUtil { gl.getGL2ES2().glGetShaderiv(state._geometryShaderID, GL2ES2.GL_COMPILE_STATUS, compiled); } } - checkProgramError(compiled.get(0), state._geometryShaderID, state._geometryShaderName); + checkShaderError(compiled.get(0), state._geometryShaderID, state._geometryShaderName); // Attach the program if (gl.isGL2()) { @@ -233,11 +232,11 @@ public abstract class JoglShaderObjectsStateUtil { } if (gl.isGL2()) { - state._tessellationControlShaderID = gl.getGL2() - .glCreateShaderObjectARB(GL4.GL_TESS_CONTROL_SHADER); + state._tessellationControlShaderID = (int) gl.getGL2().glCreateShaderObjectARB( + GL3.GL_TESS_CONTROL_SHADER); } else { if (gl.isGL2ES2()) { - state._tessellationControlShaderID = gl.getGL2ES2().glCreateShader(GL4.GL_TESS_CONTROL_SHADER); + state._tessellationControlShaderID = gl.getGL2ES2().glCreateShader(GL3.GL_TESS_CONTROL_SHADER); } } @@ -270,7 +269,7 @@ public abstract class JoglShaderObjectsStateUtil { compiled); } } - checkProgramError(compiled.get(0), state._tessellationControlShaderID, + checkShaderError(compiled.get(0), state._tessellationControlShaderID, state._tessellationControlShaderName); // Attach the program @@ -291,12 +290,12 @@ public abstract class JoglShaderObjectsStateUtil { } if (gl.isGL2()) { - state._tessellationEvaluationShaderID = gl.getGL2().glCreateShaderObjectARB( - GL4.GL_TESS_CONTROL_SHADER); + state._tessellationEvaluationShaderID = (int) gl.getGL2().glCreateShaderObjectARB( + GL3.GL_TESS_CONTROL_SHADER); } else { if (gl.isGL2ES2()) { state._tessellationEvaluationShaderID = gl.getGL2ES2().glCreateShader( - GL4.GL_TESS_CONTROL_SHADER); + GL3.GL_TESS_CONTROL_SHADER); } } @@ -314,7 +313,7 @@ public abstract class JoglShaderObjectsStateUtil { } } - // Compile the tessellation control shader + // Compile the tessellation evaluation shader final JoglRenderContext context = (JoglRenderContext) ContextManager.getCurrentContext(); final IntBuffer compiled = context.getDirectNioBuffersSet().getSingleIntBuffer(); compiled.clear(); @@ -329,7 +328,7 @@ public abstract class JoglShaderObjectsStateUtil { compiled); } } - checkProgramError(compiled.get(0), state._tessellationEvaluationShaderID, + checkShaderError(compiled.get(0), state._tessellationEvaluationShaderID, state._tessellationEvaluationShaderName); // Attach the program @@ -346,6 +345,64 @@ public abstract class JoglShaderObjectsStateUtil { } } + if (caps.isComputeShaderSupported()) { + if (state.getComputeShader() != null) { + if (state._computeShaderID != -1) { + removeCompShader(state); + } + if (gl.isGL2()) { + state._computeShaderID = (int) gl.getGL2().glCreateShaderObjectARB(GL3ES3.GL_COMPUTE_SHADER); + } else { + if (gl.isGL2ES2()) { + state._computeShaderID = gl.getGL2ES2().glCreateShader(GL3ES3.GL_COMPUTE_SHADER); + } + } + + // Create the sources + final byte array[] = new byte[state.getComputeShader().limit()]; + state.getComputeShader().rewind(); + state.getComputeShader().get(array); + if (gl.isGL2()) { + gl.getGL2().glShaderSourceARB(state._computeShaderID, 1, new String[] { new String(array) }, + new int[] { array.length }, 0); + } else { + if (gl.isGL2ES2()) { + gl.getGL2ES2().glShaderSource(state._computeShaderID, 1, new String[] { new String(array) }, + new int[] { array.length }, 0); + } + } + + // Compile the compute shader + final JoglRenderContext context = (JoglRenderContext) ContextManager.getCurrentContext(); + final IntBuffer compiled = context.getDirectNioBuffersSet().getSingleIntBuffer(); + compiled.clear(); + if (gl.isGL2()) { + gl.getGL2().glCompileShaderARB(state._computeShaderID); + gl.getGL2().glGetObjectParameterivARB(state._computeShaderID, GL2.GL_OBJECT_COMPILE_STATUS_ARB, + compiled); + } else { + if (gl.isGL2ES2()) { + gl.getGL2ES2().glCompileShader(state._computeShaderID); + gl.getGL2ES2().glGetShaderiv(state._computeShaderID, GL2ES2.GL_COMPILE_STATUS, compiled); + } + } + checkShaderError(compiled.get(0), state._computeShaderID, state._computeShaderName); + + // Attach the program + if (gl.isGL2()) { + gl.getGL2().glAttachObjectARB(state._programID, state._computeShaderID); + } else { + if (gl.isGL2ES2()) { + gl.getGL2ES2().glAttachShader(state._programID, state._computeShaderID); + } + } + + } else if (state._computeShaderID != -1) { + removeCompShader(state); + state._computeShaderID = -1; + } + } + if (gl.isGL2()) { gl.getGL2().glLinkProgramARB(state._programID); } else { @@ -494,15 +551,32 @@ public abstract class JoglShaderObjectsStateUtil { } } + /** Removes the compute shader */ + private static void removeCompShader(final GLSLShaderObjectsState state) { + final GL gl = GLContext.getCurrentGL(); + + if (state._computeShaderID != -1) { + if (gl.isGL2()) { + gl.getGL2().glDetachObjectARB(state._programID, state._computeShaderID); + gl.getGL2().glDeleteObjectARB(state._computeShaderID); + } else { + if (gl.isGL2ES2()) { + gl.getGL2ES2().glDetachShader(state._programID, state._computeShaderID); + gl.getGL2ES2().glDeleteShader(state._computeShaderID); + } + } + } + } + /** - * Check for program errors. If an error is detected, program exits. - * + * Check for shader errors. If an error is detected, program exits. + * * @param compilerState * the compiler state for a given shader - * @param id + * @param shaderId * shader's id */ - private static void checkProgramError(final int compilerState, final int id, final String shaderName) { + private static void checkShaderError(final int compilerState, final int shaderId, final String shaderName) { final GL gl = GLContext.getCurrentGL(); if (compilerState == GL.GL_FALSE) { @@ -510,10 +584,10 @@ public abstract class JoglShaderObjectsStateUtil { final IntBuffer iVal = context.getDirectNioBuffersSet().getSingleIntBuffer(); iVal.clear(); if (gl.isGL2()) { - gl.getGL2().glGetObjectParameterivARB(id, GL2.GL_OBJECT_INFO_LOG_LENGTH_ARB, iVal); + gl.getGL2().glGetObjectParameterivARB(shaderId, GL2.GL_OBJECT_INFO_LOG_LENGTH_ARB, iVal); } else { if (gl.isGL2ES2()) { - gl.getGL2ES2().glGetProgramiv(id, GL2ES2.GL_INFO_LOG_LENGTH, iVal); + gl.getGL2ES2().glGetShaderiv(shaderId, GL2ES2.GL_INFO_LOG_LENGTH, iVal); } } final int length = iVal.get(0); @@ -529,10 +603,10 @@ public abstract class JoglShaderObjectsStateUtil { infoLog = BufferUtils.createByteBuffer(length); } if (gl.isGL2()) { - gl.getGL2().glGetInfoLogARB(id, infoLog.limit(), iVal, infoLog); + gl.getGL2().glGetInfoLogARB(shaderId, infoLog.limit(), iVal, infoLog); } else { if (gl.isGL2ES2()) { - gl.getGL2ES2().glGetProgramInfoLog(id, infoLog.limit(), iVal, infoLog); + gl.getGL2ES2().glGetShaderInfoLog(shaderId, infoLog.limit(), iVal, infoLog); } } diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglShadingStateUtil.java b/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglShadingStateUtil.java index 426befb..69dbe4a 100644 --- a/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglShadingStateUtil.java +++ b/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglShadingStateUtil.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2008-2010 Ardor Labs, Inc. + * Copyright (c) 2008-2014 Ardor Labs, Inc. * * This file is part of Ardor3D. * @@ -10,9 +10,9 @@ package com.ardor3d.scene.state.jogl; -import javax.media.opengl.GL; -import javax.media.opengl.GLContext; -import javax.media.opengl.fixedfunc.GLLightingFunc; +import com.jogamp.opengl.GL; +import com.jogamp.opengl.GLContext; +import com.jogamp.opengl.fixedfunc.GLLightingFunc; import com.ardor3d.renderer.ContextManager; import com.ardor3d.renderer.RenderContext; @@ -36,7 +36,9 @@ public abstract class JoglShadingStateUtil { final int toApply = state.isEnabled() ? getGLShade(state.getShadingMode()) : GLLightingFunc.GL_SMOOTH; // only apply if we're different. Update record to reflect any changes. if (!record.isValid() || toApply != record.lastShade) { - gl.getGL2().glShadeModel(toApply); + if (gl.isGL2ES1()) { + gl.getGL2ES1().glShadeModel(toApply); + } record.lastShade = toApply; } diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglStencilStateUtil.java b/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglStencilStateUtil.java index d624b60..9af1096 100644 --- a/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglStencilStateUtil.java +++ b/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglStencilStateUtil.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2008-2010 Ardor Labs, Inc. + * Copyright (c) 2008-2014 Ardor Labs, Inc. * * This file is part of Ardor3D. * @@ -10,9 +10,9 @@ package com.ardor3d.scene.state.jogl; -import javax.media.opengl.GL; -import javax.media.opengl.GL2; -import javax.media.opengl.GLContext; +import com.jogamp.opengl.GL; +import com.jogamp.opengl.GL2; +import com.jogamp.opengl.GLContext; import com.ardor3d.renderer.ContextCapabilities; import com.ardor3d.renderer.ContextManager; @@ -38,7 +38,9 @@ public abstract class JoglStencilStateUtil { setEnabled(state.isEnabled(), caps.isTwoSidedStencilSupported() ? state.isUseTwoSided() : false, record, caps); if (state.isEnabled()) { if (state.isUseTwoSided() && caps.isTwoSidedStencilSupported()) { - gl.getGL2().glActiveStencilFaceEXT(GL.GL_BACK); + if (gl.isGL2()) { + gl.getGL2().glActiveStencilFaceEXT(GL.GL_BACK); + } applyMask(state.getStencilWriteMaskBack(), record, 2); applyFunc(getGLStencilFunction(state.getStencilFunctionBack()), state.getStencilReferenceBack(), state.getStencilFuncMaskBack(), record, 2); @@ -46,7 +48,9 @@ public abstract class JoglStencilStateUtil { getGLStencilOp(state.getStencilOpZFailBack(), caps), getGLStencilOp(state.getStencilOpZPassBack(), caps), record, 2); - gl.getGL2().glActiveStencilFaceEXT(GL.GL_FRONT); + if (gl.isGL2()) { + gl.getGL2().glActiveStencilFaceEXT(GL.GL_FRONT); + } applyMask(state.getStencilWriteMaskFront(), record, 1); applyFunc(getGLStencilFunction(state.getStencilFunctionFront()), state.getStencilReferenceFront(), state.getStencilFuncMaskFront(), record, 1); diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglTextureStateUtil.java b/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglTextureStateUtil.java index 63031ab..4aa1ad6 100644 --- a/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglTextureStateUtil.java +++ b/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglTextureStateUtil.java @@ -1,9 +1,9 @@ /** - * Copyright (c) 2008-2012 Ardor Labs, Inc. + * Copyright (c) 2008-2014 Ardor Labs, Inc. * * This file is part of Ardor3D. * - * Ardor3D is free software: you can redistribute it and/or modify it + * Ardor3D is free software: you can redistribute it and/or modify it * under the terms of its license which may be found in the accompanying * LICENSE file or at <http://www.ardor3d.com/LICENSE>. */ @@ -15,18 +15,6 @@ import java.nio.IntBuffer; import java.util.Collection; import java.util.logging.Logger; -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.GLContext; -import javax.media.opengl.GLDrawable; -import javax.media.opengl.GLException; -import javax.media.opengl.fixedfunc.GLMatrixFunc; -import javax.media.opengl.glu.GLU; - import com.ardor3d.image.Image; import com.ardor3d.image.Texture; import com.ardor3d.image.Texture.ApplyMode; @@ -64,10 +52,23 @@ import com.ardor3d.util.TextureManager; import com.ardor3d.util.geom.BufferUtils; import com.ardor3d.util.stat.StatCollector; import com.ardor3d.util.stat.StatType; +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.GLContext; +import com.jogamp.opengl.GLDrawable; +import com.jogamp.opengl.GLException; +import com.jogamp.opengl.fixedfunc.GLMatrixFunc; +import com.jogamp.opengl.glu.GLU; public class JoglTextureStateUtil { private static final Logger logger = Logger.getLogger(JoglTextureStateUtil.class.getName()); + private static GLU _glu; + public final static void load(final Texture texture, final int unit) { if (texture == null) { return; @@ -130,7 +131,9 @@ public class JoglTextureStateUtil { final Texture.Type type = texture.getType(); final GL gl = GLContext.getCurrentGL(); - final GLU glu = GLU.createGLU(gl); + if (_glu == null) { + _glu = GLU.createGLU(gl); + } // bind our texture id to this unit. doTextureBind(texture, unit, false); @@ -184,25 +187,30 @@ public class JoglTextureStateUtil { } logger.warning("Rescaling image to " + w + " x " + h + " !!!"); - // must rescale image to get "top" mipmap texture image - final int pixFormat = JoglTextureUtil.getGLPixelFormat(image.getDataFormat()); - final int pixDataType = JoglTextureUtil.getGLPixelDataType(image.getDataType()); - final int bpp = ImageUtils.getPixelByteSize(image.getDataFormat(), image.getDataType()); - final ByteBuffer scaledImage = BufferUtils.createByteBuffer((w + 4) * h * bpp); - // ensure the buffer is ready for reading - image.getData(0).rewind(); - final int error = glu.gluScaleImage(pixFormat, actualWidth, actualHeight, pixDataType, - image.getData(0), w, h, pixDataType, scaledImage); - if (error != 0) { - final int errorCode = gl.glGetError(); - if (errorCode != GL.GL_NO_ERROR) { - throw new GLException(glu.gluErrorString(errorCode)); + // FIXME workaround for the bug 1045: https://jogamp.org/bugzilla/show_bug.cgi?id=1045 + if (gl.isGL2() || gl.isGL2ES1()) { + // must rescale image to get "top" mipmap texture image + final int pixFormat = JoglTextureUtil.getGLPixelFormat(image.getDataFormat()); + final int pixDataType = JoglTextureUtil.getGLPixelDataType(image.getDataType()); + final int bpp = ImageUtils.getPixelByteSize(image.getDataFormat(), image.getDataType()); + final ByteBuffer scaledImage = BufferUtils.createByteBuffer((w + 4) * h * bpp); + // ensure the buffer is ready for reading + image.getData(0).rewind(); + final int error = _glu.gluScaleImage(pixFormat, actualWidth, actualHeight, pixDataType, + image.getData(0), w, h, pixDataType, scaledImage); + if (error != 0) { + final int errorCode = gl.glGetError(); + if (errorCode != GL.GL_NO_ERROR) { + throw new GLException(_glu.gluErrorString(errorCode)); + } } - } - image.setWidth(w); - image.setHeight(h); - image.setData(scaledImage); + image.setWidth(w); + image.setHeight(h); + image.setData(scaledImage); + } else { + logger.warning("GLU cannot rescale the image"); + } } if (!texture.getMinificationFilter().usesMipMapLevels() && !texture.getTextureStoreFormat().isCompressed()) { @@ -218,17 +226,20 @@ public class JoglTextureStateUtil { gl.glTexImage2D(GL.GL_TEXTURE_2D, 0, JoglTextureUtil.getGLInternalFormat(texture.getTextureStoreFormat()), image.getWidth(), image.getHeight(), hasBorder ? 1 : 0, - JoglTextureUtil.getGLPixelFormat(image.getDataFormat()), - JoglTextureUtil.getGLPixelDataType(image.getDataType()), image.getData(0)); + JoglTextureUtil.getGLPixelFormat(image.getDataFormat()), + JoglTextureUtil.getGLPixelDataType(image.getDataType()), image.getData(0)); break; case OneDimensional: // ensure the buffer is ready for reading image.getData(0).rewind(); // send top level to card - gl.getGL2GL3().glTexImage1D(GL2GL3.GL_TEXTURE_1D, 0, - JoglTextureUtil.getGLInternalFormat(texture.getTextureStoreFormat()), image.getWidth(), - hasBorder ? 1 : 0, JoglTextureUtil.getGLPixelFormat(image.getDataFormat()), - JoglTextureUtil.getGLPixelDataType(image.getDataType()), image.getData(0)); + if (gl.isGL2GL3()) { + gl.getGL2GL3().glTexImage1D(GL2GL3.GL_TEXTURE_1D, 0, + JoglTextureUtil.getGLInternalFormat(texture.getTextureStoreFormat()), + image.getWidth(), hasBorder ? 1 : 0, + JoglTextureUtil.getGLPixelFormat(image.getDataFormat()), + JoglTextureUtil.getGLPixelDataType(image.getDataType()), image.getData(0)); + } break; case ThreeDimensional: if (caps.isTexture3DSupported()) { @@ -258,8 +269,8 @@ public class JoglTextureStateUtil { gl.getGL2GL3().glTexImage3D(GL2ES2.GL_TEXTURE_3D, 0, JoglTextureUtil.getGLInternalFormat(texture.getTextureStoreFormat()), image.getWidth(), image.getHeight(), image.getDepth(), hasBorder ? 1 : 0, - JoglTextureUtil.getGLPixelFormat(image.getDataFormat()), - JoglTextureUtil.getGLPixelDataType(image.getDataType()), data); + JoglTextureUtil.getGLPixelFormat(image.getDataFormat()), + JoglTextureUtil.getGLPixelDataType(image.getDataType()), data); } else { logger.warning("This card does not support Texture3D."); } @@ -275,9 +286,9 @@ public class JoglTextureStateUtil { gl.glTexImage2D(getGLCubeMapFace(face), 0, JoglTextureUtil.getGLInternalFormat(texture.getTextureStoreFormat()), image.getWidth(), image.getWidth(), hasBorder ? 1 : 0, - JoglTextureUtil.getGLPixelFormat(image.getDataFormat()), - JoglTextureUtil.getGLPixelDataType(image.getDataType()), - image.getData(face.ordinal())); + JoglTextureUtil.getGLPixelFormat(image.getDataFormat()), + JoglTextureUtil.getGLPixelDataType(image.getDataType()), + image.getData(face.ordinal())); } } else { logger.warning("This card does not support Cubemaps."); @@ -298,7 +309,12 @@ public class JoglTextureStateUtil { if (caps.isAutomaticMipmapsSupported()) { // Flag the card to generate mipmaps - gl.glTexParameteri(getGLType(type), GL2ES1.GL_GENERATE_MIPMAP, GL.GL_TRUE); + if (gl.isGL2ES1()) { + final int glType = getGLType(texture.getType()); + if (glType != GL.GL_INVALID_ENUM) { + gl.glTexParameteri(glType, GL2ES1.GL_GENERATE_MIPMAP, GL.GL_TRUE); + } + } } switch (type) { @@ -310,15 +326,18 @@ public class JoglTextureStateUtil { gl.glTexImage2D(GL.GL_TEXTURE_2D, 0, JoglTextureUtil.getGLInternalFormat(texture.getTextureStoreFormat()), image.getWidth(), image.getHeight(), hasBorder ? 1 : 0, - JoglTextureUtil.getGLPixelFormat(image.getDataFormat()), - JoglTextureUtil.getGLPixelDataType(image.getDataType()), image.getData(0)); + JoglTextureUtil.getGLPixelFormat(image.getDataFormat()), + JoglTextureUtil.getGLPixelDataType(image.getDataType()), image.getData(0)); } else { - // send to card - glu.gluBuild2DMipmaps(GL.GL_TEXTURE_2D, - JoglTextureUtil.getGLInternalFormat(texture.getTextureStoreFormat()), - image.getWidth(), image.getHeight(), - JoglTextureUtil.getGLPixelFormat(image.getDataFormat()), - JoglTextureUtil.getGLPixelDataType(image.getDataType()), image.getData(0)); + // FIXME workaround for the bug 1045: https://jogamp.org/bugzilla/show_bug.cgi?id=1045 + if (gl.isGL2() /* || gl.isGL2ES1() */) { + // send to card + _glu.gluBuild2DMipmaps(GL.GL_TEXTURE_2D, + JoglTextureUtil.getGLInternalFormat(texture.getTextureStoreFormat()), + image.getWidth(), image.getHeight(), + JoglTextureUtil.getGLPixelFormat(image.getDataFormat()), + JoglTextureUtil.getGLPixelDataType(image.getDataType()), image.getData(0)); + } } break; case OneDimensional: @@ -326,11 +345,13 @@ public class JoglTextureStateUtil { image.getData(0).rewind(); if (caps.isAutomaticMipmapsSupported()) { // send top level to card - gl.getGL2GL3().glTexImage1D(GL2GL3.GL_TEXTURE_1D, 0, - JoglTextureUtil.getGLInternalFormat(texture.getTextureStoreFormat()), - image.getWidth(), hasBorder ? 1 : 0, - JoglTextureUtil.getGLPixelFormat(image.getDataFormat()), - JoglTextureUtil.getGLPixelDataType(image.getDataType()), image.getData(0)); + if (gl.isGL2GL3()) { + gl.getGL2GL3().glTexImage1D(GL2GL3.GL_TEXTURE_1D, 0, + JoglTextureUtil.getGLInternalFormat(texture.getTextureStoreFormat()), + image.getWidth(), hasBorder ? 1 : 0, + JoglTextureUtil.getGLPixelFormat(image.getDataFormat()), + JoglTextureUtil.getGLPixelDataType(image.getDataType()), image.getData(0)); + } } else { // Note: JOGL's GLU class does not support // gluBuild1DMipmaps. @@ -368,8 +389,8 @@ public class JoglTextureStateUtil { gl.getGL2GL3().glTexImage3D(GL2ES2.GL_TEXTURE_3D, 0, JoglTextureUtil.getGLInternalFormat(texture.getTextureStoreFormat()), image.getWidth(), image.getHeight(), image.getDepth(), hasBorder ? 1 : 0, - JoglTextureUtil.getGLPixelFormat(image.getDataFormat()), - JoglTextureUtil.getGLPixelDataType(image.getDataType()), data); + JoglTextureUtil.getGLPixelFormat(image.getDataFormat()), + JoglTextureUtil.getGLPixelDataType(image.getDataType()), data); } else { // Note: JOGL's GLU class does not support // gluBuild3DMipmaps. @@ -393,21 +414,24 @@ public class JoglTextureStateUtil { gl.glTexImage2D(getGLCubeMapFace(face), 0, JoglTextureUtil.getGLInternalFormat(texture.getTextureStoreFormat()), image.getWidth(), image.getWidth(), hasBorder ? 1 : 0, - JoglTextureUtil.getGLPixelFormat(image.getDataFormat()), - JoglTextureUtil.getGLPixelDataType(image.getDataType()), - image.getData(face.ordinal())); + JoglTextureUtil.getGLPixelFormat(image.getDataFormat()), + JoglTextureUtil.getGLPixelDataType(image.getDataType()), + image.getData(face.ordinal())); } } else { - for (final TextureCubeMap.Face face : TextureCubeMap.Face.values()) { - // ensure the buffer is ready for reading - image.getData(face.ordinal()).rewind(); - // send to card - glu.gluBuild2DMipmaps(getGLCubeMapFace(face), - JoglTextureUtil.getGLInternalFormat(texture.getTextureStoreFormat()), - image.getWidth(), image.getWidth(), - JoglTextureUtil.getGLPixelFormat(image.getDataFormat()), - JoglTextureUtil.getGLPixelDataType(image.getDataType()), - image.getData(face.ordinal())); + // FIXME workaround for the bug 1045: https://jogamp.org/bugzilla/show_bug.cgi?id=1045 + if (gl.isGL2() /* || gl.isGL2ES1() */) { + for (final TextureCubeMap.Face face : TextureCubeMap.Face.values()) { + // ensure the buffer is ready for reading + image.getData(face.ordinal()).rewind(); + // send to card + _glu.gluBuild2DMipmaps(getGLCubeMapFace(face), + JoglTextureUtil.getGLInternalFormat(texture.getTextureStoreFormat()), + image.getWidth(), image.getWidth(), + JoglTextureUtil.getGLPixelFormat(image.getDataFormat()), + JoglTextureUtil.getGLPixelDataType(image.getDataType()), + image.getData(face.ordinal())); + } } } } else { @@ -463,8 +487,8 @@ public class JoglTextureStateUtil { gl.glTexImage2D(getGLCubeMapFace(face), m, JoglTextureUtil.getGLInternalFormat(texture.getTextureStoreFormat()), width, height, hasBorder ? 1 : 0, - JoglTextureUtil.getGLPixelFormat(image.getDataFormat()), - JoglTextureUtil.getGLPixelDataType(image.getDataType()), data); + JoglTextureUtil.getGLPixelFormat(image.getDataFormat()), + JoglTextureUtil.getGLPixelDataType(image.getDataType()), data); } pos += mipSizes[m]; } @@ -490,10 +514,14 @@ public class JoglTextureStateUtil { gl.glTexParameteri(GL.GL_TEXTURE_2D, GL2ES3.GL_TEXTURE_MAX_LEVEL, max - 1); break; case ThreeDimensional: - gl.glTexParameteri(GL2ES2.GL_TEXTURE_3D, GL2ES3.GL_TEXTURE_MAX_LEVEL, max - 1); + if (gl.isGL2ES2()) { + gl.glTexParameteri(GL2ES2.GL_TEXTURE_3D, GL2ES3.GL_TEXTURE_MAX_LEVEL, max - 1); + } break; case OneDimensional: - gl.glTexParameteri(GL2GL3.GL_TEXTURE_1D, GL2ES3.GL_TEXTURE_MAX_LEVEL, max - 1); + if (gl.isGL2GL3()) { + gl.glTexParameteri(GL2GL3.GL_TEXTURE_1D, GL2ES3.GL_TEXTURE_MAX_LEVEL, max - 1); + } break; case CubeMap: break; @@ -549,36 +577,44 @@ public class JoglTextureStateUtil { gl.glTexImage2D(GL.GL_TEXTURE_2D, m, JoglTextureUtil.getGLInternalFormat(texture.getTextureStoreFormat()), width, height, hasBorder ? 1 : 0, - JoglTextureUtil.getGLPixelFormat(image.getDataFormat()), - JoglTextureUtil.getGLPixelDataType(image.getDataType()), data); + JoglTextureUtil.getGLPixelFormat(image.getDataFormat()), + JoglTextureUtil.getGLPixelDataType(image.getDataType()), data); } break; case OneDimensional: if (texture.getTextureStoreFormat().isCompressed()) { - gl.getGL2GL3().glCompressedTexImage1D(GL2GL3.GL_TEXTURE_1D, m, - JoglTextureUtil.getGLInternalFormat(texture.getTextureStoreFormat()), - width, hasBorder ? 1 : 0, mipSizes[m], data); + if (gl.isGL2GL3()) { + gl.getGL2GL3().glCompressedTexImage1D(GL2GL3.GL_TEXTURE_1D, m, + JoglTextureUtil.getGLInternalFormat(texture.getTextureStoreFormat()), + width, hasBorder ? 1 : 0, mipSizes[m], data); + } } else { - gl.getGL2GL3().glTexImage1D(GL2GL3.GL_TEXTURE_1D, m, - JoglTextureUtil.getGLInternalFormat(texture.getTextureStoreFormat()), - width, hasBorder ? 1 : 0, - JoglTextureUtil.getGLPixelFormat(image.getDataFormat()), - JoglTextureUtil.getGLPixelDataType(image.getDataType()), data); + if (gl.isGL2GL3()) { + gl.getGL2GL3().glTexImage1D(GL2GL3.GL_TEXTURE_1D, m, + JoglTextureUtil.getGLInternalFormat(texture.getTextureStoreFormat()), + width, hasBorder ? 1 : 0, + JoglTextureUtil.getGLPixelFormat(image.getDataFormat()), + JoglTextureUtil.getGLPixelDataType(image.getDataType()), data); + } } break; case ThreeDimensional: final int depth = Math.max(1, image.getDepth() >> m); // already checked for support above... if (texture.getTextureStoreFormat().isCompressed()) { - gl.getGL2ES2().glCompressedTexImage3D(GL2ES2.GL_TEXTURE_3D, m, - JoglTextureUtil.getGLInternalFormat(texture.getTextureStoreFormat()), - width, height, depth, hasBorder ? 1 : 0, mipSizes[m], data); + if (gl.isGL2ES2()) { + gl.getGL2ES2().glCompressedTexImage3D(GL2ES2.GL_TEXTURE_3D, m, + JoglTextureUtil.getGLInternalFormat(texture.getTextureStoreFormat()), + width, height, depth, hasBorder ? 1 : 0, mipSizes[m], data); + } } else { - gl.getGL2ES2().glTexImage3D(GL2ES2.GL_TEXTURE_3D, m, - JoglTextureUtil.getGLInternalFormat(texture.getTextureStoreFormat()), - width, height, depth, hasBorder ? 1 : 0, - JoglTextureUtil.getGLPixelFormat(image.getDataFormat()), - JoglTextureUtil.getGLPixelDataType(image.getDataType()), data); + if (gl.isGL2ES2()) { + gl.getGL2ES2().glTexImage3D(GL2ES2.GL_TEXTURE_3D, m, + JoglTextureUtil.getGLInternalFormat(texture.getTextureStoreFormat()), + width, height, depth, hasBorder ? 1 : 0, + JoglTextureUtil.getGLPixelFormat(image.getDataFormat()), + JoglTextureUtil.getGLPixelDataType(image.getDataType()), data); + } } break; case CubeMap: @@ -618,7 +654,9 @@ public class JoglTextureStateUtil { final int glHint = JoglTextureUtil.getPerspHint(state.getCorrectionType()); if (!record.isValid() || record.hint != glHint) { // set up correction mode - gl.glHint(GL2ES1.GL_PERSPECTIVE_CORRECTION_HINT, glHint); + if (gl.isGL2ES1()) { + gl.glHint(GL2ES1.GL_PERSPECTIVE_CORRECTION_HINT, glHint); + } record.hint = glHint; } @@ -685,7 +723,10 @@ public class JoglTextureStateUtil { // texture already exists in OpenGL, just bind it if needed if (!unitRecord.isValid() || unitRecord.boundTexture != textureId || fbo) { checkAndSetUnit(i, record, caps); - gl.glBindTexture(getGLType(type), textureId); + final int glType = getGLType(type); + if (glType != GL.GL_INVALID_ENUM) { + gl.glBindTexture(glType, textureId); + } if (Constants.stats) { StatCollector.addStat(StatType.STAT_TEXTURE_BINDS, 1); } @@ -712,7 +753,12 @@ public class JoglTextureStateUtil { // Enable 2D texturing on this unit if not enabled. if (!unitRecord.isValid() || !unitRecord.enabled[type.ordinal()]) { checkAndSetUnit(i, record, caps); - gl.glEnable(getGLType(type)); + final int glType = getGLType(type); + if (glType != GL.GL_INVALID_ENUM) { + if (!gl.isGLES2()) { + gl.glEnable(glType); + } + } unitRecord.enabled[type.ordinal()] = true; } @@ -805,7 +851,9 @@ public class JoglTextureStateUtil { if (!unitRecord.isValid() || unitRecord.enabled[Type.OneDimensional.ordinal()]) { // Check we are in the right unit checkAndSetUnit(unit, record, caps); - gl.glDisable(GL2GL3.GL_TEXTURE_1D); + if (gl.isGL2GL3()) { + gl.glDisable(GL2GL3.GL_TEXTURE_1D); + } unitRecord.enabled[Type.OneDimensional.ordinal()] = false; } } @@ -844,7 +892,9 @@ public class JoglTextureStateUtil { if (!unitRecord.isValid() || unitRecord.enabled[Type.OneDimensional.ordinal()]) { // Check we are in the right unit checkAndSetUnit(unit, record, caps); - gl.glDisable(GL2GL3.GL_TEXTURE_1D); + if (gl.isGL2GL3()) { + gl.glDisable(GL2GL3.GL_TEXTURE_1D); + } unitRecord.enabled[Type.OneDimensional.ordinal()] = false; } @@ -898,8 +948,10 @@ public class JoglTextureStateUtil { checkAndSetUnit(unit, record, caps); checked = true; } - gl.getGL2ES1().glTexEnvf(GL2ES1.GL_TEXTURE_ENV, GL2ES1.GL_RGB_SCALE, - texture.getCombineScaleRGB().floatValue()); + if (gl.isGL2ES1()) { + gl.getGL2ES1().glTexEnvf(GL2ES1.GL_TEXTURE_ENV, GL2ES1.GL_RGB_SCALE, + texture.getCombineScaleRGB().floatValue()); + } unitRecord.envRGBScale = texture.getCombineScaleRGB(); } // Then Alpha Combine scale if (!unitRecord.isValid() || unitRecord.envAlphaScale != texture.getCombineScaleAlpha()) { @@ -907,8 +959,10 @@ public class JoglTextureStateUtil { checkAndSetUnit(unit, record, caps); checked = true; } - gl.getGL2ES1().glTexEnvf(GL2ES1.GL_TEXTURE_ENV, GL2ES1.GL_ALPHA_SCALE, - texture.getCombineScaleAlpha().floatValue()); + if (gl.isGL2ES1()) { + gl.getGL2ES1().glTexEnvf(GL2ES1.GL_TEXTURE_ENV, GL2ES1.GL_ALPHA_SCALE, + texture.getCombineScaleAlpha().floatValue()); + } unitRecord.envAlphaScale = texture.getCombineScaleAlpha(); } @@ -919,8 +973,10 @@ public class JoglTextureStateUtil { checkAndSetUnit(unit, record, caps); checked = true; } - gl.getGL2ES1().glTexEnvi(GL2ES1.GL_TEXTURE_ENV, GL2ES1.GL_COMBINE_RGB, - JoglTextureUtil.getGLCombineFuncRGB(rgbCombineFunc)); + if (gl.isGL2ES1()) { + gl.getGL2ES1().glTexEnvi(GL2ES1.GL_TEXTURE_ENV, GL2ES1.GL_COMBINE_RGB, + JoglTextureUtil.getGLCombineFuncRGB(rgbCombineFunc)); + } unitRecord.rgbCombineFunc = rgbCombineFunc; } @@ -930,8 +986,10 @@ public class JoglTextureStateUtil { checkAndSetUnit(unit, record, caps); checked = true; } - gl.getGL2ES1().glTexEnvi(GL2ES1.GL_TEXTURE_ENV, GL2.GL_SOURCE0_RGB, - JoglTextureUtil.getGLCombineSrc(combSrcRGB)); + if (gl.isGL2ES1()) { + gl.getGL2ES1().glTexEnvi(GL2ES1.GL_TEXTURE_ENV, GL2.GL_SOURCE0_RGB, + JoglTextureUtil.getGLCombineSrc(combSrcRGB)); + } unitRecord.combSrcRGB0 = combSrcRGB; } @@ -941,8 +999,10 @@ public class JoglTextureStateUtil { checkAndSetUnit(unit, record, caps); checked = true; } - gl.getGL2ES1().glTexEnvi(GL2ES1.GL_TEXTURE_ENV, GL2ES1.GL_OPERAND0_RGB, - JoglTextureUtil.getGLCombineOpRGB(combOpRGB)); + if (gl.isGL2ES1()) { + gl.getGL2ES1().glTexEnvi(GL2ES1.GL_TEXTURE_ENV, GL2ES1.GL_OPERAND0_RGB, + JoglTextureUtil.getGLCombineOpRGB(combOpRGB)); + } unitRecord.combOpRGB0 = combOpRGB; } @@ -955,8 +1015,10 @@ public class JoglTextureStateUtil { checkAndSetUnit(unit, record, caps); checked = true; } - gl.getGL2ES1().glTexEnvi(GL2ES1.GL_TEXTURE_ENV, GL2.GL_SOURCE1_RGB, - JoglTextureUtil.getGLCombineSrc(combSrcRGB)); + if (gl.isGL2ES1()) { + gl.getGL2ES1().glTexEnvi(GL2ES1.GL_TEXTURE_ENV, GL2.GL_SOURCE1_RGB, + JoglTextureUtil.getGLCombineSrc(combSrcRGB)); + } unitRecord.combSrcRGB1 = combSrcRGB; } @@ -966,8 +1028,10 @@ public class JoglTextureStateUtil { checkAndSetUnit(unit, record, caps); checked = true; } - gl.getGL2ES1().glTexEnvi(GL2ES1.GL_TEXTURE_ENV, GL2ES1.GL_OPERAND1_RGB, - JoglTextureUtil.getGLCombineOpRGB(combOpRGB)); + if (gl.isGL2ES1()) { + gl.getGL2ES1().glTexEnvi(GL2ES1.GL_TEXTURE_ENV, GL2ES1.GL_OPERAND1_RGB, + JoglTextureUtil.getGLCombineOpRGB(combOpRGB)); + } unitRecord.combOpRGB1 = combOpRGB; } @@ -980,8 +1044,10 @@ public class JoglTextureStateUtil { checkAndSetUnit(unit, record, caps); checked = true; } - gl.getGL2ES1().glTexEnvi(GL2ES1.GL_TEXTURE_ENV, GL2.GL_SOURCE2_RGB, - JoglTextureUtil.getGLCombineSrc(combSrcRGB)); + if (gl.isGL2ES1()) { + gl.getGL2ES1().glTexEnvi(GL2ES1.GL_TEXTURE_ENV, GL2.GL_SOURCE2_RGB, + JoglTextureUtil.getGLCombineSrc(combSrcRGB)); + } unitRecord.combSrcRGB2 = combSrcRGB; } @@ -991,8 +1057,10 @@ public class JoglTextureStateUtil { checkAndSetUnit(unit, record, caps); checked = true; } - gl.getGL2ES1().glTexEnvi(GL2ES1.GL_TEXTURE_ENV, GL2ES1.GL_OPERAND2_RGB, - JoglTextureUtil.getGLCombineOpRGB(combOpRGB)); + if (gl.isGL2ES1()) { + gl.getGL2ES1().glTexEnvi(GL2ES1.GL_TEXTURE_ENV, GL2ES1.GL_OPERAND2_RGB, + JoglTextureUtil.getGLCombineOpRGB(combOpRGB)); + } unitRecord.combOpRGB2 = combOpRGB; } @@ -1006,8 +1074,10 @@ public class JoglTextureStateUtil { checkAndSetUnit(unit, record, caps); checked = true; } - gl.getGL2ES1().glTexEnvi(GL2ES1.GL_TEXTURE_ENV, GL2ES1.GL_COMBINE_ALPHA, - JoglTextureUtil.getGLCombineFuncAlpha(alphaCombineFunc)); + if (gl.isGL2ES1()) { + gl.getGL2ES1().glTexEnvi(GL2ES1.GL_TEXTURE_ENV, GL2ES1.GL_COMBINE_ALPHA, + JoglTextureUtil.getGLCombineFuncAlpha(alphaCombineFunc)); + } unitRecord.alphaCombineFunc = alphaCombineFunc; } @@ -1017,8 +1087,10 @@ public class JoglTextureStateUtil { checkAndSetUnit(unit, record, caps); checked = true; } - gl.getGL2ES1().glTexEnvi(GL2ES1.GL_TEXTURE_ENV, GL2.GL_SOURCE0_ALPHA, - JoglTextureUtil.getGLCombineSrc(combSrcAlpha)); + if (gl.isGL2ES1()) { + gl.getGL2ES1().glTexEnvi(GL2ES1.GL_TEXTURE_ENV, GL2.GL_SOURCE0_ALPHA, + JoglTextureUtil.getGLCombineSrc(combSrcAlpha)); + } unitRecord.combSrcAlpha0 = combSrcAlpha; } @@ -1028,8 +1100,10 @@ public class JoglTextureStateUtil { checkAndSetUnit(unit, record, caps); checked = true; } - gl.getGL2ES1().glTexEnvi(GL2ES1.GL_TEXTURE_ENV, GL2ES1.GL_OPERAND0_ALPHA, - JoglTextureUtil.getGLCombineOpAlpha(combOpAlpha)); + if (gl.isGL2ES1()) { + gl.getGL2ES1().glTexEnvi(GL2ES1.GL_TEXTURE_ENV, GL2ES1.GL_OPERAND0_ALPHA, + JoglTextureUtil.getGLCombineOpAlpha(combOpAlpha)); + } unitRecord.combOpAlpha0 = combOpAlpha; } @@ -1042,8 +1116,10 @@ public class JoglTextureStateUtil { checkAndSetUnit(unit, record, caps); checked = true; } - gl.getGL2ES1().glTexEnvi(GL2ES1.GL_TEXTURE_ENV, GL2.GL_SOURCE1_ALPHA, - JoglTextureUtil.getGLCombineSrc(combSrcAlpha)); + if (gl.isGL2ES1()) { + gl.getGL2ES1().glTexEnvi(GL2ES1.GL_TEXTURE_ENV, GL2.GL_SOURCE1_ALPHA, + JoglTextureUtil.getGLCombineSrc(combSrcAlpha)); + } unitRecord.combSrcAlpha1 = combSrcAlpha; } @@ -1053,8 +1129,10 @@ public class JoglTextureStateUtil { checkAndSetUnit(unit, record, caps); checked = true; } - gl.getGL2ES1().glTexEnvi(GL2ES1.GL_TEXTURE_ENV, GL2ES1.GL_OPERAND1_ALPHA, - JoglTextureUtil.getGLCombineOpAlpha(combOpAlpha)); + if (gl.isGL2ES1()) { + gl.getGL2ES1().glTexEnvi(GL2ES1.GL_TEXTURE_ENV, GL2ES1.GL_OPERAND1_ALPHA, + JoglTextureUtil.getGLCombineOpAlpha(combOpAlpha)); + } unitRecord.combOpAlpha1 = combOpAlpha; } @@ -1067,8 +1145,10 @@ public class JoglTextureStateUtil { checkAndSetUnit(unit, record, caps); checked = true; } - gl.getGL2ES1().glTexEnvi(GL2ES1.GL_TEXTURE_ENV, GL2.GL_SOURCE2_ALPHA, - JoglTextureUtil.getGLCombineSrc(combSrcAlpha)); + if (gl.isGL2ES1()) { + gl.getGL2ES1().glTexEnvi(GL2ES1.GL_TEXTURE_ENV, GL2.GL_SOURCE2_ALPHA, + JoglTextureUtil.getGLCombineSrc(combSrcAlpha)); + } unitRecord.combSrcAlpha2 = combSrcAlpha; } @@ -1078,8 +1158,10 @@ public class JoglTextureStateUtil { checkAndSetUnit(unit, record, caps); checked = true; } - gl.getGL2ES1().glTexEnvi(GL2ES1.GL_TEXTURE_ENV, GL2ES1.GL_OPERAND2_ALPHA, - JoglTextureUtil.getGLCombineOpAlpha(combOpAlpha)); + if (gl.isGL2ES1()) { + gl.getGL2ES1().glTexEnvi(GL2ES1.GL_TEXTURE_ENV, GL2ES1.GL_OPERAND2_ALPHA, + JoglTextureUtil.getGLCombineOpAlpha(combOpAlpha)); + } unitRecord.combOpAlpha2 = combOpAlpha; } } @@ -1092,8 +1174,10 @@ public class JoglTextureStateUtil { if (!unitRecord.isValid() || unitRecord.envMode != mode) { checkAndSetUnit(unit, record, caps); - gl.getGL2ES1().glTexEnvi(GL2ES1.GL_TEXTURE_ENV, GL2ES1.GL_TEXTURE_ENV_MODE, - JoglTextureUtil.getGLEnvMode(mode)); + if (gl.isGL2ES1()) { + gl.getGL2ES1().glTexEnvi(GL2ES1.GL_TEXTURE_ENV, GL2ES1.GL_TEXTURE_ENV_MODE, + JoglTextureUtil.getGLEnvMode(mode)); + } unitRecord.envMode = mode; } } @@ -1107,9 +1191,12 @@ public class JoglTextureStateUtil { checkAndSetUnit(unit, record, caps); TextureRecord.colorBuffer.clear(); TextureRecord.colorBuffer.put(texBlend.getRed()).put(texBlend.getGreen()).put(texBlend.getBlue()) - .put(texBlend.getAlpha()); + .put(texBlend.getAlpha()); TextureRecord.colorBuffer.rewind(); - gl.getGL2ES1().glTexEnvfv(GL2ES1.GL_TEXTURE_ENV, GL2ES1.GL_TEXTURE_ENV_COLOR, TextureRecord.colorBuffer); + if (gl.isGL2ES1()) { + gl.getGL2ES1() + .glTexEnvfv(GL2ES1.GL_TEXTURE_ENV, GL2ES1.GL_TEXTURE_ENV_COLOR, TextureRecord.colorBuffer); + } unitRecord.blendColor.set(texBlend); } } @@ -1123,7 +1210,9 @@ public class JoglTextureStateUtil { .getMaxLodBias(); if (!unitRecord.isValid() || unitRecord.lodBias != bias) { checkAndSetUnit(unit, record, caps); - gl.getGL2ES1().glTexEnvf(GL2.GL_TEXTURE_FILTER_CONTROL, GL2GL3.GL_TEXTURE_LOD_BIAS, bias); + if (gl.isGL2ES1()) { + gl.getGL2ES1().glTexEnvf(GL2.GL_TEXTURE_FILTER_CONTROL, GL2GL3.GL_TEXTURE_LOD_BIAS, bias); + } unitRecord.lodBias = bias; } } @@ -1137,9 +1226,14 @@ public class JoglTextureStateUtil { if (!texRecord.isValid() || !texRecord.borderColor.equals(texBorder)) { TextureRecord.colorBuffer.clear(); TextureRecord.colorBuffer.put(texBorder.getRed()).put(texBorder.getGreen()).put(texBorder.getBlue()) - .put(texBorder.getAlpha()); + .put(texBorder.getAlpha()); TextureRecord.colorBuffer.rewind(); - gl.glTexParameterfv(getGLType(texture.getType()), GL2GL3.GL_TEXTURE_BORDER_COLOR, TextureRecord.colorBuffer); + if (gl.isGL2GL3()) { + final int glType = getGLType(texture.getType()); + if (glType != GL.GL_INVALID_ENUM) { + gl.glTexParameterfv(glType, GL2ES2.GL_TEXTURE_BORDER_COLOR, TextureRecord.colorBuffer); + } + } texRecord.borderColor.set(texBorder); } } @@ -1163,13 +1257,17 @@ public class JoglTextureStateUtil { record.tmp_matrixBuffer.rewind(); texture.getTextureMatrix().toDoubleBuffer(record.tmp_matrixBuffer, true); record.tmp_matrixBuffer.rewind(); - gl.getGL2().glLoadMatrixd(record.tmp_matrixBuffer); - + if (gl.isGL2()) { + gl.getGL2().glLoadMatrixd(record.tmp_matrixBuffer); + } + // FIXME use JoglRendererRecord.getMaxtrixBackend() with float buffers, stop using doubles record.units[unit].identityMatrix = false; } else if (needsReset) { checkAndSetUnit(unit, record, caps); JoglRendererUtil.switchMode(matRecord, GL.GL_TEXTURE); - gl.getGL2().glLoadIdentity(); + if (gl.isGL2()) { + gl.getGL2().glLoadIdentity(); + } record.units[unit].identityMatrix = true; } // Switch back to the modelview matrix for further operations @@ -1190,10 +1288,14 @@ public class JoglTextureStateUtil { if (!unitRecord.isValid() || unitRecord.textureGenSMode != GL2.GL_SPHERE_MAP) { checkAndSetUnit(unit, record, caps); - gl.getGL2().glTexGeni(GL2.GL_S, GL2ES1.GL_TEXTURE_GEN_MODE, GL2.GL_SPHERE_MAP); + if (gl.isGL2()) { + gl.getGL2().glTexGeni(GL2.GL_S, GL2.GL_TEXTURE_GEN_MODE, GL2.GL_SPHERE_MAP); + } unitRecord.textureGenSMode = GL2.GL_SPHERE_MAP; - gl.getGL2().glTexGeni(GL2.GL_T, GL2ES1.GL_TEXTURE_GEN_MODE, GL2.GL_SPHERE_MAP); + if (gl.isGL2()) { + gl.getGL2().glTexGeni(GL2.GL_T, GL2.GL_TEXTURE_GEN_MODE, GL2.GL_SPHERE_MAP); + } unitRecord.textureGenTMode = GL2.GL_SPHERE_MAP; } @@ -1201,33 +1303,45 @@ public class JoglTextureStateUtil { break; case NormalMap: // generate normals based texture coordinates - if (!unitRecord.isValid() || unitRecord.textureGenSMode != GL2ES1.GL_NORMAL_MAP) { + if (!unitRecord.isValid() || unitRecord.textureGenSMode != GL2.GL_NORMAL_MAP) { checkAndSetUnit(unit, record, caps); - gl.getGL2().glTexGeni(GL2.GL_S, GL2ES1.GL_TEXTURE_GEN_MODE, GL2ES1.GL_NORMAL_MAP); - unitRecord.textureGenSMode = GL2ES1.GL_NORMAL_MAP; + if (gl.isGL2()) { + gl.getGL2().glTexGeni(GL2.GL_S, GL2.GL_TEXTURE_GEN_MODE, GL2.GL_NORMAL_MAP); + } + unitRecord.textureGenSMode = GL2.GL_NORMAL_MAP; - gl.getGL2().glTexGeni(GL2.GL_T, GL2ES1.GL_TEXTURE_GEN_MODE, GL2ES1.GL_NORMAL_MAP); - unitRecord.textureGenTMode = GL2ES1.GL_NORMAL_MAP; + if (gl.isGL2()) { + gl.getGL2().glTexGeni(GL2.GL_T, GL2.GL_TEXTURE_GEN_MODE, GL2.GL_NORMAL_MAP); + } + unitRecord.textureGenTMode = GL2.GL_NORMAL_MAP; - gl.getGL2().glTexGeni(GL2.GL_R, GL2ES1.GL_TEXTURE_GEN_MODE, GL2ES1.GL_NORMAL_MAP); - unitRecord.textureGenRMode = GL2ES1.GL_NORMAL_MAP; + if (gl.isGL2()) { + gl.getGL2().glTexGeni(GL2.GL_R, GL2.GL_TEXTURE_GEN_MODE, GL2.GL_NORMAL_MAP); + } + unitRecord.textureGenRMode = GL2.GL_NORMAL_MAP; } setTextureGen(unitRecord, unit, record, caps, true, true, true, false); break; case ReflectionMap: // generate reflection texture coordinates - if (!unitRecord.isValid() || unitRecord.textureGenSMode != GL2ES1.GL_REFLECTION_MAP) { + if (!unitRecord.isValid() || unitRecord.textureGenSMode != GL2.GL_REFLECTION_MAP) { checkAndSetUnit(unit, record, caps); - gl.getGL2ES1().glTexGeni(GL2.GL_S, GL2ES1.GL_TEXTURE_GEN_MODE, GL2ES1.GL_REFLECTION_MAP); - unitRecord.textureGenSMode = GL2ES1.GL_REFLECTION_MAP; + if (gl.isGL2()) { + gl.getGL2().glTexGeni(GL2.GL_S, GL2.GL_TEXTURE_GEN_MODE, GL2.GL_REFLECTION_MAP); + } + unitRecord.textureGenSMode = GL2.GL_REFLECTION_MAP; - gl.getGL2ES1().glTexGeni(GL2.GL_T, GL2ES1.GL_TEXTURE_GEN_MODE, GL2ES1.GL_REFLECTION_MAP); - unitRecord.textureGenTMode = GL2ES1.GL_REFLECTION_MAP; + if (gl.isGL2()) { + gl.getGL2().glTexGeni(GL2.GL_T, GL2.GL_TEXTURE_GEN_MODE, GL2.GL_REFLECTION_MAP); + } + unitRecord.textureGenTMode = GL2.GL_REFLECTION_MAP; - gl.getGL2ES1().glTexGeni(GL2.GL_R, GL2ES1.GL_TEXTURE_GEN_MODE, GL2ES1.GL_REFLECTION_MAP); - unitRecord.textureGenRMode = GL2ES1.GL_REFLECTION_MAP; + if (gl.isGL2()) { + gl.getGL2().glTexGeni(GL2.GL_R, GL2.GL_TEXTURE_GEN_MODE, GL2.GL_REFLECTION_MAP); + } + unitRecord.textureGenRMode = GL2.GL_REFLECTION_MAP; } setTextureGen(unitRecord, unit, record, caps, true, true, true, false); @@ -1238,27 +1352,43 @@ public class JoglTextureStateUtil { // generate eye linear texture coordinates if (!unitRecord.isValid() || unitRecord.textureGenSMode != GL2.GL_EYE_LINEAR) { - gl.getGL2ES1().glTexGeni(GL2.GL_S, GL2ES1.GL_TEXTURE_GEN_MODE, GL2.GL_EYE_LINEAR); + if (gl.isGL2()) { + gl.getGL2().glTexGeni(GL2.GL_S, GL2.GL_TEXTURE_GEN_MODE, GL2.GL_EYE_LINEAR); + } unitRecord.textureGenSMode = GL2.GL_EYE_LINEAR; - gl.getGL2ES1().glTexGeni(GL2.GL_T, GL2ES1.GL_TEXTURE_GEN_MODE, GL2.GL_EYE_LINEAR); + if (gl.isGL2()) { + gl.getGL2().glTexGeni(GL2.GL_T, GL2.GL_TEXTURE_GEN_MODE, GL2.GL_EYE_LINEAR); + } unitRecord.textureGenTMode = GL2.GL_EYE_LINEAR; - gl.getGL2ES1().glTexGeni(GL2.GL_R, GL2ES1.GL_TEXTURE_GEN_MODE, GL2.GL_EYE_LINEAR); + if (gl.isGL2()) { + gl.getGL2().glTexGeni(GL2.GL_R, GL2.GL_TEXTURE_GEN_MODE, GL2.GL_EYE_LINEAR); + } unitRecord.textureGenRMode = GL2.GL_EYE_LINEAR; - gl.getGL2ES1().glTexGeni(GL2.GL_Q, GL2ES1.GL_TEXTURE_GEN_MODE, GL2.GL_EYE_LINEAR); + if (gl.isGL2()) { + gl.getGL2().glTexGeni(GL2.GL_Q, GL2.GL_TEXTURE_GEN_MODE, GL2.GL_EYE_LINEAR); + } unitRecord.textureGenQMode = GL2.GL_EYE_LINEAR; } record.prepPlane(texture.getEnvPlaneS(), TextureStateRecord.DEFAULT_S_PLANE); - gl.getGL2ES1().glTexGenfv(GL2.GL_S, GL2.GL_EYE_PLANE, record.plane); + if (gl.isGL2()) { + gl.getGL2().glTexGenfv(GL2.GL_S, GL2.GL_EYE_PLANE, record.plane); + } record.prepPlane(texture.getEnvPlaneT(), TextureStateRecord.DEFAULT_T_PLANE); - gl.getGL2ES1().glTexGenfv(GL2.GL_T, GL2.GL_EYE_PLANE, record.plane); + if (gl.isGL2()) { + gl.getGL2().glTexGenfv(GL2.GL_T, GL2.GL_EYE_PLANE, record.plane); + } record.prepPlane(texture.getEnvPlaneR(), TextureStateRecord.DEFAULT_R_PLANE); - gl.getGL2ES1().glTexGenfv(GL2.GL_R, GL2.GL_EYE_PLANE, record.plane); + if (gl.isGL2()) { + gl.getGL2().glTexGenfv(GL2.GL_R, GL2.GL_EYE_PLANE, record.plane); + } record.prepPlane(texture.getEnvPlaneQ(), TextureStateRecord.DEFAULT_Q_PLANE); - gl.getGL2ES1().glTexGenfv(GL2.GL_Q, GL2.GL_EYE_PLANE, record.plane); + if (gl.isGL2()) { + gl.getGL2().glTexGenfv(GL2.GL_Q, GL2.GL_EYE_PLANE, record.plane); + } setTextureGen(unitRecord, unit, record, caps, true, true, true, true); break; @@ -1268,27 +1398,43 @@ public class JoglTextureStateUtil { // generate object linear texture coordinates if (!unitRecord.isValid() || unitRecord.textureGenSMode != GL2.GL_OBJECT_LINEAR) { - gl.getGL2ES1().glTexGeni(GL2.GL_S, GL2ES1.GL_TEXTURE_GEN_MODE, GL2.GL_OBJECT_LINEAR); + if (gl.isGL2()) { + gl.getGL2().glTexGeni(GL2.GL_S, GL2.GL_TEXTURE_GEN_MODE, GL2.GL_OBJECT_LINEAR); + } unitRecord.textureGenSMode = GL2.GL_OBJECT_LINEAR; - gl.getGL2ES1().glTexGeni(GL2.GL_T, GL2ES1.GL_TEXTURE_GEN_MODE, GL2.GL_OBJECT_LINEAR); + if (gl.isGL2()) { + gl.getGL2().glTexGeni(GL2.GL_T, GL2.GL_TEXTURE_GEN_MODE, GL2.GL_OBJECT_LINEAR); + } unitRecord.textureGenTMode = GL2.GL_OBJECT_LINEAR; - gl.getGL2ES1().glTexGeni(GL2.GL_R, GL2ES1.GL_TEXTURE_GEN_MODE, GL2.GL_OBJECT_LINEAR); + if (gl.isGL2()) { + gl.getGL2().glTexGeni(GL2.GL_R, GL2.GL_TEXTURE_GEN_MODE, GL2.GL_OBJECT_LINEAR); + } unitRecord.textureGenRMode = GL2.GL_OBJECT_LINEAR; - gl.getGL2ES1().glTexGeni(GL2.GL_Q, GL2ES1.GL_TEXTURE_GEN_MODE, GL2.GL_OBJECT_LINEAR); + if (gl.isGL2()) { + gl.getGL2().glTexGeni(GL2.GL_Q, GL2.GL_TEXTURE_GEN_MODE, GL2.GL_OBJECT_LINEAR); + } unitRecord.textureGenQMode = GL2.GL_OBJECT_LINEAR; } record.prepPlane(texture.getEnvPlaneS(), TextureStateRecord.DEFAULT_S_PLANE); - gl.getGL2ES1().glTexGenfv(GL2.GL_S, GL2.GL_OBJECT_PLANE, record.plane); + if (gl.isGL2()) { + gl.getGL2().glTexGenfv(GL2.GL_S, GL2.GL_OBJECT_PLANE, record.plane); + } record.prepPlane(texture.getEnvPlaneT(), TextureStateRecord.DEFAULT_T_PLANE); - gl.getGL2ES1().glTexGenfv(GL2.GL_T, GL2.GL_OBJECT_PLANE, record.plane); + if (gl.isGL2()) { + gl.getGL2().glTexGenfv(GL2.GL_T, GL2.GL_OBJECT_PLANE, record.plane); + } record.prepPlane(texture.getEnvPlaneR(), TextureStateRecord.DEFAULT_R_PLANE); - gl.getGL2ES1().glTexGenfv(GL2.GL_R, GL2.GL_OBJECT_PLANE, record.plane); + if (gl.isGL2()) { + gl.getGL2().glTexGenfv(GL2.GL_R, GL2.GL_OBJECT_PLANE, record.plane); + } record.prepPlane(texture.getEnvPlaneQ(), TextureStateRecord.DEFAULT_Q_PLANE); - gl.getGL2ES1().glTexGenfv(GL2.GL_Q, GL2.GL_OBJECT_PLANE, record.plane); + if (gl.isGL2()) { + gl.getGL2().glTexGenfv(GL2.GL_Q, GL2.GL_OBJECT_PLANE, record.plane); + } setTextureGen(unitRecord, unit, record, caps, true, true, true, true); break; @@ -1302,58 +1448,89 @@ public class JoglTextureStateUtil { if (!unitRecord.isValid()) { checkAndSetUnit(unit, record, caps); - if (genS) { - gl.glEnable(GL2.GL_TEXTURE_GEN_S); + if (gl.isGL2()) { + gl.glEnable(GL2.GL_TEXTURE_GEN_S); + } } else { - gl.glDisable(GL2.GL_TEXTURE_GEN_S); + if (gl.isGL2()) { + gl.glDisable(GL2.GL_TEXTURE_GEN_S); + } } if (genT) { - gl.glEnable(GL2.GL_TEXTURE_GEN_T); + if (gl.isGL2()) { + gl.glEnable(GL2.GL_TEXTURE_GEN_T); + } } else { - gl.glDisable(GL2.GL_TEXTURE_GEN_T); + if (gl.isGL2()) { + gl.glDisable(GL2.GL_TEXTURE_GEN_T); + } } if (genR) { - gl.glEnable(GL2.GL_TEXTURE_GEN_R); + if (gl.isGL2()) { + gl.glEnable(GL2.GL_TEXTURE_GEN_R); + } } else { - gl.glDisable(GL2.GL_TEXTURE_GEN_R); + if (gl.isGL2()) { + gl.glDisable(GL2.GL_TEXTURE_GEN_R); + } } if (genQ) { - gl.glEnable(GL2.GL_TEXTURE_GEN_Q); + if (gl.isGL2()) { + gl.glEnable(GL2.GL_TEXTURE_GEN_Q); + } } else { - gl.glDisable(GL2.GL_TEXTURE_GEN_Q); + if (gl.isGL2()) { + gl.glDisable(GL2.GL_TEXTURE_GEN_Q); + } } } else { if (genS != unitRecord.textureGenS) { checkAndSetUnit(unit, record, caps); if (genS) { - gl.glEnable(GL2.GL_TEXTURE_GEN_S); + if (gl.isGL2()) { + gl.glEnable(GL2.GL_TEXTURE_GEN_S); + } } else { - gl.glDisable(GL2.GL_TEXTURE_GEN_S); + if (gl.isGL2()) { + gl.glDisable(GL2.GL_TEXTURE_GEN_S); + } } } if (genT != unitRecord.textureGenT) { checkAndSetUnit(unit, record, caps); if (genT) { - gl.glEnable(GL2.GL_TEXTURE_GEN_T); + if (gl.isGL2()) { + gl.glEnable(GL2.GL_TEXTURE_GEN_T); + } } else { - gl.glDisable(GL2.GL_TEXTURE_GEN_T); + if (gl.isGL2()) { + gl.glDisable(GL2.GL_TEXTURE_GEN_T); + } } } if (genR != unitRecord.textureGenR) { checkAndSetUnit(unit, record, caps); if (genR) { - gl.glEnable(GL2.GL_TEXTURE_GEN_R); + if (gl.isGL2()) { + gl.glEnable(GL2.GL_TEXTURE_GEN_R); + } } else { - gl.glDisable(GL2.GL_TEXTURE_GEN_R); + if (gl.isGL2()) { + gl.glDisable(GL2.GL_TEXTURE_GEN_R); + } } } if (genQ != unitRecord.textureGenQ) { checkAndSetUnit(unit, record, caps); if (genQ) { - gl.glEnable(GL2.GL_TEXTURE_GEN_Q); + if (gl.isGL2()) { + gl.glEnable(GL2.GL_TEXTURE_GEN_Q); + } } else { - gl.glDisable(GL2.GL_TEXTURE_GEN_Q); + if (gl.isGL2()) { + gl.glDisable(GL2.GL_TEXTURE_GEN_Q); + } } } } @@ -1382,7 +1559,7 @@ public class JoglTextureStateUtil { /** * Check if the filter settings of this particular texture have been changed and apply as needed. - * + * * @param texture * our texture object * @param texRecord @@ -1400,7 +1577,12 @@ public class JoglTextureStateUtil { // set up magnification filter if (!texRecord.isValid() || texRecord.depthTextureMode != depthMode) { checkAndSetUnit(unit, record, caps); - gl.glTexParameteri(getGLType(type), GL2.GL_DEPTH_TEXTURE_MODE, depthMode); + if (gl.isGL2()) { + final int glType = getGLType(texture.getType()); + if (glType != GL.GL_INVALID_ENUM) { + gl.glTexParameteri(glType, GL2.GL_DEPTH_TEXTURE_MODE, depthMode); + } + } texRecord.depthTextureMode = depthMode; } } @@ -1426,7 +1608,7 @@ public class JoglTextureStateUtil { /** * Check if the filter settings of this particular texture have been changed and apply as needed. - * + * * @param texture * our texture object * @param texRecord @@ -1443,7 +1625,10 @@ public class JoglTextureStateUtil { // set up magnification filter if (!texRecord.isValid() || texRecord.magFilter != magFilter) { checkAndSetUnit(unit, record, caps); - gl.glTexParameteri(getGLType(type), GL.GL_TEXTURE_MAG_FILTER, magFilter); + final int glType = getGLType(texture.getType()); + if (glType != GL.GL_INVALID_ENUM) { + gl.glTexParameteri(glType, GL.GL_TEXTURE_MAG_FILTER, magFilter); + } texRecord.magFilter = magFilter; } @@ -1469,7 +1654,7 @@ public class JoglTextureStateUtil { /** * Check if the wrap mode of this particular texture has been changed and apply as needed. - * + * * @param texture * our texture object * @param texRecord @@ -1490,17 +1675,23 @@ public class JoglTextureStateUtil { if (!texRecord.isValid() || texRecord.wrapS != wrapS) { checkAndSetUnit(unit, record, caps); - gl.glTexParameteri(GL2ES2.GL_TEXTURE_3D, GL.GL_TEXTURE_WRAP_S, wrapS); + if (gl.isGL2ES2()) { + gl.glTexParameteri(GL2ES2.GL_TEXTURE_3D, GL.GL_TEXTURE_WRAP_S, wrapS); + } texRecord.wrapS = wrapS; } if (!texRecord.isValid() || texRecord.wrapT != wrapT) { checkAndSetUnit(unit, record, caps); - gl.glTexParameteri(GL2ES2.GL_TEXTURE_3D, GL.GL_TEXTURE_WRAP_T, wrapT); + if (gl.isGL2ES2()) { + gl.glTexParameteri(GL2ES2.GL_TEXTURE_3D, GL.GL_TEXTURE_WRAP_T, wrapT); + } texRecord.wrapT = wrapT; } if (!texRecord.isValid() || texRecord.wrapR != wrapR) { checkAndSetUnit(unit, record, caps); - gl.glTexParameteri(GL2ES2.GL_TEXTURE_3D, GL2ES2.GL_TEXTURE_WRAP_R, wrapR); + if (gl.isGL2ES2()) { + gl.glTexParameteri(GL2ES2.GL_TEXTURE_3D, GL2ES2.GL_TEXTURE_WRAP_R, wrapR); + } texRecord.wrapR = wrapR; } @@ -1508,7 +1699,7 @@ public class JoglTextureStateUtil { /** * Check if the wrap mode of this particular texture has been changed and apply as needed. - * + * * @param texture * our texture object * @param texRecord @@ -1523,14 +1714,16 @@ public class JoglTextureStateUtil { if (!texRecord.isValid() || texRecord.wrapS != wrapS) { checkAndSetUnit(unit, record, caps); - gl.glTexParameteri(GL2GL3.GL_TEXTURE_1D, GL.GL_TEXTURE_WRAP_S, wrapS); + if (gl.isGL2GL3()) { + gl.glTexParameteri(GL2GL3.GL_TEXTURE_1D, GL.GL_TEXTURE_WRAP_S, wrapS); + } texRecord.wrapS = wrapS; } } /** * Check if the wrap mode of this particular texture has been changed and apply as needed. - * + * * @param texture * our texture object * @param texRecord @@ -1552,7 +1745,7 @@ public class JoglTextureStateUtil { /** * Check if the wrap mode of this particular texture has been changed and apply as needed. - * + * * @param texture * our texture object * @param texRecord @@ -1581,7 +1774,7 @@ public class JoglTextureStateUtil { /** * Check if the wrap mode of this particular texture has been changed and apply as needed. - * + * * @param cubeMap * our texture object * @param texRecord @@ -1685,7 +1878,10 @@ public class JoglTextureStateUtil { checkAndSetUnit(unit, record, caps); final int id = texture.getTextureIdForContext(context.getGlContextRep()); - gl.glBindTexture(getGLType(texture.getType()), id); + final int glType = getGLType(texture.getType()); + if (glType != GL.GL_INVALID_ENUM) { + gl.glBindTexture(glType, id); + } if (Constants.stats) { StatCollector.addStat(StatType.STAT_TEXTURE_BINDS, 1); } @@ -1695,13 +1891,22 @@ public class JoglTextureStateUtil { } public static int getGLType(final Type type) { + final GL gl = GLContext.getCurrentGL(); switch (type) { case TwoDimensional: return GL.GL_TEXTURE_2D; case OneDimensional: - return GL2GL3.GL_TEXTURE_1D; + if (gl.isGL2GL3()) { + return GL2GL3.GL_TEXTURE_1D; + } else { + return GL.GL_INVALID_ENUM; + } case ThreeDimensional: - return GL2ES2.GL_TEXTURE_3D; + if (gl.isGL2ES2()) { + return GL2ES2.GL_TEXTURE_3D; + } else { + return GL.GL_INVALID_ENUM; + } case CubeMap: return GL.GL_TEXTURE_CUBE_MAP; case Rectangle: @@ -1754,7 +1959,7 @@ public class JoglTextureStateUtil { // FALLS THROUGH case BorderClamp: if (caps.isTextureBorderClampSupported()) { - return GL2GL3.GL_CLAMP_TO_BORDER; + return GL2ES2.GL_CLAMP_TO_BORDER; } else { return GL2.GL_CLAMP; } diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglVertexProgramStateUtil.java b/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglVertexProgramStateUtil.java index 727d7ec..e18e68f 100644 --- a/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglVertexProgramStateUtil.java +++ b/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglVertexProgramStateUtil.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2008-2010 Ardor Labs, Inc. + * Copyright (c) 2008-2014 Ardor Labs, Inc. * * This file is part of Ardor3D. * @@ -14,9 +14,9 @@ import java.nio.ByteBuffer; import java.nio.IntBuffer; import java.util.logging.Logger; -import javax.media.opengl.GL; -import javax.media.opengl.GL2; -import javax.media.opengl.GLContext; +import com.jogamp.opengl.GL; +import com.jogamp.opengl.GL2; +import com.jogamp.opengl.GLContext; import com.ardor3d.renderer.ContextCapabilities; import com.ardor3d.renderer.ContextManager; diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglWireframeStateUtil.java b/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglWireframeStateUtil.java index 7172fc0..d30a47f 100644 --- a/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglWireframeStateUtil.java +++ b/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglWireframeStateUtil.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2008-2010 Ardor Labs, Inc. + * Copyright (c) 2008-2014 Ardor Labs, Inc. * * This file is part of Ardor3D. * @@ -10,9 +10,9 @@ package com.ardor3d.scene.state.jogl; -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; import com.ardor3d.renderer.ContextManager; import com.ardor3d.renderer.RenderContext; @@ -58,26 +58,36 @@ public abstract class JoglWireframeStateUtil { if (record.isValid()) { if (frontMode == backMode && (record.frontMode != frontMode || record.backMode != backMode)) { - gl.getGL2GL3().glPolygonMode(GL.GL_FRONT_AND_BACK, frontMode); + if (gl.isGL2GL3()) { + gl.getGL2GL3().glPolygonMode(GL.GL_FRONT_AND_BACK, frontMode); + } record.frontMode = frontMode; record.backMode = backMode; } else if (frontMode != backMode) { if (record.frontMode != frontMode) { - gl.getGL2GL3().glPolygonMode(GL.GL_FRONT, frontMode); + if (gl.isGL2GL3()) { + gl.getGL2GL3().glPolygonMode(GL.GL_FRONT, frontMode); + } record.frontMode = frontMode; } if (record.backMode != backMode) { - gl.getGL2GL3().glPolygonMode(GL.GL_BACK, backMode); + if (gl.isGL2GL3()) { + gl.getGL2GL3().glPolygonMode(GL.GL_BACK, backMode); + } record.backMode = backMode; } } } else { if (frontMode == backMode) { - gl.getGL2GL3().glPolygonMode(GL.GL_FRONT_AND_BACK, frontMode); + if (gl.isGL2GL3()) { + gl.getGL2GL3().glPolygonMode(GL.GL_FRONT_AND_BACK, frontMode); + } } else if (frontMode != backMode) { - gl.getGL2GL3().glPolygonMode(GL.GL_FRONT, frontMode); - gl.getGL2GL3().glPolygonMode(GL.GL_BACK, backMode); + if (gl.isGL2GL3()) { + gl.getGL2GL3().glPolygonMode(GL.GL_FRONT, frontMode); + gl.getGL2GL3().glPolygonMode(GL.GL_BACK, backMode); + } } record.frontMode = frontMode; record.backMode = backMode; diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglZBufferStateUtil.java b/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglZBufferStateUtil.java index 4763ced..c752fda 100644 --- a/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglZBufferStateUtil.java +++ b/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglZBufferStateUtil.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2008-2010 Ardor Labs, Inc. + * Copyright (c) 2008-2014 Ardor Labs, Inc. * * This file is part of Ardor3D. * @@ -10,9 +10,9 @@ package com.ardor3d.scene.state.jogl; -import javax.media.opengl.GL; -import javax.media.opengl.GLContext; -import javax.media.opengl.glu.GLU; +import com.jogamp.opengl.GL; +import com.jogamp.opengl.GLContext; +import com.jogamp.opengl.glu.GLU; import com.ardor3d.renderer.ContextManager; import com.ardor3d.renderer.RenderContext; diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/shader/JoglShaderUtil.java b/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/shader/JoglShaderUtil.java index 3931796..90f3649 100644 --- a/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/shader/JoglShaderUtil.java +++ b/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/shader/JoglShaderUtil.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2008-2012 Ardor Labs, Inc. + * Copyright (c) 2008-2014 Ardor Labs, Inc. * * This file is part of Ardor3D. * @@ -12,9 +12,9 @@ package com.ardor3d.scene.state.jogl.shader; import java.util.logging.Logger; -import javax.media.opengl.GL; -import javax.media.opengl.GL2ES2; -import javax.media.opengl.GLContext; +import com.jogamp.opengl.GL; +import com.jogamp.opengl.GL2ES2; +import com.jogamp.opengl.GLContext; import com.ardor3d.renderer.ContextCapabilities; import com.ardor3d.renderer.ContextManager; @@ -106,8 +106,10 @@ public abstract class JoglShaderUtil { final GL gl = GLContext.getCurrentGL(); if (variable.variableID == -1) { - variable.variableID = gl.getGL2ES2().glGetUniformLocation(programID, variable.name); // TODO Check - // variable.name + if (gl.isGL2ES2()) { + variable.variableID = gl.getGL2ES2().glGetUniformLocation(programID, variable.name); // TODO Check + // variable.name + } if (variable.variableID == -1 && !variable.errorLogged) { logger.severe("Shader uniform [" + variable.name + "] could not be located in shader"); @@ -119,27 +121,35 @@ public abstract class JoglShaderUtil { private static void updateShaderUniform(final ShaderVariableInt shaderUniform) { final GL gl = GLContext.getCurrentGL(); - gl.getGL2ES2().glUniform1i(shaderUniform.variableID, shaderUniform.value1); + if (gl.isGL2ES2()) { + gl.getGL2ES2().glUniform1i(shaderUniform.variableID, shaderUniform.value1); + } } private static void updateShaderUniform(final ShaderVariableInt2 shaderUniform) { final GL gl = GLContext.getCurrentGL(); - gl.getGL2ES2().glUniform2i(shaderUniform.variableID, shaderUniform.value1, shaderUniform.value2); + if (gl.isGL2ES2()) { + gl.getGL2ES2().glUniform2i(shaderUniform.variableID, shaderUniform.value1, shaderUniform.value2); + } } private static void updateShaderUniform(final ShaderVariableInt3 shaderUniform) { final GL gl = GLContext.getCurrentGL(); - gl.getGL2ES2().glUniform3i(shaderUniform.variableID, shaderUniform.value1, shaderUniform.value2, - shaderUniform.value3); + if (gl.isGL2ES2()) { + gl.getGL2ES2().glUniform3i(shaderUniform.variableID, shaderUniform.value1, shaderUniform.value2, + shaderUniform.value3); + } } private static void updateShaderUniform(final ShaderVariableInt4 shaderUniform) { final GL gl = GLContext.getCurrentGL(); - gl.getGL2ES2().glUniform4i(shaderUniform.variableID, shaderUniform.value1, shaderUniform.value2, - shaderUniform.value3, shaderUniform.value4); + if (gl.isGL2ES2()) { + gl.getGL2ES2().glUniform4i(shaderUniform.variableID, shaderUniform.value1, shaderUniform.value2, + shaderUniform.value3, shaderUniform.value4); + } } private static void updateShaderUniform(final ShaderVariableIntArray shaderUniform) { @@ -147,20 +157,28 @@ public abstract class JoglShaderUtil { switch (shaderUniform.size) { case 1: - gl.getGL2ES2().glUniform1iv(shaderUniform.variableID, shaderUniform.value.remaining(), - shaderUniform.value); + if (gl.isGL2ES2()) { + gl.getGL2ES2().glUniform1iv(shaderUniform.variableID, shaderUniform.value.remaining(), + shaderUniform.value); + } break; case 2: - gl.getGL2ES2().glUniform2iv(shaderUniform.variableID, shaderUniform.value.remaining(), - shaderUniform.value); + if (gl.isGL2ES2()) { + gl.getGL2ES2().glUniform2iv(shaderUniform.variableID, shaderUniform.value.remaining(), + shaderUniform.value); + } break; case 3: - gl.getGL2ES2().glUniform3iv(shaderUniform.variableID, shaderUniform.value.remaining(), - shaderUniform.value); + if (gl.isGL2ES2()) { + gl.getGL2ES2().glUniform3iv(shaderUniform.variableID, shaderUniform.value.remaining(), + shaderUniform.value); + } break; case 4: - gl.getGL2ES2().glUniform4iv(shaderUniform.variableID, shaderUniform.value.remaining(), - shaderUniform.value); + if (gl.isGL2ES2()) { + gl.getGL2ES2().glUniform4iv(shaderUniform.variableID, shaderUniform.value.remaining(), + shaderUniform.value); + } break; default: throw new IllegalArgumentException("Wrong size: " + shaderUniform.size); @@ -170,27 +188,35 @@ public abstract class JoglShaderUtil { private static void updateShaderUniform(final ShaderVariableFloat shaderUniform) { final GL gl = GLContext.getCurrentGL(); - gl.getGL2ES2().glUniform1f(shaderUniform.variableID, shaderUniform.value1); + if (gl.isGL2ES2()) { + gl.getGL2ES2().glUniform1f(shaderUniform.variableID, shaderUniform.value1); + } } private static void updateShaderUniform(final ShaderVariableFloat2 shaderUniform) { final GL gl = GLContext.getCurrentGL(); - gl.getGL2ES2().glUniform2f(shaderUniform.variableID, shaderUniform.value1, shaderUniform.value2); + if (gl.isGL2ES2()) { + gl.getGL2ES2().glUniform2f(shaderUniform.variableID, shaderUniform.value1, shaderUniform.value2); + } } private static void updateShaderUniform(final ShaderVariableFloat3 shaderUniform) { final GL gl = GLContext.getCurrentGL(); - gl.getGL2ES2().glUniform3f(shaderUniform.variableID, shaderUniform.value1, shaderUniform.value2, - shaderUniform.value3); + if (gl.isGL2ES2()) { + gl.getGL2ES2().glUniform3f(shaderUniform.variableID, shaderUniform.value1, shaderUniform.value2, + shaderUniform.value3); + } } private static void updateShaderUniform(final ShaderVariableFloat4 shaderUniform) { final GL gl = GLContext.getCurrentGL(); - gl.getGL2ES2().glUniform4f(shaderUniform.variableID, shaderUniform.value1, shaderUniform.value2, - shaderUniform.value3, shaderUniform.value4); + if (gl.isGL2ES2()) { + gl.getGL2ES2().glUniform4f(shaderUniform.variableID, shaderUniform.value1, shaderUniform.value2, + shaderUniform.value3, shaderUniform.value4); + } } private static void updateShaderUniform(final ShaderVariableFloatArray shaderUniform) { @@ -198,20 +224,28 @@ public abstract class JoglShaderUtil { switch (shaderUniform.size) { case 1: - gl.getGL2ES2().glUniform1fv(shaderUniform.variableID, shaderUniform.value.remaining(), - shaderUniform.value); + if (gl.isGL2ES2()) { + gl.getGL2ES2().glUniform1fv(shaderUniform.variableID, shaderUniform.value.remaining(), + shaderUniform.value); + } break; case 2: - gl.getGL2ES2().glUniform2fv(shaderUniform.variableID, shaderUniform.value.remaining(), - shaderUniform.value); + if (gl.isGL2ES2()) { + gl.getGL2ES2().glUniform2fv(shaderUniform.variableID, shaderUniform.value.remaining(), + shaderUniform.value); + } break; case 3: - gl.getGL2ES2().glUniform3fv(shaderUniform.variableID, shaderUniform.value.remaining(), - shaderUniform.value); + if (gl.isGL2ES2()) { + gl.getGL2ES2().glUniform3fv(shaderUniform.variableID, shaderUniform.value.remaining(), + shaderUniform.value); + } break; case 4: - gl.getGL2ES2().glUniform4fv(shaderUniform.variableID, shaderUniform.value.remaining(), - shaderUniform.value); + if (gl.isGL2ES2()) { + gl.getGL2ES2().glUniform4fv(shaderUniform.variableID, shaderUniform.value.remaining(), + shaderUniform.value); + } break; default: throw new IllegalArgumentException("Wrong size: " + shaderUniform.size); @@ -222,24 +256,30 @@ public abstract class JoglShaderUtil { final GL gl = GLContext.getCurrentGL(); shaderUniform.matrixBuffer.rewind(); - gl.getGL2ES2().glUniformMatrix2fv(shaderUniform.variableID, 1, shaderUniform.rowMajor, - shaderUniform.matrixBuffer); + if (gl.isGL2ES2()) { + gl.getGL2ES2().glUniformMatrix2fv(shaderUniform.variableID, 1, shaderUniform.rowMajor, + shaderUniform.matrixBuffer); + } } private static void updateShaderUniform(final ShaderVariableMatrix3 shaderUniform) { final GL gl = GLContext.getCurrentGL(); shaderUniform.matrixBuffer.rewind(); - gl.getGL2ES2().glUniformMatrix3fv(shaderUniform.variableID, 1, shaderUniform.rowMajor, - shaderUniform.matrixBuffer); + if (gl.isGL2ES2()) { + gl.getGL2ES2().glUniformMatrix3fv(shaderUniform.variableID, 1, shaderUniform.rowMajor, + shaderUniform.matrixBuffer); + } } private static void updateShaderUniform(final ShaderVariableMatrix4 shaderUniform) { final GL gl = GLContext.getCurrentGL(); shaderUniform.matrixBuffer.rewind(); - gl.getGL2ES2().glUniformMatrix4fv(shaderUniform.variableID, 1, shaderUniform.rowMajor, - shaderUniform.matrixBuffer); + if (gl.isGL2ES2()) { + gl.getGL2ES2().glUniformMatrix4fv(shaderUniform.variableID, 1, shaderUniform.rowMajor, + shaderUniform.matrixBuffer); + } } private static void updateShaderUniform(final ShaderVariableMatrix4Array shaderUniform) { @@ -247,8 +287,10 @@ public abstract class JoglShaderUtil { shaderUniform.matrixBuffer.rewind(); // count == number of matrices we are sending, or iotw, limit / 16 - gl.getGL2ES2().glUniformMatrix4fv(shaderUniform.variableID, shaderUniform.matrixBuffer.limit() >> 4, - shaderUniform.rowMajor, shaderUniform.matrixBuffer); + if (gl.isGL2ES2()) { + gl.getGL2ES2().glUniformMatrix4fv(shaderUniform.variableID, shaderUniform.matrixBuffer.limit() >> 4, + shaderUniform.rowMajor, shaderUniform.matrixBuffer); + } } /** @@ -263,8 +305,10 @@ public abstract class JoglShaderUtil { final GL gl = GLContext.getCurrentGL(); if (variable.variableID == -1) { - variable.variableID = gl.getGL2ES2().glGetAttribLocation(programID, variable.name); // TODO Check - // variable.name + if (gl.isGL2ES2()) { + variable.variableID = gl.getGL2ES2().glGetAttribLocation(programID, variable.name); // TODO Check + // variable.name + } if (variable.variableID == -1 && !variable.errorLogged) { logger.severe("Shader attribute [" + variable.name + "] could not be located in shader"); @@ -335,12 +379,16 @@ public abstract class JoglShaderUtil { private static void enableVertexAttribute(final ShaderVariable var, final ShaderObjectsStateRecord record) { if (!record.enabledAttributes.contains(var)) { + final GL gl = GLContext.getCurrentGL(); if (var.getSize() == 1) { - GLContext.getCurrentGL().getGL2ES2().glEnableVertexAttribArray(var.variableID); + if (gl.isGL2ES2()) { + gl.getGL2ES2().glEnableVertexAttribArray(var.variableID); + } } else { - final GL gl = GLContext.getCurrentGL(); - for (int i = 0, max = var.getSize(); i < max; i++) { - gl.getGL2ES2().glEnableVertexAttribArray(var.variableID + i); + if (gl.isGL2ES2()) { + for (int i = 0, max = var.getSize(); i < max; i++) { + gl.getGL2ES2().glEnableVertexAttribArray(var.variableID + i); + } } } record.enabledAttributes.add(var); @@ -350,22 +398,21 @@ public abstract class JoglShaderUtil { private static void updateShaderAttribute(final ShaderVariablePointerFloat variable, final ShaderObjectsStateRecord record, final boolean useVBO) { enableVertexAttribute(variable, record); + final GL gl = GLContext.getCurrentGL(); if (useVBO) { final RenderContext context = ContextManager.getCurrentContext(); final int vboId = JoglRenderer.setupVBO(variable.data, context); JoglRendererUtil.setBoundVBO(context.getRendererRecord(), vboId); - GLContext - .getCurrentGL() - .getGL2ES2() - .glVertexAttribPointer(variable.variableID, variable.size, GL.GL_FLOAT, variable.normalized, - variable.stride, 0); + if (gl.isGL2ES2()) { + gl.getGL2ES2().glVertexAttribPointer(variable.variableID, variable.size, GL.GL_FLOAT, + variable.normalized, variable.stride, 0); + } } else { variable.data.getBuffer().rewind(); - GLContext - .getCurrentGL() - .getGL2() - .glVertexAttribPointer(variable.variableID, variable.size, GL.GL_FLOAT, variable.normalized, - variable.stride, variable.data.getBuffer()); + if (gl.isGL2()) { + gl.getGL2().glVertexAttribPointer(variable.variableID, variable.size, GL.GL_FLOAT, variable.normalized, + variable.stride, variable.data.getBuffer()); + } } } @@ -382,13 +429,17 @@ public abstract class JoglShaderUtil { if (useVBO) { final int vboId = JoglRenderer.setupVBO(variable.data, context); JoglRendererUtil.setBoundVBO(context.getRendererRecord(), vboId); - gl.getGL2ES2().glVertexAttribPointer(variable.variableID + i, size, GL.GL_FLOAT, variable.normalized, - 0, pos); + if (gl.isGL2ES2()) { + gl.getGL2ES2().glVertexAttribPointer(variable.variableID + i, size, GL.GL_FLOAT, + variable.normalized, 0, pos); + } } else { variable.data.getBuffer().limit(pos + length - 1); variable.data.getBuffer().position(pos); - gl.getGL2().glVertexAttribPointer(variable.variableID + i, size, GL.GL_FLOAT, variable.normalized, 0, - variable.data.getBuffer()); + if (gl.isGL2()) { + gl.getGL2().glVertexAttribPointer(variable.variableID + i, size, GL.GL_FLOAT, variable.normalized, + 0, variable.data.getBuffer()); + } } } } @@ -396,72 +447,70 @@ public abstract class JoglShaderUtil { private static void updateShaderAttribute(final ShaderVariablePointerByte variable, final ShaderObjectsStateRecord record, final boolean useVBO) { enableVertexAttribute(variable, record); + final GL gl = GLContext.getCurrentGL(); if (useVBO) { final RenderContext context = ContextManager.getCurrentContext(); final int vboId = JoglRenderer.setupVBO(variable.data, context); JoglRendererUtil.setBoundVBO(context.getRendererRecord(), vboId); - GLContext - .getCurrentGL() - .getGL2ES2() - .glVertexAttribPointer(variable.variableID, variable.size, - variable.unsigned ? GL.GL_UNSIGNED_BYTE : GL.GL_BYTE, variable.normalized, variable.stride, - 0); + if (gl.isGL2ES2()) { + gl.getGL2ES2().glVertexAttribPointer(variable.variableID, variable.size, + variable.unsigned ? GL.GL_UNSIGNED_BYTE : GL.GL_BYTE, variable.normalized, variable.stride, 0); + } } else { variable.data.getBuffer().rewind(); - GLContext - .getCurrentGL() - .getGL2() - .glVertexAttribPointer(variable.variableID, variable.size, - variable.unsigned ? GL.GL_UNSIGNED_BYTE : GL.GL_BYTE, variable.normalized, variable.stride, - variable.data.getBuffer()); + if (gl.isGL2()) { + gl.getGL2().glVertexAttribPointer(variable.variableID, variable.size, + variable.unsigned ? GL.GL_UNSIGNED_BYTE : GL.GL_BYTE, variable.normalized, variable.stride, + variable.data.getBuffer()); + } } } private static void updateShaderAttribute(final ShaderVariablePointerInt variable, final ShaderObjectsStateRecord record, final boolean useVBO) { enableVertexAttribute(variable, record); + final GL gl = GLContext.getCurrentGL(); if (useVBO) { final RenderContext context = ContextManager.getCurrentContext(); final int vboId = JoglRenderer.setupVBO(variable.data, context); JoglRendererUtil.setBoundVBO(context.getRendererRecord(), vboId); - GLContext - .getCurrentGL() - .getGL2ES2() - .glVertexAttribPointer(variable.variableID, variable.size, - variable.unsigned ? GL.GL_UNSIGNED_INT : GL2ES2.GL_INT, variable.normalized, - variable.stride, 0); + if (gl.isGL2ES2()) { + gl.getGL2ES2() + .glVertexAttribPointer(variable.variableID, variable.size, + variable.unsigned ? GL.GL_UNSIGNED_INT : GL2ES2.GL_INT, variable.normalized, + variable.stride, 0); + } } else { variable.data.getBuffer().rewind(); - GLContext - .getCurrentGL() - .getGL2() - .glVertexAttribPointer(variable.variableID, variable.size, - variable.unsigned ? GL.GL_UNSIGNED_INT : GL2ES2.GL_INT, variable.normalized, - variable.stride, variable.data.getBuffer()); + if (gl.isGL2()) { + gl.getGL2().glVertexAttribPointer(variable.variableID, variable.size, + variable.unsigned ? GL.GL_UNSIGNED_INT : GL2ES2.GL_INT, variable.normalized, variable.stride, + variable.data.getBuffer()); + } } } private static void updateShaderAttribute(final ShaderVariablePointerShort variable, final ShaderObjectsStateRecord record, final boolean useVBO) { enableVertexAttribute(variable, record); + final GL gl = GLContext.getCurrentGL(); if (useVBO) { final RenderContext context = ContextManager.getCurrentContext(); final int vboId = JoglRenderer.setupVBO(variable.data, context); JoglRendererUtil.setBoundVBO(context.getRendererRecord(), vboId); - GLContext - .getCurrentGL() - .getGL2ES2() - .glVertexAttribPointer(variable.variableID, variable.size, - variable.unsigned ? GL.GL_UNSIGNED_SHORT : GL.GL_SHORT, variable.normalized, - variable.stride, 0); + if (gl.isGL2ES2()) { + gl.getGL2ES2() + .glVertexAttribPointer(variable.variableID, variable.size, + variable.unsigned ? GL.GL_UNSIGNED_SHORT : GL.GL_SHORT, variable.normalized, + variable.stride, 0); + } } else { variable.data.getBuffer().rewind(); - GLContext - .getCurrentGL() - .getGL2() - .glVertexAttribPointer(variable.variableID, variable.size, - variable.unsigned ? GL.GL_UNSIGNED_SHORT : GL.GL_SHORT, variable.normalized, - variable.stride, variable.data.getBuffer()); + if (gl.isGL2()) { + gl.getGL2().glVertexAttribPointer(variable.variableID, variable.size, + variable.unsigned ? GL.GL_UNSIGNED_SHORT : GL.GL_SHORT, variable.normalized, variable.stride, + variable.data.getBuffer()); + } } } } diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/util/JoglRendererUtil.java b/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/util/JoglRendererUtil.java index 92b416a..dd4d06f 100644 --- a/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/util/JoglRendererUtil.java +++ b/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/util/JoglRendererUtil.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2008-2010 Ardor Labs, Inc. + * Copyright (c) 2008-2014 Ardor Labs, Inc. * * This file is part of Ardor3D. * @@ -12,8 +12,8 @@ package com.ardor3d.scene.state.jogl.util; import java.util.Stack; -import javax.media.opengl.GL; -import javax.media.opengl.GLContext; +import com.jogamp.opengl.GL; +import com.jogamp.opengl.GLContext; import com.ardor3d.math.Rectangle2; import com.ardor3d.math.type.ReadOnlyRectangle2; diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/util/JoglTextureUtil.java b/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/util/JoglTextureUtil.java index e82b96d..ef8e666 100644 --- a/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/util/JoglTextureUtil.java +++ b/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/util/JoglTextureUtil.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2008-2010 Ardor Labs, Inc. + * Copyright (c) 2008-2014 Ardor Labs, Inc. * * This file is part of Ardor3D. * @@ -10,11 +10,11 @@ package com.ardor3d.scene.state.jogl.util; -import javax.media.opengl.GL; -import javax.media.opengl.GL2; -import javax.media.opengl.GL2ES1; -import javax.media.opengl.GL2ES2; -import javax.media.opengl.GL2GL3; +import com.jogamp.opengl.GL; +import com.jogamp.opengl.GL2; +import com.jogamp.opengl.GL2ES1; +import com.jogamp.opengl.GL2ES2; +import com.jogamp.opengl.GL2GL3; import com.ardor3d.image.ImageDataFormat; import com.ardor3d.image.PixelDataType; diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/util/geom/jogl/DirectNioBuffersSet.java b/ardor3d-jogl/src/main/java/com/ardor3d/util/geom/jogl/DirectNioBuffersSet.java index c4a7264..dd61350 100644 --- a/ardor3d-jogl/src/main/java/com/ardor3d/util/geom/jogl/DirectNioBuffersSet.java +++ b/ardor3d-jogl/src/main/java/com/ardor3d/util/geom/jogl/DirectNioBuffersSet.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2008-2010 Ardor Labs, Inc. + * Copyright (c) 2008-2014 Ardor Labs, Inc. * * This file is part of Ardor3D. * |