aboutsummaryrefslogtreecommitdiffstats
path: root/src/net/java/games/jogl/impl/x11/X11OffscreenGLContext.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/x11/X11OffscreenGLContext.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/x11/X11OffscreenGLContext.java')
-rw-r--r--src/net/java/games/jogl/impl/x11/X11OffscreenGLContext.java102
1 files changed, 10 insertions, 92 deletions
diff --git a/src/net/java/games/jogl/impl/x11/X11OffscreenGLContext.java b/src/net/java/games/jogl/impl/x11/X11OffscreenGLContext.java
index c493d3380..4397c72d8 100644
--- a/src/net/java/games/jogl/impl/x11/X11OffscreenGLContext.java
+++ b/src/net/java/games/jogl/impl/x11/X11OffscreenGLContext.java
@@ -39,46 +39,24 @@
package net.java.games.jogl.impl.x11;
-import java.awt.image.BufferedImage;
import net.java.games.jogl.*;
import net.java.games.jogl.impl.*;
public class X11OffscreenGLContext extends X11GLContext {
- private long pixmap;
- private boolean isDoubleBuffered;
- // Width and height of the underlying bitmap
- private int width;
- private int height;
+ private X11OffscreenGLDrawable drawable;
- public X11OffscreenGLContext(GLCapabilities capabilities,
- GLCapabilitiesChooser chooser,
+ public X11OffscreenGLContext(X11OffscreenGLDrawable drawable,
GLContext shareWith) {
- super(null, capabilities, chooser, shareWith);
- }
-
- protected GL createGL()
- {
- return new X11GLImpl(this);
- }
-
- protected boolean isOffscreen() {
- return true;
- }
-
- public int getOffscreenContextWidth() {
- return width;
- }
-
- public int getOffscreenContextHeight() {
- return height;
+ super(drawable, shareWith);
+ this.drawable = drawable;
}
public int getOffscreenContextPixelDataType() {
- return GL.GL_UNSIGNED_BYTE;
+ return GL.GL_UNSIGNED_BYTE;
}
public int getOffscreenContextReadBuffer() {
- if (isDoubleBuffered) {
+ if (drawable.isDoubleBuffered()) {
return GL.GL_BACK;
}
return GL.GL_FRONT;
@@ -95,9 +73,9 @@ public class X11OffscreenGLContext extends X11GLContext {
return false;
}
- public GLContext createPbufferContext(GLCapabilities capabilities,
- int initialWidth,
- int initialHeight) {
+ public GLDrawableImpl createPbufferDrawable(GLCapabilities capabilities,
+ int initialWidth,
+ int initialHeight) {
throw new GLException("Not supported");
}
@@ -109,67 +87,7 @@ public class X11OffscreenGLContext extends X11GLContext {
throw new GLException("Should not call this");
}
- protected int makeCurrentImpl() throws GLException {
- display = X11GLContextFactory.getDisplayConnection();
- if (pendingOffscreenResize) {
- if (pendingOffscreenWidth != width || pendingOffscreenHeight != height) {
- if (context != 0) {
- destroy();
- }
- width = pendingOffscreenWidth;
- height = pendingOffscreenHeight;
- pendingOffscreenResize = false;
- }
- }
- mostRecentDisplay = display;
- return super.makeCurrentImpl();
- }
-
- public void swapBuffers() throws GLException {
- }
-
- protected void releaseImpl() throws GLException {
- try {
- super.releaseImpl();
- } finally {
- display = 0;
- }
- }
-
protected void create() {
- XVisualInfo vis = chooseVisual();
- int bitsPerPixel = vis.depth();
-
- if (display == 0) {
- throw new GLException("No active display");
- }
- int screen = GLX.DefaultScreen(display);
- pixmap = GLX.XCreatePixmap(display, (int) GLX.RootWindow(display, screen), width, height, bitsPerPixel);
- if (pixmap == 0) {
- throw new GLException("XCreatePixmap failed");
- }
- drawable = GLX.glXCreateGLXPixmap(display, vis, pixmap);
- if (drawable == 0) {
- throw new GLException("glXCreateGLXPixmap failed");
- }
- context = createContext(vis, false);
- if (context == 0) {
- throw new GLException("Unable to create OpenGL context");
- }
- isDoubleBuffered = (X11GLContextFactory.glXGetConfig(display, vis, GLX.GLX_DOUBLEBUFFER, new int[1], 0) != 0);
- }
-
- protected void destroyImpl() {
- if (context != 0) {
- super.destroyImpl();
- // Must destroy OpenGL context, pixmap and GLXPixmap
- GLX.glXDestroyContext(display, context);
- GLX.glXDestroyGLXPixmap(display, (int) drawable);
- GLX.XFreePixmap(display, pixmap);
- context = 0;
- drawable = 0;
- pixmap = 0;
- GLContextShareSet.contextDestroyed(this);
- }
+ createContext(false);
}
}