diff options
author | Kenneth Russel <[email protected]> | 2008-12-16 02:38:46 +0000 |
---|---|---|
committer | Kenneth Russel <[email protected]> | 2008-12-16 02:38:46 +0000 |
commit | 14a94c810910f88d3b7214ae9be5027dc74df39f (patch) | |
tree | 35792a840d433342d190e1838c456c3242b39295 /src | |
parent | 06d146fc64d934039e55a2c00a18e1056e0d85f2 (diff) |
Removed setSize(), setPosition(), setVisible(), and setFullscreen()
from javax.media.opengl.NativeWindow interface as these are concerns
of the window toolkit and not the OpenGL binding. Removed isVisible(),
isFullscreen(), getX(), and getY(). getWidth() and getHeight() remain.
Changed implementations of offscreen and pbuffer drawables and changed
GLJPanel to destroy and re-create its offscreen GLDrawable upon resize
rather than attempting to resize the GLDrawable directly.
git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/branches/JOGL_2_SANDBOX@1823 232f8b59-042b-4e1e-8c03-345bb8c30851
Diffstat (limited to 'src')
22 files changed, 74 insertions, 161 deletions
diff --git a/src/classes/com/sun/javafx/newt/Window.java b/src/classes/com/sun/javafx/newt/Window.java index 6928c3397..b4333bf2b 100755 --- a/src/classes/com/sun/javafx/newt/Window.java +++ b/src/classes/com/sun/javafx/newt/Window.java @@ -289,10 +289,22 @@ public abstract class Window implements NativeWindow return visualID; } - public boolean isVisible() { - return visible; + public int getWidth() { + return width; + } + + public int getHeight() { + return height; } + public Object getWrappedWindow() { + return null; + } + + // + // Additional methods + // + public int getX() { return x; } @@ -301,12 +313,8 @@ public abstract class Window implements NativeWindow return y; } - public int getWidth() { - return width; - } - - public int getHeight() { - return height; + public boolean isVisible() { + return visible; } public boolean isFullscreen() { @@ -314,15 +322,10 @@ public abstract class Window implements NativeWindow } public abstract void setVisible(boolean visible); - public abstract void setSize(int width, int height); public abstract void setPosition(int x, int y); public abstract boolean setFullscreen(boolean fullscreen); - public Object getWrappedWindow() { - return null; - } - // // MouseListener Support // diff --git a/src/classes/com/sun/opengl/impl/GLDrawableFactoryImpl.java b/src/classes/com/sun/opengl/impl/GLDrawableFactoryImpl.java index e252e3e6a..966d8a788 100644 --- a/src/classes/com/sun/opengl/impl/GLDrawableFactoryImpl.java +++ b/src/classes/com/sun/opengl/impl/GLDrawableFactoryImpl.java @@ -53,7 +53,9 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory implements used to implement the fallback rendering path of the GLJPanel. */ public abstract GLDrawableImpl createOffscreenDrawable(GLCapabilities capabilities, - GLCapabilitiesChooser chooser); + GLCapabilitiesChooser chooser, + int width, + int height); /** Dynamically looks up the given function. */ public abstract long dynamicLookupFunction(String glFuncName); diff --git a/src/classes/com/sun/opengl/impl/GLDrawableImpl.java b/src/classes/com/sun/opengl/impl/GLDrawableImpl.java index 643c9ebe5..0c60d6d09 100644 --- a/src/classes/com/sun/opengl/impl/GLDrawableImpl.java +++ b/src/classes/com/sun/opengl/impl/GLDrawableImpl.java @@ -108,10 +108,6 @@ public abstract class GLDrawableImpl implements GLDrawable { return realized; } - public void setSize(int width, int height) { - component.setSize(width, height); - } - public int getWidth() { return component.getWidth(); } diff --git a/src/classes/com/sun/opengl/impl/NullWindow.java b/src/classes/com/sun/opengl/impl/NullWindow.java index a366a734a..1cd4b4bc2 100644 --- a/src/classes/com/sun/opengl/impl/NullWindow.java +++ b/src/classes/com/sun/opengl/impl/NullWindow.java @@ -125,30 +125,4 @@ public class NullWindow implements NativeWindow { public int getHeight() { return height; } - - public int getX() { - return 0; - } - public int getY() { - return 0; - } - - public void setPosition(int x, int y) { - } - - public void setVisible(boolean visible) { - } - - public boolean isVisible() { - return false; - } - - public boolean setFullscreen(boolean fullscreen) { - return false; // FIXME - } - - public boolean isFullscreen() { - return false; // FIXME - } - } diff --git a/src/classes/com/sun/opengl/impl/egl/EGLDrawableFactory.java b/src/classes/com/sun/opengl/impl/egl/EGLDrawableFactory.java index 7f7c65a78..37dd6c8fe 100755 --- a/src/classes/com/sun/opengl/impl/egl/EGLDrawableFactory.java +++ b/src/classes/com/sun/opengl/impl/egl/EGLDrawableFactory.java @@ -132,7 +132,9 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { } public GLDrawableImpl createOffscreenDrawable(GLCapabilities capabilities, - GLCapabilitiesChooser chooser) { + GLCapabilitiesChooser chooser, + int width, + int height) { throw new GLUnsupportedException("Not yet implemented"); } diff --git a/src/classes/com/sun/opengl/impl/jawt/JAWTWindow.java b/src/classes/com/sun/opengl/impl/jawt/JAWTWindow.java index 905614952..b1a1d9d8e 100644 --- a/src/classes/com/sun/opengl/impl/jawt/JAWTWindow.java +++ b/src/classes/com/sun/opengl/impl/jawt/JAWTWindow.java @@ -143,40 +143,11 @@ public abstract class JAWTWindow implements NativeWindow { return component.getHeight(); } - public int getX() { - return component.getX(); - } - public int getY() { - return component.getY(); - } - - public void setPosition(int x, int y) { - component.setLocation(x,y); - } - - public void setVisible(boolean visible) { - component.setVisible(visible); - } - - public boolean isVisible() { - return component.isVisible(); - } - - public boolean setFullscreen(boolean fullscreen) { - return false; // FIXME - } - - public boolean isFullscreen() { - return false; // FIXME - } - public String toString() { return "JAWT-Window[windowHandle "+getWindowHandle()+ ", surfaceHandle "+getSurfaceHandle()+ - ", pos "+getX()+"/"+getY()+", size "+getWidth()+"x"+getHeight()+ - ", visible "+isVisible()+ + ", size "+getWidth()+"x"+getHeight()+ ", wrappedWindow "+getWrappedWindow()+ ", terminalObject "+isTerminalObject()+"]"; } - } diff --git a/src/classes/com/sun/opengl/impl/macosx/cgl/MacOSXCGLDrawableFactory.java b/src/classes/com/sun/opengl/impl/macosx/cgl/MacOSXCGLDrawableFactory.java index 5e47a4bbb..3352a137c 100644 --- a/src/classes/com/sun/opengl/impl/macosx/cgl/MacOSXCGLDrawableFactory.java +++ b/src/classes/com/sun/opengl/impl/macosx/cgl/MacOSXCGLDrawableFactory.java @@ -73,8 +73,10 @@ public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl { } public GLDrawableImpl createOffscreenDrawable(GLCapabilities capabilities, - GLCapabilitiesChooser chooser) { - return new MacOSXOffscreenCGLDrawable(this, capabilities); + GLCapabilitiesChooser chooser, + int width, + int height) { + return new MacOSXOffscreenCGLDrawable(this, capabilities, width, height); } public boolean canCreateGLPbuffer() { diff --git a/src/classes/com/sun/opengl/impl/macosx/cgl/MacOSXOffscreenCGLDrawable.java b/src/classes/com/sun/opengl/impl/macosx/cgl/MacOSXOffscreenCGLDrawable.java index bf3e402cc..a825e1c1e 100644 --- a/src/classes/com/sun/opengl/impl/macosx/cgl/MacOSXOffscreenCGLDrawable.java +++ b/src/classes/com/sun/opengl/impl/macosx/cgl/MacOSXOffscreenCGLDrawable.java @@ -44,8 +44,11 @@ import com.sun.opengl.impl.*; public class MacOSXOffscreenCGLDrawable extends MacOSXPbufferCGLDrawable { - public MacOSXOffscreenCGLDrawable(GLDrawableFactory factory, GLCapabilities capabilities) { - super(factory, capabilities, 0, 0); + public MacOSXOffscreenCGLDrawable(GLDrawableFactory factory, + GLCapabilities capabilities, + int width, + int height) { + super(factory, capabilities, width, height); } public GLContext createContext(GLContext shareWith) { diff --git a/src/classes/com/sun/opengl/impl/macosx/cgl/MacOSXOnscreenCGLDrawable.java b/src/classes/com/sun/opengl/impl/macosx/cgl/MacOSXOnscreenCGLDrawable.java index cb2799f5c..6a42700f3 100644 --- a/src/classes/com/sun/opengl/impl/macosx/cgl/MacOSXOnscreenCGLDrawable.java +++ b/src/classes/com/sun/opengl/impl/macosx/cgl/MacOSXOnscreenCGLDrawable.java @@ -71,10 +71,6 @@ public class MacOSXOnscreenCGLDrawable extends MacOSXCGLDrawable { return context; } - public void setSize(int width, int height) { - component.setSize(width, height); - } - public int getWidth() { return component.getWidth(); } diff --git a/src/classes/com/sun/opengl/impl/macosx/cgl/MacOSXPbufferCGLDrawable.java b/src/classes/com/sun/opengl/impl/macosx/cgl/MacOSXPbufferCGLDrawable.java index b11e0f275..dfd970070 100644 --- a/src/classes/com/sun/opengl/impl/macosx/cgl/MacOSXPbufferCGLDrawable.java +++ b/src/classes/com/sun/opengl/impl/macosx/cgl/MacOSXPbufferCGLDrawable.java @@ -55,10 +55,10 @@ public class MacOSXPbufferCGLDrawable extends MacOSXCGLDrawable { // semantic is that contains an NSView protected long pBuffer; - public MacOSXPbufferCGLDrawable(GLDrawableFactory factory, GLCapabilities capabilities, int initialWidth, int initialHeight) { + public MacOSXPbufferCGLDrawable(GLDrawableFactory factory, GLCapabilities capabilities, int width, int height) { super(factory, new NullWindow(), true, capabilities, null); NullWindow nw = (NullWindow) getNativeWindow(); - nw.setSize(initialWidth, initialHeight); + nw.setSize(width, height); initOpenGLImpl(); createPbuffer(); } @@ -83,12 +83,6 @@ public class MacOSXPbufferCGLDrawable extends MacOSXCGLDrawable { super.destroy(); } - public void setSize(int width, int height) { - super.setSize(width, height); - destroy(); - createPbuffer(); - } - public long getPbuffer() { return pBuffer; } diff --git a/src/classes/com/sun/opengl/impl/windows/wgl/WindowsOffscreenWGLDrawable.java b/src/classes/com/sun/opengl/impl/windows/wgl/WindowsOffscreenWGLDrawable.java index 8dded7069..38215fd46 100644 --- a/src/classes/com/sun/opengl/impl/windows/wgl/WindowsOffscreenWGLDrawable.java +++ b/src/classes/com/sun/opengl/impl/windows/wgl/WindowsOffscreenWGLDrawable.java @@ -48,20 +48,18 @@ public class WindowsOffscreenWGLDrawable extends WindowsWGLDrawable { public WindowsOffscreenWGLDrawable(GLDrawableFactory factory, GLCapabilities requestedCapabilities, - GLCapabilitiesChooser chooser) { + GLCapabilitiesChooser chooser, + int width, + int height) { super(factory, new NullWindow(), true, requestedCapabilities, chooser); + ((NullWindow) getNativeWindow()).setSize(width, height); + create(); } public GLContext createContext(GLContext shareWith) { return new WindowsOffscreenWGLContext(this, shareWith); } - public void setSize(int newWidth, int newHeight) { - super.setSize(newWidth, newHeight); - destroy(); - create(); - } - private void create() { getFactoryImpl().lockToolkit(); try { diff --git a/src/classes/com/sun/opengl/impl/windows/wgl/WindowsOnscreenWGLDrawable.java b/src/classes/com/sun/opengl/impl/windows/wgl/WindowsOnscreenWGLDrawable.java index 145858d5d..52812f0e9 100644 --- a/src/classes/com/sun/opengl/impl/windows/wgl/WindowsOnscreenWGLDrawable.java +++ b/src/classes/com/sun/opengl/impl/windows/wgl/WindowsOnscreenWGLDrawable.java @@ -62,10 +62,6 @@ public class WindowsOnscreenWGLDrawable extends WindowsWGLDrawable { return new WindowsOnscreenWGLContext(this, shareWith); } - public void setSize(int width, int height) { - component.setSize(width, height); - } - public int getWidth() { return component.getWidth(); } diff --git a/src/classes/com/sun/opengl/impl/windows/wgl/WindowsPbufferWGLDrawable.java b/src/classes/com/sun/opengl/impl/windows/wgl/WindowsPbufferWGLDrawable.java index 40e46a232..f82653bcd 100644 --- a/src/classes/com/sun/opengl/impl/windows/wgl/WindowsPbufferWGLDrawable.java +++ b/src/classes/com/sun/opengl/impl/windows/wgl/WindowsPbufferWGLDrawable.java @@ -52,17 +52,17 @@ public class WindowsPbufferWGLDrawable extends WindowsWGLDrawable { public WindowsPbufferWGLDrawable(GLDrawableFactory factory, GLCapabilities requestedCapabilities, - int initialWidth, - int initialHeight, + int width, + int height, WindowsWGLDrawable dummyDrawable, WGLExt wglExt) { super(factory, new NullWindow(), true, requestedCapabilities, null); - if (initialWidth <= 0 || initialHeight <= 0) { - throw new GLException("Initial width and height of pbuffer must be positive (were (" + - initialWidth + ", " + initialHeight + "))"); + if (width <= 0 || height <= 0) { + throw new GLException("Width and height of pbuffer must be positive (were (" + + width + ", " + height + "))"); } NullWindow nw = (NullWindow) getNativeWindow(); - nw.setSize(initialWidth, initialHeight); + nw.setSize(width, height); if (DEBUG) { System.out.println("Pbuffer caps on init: " + requestedCapabilities + @@ -104,14 +104,6 @@ public class WindowsPbufferWGLDrawable extends WindowsWGLDrawable { super.destroy(); } - public void setSize(int newWidth, int newHeight) { - super.setSize(newWidth, newHeight); - destroy(); - if(cachedParentHdc!=0 && cachedWGLExt!=null) { - createPbuffer(cachedParentHdc, cachedWGLExt); - } - } - public long getPbuffer() { return buffer; } diff --git a/src/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java b/src/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java index 762714690..4fe0900a6 100644 --- a/src/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java +++ b/src/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java @@ -80,8 +80,10 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl { } public GLDrawableImpl createOffscreenDrawable(GLCapabilities capabilities, - GLCapabilitiesChooser chooser) { - return new WindowsOffscreenWGLDrawable(this, capabilities, chooser); + GLCapabilitiesChooser chooser, + int width, + int height) { + return new WindowsOffscreenWGLDrawable(this, capabilities, chooser, width, height); } private boolean pbufferSupportInitialized = false; diff --git a/src/classes/com/sun/opengl/impl/x11/glx/X11GLXDrawableFactory.java b/src/classes/com/sun/opengl/impl/x11/glx/X11GLXDrawableFactory.java index 22ba775ec..75011ec88 100644 --- a/src/classes/com/sun/opengl/impl/x11/glx/X11GLXDrawableFactory.java +++ b/src/classes/com/sun/opengl/impl/x11/glx/X11GLXDrawableFactory.java @@ -116,8 +116,10 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl { } public GLDrawableImpl createOffscreenDrawable(GLCapabilities capabilities, - GLCapabilitiesChooser chooser) { - return new X11OffscreenGLXDrawable(this, capabilities, chooser); + GLCapabilitiesChooser chooser, + int width, + int height) { + return new X11OffscreenGLXDrawable(this, capabilities, chooser, width, height); } private boolean pbufferSupportInitialized = false; diff --git a/src/classes/com/sun/opengl/impl/x11/glx/X11OffscreenGLXDrawable.java b/src/classes/com/sun/opengl/impl/x11/glx/X11OffscreenGLXDrawable.java index 77aa03a83..bd2eb9921 100644 --- a/src/classes/com/sun/opengl/impl/x11/glx/X11OffscreenGLXDrawable.java +++ b/src/classes/com/sun/opengl/impl/x11/glx/X11OffscreenGLXDrawable.java @@ -49,20 +49,17 @@ public class X11OffscreenGLXDrawable extends X11GLXDrawable { protected X11OffscreenGLXDrawable(GLDrawableFactory factory, GLCapabilities requestedCapabilities, - GLCapabilitiesChooser chooser) { + GLCapabilitiesChooser chooser, + int width, + int height) { super(factory, new NullWindow(), true, requestedCapabilities, chooser); + ((NullWindow) getNativeWindow()).setSize(width, height); } public GLContext createContext(GLContext shareWith) { return new X11OffscreenGLXContext(this, shareWith); } - public void setSize(int newWidth, int newHeight) { - super.setSize(newWidth, newHeight); - destroy(); - create(); - } - private void create() { NullWindow nw = (NullWindow) getNativeWindow(); long dpy = X11GLXDrawableFactory.getDisplayConnection(); diff --git a/src/classes/com/sun/opengl/impl/x11/glx/X11OnscreenGLXDrawable.java b/src/classes/com/sun/opengl/impl/x11/glx/X11OnscreenGLXDrawable.java index fc3460480..23835f21b 100644 --- a/src/classes/com/sun/opengl/impl/x11/glx/X11OnscreenGLXDrawable.java +++ b/src/classes/com/sun/opengl/impl/x11/glx/X11OnscreenGLXDrawable.java @@ -52,10 +52,6 @@ public class X11OnscreenGLXDrawable extends X11GLXDrawable { return new X11OnscreenGLXContext(this, shareWith); } - public void setSize(int width, int height) { - component.setSize(width, height); - } - public int getWidth() { return component.getWidth(); } diff --git a/src/classes/com/sun/opengl/impl/x11/glx/X11PbufferGLXDrawable.java b/src/classes/com/sun/opengl/impl/x11/glx/X11PbufferGLXDrawable.java index 26a1ae932..3df6d486a 100644 --- a/src/classes/com/sun/opengl/impl/x11/glx/X11PbufferGLXDrawable.java +++ b/src/classes/com/sun/opengl/impl/x11/glx/X11PbufferGLXDrawable.java @@ -54,14 +54,14 @@ public class X11PbufferGLXDrawable extends X11GLXDrawable { protected X11PbufferGLXDrawable(GLDrawableFactory factory, GLCapabilities requestedCapabilities, - int initialWidth, int initialHeight) { + int width, int height) { super(factory, new NullWindow(), true, requestedCapabilities, null); - if (initialWidth <= 0 || initialHeight <= 0) { - throw new GLException("Initial width and height of pbuffer must be positive (were (" + - initialWidth + ", " + initialHeight + "))"); + if (width <= 0 || height <= 0) { + throw new GLException("Width and height of pbuffer must be positive (were (" + + width + ", " + height + "))"); } NullWindow nw = (NullWindow) getNativeWindow(); - nw.setSize(initialWidth, initialHeight); + nw.setSize(width, height); if (DEBUG) { System.out.println("Pbuffer caps on init: " + requestedCapabilities + @@ -93,13 +93,6 @@ public class X11PbufferGLXDrawable extends X11GLXDrawable { super.destroy(); } - public void setSize(int width, int height) { - super.setSize(width, height); - destroy(); - ((NullWindow)getNativeWindow()).setDisplayHandle(X11GLXDrawableFactory.getDisplayConnection()); - createPbuffer(); - } - private void createPbuffer() { getFactoryImpl().lockToolkit(); try { diff --git a/src/classes/javax/media/opengl/GLDrawable.java b/src/classes/javax/media/opengl/GLDrawable.java index f1468c475..39c7f96ca 100644 --- a/src/classes/javax/media/opengl/GLDrawable.java +++ b/src/classes/javax/media/opengl/GLDrawable.java @@ -110,11 +110,6 @@ public interface GLDrawable { */ public void destroy(); - /** Requests a new width and height for this GLDrawable. Not all - drawables are able to respond to this request and may silently - ignore it. */ - public void setSize(int width, int height); - /** Returns the current width of this GLDrawable. */ public int getWidth(); diff --git a/src/classes/javax/media/opengl/NativeWindow.java b/src/classes/javax/media/opengl/NativeWindow.java index f9785ccc6..a2a892d52 100644 --- a/src/classes/javax/media/opengl/NativeWindow.java +++ b/src/classes/javax/media/opengl/NativeWindow.java @@ -131,15 +131,9 @@ public interface NativeWindow { */ public boolean isTerminalObject(); - public void setSize(int width, int height); - public void setPosition(int x, int y); + /** Returns the current width of this window. */ public int getWidth(); - public int getHeight(); - public int getX(); - public int getY(); - public void setVisible(boolean visible); - public boolean setFullscreen(boolean fullscreen); - public boolean isVisible(); - public boolean isFullscreen(); + /** Returns the current height of this window. */ + public int getHeight(); } diff --git a/src/classes/javax/media/opengl/awt/AWTGLAutoDrawable.java b/src/classes/javax/media/opengl/awt/AWTGLAutoDrawable.java index 85163f0ff..d92cec389 100644 --- a/src/classes/javax/media/opengl/awt/AWTGLAutoDrawable.java +++ b/src/classes/javax/media/opengl/awt/AWTGLAutoDrawable.java @@ -43,6 +43,9 @@ import javax.media.opengl.*; import javax.media.opengl.glu.*; public interface AWTGLAutoDrawable extends GLAutoDrawable, ComponentEvents { + /** Requests a new width and height for this AWTGLAutoDrawable. */ + public void setSize(int width, int height); + /** Schedules a repaint of the component at some point in the future. */ public void repaint(); diff --git a/src/classes/javax/media/opengl/awt/GLJPanel.java b/src/classes/javax/media/opengl/awt/GLJPanel.java index c5877e5be..48a2c7cd9 100644 --- a/src/classes/javax/media/opengl/awt/GLJPanel.java +++ b/src/classes/javax/media/opengl/awt/GLJPanel.java @@ -786,8 +786,10 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable { public void initialize() { // Fall-through path: create an offscreen context instead - offscreenDrawable = factory.createOffscreenDrawable(offscreenCaps, chooser); - offscreenDrawable.setSize(Math.max(1, panelWidth), Math.max(1, panelHeight)); + offscreenDrawable = factory.createOffscreenDrawable(offscreenCaps, + chooser, + Math.max(1, panelWidth), + Math.max(1, panelHeight)); offscreenContext = (GLContextImpl) offscreenDrawable.createContext(shareWith); offscreenContext.setSynchronized(true); isInitialized = true; @@ -820,8 +822,8 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable { } public void handleReshape() { - offscreenContext.destroy(); - offscreenDrawable.setSize(Math.max(1, panelWidth), Math.max(1, panelHeight)); + destroy(); + initialize(); readBackWidthInPixels = Math.max(1, panelWidth); readBackHeightInPixels = Math.max(1, panelHeight); |