From 90beaae660222f1fb5ca15313f8e4645d3fd30fe Mon Sep 17 00:00:00 2001 From: Morris Meyer Date: Mon, 27 Jul 2009 14:06:41 -0400 Subject: mips changes --- .../classes/javax/media/nativewindow/NativeWindowFactory.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/nativewindow/classes') diff --git a/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java b/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java index cbd485649..fd6eb458e 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java +++ b/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java @@ -80,7 +80,7 @@ public abstract class NativeWindowFactory { } private static String _getNativeWindowingType(String osNameLowerCase) { - if (osNameLowerCase.startsWith("kd")) { + if (osNameLowerCase.startsWith("kd") || osNameLowerCase.startsWith("linux")) { return TYPE_EGL; } else if (osNameLowerCase.startsWith("wind")) { return TYPE_WINDOWS; @@ -101,6 +101,8 @@ public abstract class NativeWindowFactory { AccessControlContext acc = AccessController.getContext(); nativeOSNamePure = Debug.getProperty("os.name", false, acc); nativeOSNameCustom = Debug.getProperty("nativewindow.ws.name", true, acc); + System.out.println(nativeOSNamePure); + System.out.println(nativeOSNameCustom); if(null==nativeOSNameCustom||nativeOSNameCustom.length()==0) { nativeOSNameCustom = nativeOSNamePure; } -- cgit v1.2.3 From 8949675c20e3fc064d170b509391fadbdb970611 Mon Sep 17 00:00:00 2001 From: sg215889 Date: Mon, 27 Jul 2009 19:25:33 -0700 Subject: Add Custom NativeWindow Type 'BroadcomEGL' (-Dnativewindow.ws.name=BroadcomEGL): 1st Draft of supporting broadcom's proprietary EGL mapping --- make/build-jogl.xml | 39 +---- make/build-nativewindow.xml | 15 +- make/build-newt.xml | 65 ++++++-- make/config/jogl/eglext.cfg | 3 - make/make.jogl.all.linux-x86.sh | 10 +- make/make.jogl.all.linux-x86_64.sh | 13 +- make/stub_includes/egl/EGL/egl.h | 5 - .../com/sun/opengl/impl/egl/EGLDrawable.java | 38 +++-- .../opengl/impl/egl/EGLGraphicsConfiguration.java | 19 ++- .../media/nativewindow/NativeWindowFactory.java | 4 +- src/newt/classes/com/sun/javafx/newt/Display.java | 7 +- .../classes/com/sun/javafx/newt/NewtFactory.java | 5 +- src/newt/classes/com/sun/javafx/newt/Screen.java | 2 + src/newt/classes/com/sun/javafx/newt/Window.java | 2 + .../javafx/newt/opengl/broadcom/BCEGLDisplay.java | 82 ++++++++++ .../javafx/newt/opengl/broadcom/BCEGLScreen.java | 64 ++++++++ .../javafx/newt/opengl/broadcom/BCEGLWindow.java | 126 +++++++++++++++ .../com/sun/javafx/newt/opengl/egl/EGLDisplay.java | 85 ----------- src/newt/native/BroadcomEGL.c | 170 +++++++++++++++++++++ src/newt/native/KDWindow.c | 18 +-- 20 files changed, 578 insertions(+), 194 deletions(-) create mode 100644 src/newt/classes/com/sun/javafx/newt/opengl/broadcom/BCEGLDisplay.java create mode 100755 src/newt/classes/com/sun/javafx/newt/opengl/broadcom/BCEGLScreen.java create mode 100755 src/newt/classes/com/sun/javafx/newt/opengl/broadcom/BCEGLWindow.java delete mode 100644 src/newt/classes/com/sun/javafx/newt/opengl/egl/EGLDisplay.java create mode 100755 src/newt/native/BroadcomEGL.c (limited to 'src/nativewindow/classes') diff --git a/make/build-jogl.xml b/make/build-jogl.xml index 348dc0624..fda65c5b2 100644 --- a/make/build-jogl.xml +++ b/make/build-jogl.xml @@ -1199,16 +1199,9 @@ - + - - - - - - - @@ -1293,8 +1286,6 @@ - - @@ -1302,8 +1293,6 @@ - - @@ -1311,8 +1300,6 @@ - - @@ -1320,8 +1307,6 @@ - - @@ -1329,23 +1314,15 @@ - - - - - + - - @@ -1354,8 +1331,6 @@ - - @@ -1364,8 +1339,6 @@ - - @@ -1373,8 +1346,6 @@ - - @@ -1382,8 +1353,6 @@ - - @@ -1394,8 +1363,6 @@ - - @@ -1554,7 +1521,7 @@ - + diff --git a/make/build-nativewindow.xml b/make/build-nativewindow.xml index e583d05a6..641e2a4f5 100644 --- a/make/build-nativewindow.xml +++ b/make/build-nativewindow.xml @@ -490,6 +490,8 @@ + + @@ -531,35 +533,30 @@ - - - - - @@ -568,7 +565,6 @@ - @@ -576,7 +572,6 @@ - @@ -584,21 +579,18 @@ - - - @@ -608,7 +600,6 @@ - @@ -749,7 +740,7 @@ + linker.cfg.id="${linker.cfg.id.base}"/> diff --git a/make/build-newt.xml b/make/build-newt.xml index 31a23172a..95869546f 100644 --- a/make/build-newt.xml +++ b/make/build-newt.xml @@ -97,16 +97,13 @@ - - - - + @@ -118,7 +115,9 @@ + + @@ -135,7 +134,10 @@ value="com/sun/javafx/newt/macosx/*"/> + value="com/sun/javafx/newt/opengl/*, com/sun/javafx/newt/opengl/kd/*"/> + + @@ -148,7 +150,7 @@ + value="${java.part.opengl} ${java.part.broadcomegl}"> @@ -271,6 +273,7 @@ + @@ -279,6 +282,7 @@ + @@ -308,6 +312,7 @@ + @@ -364,7 +369,13 @@ + + + + + + @@ -421,7 +432,19 @@ - + + + + + + + + + + + + + @@ -521,6 +544,7 @@ + @@ -553,7 +577,8 @@ - + + @@ -583,16 +608,20 @@ - + + + + + - - - + + + - + + + + @@ -693,6 +726,10 @@ + + + @@ -735,7 +772,7 @@ + includes="${java.part.core} ${java.part.opengl} ${java.part.broadcomegl}"/> diff --git a/make/config/jogl/eglext.cfg b/make/config/jogl/eglext.cfg index 0447dd1e4..bdd9a3655 100755 --- a/make/config/jogl/eglext.cfg +++ b/make/config/jogl/eglext.cfg @@ -124,6 +124,3 @@ Ignore eglTerminate Ignore eglWaitClient Ignore eglWaitGL Ignore eglWaitNative - -Ignore EGLUtil_CreateDisplayByNative -Ignore EGLUtil_CreateWindowByNative diff --git a/make/make.jogl.all.linux-x86.sh b/make/make.jogl.all.linux-x86.sh index 915bacaf3..8842cbc0c 100644 --- a/make/make.jogl.all.linux-x86.sh +++ b/make/make.jogl.all.linux-x86.sh @@ -9,15 +9,17 @@ fi # -Dc.compiler.debug=true # -DuseOpenMAX=true \ # -Dbuild.noarchives=true +# -Dgluegen.cpptasks.detected.os=true \ +# -DisUnix=true \ +# -DisLinux=true \ +# -DisLinuxX86=true \ ant \ -Dbuild.noarchives=true \ -Djogl.cg=1 -Dx11.cg.lib=../../lib-linux-x86 \ -Drootrel.build=build-x86 \ - -Dgluegen.cpptasks.detected.os=true \ - -DisUnix=true \ - -DisLinux=true \ - -DisLinuxX86=true \ + -Dos.arch=x86 \ -DisX11=true \ + -DuseKD=true \ -DuseOpenMAX=true \ $* 2>&1 | tee make.jogl.all.linux-x86.log diff --git a/make/make.jogl.all.linux-x86_64.sh b/make/make.jogl.all.linux-x86_64.sh index b9e1d1789..90883f97c 100644 --- a/make/make.jogl.all.linux-x86_64.sh +++ b/make/make.jogl.all.linux-x86_64.sh @@ -8,14 +8,17 @@ fi # -Dc.compiler.debug=true # -Dbuild.noarchives=true +# -Dgluegen.cpptasks.detected.os=true \ +# -DisUnix=true \ +# -DisLinux=true \ +# -DisLinuxAMD64=true \ +# -DisX11=true \ + ant \ -Dbuild.noarchives=true \ -Djogl.cg=1 -Dx11.cg.lib=../../lib-linux-x86_64 \ -Dc.compiler.debug=true \ -Drootrel.build=build-x86_64 \ - -Dgluegen.cpptasks.detected.os=true \ - -DisUnix=true \ - -DisLinux=true \ - -DisLinuxAMD64=true \ - -DisX11=true \ + -DuseKD=true \ + -DuseOpenMAX=true \ $* 2>&1 | tee make.jogl.all.linux-x86_64.log diff --git a/make/stub_includes/egl/EGL/egl.h b/make/stub_includes/egl/EGL/egl.h index 5b4c4215c..86ca4818f 100755 --- a/make/stub_includes/egl/EGL/egl.h +++ b/make/stub_includes/egl/EGL/egl.h @@ -297,11 +297,6 @@ EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffers(EGLDisplay dpy, EGLSurface surface) EGLAPI EGLBoolean EGLAPIENTRY eglCopyBuffers(EGLDisplay dpy, EGLSurface surface, EGLNativePixmapType target); -EGLAPI EGLDisplay EGLAPIENTRY EGLUtil_CreateDisplayByNative(EGLint w, EGLint h); - -EGLAPI EGLSurface EGLAPIENTRY EGLUtil_CreateWindowByNative(EGLDisplay dpy, EGLint xx, - EGLint *wvalue, EGLint *hvalue); - typedef void (* EGLAPIENTRY __EGLFuncPtr)(void); EGLAPI __EGLFuncPtr eglGetProcAddress(const char *procname); 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(); } diff --git a/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java b/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java index fd6eb458e..cbd485649 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java +++ b/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java @@ -80,7 +80,7 @@ public abstract class NativeWindowFactory { } private static String _getNativeWindowingType(String osNameLowerCase) { - if (osNameLowerCase.startsWith("kd") || osNameLowerCase.startsWith("linux")) { + if (osNameLowerCase.startsWith("kd")) { return TYPE_EGL; } else if (osNameLowerCase.startsWith("wind")) { return TYPE_WINDOWS; @@ -101,8 +101,6 @@ public abstract class NativeWindowFactory { AccessControlContext acc = AccessController.getContext(); nativeOSNamePure = Debug.getProperty("os.name", false, acc); nativeOSNameCustom = Debug.getProperty("nativewindow.ws.name", true, acc); - System.out.println(nativeOSNamePure); - System.out.println(nativeOSNameCustom); if(null==nativeOSNameCustom||nativeOSNameCustom.length()==0) { nativeOSNameCustom = nativeOSNamePure; } diff --git a/src/newt/classes/com/sun/javafx/newt/Display.java b/src/newt/classes/com/sun/javafx/newt/Display.java index bdac08dab..04fdb0181 100755 --- a/src/newt/classes/com/sun/javafx/newt/Display.java +++ b/src/newt/classes/com/sun/javafx/newt/Display.java @@ -45,16 +45,15 @@ public abstract class Display implements Runnable { { Class displayClass = null; if (NativeWindowFactory.TYPE_EGL.equals(type)) { - // displayClass = Class.forName("com.sun.javafx.newt.opengl.kd.KDDisplay"); - displayClass = Class.forName("com.sun.javafx.newt.opengl.egl.EGLDisplay"); + displayClass = Class.forName("com.sun.javafx.newt.opengl.kd.KDDisplay"); } else if (NativeWindowFactory.TYPE_WINDOWS.equals(type)) { displayClass = Class.forName("com.sun.javafx.newt.windows.WindowsDisplay"); } else if (NativeWindowFactory.TYPE_MACOSX.equals(type)) { displayClass = Class.forName("com.sun.javafx.newt.macosx.MacDisplay"); } else if (NativeWindowFactory.TYPE_X11.equals(type)) { displayClass = Class.forName("com.sun.javafx.newt.x11.X11Display"); - } else if (NativeWindowFactory.TYPE_AWT.equals(type)) { - displayClass = Class.forName("com.sun.javafx.newt.awt.AWTDisplay"); + } else if (NewtFactory.TYPE_BROADCOM_EGL.equals(type)) { + displayClass = Class.forName("com.sun.javafx.newt.opengl.broadcom.BCEGLDisplay"); } else { throw new RuntimeException("Unknown display type \"" + type + "\""); } diff --git a/src/newt/classes/com/sun/javafx/newt/NewtFactory.java b/src/newt/classes/com/sun/javafx/newt/NewtFactory.java index b88e1e49e..dbae30a4b 100755 --- a/src/newt/classes/com/sun/javafx/newt/NewtFactory.java +++ b/src/newt/classes/com/sun/javafx/newt/NewtFactory.java @@ -39,6 +39,8 @@ import java.util.Iterator; import com.sun.nativewindow.impl.jvm.JVMUtil; public abstract class NewtFactory { + public static final String TYPE_BROADCOM_EGL = "BroadcomEGL"; + // Work-around for initialization order problems on Mac OS X // between native Newt and (apparently) Fmod static { @@ -50,7 +52,6 @@ public abstract class NewtFactory { * Create a Display entity, incl native creation */ public static Display createDisplay(String name) { - System.out.println("NewtFactory: NAME: " + name); return Display.create(NativeWindowFactory.getNativeWindowType(true), name); } @@ -58,8 +59,6 @@ public abstract class NewtFactory { * Create a Display entity using the given implementation type, incl native creation */ public static Display createDisplay(String type, String name) { - System.out.println("NewtFactory: TYPE: " + type); - System.out.println("NewtFactory: NAME: " + name); return Display.create(type, name); } diff --git a/src/newt/classes/com/sun/javafx/newt/Screen.java b/src/newt/classes/com/sun/javafx/newt/Screen.java index 2566041a8..57ed34211 100755 --- a/src/newt/classes/com/sun/javafx/newt/Screen.java +++ b/src/newt/classes/com/sun/javafx/newt/Screen.java @@ -54,6 +54,8 @@ public abstract class Screen { screenClass = Class.forName("com.sun.javafx.newt.x11.X11Screen"); } else if (NativeWindowFactory.TYPE_AWT.equals(type)) { screenClass = Class.forName("com.sun.javafx.newt.awt.AWTScreen"); + } else if (NewtFactory.TYPE_BROADCOM_EGL.equals(type)) { + screenClass = Class.forName("com.sun.javafx.newt.opengl.broadcom.BCEGLScreen"); } else { throw new RuntimeException("Unknown window type \"" + type + "\""); } diff --git a/src/newt/classes/com/sun/javafx/newt/Window.java b/src/newt/classes/com/sun/javafx/newt/Window.java index 36eafd32d..a1168d12d 100755 --- a/src/newt/classes/com/sun/javafx/newt/Window.java +++ b/src/newt/classes/com/sun/javafx/newt/Window.java @@ -74,6 +74,8 @@ public abstract class Window implements NativeWindow windowClass = Class.forName("com.sun.javafx.newt.x11.X11Window"); } else if (NativeWindowFactory.TYPE_AWT.equals(type)) { windowClass = Class.forName("com.sun.javafx.newt.awt.AWTWindow"); + } else if (NewtFactory.TYPE_BROADCOM_EGL.equals(type)) { + windowClass = Class.forName("com.sun.javafx.newt.opengl.broadcom.BCEGLWindow"); } else { throw new NativeWindowException("Unknown window type \"" + type + "\""); } diff --git a/src/newt/classes/com/sun/javafx/newt/opengl/broadcom/BCEGLDisplay.java b/src/newt/classes/com/sun/javafx/newt/opengl/broadcom/BCEGLDisplay.java new file mode 100644 index 000000000..abf9859c5 --- /dev/null +++ b/src/newt/classes/com/sun/javafx/newt/opengl/broadcom/BCEGLDisplay.java @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * - Redistribution of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistribution in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name of Sun Microsystems, Inc. or the names of + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * This software is provided "AS IS," without a warranty of any kind. ALL + * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, + * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN + * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR + * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR + * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR + * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR + * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE + * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, + * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF + * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * + */ + +package com.sun.javafx.newt.opengl.broadcom; + +import com.sun.javafx.newt.*; +import com.sun.javafx.newt.impl.*; +import com.sun.opengl.impl.egl.*; +import javax.media.nativewindow.*; +import javax.media.nativewindow.egl.*; + +public class BCEGLDisplay extends Display { + + static { + NativeLibLoader.loadNEWT(); + + if (!BCEGLWindow.initIDs()) { + throw new NativeWindowException("Failed to initialize BCEGLWindow jmethodIDs"); + } + } + + public static void initSingleton() { + // just exist to ensure static init has been run + } + + + public BCEGLDisplay() { + } + + protected void createNative() { + long handle = CreateDisplay(BCEGLScreen.fixedWidth, BCEGLScreen.fixedHeight); + if (handle == EGL.EGL_NO_DISPLAY) { + throw new NativeWindowException("BC EGL CreateDisplay failed"); + } + aDevice = new EGLGraphicsDevice(handle); + } + + protected void closeNative() { + if (aDevice.getHandle() != EGL.EGL_NO_DISPLAY) { + DestroyDisplay(aDevice.getHandle()); + } + } + + protected void dispatchMessages() { + DispatchMessages(); + } + + private native long CreateDisplay(int width, int height); + private native void DestroyDisplay(long dpy); + private native void DispatchMessages(); +} + diff --git a/src/newt/classes/com/sun/javafx/newt/opengl/broadcom/BCEGLScreen.java b/src/newt/classes/com/sun/javafx/newt/opengl/broadcom/BCEGLScreen.java new file mode 100755 index 000000000..165081cde --- /dev/null +++ b/src/newt/classes/com/sun/javafx/newt/opengl/broadcom/BCEGLScreen.java @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * - Redistribution of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistribution in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name of Sun Microsystems, Inc. or the names of + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * This software is provided "AS IS," without a warranty of any kind. ALL + * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, + * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN + * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR + * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR + * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR + * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR + * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE + * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, + * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF + * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * + */ + +package com.sun.javafx.newt.opengl.broadcom; + +import com.sun.javafx.newt.*; +import com.sun.javafx.newt.impl.*; +import javax.media.nativewindow.*; + +public class BCEGLScreen extends Screen { + + static { + BCEGLDisplay.initSingleton(); + } + + + public BCEGLScreen() { + } + + protected void createNative(int index) { + aScreen = new DefaultGraphicsScreen(getDisplay().getGraphicsDevice(), index); + setScreenSize(fixedWidth, fixedHeight); + } + + protected void closeNative() { } + + //---------------------------------------------------------------------- + // Internals only + // + + static final int fixedWidth = 1920; + static final int fixedHeight = 1080; +} + diff --git a/src/newt/classes/com/sun/javafx/newt/opengl/broadcom/BCEGLWindow.java b/src/newt/classes/com/sun/javafx/newt/opengl/broadcom/BCEGLWindow.java new file mode 100755 index 000000000..a91a91598 --- /dev/null +++ b/src/newt/classes/com/sun/javafx/newt/opengl/broadcom/BCEGLWindow.java @@ -0,0 +1,126 @@ +/* + * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * - Redistribution of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistribution in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name of Sun Microsystems, Inc. or the names of + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * This software is provided "AS IS," without a warranty of any kind. ALL + * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, + * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN + * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR + * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR + * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR + * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR + * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE + * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, + * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF + * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * + */ + +package com.sun.javafx.newt.opengl.broadcom; + +import com.sun.javafx.newt.*; +import com.sun.javafx.newt.impl.*; +import com.sun.opengl.impl.egl.*; +import javax.media.nativewindow.*; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLProfile; +import javax.media.nativewindow.NativeWindowException; + +public class BCEGLWindow extends Window { + static { + BCEGLDisplay.initSingleton(); + } + + public BCEGLWindow() { + } + + protected void createNative(Capabilities caps) { + // just save the GLProfile here, create window later .. + glProfile = ((GLCapabilities)caps).getGLProfile(); + } + + protected void closeNative() { + if(0!=windowHandleClose) { + CloseWindow(getDisplayHandle(), windowHandleClose); + } + } + + public void setVisible(boolean visible) { + if(this.visible!=visible) { + this.visible=visible; + if ( 0==windowHandle ) { + windowHandle = realizeWindow(true, width, height); + if (0 == windowHandle) { + throw new NativeWindowException("Error native Window Handle is null"); + } + } + clearEventMask(); + } + } + + public void setSize(int width, int height) { + if(0!=windowHandle) { + // n/a in BroadcomEGL + System.err.println("setSize n/a in BroadcomEGL with realized window"); + } else { + this.width = width; + this.height = height; + } + } + + public void setPosition(int x, int y) { + // n/a in BroadcomEGL + System.err.println("setPosition n/a in BroadcomEGL"); + } + + public boolean setFullscreen(boolean fullscreen) { + // n/a in BroadcomEGL + System.err.println("setFullscreen n/a in BroadcomEGL"); + return false; + } + + //---------------------------------------------------------------------- + // Internals only + // + + protected static native boolean initIDs(); + private native long CreateWindow(long eglDisplayHandle, boolean chromaKey, int width, int height); + private native void CloseWindow(long eglDisplayHandle, long eglWindowHandle); + + + private long realizeWindow(boolean chromaKey, int width, int height) { + long handle = CreateWindow(getDisplayHandle(), chromaKey, width, height); + if (0 == handle) { + throw new NativeWindowException("Error native Window Handle is null"); + } + windowHandleClose = handle; + return handle; + } + + private void windowCreated(int cfgID, int width, int height) { + this.width = width; + this.height = height; + config = EGLGraphicsConfiguration.create(glProfile, screen.getGraphicsScreen(), cfgID); + if (config == null) { + throw new NativeWindowException("Error creating EGLGraphicsConfiguration from id: "+cfgID+", "+this); + } + } + + private long windowHandleClose; + private GLProfile glProfile; +} diff --git a/src/newt/classes/com/sun/javafx/newt/opengl/egl/EGLDisplay.java b/src/newt/classes/com/sun/javafx/newt/opengl/egl/EGLDisplay.java deleted file mode 100644 index bebb7ccf2..000000000 --- a/src/newt/classes/com/sun/javafx/newt/opengl/egl/EGLDisplay.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * - Redistribution of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * - Redistribution in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * Neither the name of Sun Microsystems, Inc. or the names of - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * This software is provided "AS IS," without a warranty of any kind. ALL - * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, - * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A - * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN - * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR - * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR - * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR - * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR - * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE - * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, - * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF - * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * - */ - -package com.sun.javafx.newt.opengl.egl; - -import com.sun.javafx.newt.*; -import com.sun.javafx.newt.impl.*; -import com.sun.opengl.impl.egl.*; -import javax.media.nativewindow.*; -import javax.media.nativewindow.egl.*; - -public class EGLDisplay extends Display { - - static { - NativeLibLoader.loadNEWT(); - - System.loadLibrary("EglUtil"); - } - - public static void initSingleton() { - // just exist to ensure static init has been run - } - - - public EGLDisplay() { - } - - protected void createNative() { - try { - int windowWidth = 1920, windowHeight = 1080; - int width[] = { windowWidth }; - int height[] = { windowHeight }; - long eglDisplayHandle = - EGL.EGLUtil_CreateDisplayByNative(windowWidth, windowHeight); - long eglSurfaceHandle = - EGL.EGLUtil_CreateWindowByNative(eglDisplayHandle, 1, - width, 0, height, 0); - } catch (Throwable th) { - th.printStackTrace(); - } - } - - protected void closeNative() { - if (aDevice.getHandle() != EGL.EGL_NO_DISPLAY) { - EGL.eglTerminate(aDevice.getHandle()); - } - } - - protected void dispatchMessages() { - DispatchMessages(); - } - - private native void DispatchMessages(); -} - diff --git a/src/newt/native/BroadcomEGL.c b/src/newt/native/BroadcomEGL.c new file mode 100755 index 000000000..8afa71a47 --- /dev/null +++ b/src/newt/native/BroadcomEGL.c @@ -0,0 +1,170 @@ +/* + * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * - Redistribution of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistribution in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name of Sun Microsystems, Inc. or the names of + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * This software is provided "AS IS," without a warranty of any kind. ALL + * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, + * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN + * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR + * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR + * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR + * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR + * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE + * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, + * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF + * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * + */ + +#ifdef _WIN32 + #include +#else + #include +#endif + +#include +#include +#include + +#include "com_sun_javafx_newt_opengl_broadcom_BCEGLWindow.h" + +#include "EventListener.h" +#include "MouseEvent.h" +#include "KeyEvent.h" + +#include + +typedef unsigned int GLuint; + +EGLDisplay EGLUtil_CreateDisplay( GLuint uiWidth, GLuint uiHeight ); +void EGLUtil_DestroyDisplay( EGLDisplay eglDisplay ); + +EGLSurface EGLUtil_CreateWindow( EGLDisplay eglDisplay, /* bool */ GLuint bChromakey, GLuint *puiWidth, GLuint *puiHeight ); +void EGLUtil_DestroyWindow( EGLDisplay eglDisplay, EGLSurface eglSurface ); +void EGLUtil_SwapWindow( EGLDisplay eglDisplay, EGLSurface eglSurface ); + +#define VERBOSE_ON 1 + +#ifdef VERBOSE_ON + #define DBG_PRINT(...) fprintf(stdout, __VA_ARGS__) +#else + #define DBG_PRINT(...) +#endif + +static jmethodID windowCreatedID = NULL; + +/** + * Display + */ + +JNIEXPORT void JNICALL Java_com_sun_javafx_newt_opengl_broadcom_BCEGLDisplay_DispatchMessages + (JNIEnv *env, jobject obj) +{ + // FIXME: n/a + (void) env; + (void) obj; +} + +JNIEXPORT jlong JNICALL Java_com_sun_javafx_newt_opengl_broadcom_BCEGLDisplay_CreateDisplay + (JNIEnv *env, jobject obj, jint width, jint height) +{ + (void) env; + (void) obj; + EGLDisplay dpy = EGLUtil_CreateDisplay( (GLuint) width, (GLuint) height ); + if(NULL==dpy) { + fprintf(stderr, "[CreateDisplay] failed: NULL\n"); + } else { + DBG_PRINT( "[CreateDisplay] ok: %p, %ux%u\n", dpy, width, height); + } + return (jlong) (intptr_t) dpy; +} + +JNIEXPORT void JNICALL Java_com_sun_javafx_newt_opengl_broadcom_BCEGLDisplay_DestroyDisplay + (JNIEnv *env, jobject obj, jlong display) +{ + EGLDisplay dpy = (EGLDisplay)(intptr_t)display; + (void) env; + (void) obj; + EGLUtil_DestroyDisplay(dpy); +} + +/** + * Window + */ + +JNIEXPORT jboolean JNICALL Java_com_sun_javafx_newt_opengl_broadcom_BCEGLWindow_initIDs + (JNIEnv *env, jclass clazz) +{ + windowCreatedID = (*env)->GetMethodID(env, clazz, "windowCreated", "(III)V"); + if (windowCreatedID == NULL) { + DBG_PRINT( "initIDs failed\n" ); + return JNI_FALSE; + } + DBG_PRINT( "initIDs ok\n" ); + return JNI_TRUE; +} + +JNIEXPORT jlong JNICALL Java_com_sun_javafx_newt_opengl_broadcom_BCEGLWindow_CreateWindow + (JNIEnv *env, jobject obj, jlong display, jboolean chromaKey, jint width, jint height) +{ + EGLDisplay dpy = (EGLDisplay)(intptr_t)display; + EGLSurface window = 0; + GLuint uiWidth=(GLuint)width, uiHeight=(GLuint)height; + + if(dpy==NULL) { + fprintf(stderr, "[RealizeWindow] invalid display connection..\n"); + return 0; + } + + window = EGLUtil_CreateWindow( dpy, chromaKey, &uiWidth, &uiHeight ); + // EGLUtil_DestroyWindow( dpy, window ); + + if(NULL==window) { + fprintf(stderr, "[RealizeWindow.Create] failed: NULL\n"); + return 0; + } + EGLint cfgID=0; + if(EGL_FALSE==eglQuerySurface(dpy, window, EGL_CONFIG_ID, &cfgID)) { + fprintf(stderr, "[RealizeWindow.ConfigID] failed: window %p\n", window); + EGLUtil_DestroyWindow(dpy, window); + return 0; + } + (*env)->CallVoidMethod(env, obj, windowCreatedID, (jint) cfgID, (jint)uiWidth, (jint)uiHeight); + DBG_PRINT( "[RealizeWindow.Create] ok: %p, cfgid %d, %ux%u\n", window, cfgID, uiWidth, uiHeight); + + // release and destroy already made context .. + EGLContext ctx = eglGetCurrentContext(); + eglMakeCurrent(dpy, + EGL_NO_SURFACE, + EGL_NO_SURFACE, + EGL_NO_CONTEXT); + eglDestroyContext(dpy, ctx); + + return (jlong) (intptr_t) window; +} + +JNIEXPORT void JNICALL Java_com_sun_javafx_newt_opengl_broadcom_BCEGLWindow_CloseWindow + (JNIEnv *env, jobject obj, jlong display, jlong window) +{ + EGLDisplay dpy = (EGLDisplay)(intptr_t)display; + EGLSurface surf = (EGLSurface) (intptr_t) window; + EGLUtil_DestroyWindow(dpy, surf); + + DBG_PRINT( "[CloseWindow]\n"); +} + diff --git a/src/newt/native/KDWindow.c b/src/newt/native/KDWindow.c index 8e57237b3..6c7aa7731 100755 --- a/src/newt/native/KDWindow.c +++ b/src/newt/native/KDWindow.c @@ -103,7 +103,7 @@ static jmethodID sendKeyEventID = NULL; * Display */ -JNIEXPORT void JNICALL Java_com_sun_javafx_newt_kd_KDDisplay_DispatchMessages +JNIEXPORT void JNICALL Java_com_sun_javafx_newt_opengl_kd_KDDisplay_DispatchMessages (JNIEnv *env, jobject obj) { const KDEvent * evt; @@ -200,7 +200,7 @@ JNIEXPORT void JNICALL Java_com_sun_javafx_newt_kd_KDDisplay_DispatchMessages * Window */ -JNIEXPORT jboolean JNICALL Java_com_sun_javafx_newt_kd_KDWindow_initIDs +JNIEXPORT jboolean JNICALL Java_com_sun_javafx_newt_opengl_kd_KDWindow_initIDs (JNIEnv *env, jclass clazz) { #ifdef VERBOSE_ON @@ -228,7 +228,7 @@ JNIEXPORT jboolean JNICALL Java_com_sun_javafx_newt_kd_KDWindow_initIDs return JNI_TRUE; } -JNIEXPORT jlong JNICALL Java_com_sun_javafx_newt_kd_KDWindow_CreateWindow +JNIEXPORT jlong JNICALL Java_com_sun_javafx_newt_opengl_kd_KDWindow_CreateWindow (JNIEnv *env, jobject obj, jlong display, jintArray jAttrs) { jint * attrs = NULL; @@ -270,7 +270,7 @@ JNIEXPORT jlong JNICALL Java_com_sun_javafx_newt_kd_KDWindow_CreateWindow return (jlong) (intptr_t) window; } -JNIEXPORT jlong JNICALL Java_com_sun_javafx_newt_kd_KDWindow_RealizeWindow +JNIEXPORT jlong JNICALL Java_com_sun_javafx_newt_opengl_kd_KDWindow_RealizeWindow (JNIEnv *env, jobject obj, jlong window) { KDWindow *w = (KDWindow*) (intptr_t) window; @@ -285,7 +285,7 @@ JNIEXPORT jlong JNICALL Java_com_sun_javafx_newt_kd_KDWindow_RealizeWindow return (jlong) (intptr_t) nativeWindow; } -JNIEXPORT jint JNICALL Java_com_sun_javafx_newt_kd_KDWindow_CloseWindow +JNIEXPORT jint JNICALL Java_com_sun_javafx_newt_opengl_kd_KDWindow_CloseWindow (JNIEnv *env, jobject obj, jlong window, jlong juserData) { KDWindow *w = (KDWindow*) (intptr_t) window; @@ -299,11 +299,11 @@ JNIEXPORT jint JNICALL Java_com_sun_javafx_newt_kd_KDWindow_CloseWindow } /* - * Class: com_sun_javafx_newt_kd_KDWindow + * Class: com_sun_javafx_newt_opengl_kd_KDWindow * Method: setVisible0 * Signature: (JJZ)V */ -JNIEXPORT void JNICALL Java_com_sun_javafx_newt_kd_KDWindow_setVisible0 +JNIEXPORT void JNICALL Java_com_sun_javafx_newt_opengl_kd_KDWindow_setVisible0 (JNIEnv *env, jobject obj, jlong window, jboolean visible) { KDWindow *w = (KDWindow*) (intptr_t) window; @@ -312,7 +312,7 @@ JNIEXPORT void JNICALL Java_com_sun_javafx_newt_kd_KDWindow_setVisible0 DBG_PRINT( "[setVisible] v=%d\n", visible); } -JNIEXPORT void JNICALL Java_com_sun_javafx_newt_kd_KDWindow_setFullScreen0 +JNIEXPORT void JNICALL Java_com_sun_javafx_newt_opengl_kd_KDWindow_setFullScreen0 (JNIEnv *env, jobject obj, jlong window, jboolean fullscreen) { KDWindow *w = (KDWindow*) (intptr_t) window; @@ -323,7 +323,7 @@ JNIEXPORT void JNICALL Java_com_sun_javafx_newt_kd_KDWindow_setFullScreen0 (void)res; } -JNIEXPORT void JNICALL Java_com_sun_javafx_newt_kd_KDWindow_setSize0 +JNIEXPORT void JNICALL Java_com_sun_javafx_newt_opengl_kd_KDWindow_setSize0 (JNIEnv *env, jobject obj, jlong window, jint width, jint height) { KDWindow *w = (KDWindow*) (intptr_t) window; -- cgit v1.2.3 From b6d75cac68340878b20d35b23c8449c97ad9d819 Mon Sep 17 00:00:00 2001 From: Morris Meyer Date: Tue, 28 Jul 2009 17:34:20 -0400 Subject: EGL changes for device --- make/build-newt.xml | 1 + .../classes/com/sun/opengl/impl/GLDrawableImpl.java | 19 ++++++++++++++++++- .../com/sun/opengl/impl/egl/EGLDrawableFactory.java | 6 +++++- .../sun/opengl/impl/egl/EGLDynamicLookupHelper.java | 14 ++++++++++---- .../opengl/impl/egl/EGLES1DynamicLookupHelper.java | 2 ++ src/jogl/classes/javax/media/opengl/GLProfile.java | 6 +++--- .../com/sun/nativewindow/impl/NWReflection.java | 11 +++++++++-- .../javax/media/nativewindow/NativeWindowFactory.java | 5 +++++ src/newt/native/BroadcomEGL.c | 4 ++-- 9 files changed, 55 insertions(+), 13 deletions(-) (limited to 'src/nativewindow/classes') diff --git a/make/build-newt.xml b/make/build-newt.xml index 48c11f6dd..1ed039a57 100644 --- a/make/build-newt.xml +++ b/make/build-newt.xml @@ -371,6 +371,7 @@ + diff --git a/src/jogl/classes/com/sun/opengl/impl/GLDrawableImpl.java b/src/jogl/classes/com/sun/opengl/impl/GLDrawableImpl.java index c381f68f5..e71cf33a0 100644 --- a/src/jogl/classes/com/sun/opengl/impl/GLDrawableImpl.java +++ b/src/jogl/classes/com/sun/opengl/impl/GLDrawableImpl.java @@ -52,7 +52,24 @@ public abstract class GLDrawableImpl implements GLDrawable { this.factory = factory; this.component = comp; this.realized = realized; - this.requestedCapabilities = (GLCapabilities)component.getGraphicsConfiguration().getNativeGraphicsConfiguration().getRequestedCapabilities(); // a copy .. + + AbstractGraphicsConfiguration agc = component.getGraphicsConfiguration(); + if (agc == null) { + System.out.println("GLDrawableImpl no AbstractGraphicsConfiguration"); + System.out.println(component.getClass().getName()); + return; + } + AbstractGraphicsConfiguration ngc = agc.getNativeGraphicsConfiguration(); + if (ngc == null) { + System.out.println("GLDrawableImpl no native AbstractGraphicsConfiguration"); + return; + } + Capabilities caps = ngc.getRequestedCapabilities(); + if (caps == null) { + System.out.println("GLDrawableImpl no native Capabilities"); + return; + } + this.requestedCapabilities = (GLCapabilities)caps; // a copy .. } /** diff --git a/src/jogl/classes/com/sun/opengl/impl/egl/EGLDrawableFactory.java b/src/jogl/classes/com/sun/opengl/impl/egl/EGLDrawableFactory.java index 396580c1d..e2ee65d27 100755 --- a/src/jogl/classes/com/sun/opengl/impl/egl/EGLDrawableFactory.java +++ b/src/jogl/classes/com/sun/opengl/impl/egl/EGLDrawableFactory.java @@ -45,15 +45,19 @@ import com.sun.gluegen.runtime.NativeLibrary; public class EGLDrawableFactory extends GLDrawableFactoryImpl { static { + try { // Register our GraphicsConfigurationFactory implementations // The act of constructing them causes them to be registered new EGLGraphicsConfigurationFactory(); // Check for other underlying stuff .. - if(NativeWindowFactory.TYPE_X11.equals(NativeWindowFactory.getNativeWindowType(false))) { + /* if(NativeWindowFactory.TYPE_X11.equals(NativeWindowFactory.getNativeWindowType(false))) { try { NWReflection.createInstance("com.sun.opengl.impl.x11.glx.X11GLXGraphicsConfigurationFactory"); } catch (Throwable t) {} + } */ + } catch (Throwable th) { + th.printStackTrace(); } } diff --git a/src/jogl/classes/com/sun/opengl/impl/egl/EGLDynamicLookupHelper.java b/src/jogl/classes/com/sun/opengl/impl/egl/EGLDynamicLookupHelper.java index 8bed0eb35..99f163ca1 100755 --- a/src/jogl/classes/com/sun/opengl/impl/egl/EGLDynamicLookupHelper.java +++ b/src/jogl/classes/com/sun/opengl/impl/egl/EGLDynamicLookupHelper.java @@ -50,7 +50,7 @@ import com.sun.gluegen.runtime.DynamicLookupHelper; * Currently two implementations exist, one for ES1 and one for ES2. */ public abstract class EGLDynamicLookupHelper implements DynamicLookupHelper { - protected static final boolean DEBUG = com.sun.opengl.impl.Debug.debug("EGL"); + protected static final boolean DEBUG = true; /* com.sun.opengl.impl.Debug.debug("EGL"); */ private static final EGLDynamicLookupHelper eglES1DynamicLookupHelper; private static final EGLDynamicLookupHelper eglES2DynamicLookupHelper; @@ -136,9 +136,13 @@ public abstract class EGLDynamicLookupHelper implements DynamicLookupHelper { private NativeLibrary loadFirstAvailable(List/**/ libNames, ClassLoader loader) { for (Iterator iter = libNames.iterator(); iter.hasNext(); ) { - NativeLibrary lib = NativeLibrary.open((String) iter.next(), loader, false /*global*/); + String libname = (String) iter.next(); + NativeLibrary lib = NativeLibrary.open(libname, loader, false /*global*/); if (lib != null) { + System.out.println("found: " + libname); return lib; + } else { + System.out.println("looked for: " + libname); } } return null; @@ -164,9 +168,11 @@ public abstract class EGLDynamicLookupHelper implements DynamicLookupHelper { // EGL libraries .. lib = loadFirstAvailable(eglLibNames, loader); if (lib == null) { - throw new GLException("Unable to dynamically load EGL library for profile ES" + esProfile); + // throw new GLException("Unable to dynamically load EGL library for profile ES" + esProfile); + System.out.println("Unable to dynamically load EGL library for profile ES" + esProfile); + } else { + glesLibraries.add(lib); } - glesLibraries.add(lib); } if (esProfile==2) { diff --git a/src/jogl/classes/com/sun/opengl/impl/egl/EGLES1DynamicLookupHelper.java b/src/jogl/classes/com/sun/opengl/impl/egl/EGLES1DynamicLookupHelper.java index 7e60e25c0..68630344a 100755 --- a/src/jogl/classes/com/sun/opengl/impl/egl/EGLES1DynamicLookupHelper.java +++ b/src/jogl/classes/com/sun/opengl/impl/egl/EGLES1DynamicLookupHelper.java @@ -58,6 +58,8 @@ public class EGLES1DynamicLookupHelper extends EGLDynamicLookupHelper { protected List/**/ getGLESLibNames() { List/**/ glesLibNames = new ArrayList(); + glesLibNames.add("nexus"); + glesLibNames.add("GLES_CM"); glesLibNames.add("GLES_CL"); glesLibNames.add("GLESv1_CM"); diff --git a/src/jogl/classes/javax/media/opengl/GLProfile.java b/src/jogl/classes/javax/media/opengl/GLProfile.java index ead5f6396..83a9b0098 100644 --- a/src/jogl/classes/javax/media/opengl/GLProfile.java +++ b/src/jogl/classes/javax/media/opengl/GLProfile.java @@ -54,7 +54,7 @@ import com.sun.nativewindow.impl.jvm.JVMUtil; * or more specialized versions using the other static GetProfile methods. */ public class GLProfile implements Cloneable { - public static final boolean DEBUG = Debug.debug("GLProfile"); + public static final boolean DEBUG = true; /* Debug.debug("GLProfile"); */ // // Public (user-visible) profiles @@ -736,8 +736,8 @@ public class GLProfile implements Cloneable { } } mappedProfiles = _mappedProfiles; // final .. - if(null==defaultGLProfile) { - throw new GLException("No profile available: "+list2String(GL_PROFILE_LIST_ALL)); + if (null==defaultGLProfile) { + System.out.println("No profile available: "+list2String(GL_PROFILE_LIST_ALL)); } } diff --git a/src/nativewindow/classes/com/sun/nativewindow/impl/NWReflection.java b/src/nativewindow/classes/com/sun/nativewindow/impl/NWReflection.java index b13cf4317..d054c205b 100644 --- a/src/nativewindow/classes/com/sun/nativewindow/impl/NWReflection.java +++ b/src/nativewindow/classes/com/sun/nativewindow/impl/NWReflection.java @@ -40,7 +40,7 @@ import java.lang.reflect.*; import javax.media.nativewindow.*; public final class NWReflection { - public static final boolean DEBUG = Debug.debug("NWReflection"); + public static final boolean DEBUG = true; /* Debug.debug("NWReflection"); */ public static final boolean isClassAvailable(String clazzName) { try { @@ -69,7 +69,11 @@ public final class NWReflection { try { factory = factoryClass.getDeclaredConstructor( cstrArgTypes ); } catch(NoSuchMethodException nsme) { - throw new NativeWindowException("Constructor: '" + clazzName + "("+cstrArgTypes+")' not found"); + nsme.printStackTrace(); + throw new NativeWindowException("Constructor: '" + clazzName + "("+cstrArgTypes+")' not found"); + } catch (Throwable th) { + th.printStackTrace(); + throw new NativeWindowException(th); } return factory; } catch (Throwable e) { @@ -91,6 +95,9 @@ public final class NWReflection { factory = getConstructor(clazzName, cstrArgTypes); return factory.newInstance( cstrArgs ) ; } catch (Exception e) { + if (DEBUG) { + e.printStackTrace(); + } throw new NativeWindowException(e); } } diff --git a/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java b/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java index cbd485649..d4684c783 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java +++ b/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java @@ -48,6 +48,9 @@ import com.sun.nativewindow.impl.jvm.JVMUtil; public abstract class NativeWindowFactory { protected static final boolean DEBUG = Debug.debug("NativeWindow"); + /** Broadcom EGL type */ + public static final String TYPE_BROADCOM_EGL = "BroadcomEGL"; + /** OpenKODE/EGL type */ public static final String TYPE_EGL = "EGL"; @@ -82,6 +85,8 @@ public abstract class NativeWindowFactory { private static String _getNativeWindowingType(String osNameLowerCase) { if (osNameLowerCase.startsWith("kd")) { return TYPE_EGL; + } else if (osNameLowerCase.startsWith(TYPE_BROADCOM_EGL.toLowerCase())) { + return TYPE_BROADCOM_EGL; } else if (osNameLowerCase.startsWith("wind")) { return TYPE_WINDOWS; } else if (osNameLowerCase.startsWith("mac os x") || diff --git a/src/newt/native/BroadcomEGL.c b/src/newt/native/BroadcomEGL.c index 8afa71a47..55ca5f155 100755 --- a/src/newt/native/BroadcomEGL.c +++ b/src/newt/native/BroadcomEGL.c @@ -85,7 +85,7 @@ JNIEXPORT jlong JNICALL Java_com_sun_javafx_newt_opengl_broadcom_BCEGLDisplay_Cr { (void) env; (void) obj; - EGLDisplay dpy = EGLUtil_CreateDisplay( (GLuint) width, (GLuint) height ); + EGLDisplay dpy = EGLUtil_CreateDisplayByNative( (GLuint) width, (GLuint) height ); if(NULL==dpy) { fprintf(stderr, "[CreateDisplay] failed: NULL\n"); } else { @@ -131,7 +131,7 @@ JNIEXPORT jlong JNICALL Java_com_sun_javafx_newt_opengl_broadcom_BCEGLWindow_Cre return 0; } - window = EGLUtil_CreateWindow( dpy, chromaKey, &uiWidth, &uiHeight ); + window = EGLUtil_CreateWindowByNative( dpy, chromaKey, &uiWidth, &uiHeight ); // EGLUtil_DestroyWindow( dpy, window ); if(NULL==window) { -- cgit v1.2.3 From 4b5e1a0f826597d8cdcf81865194ee8d67511b70 Mon Sep 17 00:00:00 2001 From: sg215889 Date: Tue, 28 Jul 2009 19:03:32 -0700 Subject: Cleanup .. --- make/build-jogl.xml | 24 ++++------------- make/build-nativewindow.xml | 31 +++++++--------------- make/build-newt.xml | 28 ++++++------------- make/make.jogl.all.linux-x86.sh | 2 +- .../com/sun/opengl/impl/GLDrawableImpl.java | 19 +------------ .../sun/opengl/impl/egl/EGLDrawableFactory.java | 6 +---- .../opengl/impl/egl/EGLDynamicLookupHelper.java | 14 +++------- src/jogl/classes/javax/media/opengl/GLProfile.java | 6 ++--- .../com/sun/nativewindow/impl/NWReflection.java | 11 ++------ .../javafx/newt/opengl/broadcom/BCEGLWindow.java | 3 +++ src/newt/native/BroadcomEGL.c | 2 +- 11 files changed, 38 insertions(+), 108 deletions(-) (limited to 'src/nativewindow/classes') diff --git a/make/build-jogl.xml b/make/build-jogl.xml index fda65c5b2..6a065a8e4 100644 --- a/make/build-jogl.xml +++ b/make/build-jogl.xml @@ -51,8 +51,8 @@ - - Some environment defs affecting compilation - - setup.noAWT is set iff: - !isWindows && !isOSX && !noX11 + - setup.nodesktop is set iff: + !isWindows && !isOSX && !isX11 - Internal settings, may not be necessary to set them manually, since all JAR archives are orthogonal. @@ -77,7 +77,7 @@ --> - + @@ -86,25 +86,11 @@ - - - - - - - - - - - - - - + - @@ -1769,7 +1755,7 @@ includes="${java.part.util.fixedfunc.shaders}"/> - + - + @@ -77,21 +77,13 @@ - - - - - - - - - + + - @@ -108,17 +100,12 @@ - - - - - + @@ -842,13 +829,13 @@ - + - + @@ -865,7 +852,7 @@ - + diff --git a/make/build-newt.xml b/make/build-newt.xml index 1ed039a57..be9547684 100644 --- a/make/build-newt.xml +++ b/make/build-newt.xml @@ -50,8 +50,8 @@ setup.noAWT setup.noOpenGL - - setup.noAWT is set iff: - !isWindows && !isOSX && !noX11 + - setup.nodesktop is set iff: + !isWindows && !isOSX && !isX11 --> @@ -73,28 +73,16 @@ - + + - - - - - - - - - - - - - - + @@ -110,7 +98,6 @@ - @@ -764,10 +751,11 @@ - + + includes="com/sun/javafx/newt/**" + excludes="${java.excludes.cdcfp}" /> diff --git a/make/make.jogl.all.linux-x86.sh b/make/make.jogl.all.linux-x86.sh index 8842cbc0c..0f764b360 100644 --- a/make/make.jogl.all.linux-x86.sh +++ b/make/make.jogl.all.linux-x86.sh @@ -13,13 +13,13 @@ fi # -DisUnix=true \ # -DisLinux=true \ # -DisLinuxX86=true \ +# -DisX11=true \ ant \ -Dbuild.noarchives=true \ -Djogl.cg=1 -Dx11.cg.lib=../../lib-linux-x86 \ -Drootrel.build=build-x86 \ -Dos.arch=x86 \ - -DisX11=true \ -DuseKD=true \ -DuseOpenMAX=true \ $* 2>&1 | tee make.jogl.all.linux-x86.log diff --git a/src/jogl/classes/com/sun/opengl/impl/GLDrawableImpl.java b/src/jogl/classes/com/sun/opengl/impl/GLDrawableImpl.java index e71cf33a0..c381f68f5 100644 --- a/src/jogl/classes/com/sun/opengl/impl/GLDrawableImpl.java +++ b/src/jogl/classes/com/sun/opengl/impl/GLDrawableImpl.java @@ -52,24 +52,7 @@ public abstract class GLDrawableImpl implements GLDrawable { this.factory = factory; this.component = comp; this.realized = realized; - - AbstractGraphicsConfiguration agc = component.getGraphicsConfiguration(); - if (agc == null) { - System.out.println("GLDrawableImpl no AbstractGraphicsConfiguration"); - System.out.println(component.getClass().getName()); - return; - } - AbstractGraphicsConfiguration ngc = agc.getNativeGraphicsConfiguration(); - if (ngc == null) { - System.out.println("GLDrawableImpl no native AbstractGraphicsConfiguration"); - return; - } - Capabilities caps = ngc.getRequestedCapabilities(); - if (caps == null) { - System.out.println("GLDrawableImpl no native Capabilities"); - return; - } - this.requestedCapabilities = (GLCapabilities)caps; // a copy .. + this.requestedCapabilities = (GLCapabilities)component.getGraphicsConfiguration().getNativeGraphicsConfiguration().getRequestedCapabilities(); // a copy .. } /** diff --git a/src/jogl/classes/com/sun/opengl/impl/egl/EGLDrawableFactory.java b/src/jogl/classes/com/sun/opengl/impl/egl/EGLDrawableFactory.java index e2ee65d27..396580c1d 100755 --- a/src/jogl/classes/com/sun/opengl/impl/egl/EGLDrawableFactory.java +++ b/src/jogl/classes/com/sun/opengl/impl/egl/EGLDrawableFactory.java @@ -45,19 +45,15 @@ import com.sun.gluegen.runtime.NativeLibrary; public class EGLDrawableFactory extends GLDrawableFactoryImpl { static { - try { // Register our GraphicsConfigurationFactory implementations // The act of constructing them causes them to be registered new EGLGraphicsConfigurationFactory(); // Check for other underlying stuff .. - /* if(NativeWindowFactory.TYPE_X11.equals(NativeWindowFactory.getNativeWindowType(false))) { + if(NativeWindowFactory.TYPE_X11.equals(NativeWindowFactory.getNativeWindowType(false))) { try { NWReflection.createInstance("com.sun.opengl.impl.x11.glx.X11GLXGraphicsConfigurationFactory"); } catch (Throwable t) {} - } */ - } catch (Throwable th) { - th.printStackTrace(); } } diff --git a/src/jogl/classes/com/sun/opengl/impl/egl/EGLDynamicLookupHelper.java b/src/jogl/classes/com/sun/opengl/impl/egl/EGLDynamicLookupHelper.java index 99f163ca1..8bed0eb35 100755 --- a/src/jogl/classes/com/sun/opengl/impl/egl/EGLDynamicLookupHelper.java +++ b/src/jogl/classes/com/sun/opengl/impl/egl/EGLDynamicLookupHelper.java @@ -50,7 +50,7 @@ import com.sun.gluegen.runtime.DynamicLookupHelper; * Currently two implementations exist, one for ES1 and one for ES2. */ public abstract class EGLDynamicLookupHelper implements DynamicLookupHelper { - protected static final boolean DEBUG = true; /* com.sun.opengl.impl.Debug.debug("EGL"); */ + protected static final boolean DEBUG = com.sun.opengl.impl.Debug.debug("EGL"); private static final EGLDynamicLookupHelper eglES1DynamicLookupHelper; private static final EGLDynamicLookupHelper eglES2DynamicLookupHelper; @@ -136,13 +136,9 @@ public abstract class EGLDynamicLookupHelper implements DynamicLookupHelper { private NativeLibrary loadFirstAvailable(List/**/ libNames, ClassLoader loader) { for (Iterator iter = libNames.iterator(); iter.hasNext(); ) { - String libname = (String) iter.next(); - NativeLibrary lib = NativeLibrary.open(libname, loader, false /*global*/); + NativeLibrary lib = NativeLibrary.open((String) iter.next(), loader, false /*global*/); if (lib != null) { - System.out.println("found: " + libname); return lib; - } else { - System.out.println("looked for: " + libname); } } return null; @@ -168,11 +164,9 @@ public abstract class EGLDynamicLookupHelper implements DynamicLookupHelper { // EGL libraries .. lib = loadFirstAvailable(eglLibNames, loader); if (lib == null) { - // throw new GLException("Unable to dynamically load EGL library for profile ES" + esProfile); - System.out.println("Unable to dynamically load EGL library for profile ES" + esProfile); - } else { - glesLibraries.add(lib); + throw new GLException("Unable to dynamically load EGL library for profile ES" + esProfile); } + glesLibraries.add(lib); } if (esProfile==2) { diff --git a/src/jogl/classes/javax/media/opengl/GLProfile.java b/src/jogl/classes/javax/media/opengl/GLProfile.java index 83a9b0098..ead5f6396 100644 --- a/src/jogl/classes/javax/media/opengl/GLProfile.java +++ b/src/jogl/classes/javax/media/opengl/GLProfile.java @@ -54,7 +54,7 @@ import com.sun.nativewindow.impl.jvm.JVMUtil; * or more specialized versions using the other static GetProfile methods. */ public class GLProfile implements Cloneable { - public static final boolean DEBUG = true; /* Debug.debug("GLProfile"); */ + public static final boolean DEBUG = Debug.debug("GLProfile"); // // Public (user-visible) profiles @@ -736,8 +736,8 @@ public class GLProfile implements Cloneable { } } mappedProfiles = _mappedProfiles; // final .. - if (null==defaultGLProfile) { - System.out.println("No profile available: "+list2String(GL_PROFILE_LIST_ALL)); + if(null==defaultGLProfile) { + throw new GLException("No profile available: "+list2String(GL_PROFILE_LIST_ALL)); } } diff --git a/src/nativewindow/classes/com/sun/nativewindow/impl/NWReflection.java b/src/nativewindow/classes/com/sun/nativewindow/impl/NWReflection.java index d054c205b..b13cf4317 100644 --- a/src/nativewindow/classes/com/sun/nativewindow/impl/NWReflection.java +++ b/src/nativewindow/classes/com/sun/nativewindow/impl/NWReflection.java @@ -40,7 +40,7 @@ import java.lang.reflect.*; import javax.media.nativewindow.*; public final class NWReflection { - public static final boolean DEBUG = true; /* Debug.debug("NWReflection"); */ + public static final boolean DEBUG = Debug.debug("NWReflection"); public static final boolean isClassAvailable(String clazzName) { try { @@ -69,11 +69,7 @@ public final class NWReflection { try { factory = factoryClass.getDeclaredConstructor( cstrArgTypes ); } catch(NoSuchMethodException nsme) { - nsme.printStackTrace(); - throw new NativeWindowException("Constructor: '" + clazzName + "("+cstrArgTypes+")' not found"); - } catch (Throwable th) { - th.printStackTrace(); - throw new NativeWindowException(th); + throw new NativeWindowException("Constructor: '" + clazzName + "("+cstrArgTypes+")' not found"); } return factory; } catch (Throwable e) { @@ -95,9 +91,6 @@ public final class NWReflection { factory = getConstructor(clazzName, cstrArgTypes); return factory.newInstance( cstrArgs ) ; } catch (Exception e) { - if (DEBUG) { - e.printStackTrace(); - } throw new NativeWindowException(e); } } diff --git a/src/newt/classes/com/sun/javafx/newt/opengl/broadcom/BCEGLWindow.java b/src/newt/classes/com/sun/javafx/newt/opengl/broadcom/BCEGLWindow.java index 9b790bd1f..29b92bc8f 100755 --- a/src/newt/classes/com/sun/javafx/newt/opengl/broadcom/BCEGLWindow.java +++ b/src/newt/classes/com/sun/javafx/newt/opengl/broadcom/BCEGLWindow.java @@ -124,6 +124,9 @@ public class BCEGLWindow extends Window { if (config == null) { throw new NativeWindowException("Error creating EGLGraphicsConfiguration from id: "+cfgID+", "+this); } + if(DEBUG_IMPLEMENTATION) { + System.out.println("BCEGLWindow.windowCreated: 0x"+Integer.toHexString(cfgID)+", "+width+"x"+height+", "+config); + } } private long windowHandleClose; diff --git a/src/newt/native/BroadcomEGL.c b/src/newt/native/BroadcomEGL.c index 55ca5f155..716f7d9ee 100755 --- a/src/newt/native/BroadcomEGL.c +++ b/src/newt/native/BroadcomEGL.c @@ -58,7 +58,7 @@ EGLSurface EGLUtil_CreateWindow( EGLDisplay eglDisplay, /* bool */ GLuint bChrom void EGLUtil_DestroyWindow( EGLDisplay eglDisplay, EGLSurface eglSurface ); void EGLUtil_SwapWindow( EGLDisplay eglDisplay, EGLSurface eglSurface ); -#define VERBOSE_ON 1 +// #define VERBOSE_ON 1 #ifdef VERBOSE_ON #define DBG_PRINT(...) fprintf(stdout, __VA_ARGS__) -- cgit v1.2.3 From ce34e2286a1ef4f8be874144e25c0268a1abf90f Mon Sep 17 00:00:00 2001 From: sg215889 Date: Tue, 28 Jul 2009 20:20:02 -0700 Subject: Use getNativeWindowType(custom=true) for factory selection; Don't fail is non native OS factory is available --- .../com/sun/opengl/impl/egl/EGLDrawableFactory.java | 2 +- src/jogl/classes/javax/media/opengl/GLDrawableFactory.java | 14 +++++++++----- .../com/sun/nativewindow/impl/NativeWindowFactoryImpl.java | 2 +- .../media/nativewindow/GraphicsConfigurationFactory.java | 2 +- 4 files changed, 12 insertions(+), 8 deletions(-) (limited to 'src/nativewindow/classes') diff --git a/src/jogl/classes/com/sun/opengl/impl/egl/EGLDrawableFactory.java b/src/jogl/classes/com/sun/opengl/impl/egl/EGLDrawableFactory.java index 396580c1d..7af45d683 100755 --- a/src/jogl/classes/com/sun/opengl/impl/egl/EGLDrawableFactory.java +++ b/src/jogl/classes/com/sun/opengl/impl/egl/EGLDrawableFactory.java @@ -50,7 +50,7 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { new EGLGraphicsConfigurationFactory(); // Check for other underlying stuff .. - if(NativeWindowFactory.TYPE_X11.equals(NativeWindowFactory.getNativeWindowType(false))) { + if(NativeWindowFactory.TYPE_X11.equals(NativeWindowFactory.getNativeWindowType(true))) { try { NWReflection.createInstance("com.sun.opengl.impl.x11.glx.X11GLXGraphicsConfigurationFactory"); } catch (Throwable t) {} diff --git a/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java b/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java index cee721fa6..5a761119f 100644 --- a/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java +++ b/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java @@ -106,16 +106,14 @@ public abstract class GLDrawableFactory { } eglFactory = tmp; - nativeOSType = NativeWindowFactory.getNativeWindowType(false); + nativeOSType = NativeWindowFactory.getNativeWindowType(true); String factoryClassName = null; tmp = null; try { factoryClassName = Debug.getProperty("jogl.gldrawablefactory.class.name", true, AccessController.getContext()); if (null == factoryClassName) { - if ( nativeOSType.equals(NativeWindowFactory.TYPE_EGL) ) { - // use egl*Factory .. - } else if ( nativeOSType.equals(NativeWindowFactory.TYPE_X11) ) { + if ( nativeOSType.equals(NativeWindowFactory.TYPE_X11) ) { factoryClassName = "com.sun.opengl.impl.x11.glx.X11GLXDrawableFactory"; } else if ( nativeOSType.equals(NativeWindowFactory.TYPE_WINDOWS) ) { factoryClassName = "com.sun.opengl.impl.windows.wgl.WindowsWGLDrawableFactory"; @@ -126,10 +124,16 @@ public abstract class GLDrawableFactory { factoryClassName = macosxFactoryClassNameCGL; } } else { - throw new GLException("Unsupported NativeWindow type: "+nativeOSType); + // may use egl*Factory .. + if (GLProfile.DEBUG) { + System.err.println("GLDrawableFactory.static - No Native OS Factory for: "+nativeOSType); + } } } if (null != factoryClassName) { + if (GLProfile.DEBUG) { + System.err.println("GLDrawableFactory.static - Native OS Factory for: "+nativeOSType+": "+factoryClassName); + } tmp = (GLDrawableFactory) NWReflection.createInstance(factoryClassName); } } catch (Throwable t) { diff --git a/src/nativewindow/classes/com/sun/nativewindow/impl/NativeWindowFactoryImpl.java b/src/nativewindow/classes/com/sun/nativewindow/impl/NativeWindowFactoryImpl.java index 424b44c8c..c94dab2f6 100644 --- a/src/nativewindow/classes/com/sun/nativewindow/impl/NativeWindowFactoryImpl.java +++ b/src/nativewindow/classes/com/sun/nativewindow/impl/NativeWindowFactoryImpl.java @@ -69,7 +69,7 @@ public class NativeWindowFactoryImpl extends NativeWindowFactory { private NativeWindow getAWTNativeWindow(Object winObj, AbstractGraphicsConfiguration config) { if (nativeWindowConstructor == null) { try { - String osType = getNativeWindowType(false); + String osType = getNativeWindowType(true); String windowClassName = null; // We break compile-time dependencies on the AWT here to diff --git a/src/nativewindow/classes/javax/media/nativewindow/GraphicsConfigurationFactory.java b/src/nativewindow/classes/javax/media/nativewindow/GraphicsConfigurationFactory.java index 1a9d4ac55..881499bec 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/GraphicsConfigurationFactory.java +++ b/src/nativewindow/classes/javax/media/nativewindow/GraphicsConfigurationFactory.java @@ -74,7 +74,7 @@ public abstract class GraphicsConfigurationFactory { abstractGraphicsDeviceClass = javax.media.nativewindow.AbstractGraphicsDevice.class; - if (NativeWindowFactory.TYPE_X11.equals(NativeWindowFactory.getNativeWindowType(false))) { + if (NativeWindowFactory.TYPE_X11.equals(NativeWindowFactory.getNativeWindowType(true))) { try { GraphicsConfigurationFactory factory = (GraphicsConfigurationFactory) NWReflection.createInstance("com.sun.nativewindow.impl.x11.X11GraphicsConfigurationFactory", new Object[] {}); -- cgit v1.2.3 From 8883fa885e68cd21e8b8cd3343db0580913aebdf Mon Sep 17 00:00:00 2001 From: sg215889 Date: Wed, 29 Jul 2009 09:49:33 -0700 Subject: Fix: doxygen-all-pub.cfg; Add NativeWindow: surfaceSwap() and surfaceUpdated(); BroadcomEGL: Use custom surfaceSwap(); GLDrawableImpl's: Utilize NativeWindow's surfaceSwap() and surfaceUpdated(); Fix common enum of GL2ES1 and GL2GL3, merge them in GL --- doc/TODO.txt | 11 ---- doxygen/doxygen-all-pub.cfg | 2 +- make/config/jogl/gl-if-CustomJavaCode-gl.java | 37 +++++++++++++ make/lsGL23toGL2ES1_commons.sh | 18 +++++++ .../com/sun/opengl/impl/GLDrawableImpl.java | 9 ++++ .../sun/opengl/impl/egl/EGLOnscreenDrawable.java | 2 +- .../sun/opengl/impl/egl/EGLPbufferDrawable.java | 1 + .../impl/macosx/cgl/MacOSXOnscreenCGLContext.java | 2 +- .../impl/macosx/cgl/MacOSXOnscreenCGLDrawable.java | 2 +- .../impl/macosx/cgl/MacOSXPbufferCGLDrawable.java | 2 +- .../windows/wgl/WindowsOffscreenWGLDrawable.java | 2 +- .../windows/wgl/WindowsPbufferWGLDrawable.java | 2 +- .../impl/windows/wgl/WindowsWGLDrawable.java | 63 +++++++++++----------- .../sun/opengl/impl/x11/glx/X11GLXDrawable.java | 31 +++++------ .../impl/x11/glx/X11OffscreenGLXDrawable.java | 2 +- .../opengl/impl/x11/glx/X11PbufferGLXDrawable.java | 2 +- .../com/sun/nativewindow/impl/NullWindow.java | 6 +++ .../com/sun/nativewindow/impl/jawt/JAWTWindow.java | 6 +++ .../javax/media/nativewindow/NativeWindow.java | 18 +++++++ src/newt/classes/com/sun/javafx/newt/Window.java | 6 +++ .../com/sun/javafx/newt/opengl/GLWindow.java | 13 +++++ .../javafx/newt/opengl/broadcom/BCEGLWindow.java | 13 ++++- src/newt/native/BroadcomEGL.c | 17 ++++-- 23 files changed, 191 insertions(+), 76 deletions(-) create mode 100644 make/lsGL23toGL2ES1_commons.sh (limited to 'src/nativewindow/classes') diff --git a/doc/TODO.txt b/doc/TODO.txt index 1fbb12616..8aa9e96ed 100644 --- a/doc/TODO.txt +++ b/doc/TODO.txt @@ -4,17 +4,6 @@ Random, somewhat old to-do list: - Non-const array types must be properly released with JNI_COMMIT in order to see side effects if the array was copied. -- Figure out how to implement GLEventListener.displayChanged(bool,bool). - I believe we need additional support in J2SE before this will be possible - to detect and implement. The basic problem is that we need to find a way - to determine when a GLCanvas has moved to a different - display device, so we can re-load the GL function addresses using - wgl/glXGetProcAddress. See comments at top of GLCanvas.java. Also need a - way to determine with the display mode (e.g., bit depth) of the GLDrawable - has changed. Once both of these problems are solved, we'll need to hook it - into GLEventListener.displayChanged() and also be sure to reset the - GLDrawable's glProcAddress table as appropriate. - - Think about e.g. protected access for Impl classes - Fix glProgramStringARB and glGetProgramString{NV,ARB} so that they diff --git a/doxygen/doxygen-all-pub.cfg b/doxygen/doxygen-all-pub.cfg index cd8dfb6a0..8bf4685cb 100644 --- a/doxygen/doxygen-all-pub.cfg +++ b/doxygen/doxygen-all-pub.cfg @@ -460,7 +460,7 @@ WARN_LOGFILE = # with spaces. INPUT = ../src/jogl/classes/javax -INPUT += ../build/jogl/gensrc/classes/javax +INPUT += ../build-x86_64/jogl/gensrc/classes/javax INPUT += ../src/jogl/classes/com/sun/opengl/util INPUT += ../src/newt/classes/com/sun/javafx/newt diff --git a/make/config/jogl/gl-if-CustomJavaCode-gl.java b/make/config/jogl/gl-if-CustomJavaCode-gl.java index c5ce8d9a6..2bdc4e47c 100644 --- a/make/config/jogl/gl-if-CustomJavaCode-gl.java +++ b/make/config/jogl/gl-if-CustomJavaCode-gl.java @@ -1,4 +1,41 @@ + /** + * The following enumeration are common in GL2ES1 and GL2GL3 + */ + public static final int GL_AND = 0x1501; + public static final int GL_AND_INVERTED = 0x1504; + public static final int GL_AND_REVERSE = 0x1502; + public static final int GL_BLEND_DST = 0x0BE0; + public static final int GL_BLEND_SRC = 0x0BE1; + public static final int GL_BUFFER_ACCESS = 0x88BB; + public static final int GL_CLEAR = 0x1500; + public static final int GL_COLOR_LOGIC_OP = 0x0BF2; + public static final int GL_COPY = 0x1503; + public static final int GL_COPY_INVERTED = 0x150C; + public static final int GL_DEPTH_COMPONENT24 = 0x81A6; + public static final int GL_DEPTH_COMPONENT32 = 0x81A7; + public static final int GL_EQUIV = 0x1509; + public static final int GL_LINE_SMOOTH = 0x0B20; + public static final int GL_LINE_SMOOTH_HINT = 0x0C52; + public static final int GL_LOGIC_OP_MODE = 0x0BF0; + public static final int GL_MULTISAMPLE = 0x809D; + public static final int GL_NAND = 0x150E; + public static final int GL_NOOP = 0x1505; + public static final int GL_NOR = 0x1508; + public static final int GL_OR = 0x1507; + public static final int GL_OR_INVERTED = 0x150D; + public static final int GL_OR_REVERSE = 0x150B; + public static final int GL_POINT_FADE_THRESHOLD_SIZE = 0x8128; + public static final int GL_POINT_SIZE = 0x0B11; + public static final int GL_SAMPLE_ALPHA_TO_ONE = 0x809F; + public static final int GL_SET = 0x150F; + public static final int GL_SMOOTH_LINE_WIDTH_RANGE = 0x0B22; + public static final int GL_SMOOTH_POINT_SIZE_RANGE = 0x0B12; + public static final int GL_STENCIL_INDEX1 = 0x8D46; + public static final int GL_STENCIL_INDEX4 = 0x8D47; + public static final int GL_WRITE_ONLY = 0x88B9; + public static final int GL_XOR = 0x1506; + public void glClearDepth( double depth ); public void glDepthRange(double zNear, double zFar); diff --git a/make/lsGL23toGL2ES1_commons.sh b/make/lsGL23toGL2ES1_commons.sh new file mode 100644 index 000000000..b91edb794 --- /dev/null +++ b/make/lsGL23toGL2ES1_commons.sh @@ -0,0 +1,18 @@ +#! /bin/sh + +BUILDDIR=$1 +shift +if [ -z "$BUILDDIR" ] ; then + echo "usage $0 " + exit 1 +fi + +idir=$BUILDDIR/jogl/gensrc/classes/javax/media/opengl + +echo GL2GL3 to GL2ES1 enums +# sort $idir/GL2.java $idir/GL3.java $idir/GL2ES1.java $idir/GL2GL3.java | uniq -d | grep GL_ | awk ' { print $5 } ' +sort $idir/GL2.java $idir/GL3.java $idir/GL2ES1.java $idir/GL2GL3.java | uniq -d | grep GL_ + +echo GL2GL3 to GL2ES1 functions +# sort $idir/GL2.java $idir/GL3.java $idir/GL2ES1.java $idir/GL2GL3.java | uniq -d | grep "public [a-z0-9_]* gl" +sort $idir/GL2.java $idir/GL3.java $idir/GL2ES1.java $idir/GL2GL3.java | uniq -d | grep "public [a-z0-9_]* gl" diff --git a/src/jogl/classes/com/sun/opengl/impl/GLDrawableImpl.java b/src/jogl/classes/com/sun/opengl/impl/GLDrawableImpl.java index c381f68f5..15ccc0f96 100644 --- a/src/jogl/classes/com/sun/opengl/impl/GLDrawableImpl.java +++ b/src/jogl/classes/com/sun/opengl/impl/GLDrawableImpl.java @@ -71,8 +71,17 @@ public abstract class GLDrawableImpl implements GLDrawable { } public void swapBuffers() throws GLException { + GLCapabilities caps = (GLCapabilities)component.getGraphicsConfiguration().getNativeGraphicsConfiguration().getChosenCapabilities(); + if (caps.getDoubleBuffered()) { + if(!component.surfaceSwap()) { + swapBuffersImpl(); + } + } + component.surfaceUpdated(); } + protected abstract void swapBuffersImpl(); + public static String toHexString(long hex) { return GLContextImpl.toHexString(hex); } diff --git a/src/jogl/classes/com/sun/opengl/impl/egl/EGLOnscreenDrawable.java b/src/jogl/classes/com/sun/opengl/impl/egl/EGLOnscreenDrawable.java index c7c2bcab2..36117f059 100644 --- a/src/jogl/classes/com/sun/opengl/impl/egl/EGLOnscreenDrawable.java +++ b/src/jogl/classes/com/sun/opengl/impl/egl/EGLOnscreenDrawable.java @@ -64,7 +64,7 @@ public class EGLOnscreenDrawable extends EGLDrawable { return surf; } - public void swapBuffers() throws GLException { + protected void swapBuffersImpl() { boolean didLock = false; try { if ( !isSurfaceLocked() ) { diff --git a/src/jogl/classes/com/sun/opengl/impl/egl/EGLPbufferDrawable.java b/src/jogl/classes/com/sun/opengl/impl/egl/EGLPbufferDrawable.java index bcf3294c1..a792762a4 100644 --- a/src/jogl/classes/com/sun/opengl/impl/egl/EGLPbufferDrawable.java +++ b/src/jogl/classes/com/sun/opengl/impl/egl/EGLPbufferDrawable.java @@ -118,5 +118,6 @@ public class EGLPbufferDrawable extends EGLDrawable { return new EGLPbufferContext(this, shareWith); } + protected void swapBuffersImpl() { } } diff --git a/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXOnscreenCGLContext.java b/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXOnscreenCGLContext.java index f87cc150b..4a3e0a8eb 100644 --- a/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXOnscreenCGLContext.java +++ b/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXOnscreenCGLContext.java @@ -102,7 +102,7 @@ public class MacOSXOnscreenCGLContext extends MacOSXCGLContext { } } - public void swapBuffers() throws GLException { + protected void swapBuffers() { if (!CGL.flushBuffer(nsContext)) { throw new GLException("Error swapping buffers"); } diff --git a/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXOnscreenCGLDrawable.java b/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXOnscreenCGLDrawable.java index 98687b5ef..56951ae10 100644 --- a/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXOnscreenCGLDrawable.java +++ b/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXOnscreenCGLDrawable.java @@ -78,7 +78,7 @@ public class MacOSXOnscreenCGLDrawable extends MacOSXCGLDrawable { return component.getHeight(); } - public void swapBuffers() throws GLException { + protected void swapBuffersImpl() { for (Iterator iter = createdContexts.iterator(); iter.hasNext(); ) { WeakReference ref = (WeakReference) iter.next(); MacOSXOnscreenCGLContext ctx = (MacOSXOnscreenCGLContext) ref.get(); diff --git a/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXPbufferCGLDrawable.java b/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXPbufferCGLDrawable.java index 54101331d..0d031ffff 100644 --- a/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXPbufferCGLDrawable.java +++ b/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXPbufferCGLDrawable.java @@ -87,7 +87,7 @@ public class MacOSXPbufferCGLDrawable extends MacOSXCGLDrawable { return pBuffer; } - public void swapBuffers() throws GLException { + protected void swapBuffersImpl() { // FIXME: do we need to do anything if the pbuffer is double-buffered? } diff --git a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsOffscreenWGLDrawable.java b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsOffscreenWGLDrawable.java index ecd4e1685..71d82e784 100644 --- a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsOffscreenWGLDrawable.java +++ b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsOffscreenWGLDrawable.java @@ -127,7 +127,7 @@ public class WindowsOffscreenWGLDrawable extends WindowsWGLDrawable { } } - public void swapBuffers() throws GLException { + protected void swapBuffersImpl() { } } diff --git a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsPbufferWGLDrawable.java b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsPbufferWGLDrawable.java index 6a03406f9..f54e8f1a0 100644 --- a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsPbufferWGLDrawable.java +++ b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsPbufferWGLDrawable.java @@ -107,7 +107,7 @@ public class WindowsPbufferWGLDrawable extends WindowsWGLDrawable { return floatMode; } - public void swapBuffers() throws GLException { + protected void swapBuffersImpl() { } private void createPbuffer(long parentHdc, WGLExt wglExt) { diff --git a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLDrawable.java b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLDrawable.java index 3017d258b..01e259665 100644 --- a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLDrawable.java +++ b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLDrawable.java @@ -82,44 +82,41 @@ public abstract class WindowsWGLDrawable extends GLDrawableImpl { } } - public void swapBuffers() throws GLException { - GLCapabilities caps = (GLCapabilities)getNativeWindow().getGraphicsConfiguration().getNativeGraphicsConfiguration().getChosenCapabilities(); - if (caps.getDoubleBuffered()) { - boolean didLock = false; + protected void swapBuffersImpl() { + boolean didLock = false; - try { - if ( !isSurfaceLocked() ) { - // Usually the surface shall be locked within [makeCurrent .. swap .. release] - if (lockSurface() == NativeWindow.LOCK_SURFACE_NOT_READY) { - return; - } - didLock = true; + try { + if ( !isSurfaceLocked() ) { + // Usually the surface shall be locked within [makeCurrent .. swap .. release] + if (lockSurface() == NativeWindow.LOCK_SURFACE_NOT_READY) { + return; } + didLock = true; + } - long startTime = 0; - if (PROFILING) { - startTime = System.currentTimeMillis(); - } + long startTime = 0; + if (PROFILING) { + startTime = System.currentTimeMillis(); + } - if (!WGL.SwapBuffers(getNativeWindow().getSurfaceHandle()) && (WGL.GetLastError() != 0)) { - throw new GLException("Error swapping buffers"); - } + if (!WGL.SwapBuffers(getNativeWindow().getSurfaceHandle()) && (WGL.GetLastError() != 0)) { + throw new GLException("Error swapping buffers"); + } - if (PROFILING) { - long endTime = System.currentTimeMillis(); - profilingSwapBuffersTime += (endTime - startTime); - int ticks = PROFILING_TICKS; - if (++profilingSwapBuffersTicks == ticks) { - System.err.println("SwapBuffers calls: " + profilingSwapBuffersTime + " ms / " + ticks + " calls (" + - ((float) profilingSwapBuffersTime / (float) ticks) + " ms/call)"); - profilingSwapBuffersTime = 0; - profilingSwapBuffersTicks = 0; - } - } - } finally { - if (didLock) { - unlockSurface(); - } + if (PROFILING) { + long endTime = System.currentTimeMillis(); + profilingSwapBuffersTime += (endTime - startTime); + int ticks = PROFILING_TICKS; + if (++profilingSwapBuffersTicks == ticks) { + System.err.println("SwapBuffers calls: " + profilingSwapBuffersTime + " ms / " + ticks + " calls (" + + ((float) profilingSwapBuffersTime / (float) ticks) + " ms/call)"); + profilingSwapBuffersTime = 0; + profilingSwapBuffersTicks = 0; + } + } + } finally { + if (didLock) { + unlockSurface(); } } } diff --git a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXDrawable.java b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXDrawable.java index 738714ecb..1abc36c58 100644 --- a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXDrawable.java +++ b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXDrawable.java @@ -76,26 +76,23 @@ public abstract class X11GLXDrawable extends GLDrawableImpl { } } - public void swapBuffers() throws GLException { - GLCapabilities caps = (GLCapabilities)getNativeWindow().getGraphicsConfiguration().getNativeGraphicsConfiguration().getChosenCapabilities(); - if (caps.getDoubleBuffered()) { - boolean didLock = false; - try { - if ( !isSurfaceLocked() ) { - // Usually the surface shall be locked within [makeCurrent .. swap .. release] - if (lockSurface() == NativeWindow.LOCK_SURFACE_NOT_READY) { - return; - } - didLock=true; + protected void swapBuffersImpl() { + boolean didLock = false; + try { + if ( !isSurfaceLocked() ) { + // Usually the surface shall be locked within [makeCurrent .. swap .. release] + if (lockSurface() == NativeWindow.LOCK_SURFACE_NOT_READY) { + return; } + didLock=true; + } - GLX.glXSwapBuffers(component.getDisplayHandle(), component.getSurfaceHandle()); + GLX.glXSwapBuffers(component.getDisplayHandle(), component.getSurfaceHandle()); - } finally { - if(didLock) { - unlockSurface(); - } - } + } finally { + if(didLock) { + unlockSurface(); + } } } 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 51938df5f..768f6b8e8 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 @@ -133,6 +133,6 @@ public class X11OffscreenGLXDrawable extends X11GLXDrawable { getFactoryImpl().unlockToolkit(); } } - public void swapBuffers() throws GLException { + protected void swapBuffersImpl() { } } 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 eecd92a53..bee24fa47 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 @@ -148,6 +148,6 @@ public class X11PbufferGLXDrawable extends X11GLXDrawable { return GLPbuffer.NV_FLOAT; } - public void swapBuffers() throws GLException { + protected void swapBuffersImpl() { } } diff --git a/src/nativewindow/classes/com/sun/nativewindow/impl/NullWindow.java b/src/nativewindow/classes/com/sun/nativewindow/impl/NullWindow.java index c7d2acec0..48a04a3c9 100644 --- a/src/nativewindow/classes/com/sun/nativewindow/impl/NullWindow.java +++ b/src/nativewindow/classes/com/sun/nativewindow/impl/NullWindow.java @@ -88,6 +88,12 @@ public class NullWindow implements NativeWindow { return lockedStack; } + public boolean surfaceSwap() { + return false; + } + + public void surfaceUpdated() { } + public long getDisplayHandle() { return displayHandle; } diff --git a/src/nativewindow/classes/com/sun/nativewindow/impl/jawt/JAWTWindow.java b/src/nativewindow/classes/com/sun/nativewindow/impl/jawt/JAWTWindow.java index a4a529c54..5ad2804c1 100644 --- a/src/nativewindow/classes/com/sun/nativewindow/impl/jawt/JAWTWindow.java +++ b/src/nativewindow/classes/com/sun/nativewindow/impl/jawt/JAWTWindow.java @@ -115,6 +115,12 @@ public abstract class JAWTWindow implements NativeWindow { return lockedStack; } + public boolean surfaceSwap() { + return false; + } + + public void surfaceUpdated() { } + public long getDisplayHandle() { return config.getScreen().getDevice().getHandle(); } diff --git a/src/nativewindow/classes/javax/media/nativewindow/NativeWindow.java b/src/nativewindow/classes/javax/media/nativewindow/NativeWindow.java index 2a9782c12..6a588538d 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/NativeWindow.java +++ b/src/nativewindow/classes/javax/media/nativewindow/NativeWindow.java @@ -111,6 +111,24 @@ public interface NativeWindow { */ public Exception getLockedStack(); + /** + * Provide a mechanism to utilize custom (pre-) swap surface + * code. This method is called before the render toolkit (e.g. JOGL) + * swaps the buffer/surface. The implementation may itself apply the swapping, + * in which case true shall be returned. + * + * @return true if this method completed swapping the surface, + * otherwise false, in which case eg the GLDrawable + * implementation has to swap the code. + */ + public boolean surfaceSwap(); + + /** + * Method invoked after the render toolkit (e.g. JOGL) + * swapped/changed the buffer/surface. + */ + public void surfaceUpdated(); + /** * render all native window information invalid, * as if the native window was destroyed diff --git a/src/newt/classes/com/sun/javafx/newt/Window.java b/src/newt/classes/com/sun/javafx/newt/Window.java index a1168d12d..e2903bd62 100755 --- a/src/newt/classes/com/sun/javafx/newt/Window.java +++ b/src/newt/classes/com/sun/javafx/newt/Window.java @@ -269,6 +269,12 @@ public abstract class Window implements NativeWindow y=0; } + public boolean surfaceSwap() { + return false; + } + + public void surfaceUpdated() {} + protected void clearEventMask() { eventMask=0; } diff --git a/src/newt/classes/com/sun/javafx/newt/opengl/GLWindow.java b/src/newt/classes/com/sun/javafx/newt/opengl/GLWindow.java index 8ecfe6216..7a7ff0859 100644 --- a/src/newt/classes/com/sun/javafx/newt/opengl/GLWindow.java +++ b/src/newt/classes/com/sun/javafx/newt/opengl/GLWindow.java @@ -654,6 +654,19 @@ public class GLWindow extends Window implements GLAutoDrawable { return null; } + public boolean surfaceSwap() { + if(null!=drawable) return drawable.getNativeWindow().surfaceSwap(); + return super.surfaceSwap(); + } + + public void surfaceUpdated() { + if(null!=drawable) { + drawable.getNativeWindow().surfaceUpdated(); + } else { + super.surfaceUpdated(); + } + } + public long getWindowHandle() { if(null!=drawable) return drawable.getNativeWindow().getWindowHandle(); return super.getWindowHandle(); diff --git a/src/newt/classes/com/sun/javafx/newt/opengl/broadcom/BCEGLWindow.java b/src/newt/classes/com/sun/javafx/newt/opengl/broadcom/BCEGLWindow.java index 10e70baa0..ddee07c49 100755 --- a/src/newt/classes/com/sun/javafx/newt/opengl/broadcom/BCEGLWindow.java +++ b/src/newt/classes/com/sun/javafx/newt/opengl/broadcom/BCEGLWindow.java @@ -85,10 +85,10 @@ public class BCEGLWindow extends Window { void setSizeImpl(int width, int height) { if(0!=windowHandle) { // n/a in BroadcomEGL - System.err.println("setSize n/a in BroadcomEGL with realized window"); + System.err.println("BCEGLWindow.setSizeImpl n/a in BroadcomEGL with realized window"); } else { if(DEBUG_IMPLEMENTATION) { - Exception e = new Exception("BCEGLWindow.setSize() "+this.width+"x"+this.height+" -> "+width+"x"+height); + Exception e = new Exception("BCEGLWindow.setSizeImpl() "+this.width+"x"+this.height+" -> "+width+"x"+height); e.printStackTrace(); } this.width = width; @@ -107,6 +107,14 @@ public class BCEGLWindow extends Window { return false; } + public boolean surfaceSwap() { + if ( 0!=windowHandle ) { + SwapWindow(getDisplayHandle(), windowHandle); + return true; + } + return false; + } + //---------------------------------------------------------------------- // Internals only // @@ -114,6 +122,7 @@ public class BCEGLWindow extends Window { protected static native boolean initIDs(); private native long CreateWindow(long eglDisplayHandle, boolean chromaKey, int width, int height); private native void CloseWindow(long eglDisplayHandle, long eglWindowHandle); + private native void SwapWindow(long eglDisplayHandle, long eglWindowHandle); private long realizeWindow(boolean chromaKey, int width, int height) { diff --git a/src/newt/native/BroadcomEGL.c b/src/newt/native/BroadcomEGL.c index 716f7d9ee..764fa9b16 100755 --- a/src/newt/native/BroadcomEGL.c +++ b/src/newt/native/BroadcomEGL.c @@ -51,10 +51,10 @@ typedef unsigned int GLuint; -EGLDisplay EGLUtil_CreateDisplay( GLuint uiWidth, GLuint uiHeight ); +EGLDisplay EGLUtil_CreateDisplayByNative( GLuint uiWidth, GLuint uiHeight ); void EGLUtil_DestroyDisplay( EGLDisplay eglDisplay ); -EGLSurface EGLUtil_CreateWindow( EGLDisplay eglDisplay, /* bool */ GLuint bChromakey, GLuint *puiWidth, GLuint *puiHeight ); +EGLSurface EGLUtil_CreateWindowByNative( EGLDisplay eglDisplay, /* bool */ GLuint bChromakey, GLuint *puiWidth, GLuint *puiHeight ); void EGLUtil_DestroyWindow( EGLDisplay eglDisplay, EGLSurface eglSurface ); void EGLUtil_SwapWindow( EGLDisplay eglDisplay, EGLSurface eglSurface ); @@ -132,7 +132,6 @@ JNIEXPORT jlong JNICALL Java_com_sun_javafx_newt_opengl_broadcom_BCEGLWindow_Cre } window = EGLUtil_CreateWindowByNative( dpy, chromaKey, &uiWidth, &uiHeight ); - // EGLUtil_DestroyWindow( dpy, window ); if(NULL==window) { fprintf(stderr, "[RealizeWindow.Create] failed: NULL\n"); @@ -161,10 +160,20 @@ JNIEXPORT jlong JNICALL Java_com_sun_javafx_newt_opengl_broadcom_BCEGLWindow_Cre JNIEXPORT void JNICALL Java_com_sun_javafx_newt_opengl_broadcom_BCEGLWindow_CloseWindow (JNIEnv *env, jobject obj, jlong display, jlong window) { - EGLDisplay dpy = (EGLDisplay)(intptr_t)display; + EGLDisplay dpy = (EGLDisplay) (intptr_t) display; EGLSurface surf = (EGLSurface) (intptr_t) window; EGLUtil_DestroyWindow(dpy, surf); DBG_PRINT( "[CloseWindow]\n"); } +JNIEXPORT void JNICALL Java_com_sun_javafx_newt_opengl_broadcom_BCEGLWindow_SwapWindow + (JNIEnv *env, jobject obj, jlong display, jlong window) +{ + EGLDisplay dpy = (EGLDisplay) (intptr_t) display; + EGLSurface surf = (EGLSurface) (intptr_t) window; + EGLUtil_SwapWindow( dpy, surf ); + + DBG_PRINT( "[SwapWindow]\n"); +} + -- cgit v1.2.3 From 16535530bf15f9f4d6cdd3ff38132c2487f96e05 Mon Sep 17 00:00:00 2001 From: sg215889 Date: Thu, 30 Jul 2009 05:20:43 -0700 Subject: Cleanup: Remove NativeWindowFactory.TYPE_BROADCOM_EGL --- make/make.jogl.all.linux-x86.sh | 1 + .../classes/javax/media/nativewindow/NativeWindowFactory.java | 5 ----- 2 files changed, 1 insertion(+), 5 deletions(-) (limited to 'src/nativewindow/classes') diff --git a/make/make.jogl.all.linux-x86.sh b/make/make.jogl.all.linux-x86.sh index 0f764b360..081d8328b 100644 --- a/make/make.jogl.all.linux-x86.sh +++ b/make/make.jogl.all.linux-x86.sh @@ -14,6 +14,7 @@ fi # -DisLinux=true \ # -DisLinuxX86=true \ # -DisX11=true \ +# -Djogl.cg=1 -Dx11.cg.lib=../../lib-linux-x86 \ ant \ -Dbuild.noarchives=true \ diff --git a/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java b/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java index d4684c783..cbd485649 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java +++ b/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java @@ -48,9 +48,6 @@ import com.sun.nativewindow.impl.jvm.JVMUtil; public abstract class NativeWindowFactory { protected static final boolean DEBUG = Debug.debug("NativeWindow"); - /** Broadcom EGL type */ - public static final String TYPE_BROADCOM_EGL = "BroadcomEGL"; - /** OpenKODE/EGL type */ public static final String TYPE_EGL = "EGL"; @@ -85,8 +82,6 @@ public abstract class NativeWindowFactory { private static String _getNativeWindowingType(String osNameLowerCase) { if (osNameLowerCase.startsWith("kd")) { return TYPE_EGL; - } else if (osNameLowerCase.startsWith(TYPE_BROADCOM_EGL.toLowerCase())) { - return TYPE_BROADCOM_EGL; } else if (osNameLowerCase.startsWith("wind")) { return TYPE_WINDOWS; } else if (osNameLowerCase.startsWith("mac os x") || -- cgit v1.2.3