aboutsummaryrefslogtreecommitdiffstats
path: root/src/classes/com
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2008-05-30 13:35:03 +0000
committerSven Gothel <[email protected]>2008-05-30 13:35:03 +0000
commitacdd8ef2e4af64871c62b8b9b84af83a32fd1aba (patch)
tree6fcd5b019550b31b2b2235fbe25c174628ffeb0b /src/classes/com
parentefcbd94ea40dd4fb532707765535bd1af1639a03 (diff)
Completing com.sun.javafx.newt.* package, WIP, working under X11/ES1.1.
- Fixed: - EGLDrawable[Factory] - Object target is a 'long[3]' with [display, screen, window] native handles. Depending on the platform, display and screen handles may be 0. - Moved EGL.eglGetDisplay and EGL.eglInitialize from EGLDrawableFactory -> EGLDrawable, since the factory has no notion of the native handles, but the display is necessary. - newt.*: - Added Display and Screen abstraction - Added 'long[] Window.getHandles()', to feed EGLDrawableFactory.getGLDrawable() with the 3 native handles. - MouseEvent: - Java: Clicked and Dragged working - native/X11: SelectInput with proper args - KeyEvent: - native/X11: added XSetInputFocus and XLookupString git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/branches/JOGL_2_SANDBOX@1652 232f8b59-042b-4e1e-8c03-345bb8c30851
Diffstat (limited to 'src/classes/com')
-rwxr-xr-xsrc/classes/com/sun/javafx/newt/Display.java69
-rw-r--r--src/classes/com/sun/javafx/newt/KeyEvent.java12
-rw-r--r--src/classes/com/sun/javafx/newt/MouseEvent.java16
-rwxr-xr-xsrc/classes/com/sun/javafx/newt/Screen.java75
-rwxr-xr-xsrc/classes/com/sun/javafx/newt/Window.java56
-rwxr-xr-xsrc/classes/com/sun/javafx/newt/windows/WindowsWindow.java15
-rwxr-xr-xsrc/classes/com/sun/javafx/newt/x11/X11Window.java33
-rwxr-xr-xsrc/classes/com/sun/opengl/impl/egl/EGLDrawable.java38
-rwxr-xr-xsrc/classes/com/sun/opengl/impl/egl/EGLDrawableFactory.java34
9 files changed, 292 insertions, 56 deletions
diff --git a/src/classes/com/sun/javafx/newt/Display.java b/src/classes/com/sun/javafx/newt/Display.java
new file mode 100755
index 000000000..7be9a1b12
--- /dev/null
+++ b/src/classes/com/sun/javafx/newt/Display.java
@@ -0,0 +1,69 @@
+/*
+ * 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;
+
+public class Display {
+
+ public Display() {
+ this(null);
+ }
+
+ public Display(String name) {
+ this.name=name;
+ this.handle=-1;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public long getHandle() {
+ return handle;
+ }
+
+ /**
+ * native handle
+ *
+ * write once ..
+ */
+ public void setHandle(long handle) {
+ if(this.handle<0) {
+ this.handle=handle;
+ }
+ }
+
+ protected String name;
+ protected long handle;
+}
+
diff --git a/src/classes/com/sun/javafx/newt/KeyEvent.java b/src/classes/com/sun/javafx/newt/KeyEvent.java
index 96df883df..47d7d1f7d 100644
--- a/src/classes/com/sun/javafx/newt/KeyEvent.java
+++ b/src/classes/com/sun/javafx/newt/KeyEvent.java
@@ -56,7 +56,17 @@ public class KeyEvent extends InputEvent
}
public String toString() {
- return "KeyEvent[code "+keyCode+", char "+keyChar+", "+super.toString();
+ return "KeyEvent["+getEventTypeString(eventType)+
+ ", code "+keyCode+", char "+keyChar+", "+super.toString();
+ }
+
+ public static String getEventTypeString(int type) {
+ switch(type) {
+ case EVENT_KEY_PRESSED: return "EVENT_KEY_PRESSED";
+ case EVENT_KEY_RELEASED: return "EVENT_KEY_RELEASED";
+ case EVENT_KEY_TYPED: return "EVENT_KEY_TYPED";
+ default: return "unknown";
+ }
}
public boolean isActionKey() {
diff --git a/src/classes/com/sun/javafx/newt/MouseEvent.java b/src/classes/com/sun/javafx/newt/MouseEvent.java
index 99026bd7b..19b5f2b93 100644
--- a/src/classes/com/sun/javafx/newt/MouseEvent.java
+++ b/src/classes/com/sun/javafx/newt/MouseEvent.java
@@ -69,7 +69,21 @@ public class MouseEvent extends InputEvent
}
public String toString() {
- return "MouseEvent["+x+"/"+y+", button "+button+", count "+clickCount+", "+super.toString();
+ return "MouseEvent["+getEventTypeString(eventType)+
+ ", "+x+"/"+y+", button "+button+", count "+clickCount+", "+super.toString();
+ }
+
+ public static String getEventTypeString(int type) {
+ switch(type) {
+ case EVENT_MOUSE_CLICKED: return "EVENT_MOUSE_CLICKED";
+ case EVENT_MOUSE_ENTERED: return "EVENT_MOUSE_ENTERED";
+ case EVENT_MOUSE_EXITED: return "EVENT_MOUSE_EXITED";
+ case EVENT_MOUSE_PRESSED: return "EVENT_MOUSE_PRESSED";
+ case EVENT_MOUSE_RELEASED: return "EVENT_MOUSE_RELEASED";
+ case EVENT_MOUSE_MOVED: return "EVENT_MOUSE_MOVED";
+ case EVENT_MOUSE_DRAGGED: return "EVENT_MOUSE_DRAGGED";
+ default: return "unknown";
+ }
}
private int eventType, x, y, clickCount, button;
diff --git a/src/classes/com/sun/javafx/newt/Screen.java b/src/classes/com/sun/javafx/newt/Screen.java
new file mode 100755
index 000000000..b698a0248
--- /dev/null
+++ b/src/classes/com/sun/javafx/newt/Screen.java
@@ -0,0 +1,75 @@
+/*
+ * 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;
+
+public class Screen {
+
+ public Screen(Display display) {
+ this(display, 0);
+ }
+
+ public Screen(Display display, int idx) {
+ this.display=display;
+ this.index=idx;
+ this.handle=-1;
+ }
+
+ public Display getDisplay() {
+ return display;
+ }
+
+ public int getIndex() {
+ return index;
+ }
+
+ public long getHandle() {
+ return handle;
+ }
+
+ /**
+ * native handle
+ *
+ * write once ..
+ */
+ public void setHandle(long handle) {
+ if(this.handle<0) {
+ this.handle=handle;
+ }
+ }
+
+ protected Display display;
+ protected int index;
+ protected long handle;
+}
+
diff --git a/src/classes/com/sun/javafx/newt/Window.java b/src/classes/com/sun/javafx/newt/Window.java
index 2bfcf1265..27610cdf2 100755
--- a/src/classes/com/sun/javafx/newt/Window.java
+++ b/src/classes/com/sun/javafx/newt/Window.java
@@ -37,6 +37,9 @@ import java.util.ArrayList;
import java.util.Iterator;
public abstract class Window {
+ public static final boolean DEBUG_MOUSE_EVENT = false;
+ public static final boolean DEBUG_KEY_EVENT = false;
+
/** OpenKODE window type */
public static final String KD = "KD";
@@ -50,7 +53,7 @@ public abstract class Window {
public static final String MACOSX = "MacOSX";
/** Creates a Window of the default type for the current operating system. */
- public static Window create(long visualID) {
+ public static Window create(Screen screen, long visualID) {
String osName = System.getProperty("os.name");
String osNameLowerCase = osName.toLowerCase();
String windowType;
@@ -62,7 +65,7 @@ public abstract class Window {
windowType = X11;
}
Window window = create(windowType);
- window.initNative(visualID);
+ window.initNative(screen, visualID);
return window;
}
@@ -87,7 +90,19 @@ public abstract class Window {
}
}
- protected abstract void initNative(long visualID);
+
+ /**
+ * [ display, screen, window ]
+ */
+ public long[] getHandles() {
+ long[] handles = new long[3];
+ handles[0] = getScreen().getDisplay().getHandle();
+ handles[1] = getScreen().getHandle();
+ handles[2] = getWindowHandle();
+ return handles;
+ }
+
+ protected abstract void initNative(Screen screen, long visualID);
public abstract void setVisible(boolean visible);
public abstract void setSize(int width, int height);
@@ -101,9 +116,18 @@ public abstract class Window {
public abstract boolean isFullscreen();
public abstract int getDisplayWidth();
public abstract int getDisplayHeight();
+
+ public abstract Screen getScreen();
public abstract long getWindowHandle();
+
public abstract void pumpMessages();
+ public String toString() {
+ return "Window[handle "+getWindowHandle()+
+ ", pos "+getX()+"/"+getY()+", size "+getWidth()+"x"+getHeight()+
+ ", visible "+isVisible()+"]";
+ }
+
//
// MouseListener Support
//
@@ -132,6 +156,10 @@ public abstract class Window {
public static final int ClickTimeout = 200;
private void sendMouseEvent(int eventType, int modifiers, int x, int y, int button) {
+ if(DEBUG_MOUSE_EVENT) {
+ System.out.println("sendMouseEvent: "+MouseEvent.getEventTypeString(eventType)+
+ ", mod "+modifiers+", pos "+x+"/"+y+", button "+button);
+ }
long when = System.currentTimeMillis();
MouseEvent eClicked = null;
MouseEvent e = null;
@@ -151,18 +179,26 @@ public abstract class Window {
if(when-lastMousePressed<ClickTimeout) {
eClicked = new MouseEvent(true, MouseEvent.EVENT_MOUSE_CLICKED, this, when,
modifiers, x, y, lastMouseClickCount, button);
+ } else {
+ lastMouseClickCount=0;
+ lastMousePressed=0;
}
- lastMouseClickCount=0;
- lastMousePressed=0;
} else if(MouseEvent.EVENT_MOUSE_MOVED==eventType &&
1==lastMouseClickCount) {
- e = new MouseEvent(true, eventType, this, when,
+ e = new MouseEvent(true, MouseEvent.EVENT_MOUSE_DRAGGED, this, when,
modifiers, x, y, 1, button);
} else {
e = new MouseEvent(true, eventType, this, when,
modifiers, x, y, 0, button);
}
+ if(DEBUG_MOUSE_EVENT) {
+ System.out.println("sendMouseEvent: event: "+e);
+ if(null!=eClicked) {
+ System.out.println("sendMouseEvent: event Clicked: "+eClicked);
+ }
+ }
+
for(Iterator i = mouseListener.iterator(); i.hasNext(); ) {
switch(eventType) {
case MouseEvent.EVENT_MOUSE_ENTERED:
@@ -175,9 +211,10 @@ public abstract class Window {
((MouseListener)i.next()).mousePressed(e);
break;
case MouseEvent.EVENT_MOUSE_RELEASED:
- ((MouseListener)i.next()).mouseReleased(e);
+ MouseListener ml = (MouseListener)i.next();
+ ml.mouseReleased(e);
if(null!=eClicked) {
- ((MouseListener)i.next()).mouseClicked(eClicked);
+ ml.mouseClicked(eClicked);
}
break;
case MouseEvent.EVENT_MOUSE_MOVED:
@@ -217,6 +254,9 @@ public abstract class Window {
private void sendKeyEvent(int eventType, int modifiers, int keyCode, char keyChar) {
KeyEvent e = new KeyEvent(true, eventType, this, System.currentTimeMillis(),
modifiers, keyCode, keyChar);
+ if(DEBUG_KEY_EVENT) {
+ System.out.println("sendKeyEvent: "+e);
+ }
for(Iterator i = keyListener.iterator(); i.hasNext(); ) {
switch(eventType) {
case KeyEvent.EVENT_KEY_PRESSED:
diff --git a/src/classes/com/sun/javafx/newt/windows/WindowsWindow.java b/src/classes/com/sun/javafx/newt/windows/WindowsWindow.java
index faa26dcb7..e170f9b56 100755
--- a/src/classes/com/sun/javafx/newt/windows/WindowsWindow.java
+++ b/src/classes/com/sun/javafx/newt/windows/WindowsWindow.java
@@ -37,8 +37,9 @@ import com.sun.javafx.newt.*;
import com.sun.opengl.impl.*;
public class WindowsWindow extends Window {
- private boolean fullscreen, visible;
+ private Screen screen;
private long visualID;
+ private boolean fullscreen, visible;
private long window;
// Default width and height -- will likely be re-set immediately by user
private int width = 100;
@@ -55,10 +56,12 @@ public class WindowsWindow extends Window {
}
}
- protected WindowsWindow() {
+ public WindowsWindow() {
}
- protected void initNative(long visualID) {
+ public void initNative(Screen screen, long visualID) {
+ this.screen = screen;
+ this.visualID = visualID;
long wndClass = getWindowClass();
fullscreen=false;
visible=false;
@@ -66,6 +69,12 @@ public class WindowsWindow extends Window {
if (window == 0) {
throw new RuntimeException("Error creating window");
}
+ screen.setHandle(0); // dummy
+ screen.getDisplay().setHandle(0); // dummy
+ }
+
+ public Screen getScreen() {
+ return screen;
}
public void setVisible(boolean visible) {
diff --git a/src/classes/com/sun/javafx/newt/x11/X11Window.java b/src/classes/com/sun/javafx/newt/x11/X11Window.java
index 828f08eff..80021dca4 100755
--- a/src/classes/com/sun/javafx/newt/x11/X11Window.java
+++ b/src/classes/com/sun/javafx/newt/x11/X11Window.java
@@ -37,8 +37,10 @@ import com.sun.javafx.newt.*;
import com.sun.opengl.impl.*;
public class X11Window extends Window {
+ private Screen screen;
private long visualID;
- private long dpy, screen, window;
+ private long dpy, scrn, window;
+ private int scrn_idx;
private static final String WINDOW_CLASS_NAME = "NewtWindow";
// Default width and height -- will likely be re-set immediately by user
private int width = 100;
@@ -57,16 +59,24 @@ public class X11Window extends Window {
}
}
- protected X11Window() {
+ public X11Window() {
}
- protected void initNative(long visualID) {
+ public void initNative(Screen screen, long visualID) {
+ this.screen = screen;
+ this.visualID = visualID;
fullscreen=false;
visible=false;
long w = CreateWindow(visualID, x, y, width, height);
if (w == 0 || w!=window) {
throw new RuntimeException("Error creating window: "+w);
}
+ screen.setHandle(scrn);
+ screen.getDisplay().setHandle(dpy);
+ }
+
+ public Screen getScreen() {
+ return screen;
}
public void setVisible(boolean visible) {
@@ -110,8 +120,8 @@ public class X11Window extends Window {
this.fullscreen=fullscreen;
if(this.fullscreen) {
x = 0; y = 0;
- w = getDisplayWidth0(dpy, screen);
- h = getDisplayHeight0(dpy, screen);
+ w = getDisplayWidth0(dpy, scrn_idx)/2;
+ h = getDisplayHeight0(dpy, scrn_idx)/2;
} else {
x = nfs_x;
y = nfs_y;
@@ -137,11 +147,11 @@ public class X11Window extends Window {
}
public int getDisplayWidth() {
- return getDisplayWidth0(dpy, screen);
+ return getDisplayWidth0(dpy, scrn_idx);
}
public int getDisplayHeight() {
- return getDisplayHeight0(dpy, screen);
+ return getDisplayHeight0(dpy, scrn_idx);
}
//----------------------------------------------------------------------
@@ -154,8 +164,8 @@ public class X11Window extends Window {
private native void DispatchMessages(long display, long window);
private native void setSize0(long display, long window, int width, int height);
private native void setPosition0(long display, long window, int x, int y);
- private native int getDisplayWidth0(long display, long screen);
- private native int getDisplayHeight0(long display, long screen);
+ private native int getDisplayWidth0(long display, int scrn_idx);
+ private native int getDisplayHeight0(long display, int scrn_idx);
private void sizeChanged(int newWidth, int newHeight) {
width = newWidth;
@@ -175,9 +185,10 @@ public class X11Window extends Window {
}
}
- private void windowCreated(long dpy, long scrn, long window) {
+ private void windowCreated(long dpy, int scrn_idx, long scrn, long window) {
this.dpy = dpy;
- this.screen = scrn;
+ this.scrn_idx = scrn_idx;
+ this.scrn = scrn;
this.window = window;
}
diff --git a/src/classes/com/sun/opengl/impl/egl/EGLDrawable.java b/src/classes/com/sun/opengl/impl/egl/EGLDrawable.java
index abdbd2b7f..22b39e291 100755
--- a/src/classes/com/sun/opengl/impl/egl/EGLDrawable.java
+++ b/src/classes/com/sun/opengl/impl/egl/EGLDrawable.java
@@ -38,7 +38,9 @@ package com.sun.opengl.impl.egl;
import javax.media.opengl.*;
public class EGLDrawable implements GLDrawable {
- private long nativeWindow;
+ private long windowHandle;
+ private long screenHandle;
+ private long displayHandle;
private long display;
private GLCapabilities capabilities;
private GLCapabilitiesChooser chooser;
@@ -46,17 +48,27 @@ public class EGLDrawable implements GLDrawable {
private long surface;
private int[] tmp = new int[1];
- public EGLDrawable(long nativeWindow,
+ public EGLDrawable(long displayHandle,
+ long screenHandle,
+ long windowHandle,
GLCapabilities capabilities,
GLCapabilitiesChooser chooser) throws GLException {
- this.nativeWindow = nativeWindow;
+ this.displayHandle = displayHandle;
+ this.screenHandle = screenHandle;
+ this.windowHandle = windowHandle;
this.capabilities = capabilities;
this.chooser = chooser;
// Set things up
EGLDrawableFactory factory = (EGLDrawableFactory) GLDrawableFactory.getFactory();
- // FIXME: need to ultimately fetch this from the native window, at least on X11 platforms
- display = factory.getDisplay();
+
+ display = EGL.eglGetDisplay((displayHandle>0)?displayHandle:EGL.EGL_DEFAULT_DISPLAY);
+ if (display == EGL.EGL_NO_DISPLAY) {
+ throw new GLException("eglGetDisplay failed");
+ }
+ if (!EGL.eglInitialize(display, null, null)) {
+ throw new GLException("eglInitialize failed");
+ }
int[] attrs = factory.glCapabilities2AttribList(capabilities);
_EGLConfig[] configs = new _EGLConfig[1];
int[] numConfigs = new int[1];
@@ -76,6 +88,10 @@ public class EGLDrawable implements GLDrawable {
return display;
}
+ public void shutdown() {
+ EGL.eglTerminate(display);
+ }
+
public _EGLConfig getConfig() {
return config;
}
@@ -91,7 +107,7 @@ public class EGLDrawable implements GLDrawable {
public void setRealized(boolean realized) {
if (realized) {
// Create the window surface
- surface = EGL.eglCreateWindowSurface(display, config, nativeWindow, null);
+ surface = EGL.eglCreateWindowSurface(display, config, windowHandle, null);
if (surface == EGL.EGL_NO_SURFACE) {
throw new GLException("Creation of window surface (eglCreateWindowSurface) failed");
}
@@ -134,4 +150,14 @@ public class EGLDrawable implements GLDrawable {
// FIXME
return null;
}
+
+ public String toString() {
+ return "EGLDrawable[ displayHandle " + displayHandle +
+ ", screenHandle "+ screenHandle +
+ ", windowHandle "+ windowHandle +
+ ", display " + display +
+ ", config " + config +
+ ", surface " + surface +
+ "]";
+ }
}
diff --git a/src/classes/com/sun/opengl/impl/egl/EGLDrawableFactory.java b/src/classes/com/sun/opengl/impl/egl/EGLDrawableFactory.java
index b66d1d33e..516f6d5a9 100755
--- a/src/classes/com/sun/opengl/impl/egl/EGLDrawableFactory.java
+++ b/src/classes/com/sun/opengl/impl/egl/EGLDrawableFactory.java
@@ -48,28 +48,11 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl {
// We need more than one of these on certain devices (the NVidia APX 2500 in particular)
private List/*<NativeLibrary>*/ glesLibraries;
- // FIXME: this state should probably not be here
- private long display;
- private _EGLConfig config;
-
public EGLDrawableFactory(String profile) {
super(profile);
loadGLESLibrary();
EGL.resetProcAddressTable(this);
-
- // FIXME: this initialization sequence needs to be refactored
- // at least for X11 platforms to allow a little window
- // system-specific code to run (to open the display, in
- // particular)
-
- display = EGL.eglGetDisplay(EGL.EGL_DEFAULT_DISPLAY);
- if (display == EGL.EGL_NO_DISPLAY) {
- throw new GLException("eglGetDisplay failed");
- }
- if (!EGL.eglInitialize(display, null, null)) {
- throw new GLException("eglInitialize failed");
- }
}
private void loadGLESLibrary() {
@@ -113,10 +96,6 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl {
glesLibraries = libs;
}
- public void shutdown() {
- EGL.eglTerminate(display);
- }
-
public AbstractGraphicsConfiguration chooseGraphicsConfiguration(GLCapabilities capabilities,
GLCapabilitiesChooser chooser,
AbstractGraphicsDevice device) {
@@ -126,7 +105,14 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl {
public GLDrawable getGLDrawable(Object target,
GLCapabilities capabilities,
GLCapabilitiesChooser chooser) {
- return new EGLDrawable(((Long) target).longValue(),
+ if( !(target instanceof long[]) ) {
+ throw new GLException("target is not instanceof long[]");
+ }
+ long[] targetHandles = (long[])target;
+ if(targetHandles.length!=3) {
+ throw new GLException("target handle array != 3 [display, screen, window]");
+ }
+ return new EGLDrawable(targetHandles[0], targetHandles[1], targetHandles[2],
capabilities,
chooser);
}
@@ -189,10 +175,6 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl {
return false;
}
- public long getDisplay() {
- return display;
- }
-
public int[] glCapabilities2AttribList(GLCapabilities caps) {
int[] attrs = new int[] {
EGL.EGL_DEPTH_SIZE, caps.getDepthBits(),