summaryrefslogtreecommitdiffstats
path: root/src/jogl/classes
diff options
context:
space:
mode:
Diffstat (limited to 'src/jogl/classes')
-rwxr-xr-xsrc/jogl/classes/com/sun/opengl/impl/egl/EGLDrawable.java38
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/egl/EGLGraphicsConfiguration.java19
2 files changed, 46 insertions, 11 deletions
diff --git a/src/jogl/classes/com/sun/opengl/impl/egl/EGLDrawable.java b/src/jogl/classes/com/sun/opengl/impl/egl/EGLDrawable.java
index d2907c83d..aabc6f263 100755
--- a/src/jogl/classes/com/sun/opengl/impl/egl/EGLDrawable.java
+++ b/src/jogl/classes/com/sun/opengl/impl/egl/EGLDrawable.java
@@ -45,10 +45,10 @@ import javax.media.opengl.*;
public abstract class EGLDrawable extends GLDrawableImpl {
protected boolean ownEGLDisplay = false;
+ protected boolean ownEGLSurface = false;
private EGLGraphicsConfiguration eglConfig;
protected long eglDisplay;
protected long eglSurface;
- private int[] tmp = new int[1];
protected EGLDrawable(EGLDrawableFactory factory,
NativeWindow component) throws GLException {
@@ -78,13 +78,16 @@ public abstract class EGLDrawable extends GLDrawableImpl {
protected abstract long createSurface(long eglDpy, _EGLConfig eglNativeCfg);
private void recreateSurface() {
- if(EGL.EGL_NO_SURFACE!=eglSurface) {
- EGL.eglDestroySurface(eglDisplay, eglSurface);
- }
- eglSurface = createSurface(eglDisplay, eglConfig.getNativeConfig());
+ if(ownEGLSurface) {
+ // create a new EGLSurface ..
+ if(EGL.EGL_NO_SURFACE!=eglSurface) {
+ EGL.eglDestroySurface(eglDisplay, eglSurface);
+ }
+ eglSurface = createSurface(eglDisplay, eglConfig.getNativeConfig());
- if(DEBUG) {
- System.err.println("setSurface using component: handle 0x"+Long.toHexString(component.getWindowHandle())+" -> 0x"+Long.toHexString(eglSurface));
+ if(DEBUG) {
+ System.err.println("setSurface using component: handle 0x"+Long.toHexString(component.getWindowHandle())+" -> 0x"+Long.toHexString(eglSurface));
+ }
}
}
@@ -110,13 +113,28 @@ public abstract class EGLDrawable extends GLDrawableImpl {
if (null == eglConfig) {
throw new GLException("Null EGLGraphicsConfiguration from "+aConfig);
}
- eglConfig.updateGraphicsConfiguration();
+ int[] tmp = new int[1];
+ if (EGL.eglQuerySurface(eglDisplay, component.getWindowHandle(), EGL.EGL_CONFIG_ID, tmp, 0)) {
+ // component holds static EGLSurface
+ eglSurface = component.getWindowHandle();
+ if(DEBUG) {
+ System.err.println("setSurface re-using component's EGLSurface: handle 0x"+Long.toHexString(eglSurface));
+ }
+ } else {
+ // EGLSurface is ours ..
+ ownEGLSurface=true;
+
+ eglConfig.updateGraphicsConfiguration();
+ }
} else {
throw new GLException("EGLGraphicsConfiguration doesn't carry a EGLGraphicsDevice: "+aConfig);
}
} else {
// create a new EGL config ..
ownEGLDisplay=true;
+ // EGLSurface is ours ..
+ ownEGLSurface=true;
+
long nDisplay;
if( NativeWindowFactory.TYPE_WINDOWS.equals(NativeWindowFactory.getNativeWindowType(false)) ) {
nDisplay = component.getSurfaceHandle(); // don't even ask ..
@@ -153,7 +171,7 @@ public abstract class EGLDrawable extends GLDrawableImpl {
} finally {
unlockSurface();
}
- } else if (eglSurface != EGL.EGL_NO_SURFACE) {
+ } else if (ownEGLSurface && eglSurface != EGL.EGL_NO_SURFACE) {
// Destroy the window surface
if (!EGL.eglDestroySurface(eglDisplay, eglSurface)) {
throw new GLException("Error destroying window surface (eglDestroySurface)");
@@ -168,6 +186,7 @@ public abstract class EGLDrawable extends GLDrawableImpl {
}
public int getWidth() {
+ int[] tmp = new int[1];
if (!EGL.eglQuerySurface(eglDisplay, eglSurface, EGL.EGL_WIDTH, tmp, 0)) {
throw new GLException("Error querying surface width");
}
@@ -175,6 +194,7 @@ public abstract class EGLDrawable extends GLDrawableImpl {
}
public int getHeight() {
+ int[] tmp = new int[1];
if (!EGL.eglQuerySurface(eglDisplay, eglSurface, EGL.EGL_HEIGHT, tmp, 0)) {
throw new GLException("Error querying surface height");
}
diff --git a/src/jogl/classes/com/sun/opengl/impl/egl/EGLGraphicsConfiguration.java b/src/jogl/classes/com/sun/opengl/impl/egl/EGLGraphicsConfiguration.java
index 4f04bb57a..08fbae5bc 100644
--- a/src/jogl/classes/com/sun/opengl/impl/egl/EGLGraphicsConfiguration.java
+++ b/src/jogl/classes/com/sun/opengl/impl/egl/EGLGraphicsConfiguration.java
@@ -37,6 +37,7 @@ package com.sun.opengl.impl.egl;
import java.util.*;
import javax.media.nativewindow.*;
+import javax.media.nativewindow.egl.*;
import javax.media.opengl.*;
import com.sun.opengl.impl.*;
import com.sun.gluegen.runtime.NativeLibrary;
@@ -52,15 +53,29 @@ public class EGLGraphicsConfiguration extends DefaultGraphicsConfiguration imple
return configID;
}
- public EGLGraphicsConfiguration(AbstractGraphicsScreen screen,
+ public EGLGraphicsConfiguration(AbstractGraphicsScreen absScreen,
GLCapabilities capsChosen, GLCapabilities capsRequested, GLCapabilitiesChooser chooser,
_EGLConfig cfg, int cfgID) {
- super(screen, capsChosen, capsRequested);
+ super(absScreen, capsChosen, capsRequested);
this.chooser = chooser;
_config = cfg;
configID = cfgID;
}
+ public static EGLGraphicsConfiguration create(GLProfile glp, AbstractGraphicsScreen absScreen, int cfgID) {
+ AbstractGraphicsDevice absDevice = absScreen.getDevice();
+ if(null==absDevice || !(absDevice instanceof EGLGraphicsDevice)) {
+ throw new GLException("GraphicsDevice must be a valid EGLGraphicsDevice");
+ }
+ long dpy = absDevice.getHandle();
+ if (dpy == EGL.EGL_NO_DISPLAY) {
+ throw new GLException("Invalid EGL display: "+absDevice);
+ }
+ _EGLConfig _cfg = EGLConfigId2EGLConfig(glp, dpy, cfgID);
+ GLCapabilities caps = EGLConfig2Capabilities(glp, dpy, _cfg);
+ return new EGLGraphicsConfiguration(absScreen, caps, caps, new DefaultGLCapabilitiesChooser(), _cfg, cfgID);
+ }
+
public Object clone() {
return super.clone();
}