aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/com/sun/opengl/impl/x11/glx
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2009-10-05 02:54:59 -0700
committerSven Gothel <[email protected]>2009-10-05 02:54:59 -0700
commit76bf2e5a7f23def0a3bf2b688791b593ecb283ab (patch)
tree84b7b2a25cc38450dc83a78d1f1ed165195a599e /src/jogl/classes/com/sun/opengl/impl/x11/glx
parent59257476777104ff3f117d87a8205161cb800abf (diff)
GLDrawableFactory Cleanup (-> On- Offscreen and PBuffer)
- Base all PBuffer/Offscreen GLDrawable creators on a prev. created 'NativeWindow + SurfaceChangeable' instance. Simplifies implementation path. This also removes the almost cyclic referencing of GLWindow -> OffscreenWindow GLWindow -> Drawable -> NullWindow -> OffscreenWindow Now it is just GLWindow -> OffscreenWindow GLWindow -> Drawable -> OffscreenWindow - createGLDrawable() shall be used for all types now, especially if you want to pass the offscreen NativeWindow and benefit from the surfaceChangedListener etc .. - Add public createOffscreenDrawable(..) - EGLDrawable: - Query surface only if not 0 - [re]create surface only if needed, using 'ownEGL*' flag for destruction only.
Diffstat (limited to 'src/jogl/classes/com/sun/opengl/impl/x11/glx')
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXDrawableFactory.java39
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/x11/glx/X11OffscreenGLXDrawable.java14
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/x11/glx/X11PbufferGLXDrawable.java41
3 files changed, 30 insertions, 64 deletions
diff --git a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXDrawableFactory.java b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXDrawableFactory.java
index f278d76d0..f6c911c63 100644
--- a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXDrawableFactory.java
+++ b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXDrawableFactory.java
@@ -72,15 +72,8 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl implements Dyna
return new X11OnscreenGLXDrawable(this, target);
}
- public GLDrawableImpl createOffscreenDrawable(GLCapabilities capabilities,
- GLCapabilitiesChooser chooser,
- int width,
- int height) {
- AbstractGraphicsScreen screen = X11GraphicsScreen.createDefault();
- capabilities.setDoubleBuffered(false); // FIXME
- capabilities.setOnscreen(false);
- capabilities.setPBuffer(false);
- return new X11OffscreenGLXDrawable(this, screen, capabilities, chooser, width, height);
+ protected GLDrawableImpl createOffscreenDrawable(NativeWindow target) {
+ return new X11OffscreenGLXDrawable(this, target);
}
private boolean pbufferSupportInitialized = false;
@@ -117,29 +110,15 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl implements Dyna
return canCreateGLPbuffer;
}
- public GLDrawableImpl createGLPbufferDrawable(GLCapabilities capabilities,
- final GLCapabilitiesChooser chooser,
- final int initialWidth,
- final int initialHeight) {
- if (!canCreateGLPbuffer()) {
- throw new GLException("Pbuffer support not available with current graphics card");
- }
-
- capabilities.setDoubleBuffered(false); // FIXME
- capabilities.setOnscreen(false);
- capabilities.setPBuffer(true);
- AbstractGraphicsScreen screen = X11GraphicsScreen.createDefault();
- return new X11PbufferGLXDrawable(this, screen, capabilities, chooser,
- initialWidth, initialHeight);
+ protected GLDrawableImpl createGLPbufferDrawableImpl(NativeWindow target) {
+ return new X11PbufferGLXDrawable(this, target);
}
- public GLPbuffer createGLPbuffer(final GLCapabilities capabilities,
- final GLCapabilitiesChooser chooser,
- final int initialWidth,
- final int initialHeight,
- final GLContext shareWith) {
- GLDrawableImpl drawable = createGLPbufferDrawable(capabilities, chooser, initialWidth, initialHeight);
- return new GLPbufferImpl(drawable, shareWith);
+ protected NativeWindow createOffscreenWindow(GLCapabilities capabilities, GLCapabilitiesChooser chooser, int width, int height) {
+ AbstractGraphicsScreen screen = X11GraphicsScreen.createDefault();
+ NullWindow nw = new NullWindow(X11GLXGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(capabilities, chooser, screen));
+ nw.setSize(width, height);
+ return nw;
}
public GLContext createExternalGLContext() {
diff --git a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11OffscreenGLXDrawable.java b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11OffscreenGLXDrawable.java
index 4c4546854..98eca44d9 100644
--- a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11OffscreenGLXDrawable.java
+++ b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11OffscreenGLXDrawable.java
@@ -42,19 +42,13 @@ package com.sun.opengl.impl.x11.glx;
import javax.media.nativewindow.*;
import javax.media.opengl.*;
import com.sun.opengl.impl.*;
-import com.sun.nativewindow.impl.NullWindow;
import com.sun.nativewindow.impl.x11.*;
public class X11OffscreenGLXDrawable extends X11GLXDrawable {
private long pixmap;
- protected X11OffscreenGLXDrawable(GLDrawableFactory factory, AbstractGraphicsScreen screen,
- GLCapabilities caps,
- GLCapabilitiesChooser chooser,
- int width,
- int height) {
- super(factory, new NullWindow(X11GLXGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(caps, chooser, screen)), true);
- ((NullWindow) getNativeWindow()).setSize(width, height);
+ protected X11OffscreenGLXDrawable(GLDrawableFactory factory, NativeWindow target) {
+ super(factory, target, true);
create();
}
@@ -63,7 +57,7 @@ public class X11OffscreenGLXDrawable extends X11GLXDrawable {
}
private void create() {
- NullWindow nw = (NullWindow) getNativeWindow();
+ NativeWindow nw = getNativeWindow();
X11GLXGraphicsConfiguration config = (X11GLXGraphicsConfiguration) nw.getGraphicsConfiguration().getNativeGraphicsConfiguration();
XVisualInfo vis = config.getXVisualInfo();
int bitsPerPixel = vis.depth();
@@ -85,7 +79,7 @@ public class X11OffscreenGLXDrawable extends X11GLXDrawable {
pixmap = 0;
throw new GLException("glXCreateGLXPixmap failed");
}
- nw.setSurfaceHandle(drawable);
+ ((SurfaceChangeable)nw).setSurfaceHandle(drawable);
if (DEBUG) {
System.err.println("Created pixmap " + toHexString(pixmap) +
", GLXPixmap " + toHexString(drawable) +
diff --git a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11PbufferGLXDrawable.java b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11PbufferGLXDrawable.java
index 0f758a2f7..ddb96ae6b 100644
--- a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11PbufferGLXDrawable.java
+++ b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11PbufferGLXDrawable.java
@@ -43,27 +43,24 @@ import javax.media.opengl.*;
import javax.media.nativewindow.*;
import com.sun.opengl.impl.*;
import com.sun.opengl.impl.x11.glx.*;
-import com.sun.nativewindow.impl.NullWindow;
import com.sun.nativewindow.impl.x11.*;
public class X11PbufferGLXDrawable extends X11GLXDrawable {
- protected X11PbufferGLXDrawable(GLDrawableFactory factory, AbstractGraphicsScreen screen,
- GLCapabilities caps,
+ protected X11PbufferGLXDrawable(GLDrawableFactory factory, NativeWindow target) {
+ /* GLCapabilities caps,
GLCapabilitiesChooser chooser,
- int width, int height) {
- super(factory, new NullWindow(X11GLXGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(caps, chooser, screen)), true);
- 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(width, height);
+ int width, int height */
+ super(factory, target, true);
if (DEBUG) {
- System.out.println("Pbuffer config: " + getNativeWindow().getGraphicsConfiguration().getNativeGraphicsConfiguration());
+ System.out.println("Pbuffer config: " + getNativeWindow().getGraphicsConfiguration().getNativeGraphicsConfiguration());
}
createPbuffer();
+
+ if (DEBUG) {
+ System.err.println("Created pbuffer " + this);
+ }
}
public GLContext createContext(GLContext shareWith) {
@@ -73,7 +70,7 @@ public class X11PbufferGLXDrawable extends X11GLXDrawable {
public void destroy() {
getFactoryImpl().lockToolkit();
try {
- NullWindow nw = (NullWindow) getNativeWindow();
+ NativeWindow nw = getNativeWindow();
if (nw.getSurfaceHandle() != 0) {
GLX.glXDestroyPbuffer(nw.getDisplayHandle(), nw.getSurfaceHandle());
}
@@ -96,7 +93,7 @@ public class X11PbufferGLXDrawable extends X11GLXDrawable {
throw new GLException("Null display");
}
- NullWindow nw = (NullWindow) getNativeWindow();
+ NativeWindow nw = getNativeWindow();
GLCapabilities capabilities = (GLCapabilities)config.getChosenCapabilities();
@@ -118,26 +115,22 @@ public class X11PbufferGLXDrawable extends X11GLXDrawable {
iattributes[niattribs++] = nw.getHeight();
iattributes[niattribs++] = 0;
- long drawable = GLX.glXCreatePbuffer(display, config.getFBConfig(), iattributes, 0);
- if (drawable == 0) {
+ long pbuffer = GLX.glXCreatePbuffer(display, config.getFBConfig(), iattributes, 0);
+ if (pbuffer == 0) {
// FIXME: query X error code for detail error message
throw new GLException("pbuffer creation error: glXCreatePbuffer() failed");
}
// Set up instance variables
- nw.setSurfaceHandle(drawable);
+ ((SurfaceChangeable)nw).setSurfaceHandle(pbuffer);
// Determine the actual width and height we were able to create.
int[] tmp = new int[1];
- GLX.glXQueryDrawable(display, drawable, GLX.GLX_WIDTH, tmp, 0);
+ GLX.glXQueryDrawable(display, pbuffer, GLX.GLX_WIDTH, tmp, 0);
int width = tmp[0];
- GLX.glXQueryDrawable(display, drawable, GLX.GLX_HEIGHT, tmp, 0);
+ GLX.glXQueryDrawable(display, pbuffer, GLX.GLX_HEIGHT, tmp, 0);
int height = tmp[0];
- nw.setSize(width, height);
-
- if (DEBUG) {
- System.err.println("Created pbuffer " + width + " x " + height);
- }
+ ((SurfaceChangeable)nw).setSize(width, height);
} finally {
getFactoryImpl().unlockToolkit();
}