aboutsummaryrefslogtreecommitdiffstats
path: root/src/net/java/games/jogl/impl/GLContextImpl.java
diff options
context:
space:
mode:
authorKenneth Russel <[email protected]>2005-07-17 06:13:24 +0000
committerKenneth Russel <[email protected]>2005-07-17 06:13:24 +0000
commit7e7e225eaf4fddb31152ab204bf1776f26079d40 (patch)
tree522044c1fb226235fa34b9d013945f320765edd8 /src/net/java/games/jogl/impl/GLContextImpl.java
parent9d28b7f7fffdaeee7353945000546cb73a00157b (diff)
Further context-related changes for the JSR-231 API. The GLContext
implementations on all platforms have been split into orthogonal GLDrawable and GLContext concepts. It is now possible to create more than one GLContet per GLDrawable (though this has not been tested yet). GLCanvas has been reimplemented in terms of GLDrawableFactory.getGLDrawable(). More functionality has been moved from GLDrawable to GLAutoDrawable. Reimplemented lazy sending of reshape GLEventListener events in GLCanvas and GLJPanel and deleted notion of deferred reshapes from GLDrawableHelper and elsewhere. Sharing of textures and display lists is now expressed in terms of GLContexts instead of GLDrawables. Still need to move pbuffer creation into GLDrawableFactory from the onscreen GLContext implementations. Added option to gleem ExaminerViewer to disable automatic redraws upon mouse events and respecified more of gleem to work on GLAutoDrawables rather than GLDrawables. Updated all JOGL demos to work with new APIs and slightly different initialization sequences (in particular, for pbuffers -- this will change with the addition of GLDrawableFactory.createGLPbuffer()). git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/branches/JSR-231@324 232f8b59-042b-4e1e-8c03-345bb8c30851
Diffstat (limited to 'src/net/java/games/jogl/impl/GLContextImpl.java')
-rwxr-xr-xsrc/net/java/games/jogl/impl/GLContextImpl.java76
1 files changed, 12 insertions, 64 deletions
diff --git a/src/net/java/games/jogl/impl/GLContextImpl.java b/src/net/java/games/jogl/impl/GLContextImpl.java
index 26547c8c3..fd164321f 100755
--- a/src/net/java/games/jogl/impl/GLContextImpl.java
+++ b/src/net/java/games/jogl/impl/GLContextImpl.java
@@ -50,14 +50,6 @@ public abstract class GLContextImpl extends GLContext {
protected static final boolean VERBOSE = Debug.verbose();
protected static final boolean NO_FREE = Debug.isPropertyDefined("jogl.GLContext.nofree");
- static {
- NativeLibLoader.load();
- }
-
- protected GLCapabilities capabilities;
- protected GLCapabilitiesChooser chooser;
- protected Component component;
-
// Cache of the functions that are available to be called at the current
// moment in time
protected FunctionAvailabilityCache functionAvailability;
@@ -67,13 +59,7 @@ public abstract class GLContextImpl extends GLContext {
protected static final GLUProcAddressTable gluProcAddressTable = new GLUProcAddressTable();
protected static boolean haveResetGLUProcAddressTable;
- public GLContextImpl(Component component,
- GLCapabilities capabilities,
- GLCapabilitiesChooser chooser,
- GLContext shareWith) {
- this.component = component;
- this.capabilities = (GLCapabilities) capabilities.clone();
- this.chooser = chooser;
+ public GLContextImpl(GLContext shareWith) {
setGL(createGL());
functionAvailability = new FunctionAvailabilityCache(this);
if (shareWith != null) {
@@ -115,6 +101,9 @@ public abstract class GLContextImpl extends GLContext {
protected abstract void releaseImpl() throws GLException;
public void destroy() {
+ if (lock.isHeld()) {
+ throw new GLException("Can not destroy context while it is current");
+ }
// Should we check the lock state? It should not be current on any
// thread.
destroyImpl();
@@ -148,27 +137,10 @@ public abstract class GLContextImpl extends GLContext {
this.glu = glu;
}
- // Subclasses for onscreen GLContexts should override this to
- // receive a notification from the GLCanvas or other implementation
- // upon addNotify
- public void setRealized() {
- }
-
//----------------------------------------------------------------------
// Helpers for various context implementations
//
- // Flag for enabling / disabling automatic swapping of the front and
- // back buffers
- protected boolean autoSwapBuffers = true;
-
- // Offscreen context handling. Offscreen contexts should handle
- // these resize requests in makeCurrent and clear the
- // pendingOffscreenResize flag.
- protected boolean pendingOffscreenResize;
- protected int pendingOffscreenWidth;
- protected int pendingOffscreenHeight;
-
/** Create the GL for this context. */
protected abstract GL createGL();
@@ -181,12 +153,12 @@ public abstract class GLContextImpl extends GLContext {
public abstract boolean canCreatePbufferContext();
/**
- * Pbuffer support; creates a subordinate GLContext for a pbuffer
+ * Pbuffer support; creates a subordinate GLDrawable for a pbuffer
* associated with this context.
*/
- public abstract GLContext createPbufferContext(GLCapabilities capabilities,
- int initialWidth,
- int initialHeight);
+ public abstract GLDrawableImpl createPbufferDrawable(GLCapabilities capabilities,
+ int initialWidth,
+ int initialHeight);
/**
* Pbuffer support; given that this is a GLContext associated with a
@@ -218,18 +190,6 @@ public abstract class GLContextImpl extends GLContext {
and "WGL_ARB_pixel_format" (not yet mapped to X11). */
protected abstract String mapToRealGLExtensionName(String glExtensionName);
- public void setAutoSwapBufferMode(boolean autoSwapBuffers) {
- this.autoSwapBuffers = autoSwapBuffers;
- }
-
- public boolean getAutoSwapBufferMode() {
- return autoSwapBuffers;
- }
-
- /** Swaps the buffers of the OpenGL context if necessary. All error
- conditions cause a GLException to be thrown. */
- public abstract void swapBuffers() throws GLException;
-
/** Returns a non-null (but possibly empty) string containing the
space-separated list of available platform-dependent (e.g., WGL,
GLX) extensions. Can only be called while this context is
@@ -333,11 +293,6 @@ public abstract class GLContextImpl extends GLContext {
throw new GLException("Not supported on non-pbuffer contexts");
}
- /** Hook indicating whether the concrete GLContext implementation is
- offscreen and therefore whether we need to process resize
- requests. */
- protected abstract boolean isOffscreen();
-
/** On some platforms the mismatch between OpenGL's coordinate
system (origin at bottom left) and the window system's
coordinate system (origin at top left) necessitates a vertical
@@ -347,18 +302,11 @@ public abstract class GLContextImpl extends GLContext {
/** Only called for offscreen contexts; needed by glReadPixels */
public abstract int getOffscreenContextPixelDataType();
- /** Routine needed only for offscreen contexts in order to resize
- the underlying bitmap. Called by GLJPanel. */
- public void resizeOffscreenContext(int newWidth, int newHeight) {
- if (!isOffscreen()) {
- throw new GLException("Should only call for offscreen OpenGL contexts");
- }
- pendingOffscreenResize = true;
- pendingOffscreenWidth = newWidth;
- pendingOffscreenHeight = newHeight;
- }
-
protected static String getThreadName() {
return Thread.currentThread().getName();
}
+
+ public static String toHexString(long hex) {
+ return "0x" + Long.toHexString(hex);
+ }
}