aboutsummaryrefslogtreecommitdiffstats
path: root/src/classes/com/sun/opengl/impl/GLDrawableImpl.java
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2008-06-21 02:33:51 +0000
committerSven Gothel <[email protected]>2008-06-21 02:33:51 +0000
commit006acbb9463af33a8b45aa0b3a298604eba72d82 (patch)
tree2c71662575a2c098b22c4b19b471bb5c732041c5 /src/classes/com/sun/opengl/impl/GLDrawableImpl.java
parentcbc45e816f4ee81031bffce19a99550681462a24 (diff)
2nd big refactoring.
Goals are orthogonal components for: - OS Windowing system - NEWT, X11, Windows, MacOsX - GL Windowing GLUE - EGL, GLX, WGL, CGL - GL profiles - core and util packages - generate all Java components from any platform All above goals are achieved. TODO: - Native compilation fix and test - Check/Fix Win32, MacOSX and the mobile devices - .. git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/branches/JOGL_2_SANDBOX@1665 232f8b59-042b-4e1e-8c03-345bb8c30851
Diffstat (limited to 'src/classes/com/sun/opengl/impl/GLDrawableImpl.java')
-rw-r--r--src/classes/com/sun/opengl/impl/GLDrawableImpl.java78
1 files changed, 71 insertions, 7 deletions
diff --git a/src/classes/com/sun/opengl/impl/GLDrawableImpl.java b/src/classes/com/sun/opengl/impl/GLDrawableImpl.java
index 690bfd88c..26f3d6585 100644
--- a/src/classes/com/sun/opengl/impl/GLDrawableImpl.java
+++ b/src/classes/com/sun/opengl/impl/GLDrawableImpl.java
@@ -42,18 +42,29 @@ package com.sun.opengl.impl;
import javax.media.opengl.*;
public abstract class GLDrawableImpl implements GLDrawable {
- protected GLDrawableFactory factory;
- protected NativeWindow component;
- private GLCapabilities chosenCapabilities;
+ protected GLDrawableImpl(GLDrawableFactory factory, NativeWindow comp, boolean realized) {
+ this.factory = factory;
+ this.component = comp;
+ this.realized = realized;
+ this.chosenCapabilities=null;
+ }
/** For offscreen GLDrawables (pbuffers and "pixmap" drawables),
indicates that native resources should be reclaimed. */
- public abstract void destroy() throws GLException;
+ public void destroy() throws GLException {
+ }
+
+ public void swapBuffers() throws GLException {
+ }
public static String toHexString(long hex) {
return GLContextImpl.toHexString(hex);
}
+ public GLCapabilities getCapabilities() {
+ return chosenCapabilities;
+ }
+
public GLCapabilities getChosenGLCapabilities() {
if (chosenCapabilities == null)
return null;
@@ -63,7 +74,7 @@ public abstract class GLDrawableImpl implements GLDrawable {
}
public void setChosenGLCapabilities(GLCapabilities caps) {
- chosenCapabilities = caps;
+ chosenCapabilities = (caps==null) ? null : (GLCapabilities) caps.clone();
}
public NativeWindow getNativeWindow() {
@@ -74,7 +85,60 @@ public abstract class GLDrawableImpl implements GLDrawable {
return factory;
}
- public String getProfile() {
- return factory.getProfile();
+ public void setRealized(boolean realized) {
+ this.realized = realized;
+ if(!realized) {
+ setChosenGLCapabilities(null);
+ component.invalidate();
+ }
+ }
+
+ public boolean getRealized() {
+ return realized;
+ }
+
+ public void setSize(int width, int height) {
+ component.setSize(width, height);
+ }
+
+ public int getWidth() {
+ return component.getWidth();
}
+
+ /** Returns the current height of this GLDrawable. */
+ public int getHeight() {
+ return component.getHeight();
+ }
+
+ public int lockSurface() throws GLException {
+ if (!realized) {
+ return NativeWindow.LOCK_SURFACE_NOT_READY;
+ }
+ return component.lockSurface();
+ }
+
+ public void unlockSurface() {
+ component.unlockSurface();
+ }
+
+ public boolean isSurfaceLocked() {
+ return component.isSurfaceLocked();
+ }
+
+ protected GLDrawableFactory factory;
+ protected NativeWindow component;
+ private GLCapabilities chosenCapabilities;
+
+ // Indicates whether the component (if an onscreen context) has been
+ // realized. Plausibly, before the component is realized the JAWT
+ // should return an error or NULL object from some of its
+ // operations; this appears to be the case on Win32 but is not true
+ // at least with Sun's current X11 implementation (1.4.x), which
+ // crashes with no other error reported if the DrawingSurfaceInfo is
+ // fetched from a locked DrawingSurface during the validation as a
+ // result of calling show() on the main thread. To work around this
+ // we prevent any JAWT or OpenGL operations from being done until
+ // addNotify() is called on the component.
+ protected boolean realized;
+
}