aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2008-11-26 22:05:16 +0000
committerSven Gothel <[email protected]>2008-11-26 22:05:16 +0000
commit47c0b60fa9fdd1df48cad1ec999ba40c3185e28f (patch)
treeead27b319ac5a8cf5a839e8c654b71c69d3efada /src
parent3fac9daea59c6231f96ef162e6ea64ff35e0b958 (diff)
Newt-KD: window working, pointer event buggy
git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/branches/JOGL_2_SANDBOX@1806 232f8b59-042b-4e1e-8c03-345bb8c30851
Diffstat (limited to 'src')
-rwxr-xr-xsrc/classes/com/sun/javafx/newt/kd/KDWindow.java41
-rw-r--r--src/classes/com/sun/opengl/impl/egl/EGLConfig.java4
-rwxr-xr-xsrc/classes/com/sun/opengl/impl/egl/EGLDrawable.java2
-rwxr-xr-xsrc/native/newt/KDWindow.c76
4 files changed, 65 insertions, 58 deletions
diff --git a/src/classes/com/sun/javafx/newt/kd/KDWindow.java b/src/classes/com/sun/javafx/newt/kd/KDWindow.java
index 7cc4724bc..3ac502111 100755
--- a/src/classes/com/sun/javafx/newt/kd/KDWindow.java
+++ b/src/classes/com/sun/javafx/newt/kd/KDWindow.java
@@ -78,16 +78,17 @@ public class KDWindow extends Window {
visualID = config.getNativeConfigID();
chosenCaps = config.getCapabilities();
- windowHandle = CreateWindow(getDisplayHandle(), visualID, eglRenderableType);
- if (windowHandle == 0) {
- throw new RuntimeException("Error creating window: "+windowHandle);
+ windowHandle = 0;
+ eglWindowHandle = CreateWindow(getDisplayHandle(), visualID, eglRenderableType);
+ if (eglWindowHandle == 0) {
+ throw new RuntimeException("Error creating egl window: "+eglWindowHandle);
}
- nativeWindowHandle = RealizeWindow(windowHandle);
- if (nativeWindowHandle == 0) {
+ setVisible0(eglWindowHandle, false);
+ windowHandle = RealizeWindow(eglWindowHandle);
+ if (0 == windowHandle) {
throw new RuntimeException("Error native Window Handle is null");
}
-
- windowHandleClose = windowHandle;
+ windowHandleClose = eglWindowHandle;
}
protected void closeNative() {
@@ -99,13 +100,13 @@ public class KDWindow extends Window {
public void setVisible(boolean visible) {
if(this.visible!=visible) {
this.visible=visible;
- setVisible0(windowHandle, visible);
+ setVisible0(eglWindowHandle, visible);
clearEventMask();
}
}
public void setSize(int width, int height) {
- setSize0(windowHandle, width, height);
+ setSize0(eglWindowHandle, width, height);
}
public void setPosition(int x, int y) {
@@ -117,10 +118,10 @@ public class KDWindow extends Window {
if(this.fullscreen!=fullscreen) {
this.fullscreen=fullscreen;
if(this.fullscreen) {
- setFullScreen0(windowHandle, true);
+ setFullScreen0(eglWindowHandle, true);
} else {
- setFullScreen0(windowHandle, false);
- setSize0(windowHandle, nfs_width, nfs_height);
+ setFullScreen0(eglWindowHandle, false);
+ setSize0(eglWindowHandle, nfs_width, nfs_height);
}
}
return true;
@@ -135,7 +136,7 @@ public class KDWindow extends Window {
}
protected void dispatchMessages(int eventMask) {
- DispatchMessages(windowHandle, eventMask);
+ DispatchMessages(eglWindowHandle, eventMask);
}
//----------------------------------------------------------------------
@@ -144,12 +145,12 @@ public class KDWindow extends Window {
private static native boolean initIDs();
private native long CreateWindow(long displayHandle, long eglConfig, int eglRenderableType);
- private native long RealizeWindow(long windowHandle);
- private native int CloseWindow(long windowHandle);
- private native void setVisible0(long windowHandle, boolean visible);
- private native void setSize0(long windowHandle, int width, int height);
- private native void setFullScreen0(long windowHandle, boolean fullscreen);
- private native void DispatchMessages(long windowHandle, int eventMask);
+ private native long RealizeWindow(long eglWindowHandle);
+ private native int CloseWindow(long eglWindowHandle);
+ private native void setVisible0(long eglWindowHandle, boolean visible);
+ private native void setSize0(long eglWindowHandle, int width, int height);
+ private native void setFullScreen0(long eglWindowHandle, boolean fullscreen);
+ private native void DispatchMessages(long eglWindowHandle, int eventMask);
private void sizeChanged(int newWidth, int newHeight) {
width = newWidth;
@@ -167,6 +168,6 @@ public class KDWindow extends Window {
private void windowClosed() {
}
- private long nativeWindowHandle; // THE KD underlying native window handle
+ private long eglWindowHandle;
private long windowHandleClose;
}
diff --git a/src/classes/com/sun/opengl/impl/egl/EGLConfig.java b/src/classes/com/sun/opengl/impl/egl/EGLConfig.java
index 0b33f91cc..49c1a895f 100644
--- a/src/classes/com/sun/opengl/impl/egl/EGLConfig.java
+++ b/src/classes/com/sun/opengl/impl/egl/EGLConfig.java
@@ -156,6 +156,10 @@ public class EGLConfig {
return attrs;
}
+ public String toString() {
+ return "EGLConfig[ id "+configID+
+ ", "+capabilities+"]";
+ }
private _EGLConfig _config;
private int configID;
private GLCapabilities capabilities;
diff --git a/src/classes/com/sun/opengl/impl/egl/EGLDrawable.java b/src/classes/com/sun/opengl/impl/egl/EGLDrawable.java
index 77698f76d..fd0405a69 100755
--- a/src/classes/com/sun/opengl/impl/egl/EGLDrawable.java
+++ b/src/classes/com/sun/opengl/impl/egl/EGLDrawable.java
@@ -181,7 +181,7 @@ public class EGLDrawable extends GLDrawableImpl {
return "EGLDrawable[ realized "+getRealized()+
", window "+getNativeWindow()+
", egl display " + display +
- ", egl config " + config +
+ ", " + config +
", egl surface " + surface +
", factory "+getFactory()+"]";
}
diff --git a/src/native/newt/KDWindow.c b/src/native/newt/KDWindow.c
index c9118d5ec..cc51bdf1f 100755
--- a/src/native/newt/KDWindow.c
+++ b/src/native/newt/KDWindow.c
@@ -31,10 +31,30 @@
*
*/
+#ifdef _WIN32
+ #include <windows.h>
+#endif
+
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
-#include <unistd.h>
+
+#ifdef _WIN32_WCE
+ #define STDOUT_FILE "\\Storage Card\\jogl_demos\\stdout.txt"
+ #define STDERR_FILE "\\Storage Card\\jogl_demos\\stderr.txt"
+#endif
+
+/* This typedef is apparently needed for Microsoft compilers before VC8,
+ and on Windows CE */
+#if (_MSC_VER < 1400) || defined(UNDER_CE)
+ #ifdef _WIN64
+ typedef long long intptr_t;
+ #else
+ typedef int intptr_t;
+ #endif
+#else
+ #include <inttypes.h>
+#endif
#include <EGL/egl.h>
#include <KD/kd.h>
@@ -49,39 +69,9 @@
#define VERBOSE_ON 1
#ifdef VERBOSE_ON
- #define DBG_PRINT(args...) fprintf(stderr, args)
-
- #define DUMP_VISUAL_INFO(a,b)
- /*
- #define DUMP_VISUAL_INFO(a,b) _dumpVisualInfo((a),(b))
-
- static void _dumpVisualInfo(const char * msg, XVisualInfo *pVisualQuery) {
- if(pVisualQuery!=NULL) {
- fprintf(stderr, "%s: screen %d, visual: %p, visual-id: 0x%X, depth: %d, class %d, cmap sz: %d, bpp: 3x%d, rgb 0x%X 0x%X 0x%X\n",
- msg,
- pVisualQuery->screen,
- pVisualQuery->visual,
- (int)pVisualQuery->visualid,
- pVisualQuery->depth,
- pVisualQuery->class,
- pVisualQuery->colormap_size,
- pVisualQuery->bits_per_rgb,
- (int)pVisualQuery->red_mask,
- (int)pVisualQuery->green_mask,
- (int)pVisualQuery->blue_mask
- );
- } else {
- fprintf(stderr, "%s: NULL XVisualInfo\n", msg);
- }
- }
- */
-
+ #define DBG_PRINT(...) fprintf(stderr, __VA_ARGS__)
#else
-
- #define DBG_PRINT(args...)
-
- #define DUMP_VISUAL_INFO(a,b)
-
+ #define DBG_PRINT(...)
#endif
/**
@@ -96,6 +86,10 @@ static jmethodID sendKeyEventID = NULL;
JNIEXPORT jboolean JNICALL Java_com_sun_javafx_newt_kd_KDWindow_initIDs
(JNIEnv *env, jclass clazz)
{
+#ifdef _WIN32_WCE
+ _wfreopen(TEXT(STDOUT_FILE),L"w",stdout);
+ _wfreopen(TEXT(STDERR_FILE),L"w",stderr);
+#endif
sizeChangedID = (*env)->GetMethodID(env, clazz, "sizeChanged", "(II)V");
windowClosedID = (*env)->GetMethodID(env, clazz, "windowClosed", "()V");
sendMouseEventID = (*env)->GetMethodID(env, clazz, "sendMouseEvent", "(IIIII)V");
@@ -104,8 +98,10 @@ JNIEXPORT jboolean JNICALL Java_com_sun_javafx_newt_kd_KDWindow_initIDs
windowClosedID == NULL ||
sendMouseEventID == NULL ||
sendKeyEventID == NULL) {
+ DBG_PRINT( "initIDs failed\n" );
return JNI_FALSE;
}
+ DBG_PRINT( "initIDs ok\n" );
return JNI_TRUE;
}
@@ -156,6 +152,7 @@ JNIEXPORT jlong JNICALL Java_com_sun_javafx_newt_kd_KDWindow_CreateWindow
if(NULL==window) {
fprintf(stderr, "[CreateWindow] failed: 0x%X\n", kdGetError());
}
+ DBG_PRINT( "[CreateWindow] ok: %p\n", window);
return (jlong) (intptr_t) window;
}
@@ -170,6 +167,7 @@ JNIEXPORT jlong JNICALL Java_com_sun_javafx_newt_kd_KDWindow_RealizeWindow
fprintf(stderr, "[RealizeWindow] failed: 0x%X, 0x%X\n", res, kdGetError());
nativeWindow = NULL;
}
+ DBG_PRINT( "[RealizeWindow] ok: %p\n", nativeWindow);
return (jlong) (intptr_t) nativeWindow;
}
@@ -177,8 +175,10 @@ JNIEXPORT jint JNICALL Java_com_sun_javafx_newt_kd_KDWindow_CloseWindow
(JNIEnv *env, jobject obj, jlong window)
{
KDWindow *w = (KDWindow*) (intptr_t) window;
+ int res = kdDestroyWindow(w);
- return kdDestroyWindow(w);
+ DBG_PRINT( "[CloseWindow] res: %d\n", res);
+ return res;
}
/*
@@ -192,6 +192,7 @@ JNIEXPORT void JNICALL Java_com_sun_javafx_newt_kd_KDWindow_setVisible0
KDWindow *w = (KDWindow*) (intptr_t) window;
KDboolean v = (visible==JNI_TRUE)?KD_TRUE:KD_FALSE;
kdSetWindowPropertybv(w, KD_WINDOWPROPERTY_VISIBILITY, &v);
+ DBG_PRINT( "[setVisible] v=%d\n", visible);
}
/*
@@ -212,6 +213,7 @@ JNIEXPORT void JNICALL Java_com_sun_javafx_newt_kd_KDWindow_DispatchMessages
DBG_PRINT( "event unrelated: src: %p, caller: %p\n", src_obj, obj);
continue;
}
+ DBG_PRINT( "[DispatchMessages]: caller %p, evt type: 0x%X\n", obj, evt->type);
switch(evt->type) {
case KD_EVENT_INPUT_POINTER:
@@ -311,7 +313,7 @@ JNIEXPORT void JNICALL Java_com_sun_javafx_newt_kd_KDWindow_DispatchMessages
}
}
-JNIEXPORT void JNICALL Java_com_sun_javafx_newt_kd_KDWindow_setFullscreen0
+JNIEXPORT void JNICALL Java_com_sun_javafx_newt_kd_KDWindow_setFullScreen0
(JNIEnv *env, jobject obj, jlong window, jboolean fullscreen)
{
KDWindow *w = (KDWindow*) (intptr_t) window;
@@ -319,7 +321,7 @@ JNIEXPORT void JNICALL Java_com_sun_javafx_newt_kd_KDWindow_setFullscreen0
int res = kdSetWindowPropertyiv(w, KD_WINDOWPROPERTY_FULLSCREEN_NV, &v);
- DBG_PRINT( "setFullscreen0 . fullscreen call: %d\n", res);
+ DBG_PRINT( "[setFullScreen] v=%d, res=%d\n", fullscreen, res);
}
JNIEXPORT void JNICALL Java_com_sun_javafx_newt_kd_KDWindow_setSize0
@@ -330,7 +332,7 @@ JNIEXPORT void JNICALL Java_com_sun_javafx_newt_kd_KDWindow_setSize0
int res = kdSetWindowPropertyiv(w, KD_WINDOWPROPERTY_SIZE, v);
- DBG_PRINT( "setSize0 . sizeChangedID call: %d\n", res);
+ DBG_PRINT( "[setSize] v=%dx%d, res=%d\n", width, height, res);
(*env)->CallVoidMethod(env, obj, sizeChangedID, (jint) width, (jint) height);
}