diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/classes/share/javax/media/j3d/JoglDrawable.java | 33 | ||||
-rw-r--r-- | src/classes/share/javax/media/j3d/JoglPipeline.java | 31 |
2 files changed, 55 insertions, 9 deletions
diff --git a/src/classes/share/javax/media/j3d/JoglDrawable.java b/src/classes/share/javax/media/j3d/JoglDrawable.java index 7981b1b..1ce492e 100644 --- a/src/classes/share/javax/media/j3d/JoglDrawable.java +++ b/src/classes/share/javax/media/j3d/JoglDrawable.java @@ -26,19 +26,38 @@ package javax.media.j3d; +import javax.media.nativewindow.NativeWindow; import javax.media.opengl.GLDrawable; /** * Drawable class for the Jogl rendering pipeline. */ class JoglDrawable implements Drawable { - private GLDrawable drawable; + private GLDrawable drawable; + private NativeWindow nativeWindow; - JoglDrawable(GLDrawable drawable) { - this.drawable = drawable; - } + JoglDrawable(GLDrawable drawable, NativeWindow nativeWindow) { + this.drawable = drawable; + this.nativeWindow = nativeWindow; + } - GLDrawable getGLDrawable() { - return drawable; - } + GLDrawable getGLDrawable() { + return drawable; + } + + void setGLDrawable(GLDrawable drawable) { + this.drawable = drawable; + } + + NativeWindow getNativeWindow() { + return nativeWindow; + } + + void destroyNativeWindow() { + if (nativeWindow == null) + return; + + nativeWindow.destroy(); + nativeWindow = null; + } } diff --git a/src/classes/share/javax/media/j3d/JoglPipeline.java b/src/classes/share/javax/media/j3d/JoglPipeline.java index 714c013..430c970 100644 --- a/src/classes/share/javax/media/j3d/JoglPipeline.java +++ b/src/classes/share/javax/media/j3d/JoglPipeline.java @@ -54,6 +54,9 @@ import java.util.regex.Pattern; import com.jogamp.nativewindow.awt.AWTGraphicsConfiguration; import com.jogamp.nativewindow.awt.AWTGraphicsDevice; import com.jogamp.nativewindow.awt.AWTGraphicsScreen; +import com.jogamp.nativewindow.awt.JAWTWindow; +import com.jogamp.opengl.FBObject; + import javax.media.nativewindow.AbstractGraphicsConfiguration; import javax.media.nativewindow.CapabilitiesChooser; import javax.media.nativewindow.CapabilitiesImmutable; @@ -70,6 +73,7 @@ import javax.media.opengl.GLContext; import javax.media.opengl.GLDrawable; import javax.media.opengl.GLDrawableFactory; import javax.media.opengl.GLException; +import javax.media.opengl.GLFBODrawable; import javax.media.opengl.GLPbuffer; import javax.media.opengl.GLProfile; import javax.media.opengl.Threading; @@ -6178,7 +6182,7 @@ class JoglPipeline extends Pipeline { indexChooser, awtGraphicsScreen, VisualIDHolder.VID_UNDEFINED); NativeWindow nativeWindow = NativeWindowFactory.getNativeWindow(cv, awtGraphicsConfiguration); draw = GLDrawableFactory.getFactory(profile).createGLDrawable(nativeWindow); - cv.drawable = new JoglDrawable(draw); + cv.drawable = new JoglDrawable(draw, null); } else { draw = drawable(cv.drawable); } @@ -6311,7 +6315,7 @@ class JoglPipeline extends Pipeline { //FIXME use the real AWTGraphicsDevice GLPbuffer pbuffer = GLDrawableFactory.getFactory(profile).createGLPbuffer(GLDrawableFactory.getDesktopFactory().getDefaultDevice() ,caps, null,width, height, GLContext.getCurrent()); - return new JoglDrawable(pbuffer); + return new JoglDrawable(pbuffer, null); } void destroyOffScreenBuffer(Canvas3D cv, Context ctx, Drawable drawable) { @@ -7148,6 +7152,29 @@ void swapBuffers(Canvas3D cv, Context ctx, Drawable drawable) { } } +private boolean isOffscreenLayerSurfaceEnabled(Canvas3D cv) { + if (cv.drawable == null || cv.offScreen) + return false; + + JoglDrawable joglDrawble = (JoglDrawable)cv.drawable; + final JAWTWindow jawtwindow = (JAWTWindow)joglDrawble.getNativeWindow(); + if (jawtwindow == null) + return false; + + return jawtwindow.isOffscreenLayerSurfaceEnabled(); +} + +private boolean hasFBObjectSizeChanged(JoglDrawable jdraw, int width, int height) { + if (!(jdraw.getGLDrawable() instanceof GLFBODrawable)) + return false; + + FBObject fboBack = ((GLFBODrawable)jdraw.getGLDrawable()).getFBObject(GL.GL_BACK); + if (fboBack == null) + return false; + + return (width != fboBack.getWidth() || height != fboBack.getHeight()); +} + // The native method for setting the Viewport. void setViewport(Context ctx, int x, int y, int width, int height) { if (VERBOSE) System.err.println("JoglPipeline.setViewport()"); |