From: <eli...@us...> - 2007-01-17 08:16:21
|
Revision: 2727 http://svn.sourceforge.net/java-game-lib/?rev=2727&view=rev Author: elias_naur Date: 2007-01-17 00:16:16 -0800 (Wed, 17 Jan 2007) Log Message: ----------- Linux: Fixed wrong return type in LinuxEvent.nGetKeyAddress Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxEvent.java trunk/LWJGL/src/native/linux/org_lwjgl_opengl_LinuxEvent.c Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxEvent.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxEvent.java 2007-01-17 08:01:49 UTC (rev 2726) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxEvent.java 2007-01-17 08:16:16 UTC (rev 2727) @@ -149,7 +149,7 @@ public final long getKeyAddress() { return nGetKeyAddress(event_buffer); } - private static native int nGetKeyAddress(ByteBuffer event_buffer); + private static native long nGetKeyAddress(ByteBuffer event_buffer); public final long getKeyTime() { return nGetKeyTime(event_buffer); Modified: trunk/LWJGL/src/native/linux/org_lwjgl_opengl_LinuxEvent.c =================================================================== --- trunk/LWJGL/src/native/linux/org_lwjgl_opengl_LinuxEvent.c 2007-01-17 08:01:49 UTC (rev 2726) +++ trunk/LWJGL/src/native/linux/org_lwjgl_opengl_LinuxEvent.c 2007-01-17 08:16:16 UTC (rev 2727) @@ -135,9 +135,10 @@ return event->xbutton.y; } -JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxEvent_nGetKeyAddress(JNIEnv *env, jclass unused, jobject event_buffer) { +JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxEvent_nGetKeyAddress(JNIEnv *env, jclass unused, jobject event_buffer) { XEvent *event = (XEvent *)(*env)->GetDirectBufferAddress(env, event_buffer); - return (jlong)(intptr_t)&(event->xkey); + XKeyEvent *key_event = &(event->xkey); + return (jlong)(intptr_t)key_event; } JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxEvent_nGetKeyTime(JNIEnv *env, jclass unused, jobject event_buffer) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sp...@us...> - 2007-02-21 13:44:36
|
Revision: 2741 http://svn.sourceforge.net/java-game-lib/?rev=2741&view=rev Author: spasi Date: 2007-02-21 05:44:33 -0800 (Wed, 21 Feb 2007) Log Message: ----------- Added NV_geometry_shader4 Modified Paths: -------------- trunk/LWJGL/src/generated/org/lwjgl/opengl/ContextCapabilities.java Added Paths: ----------- trunk/LWJGL/src/templates/org/lwjgl/opengl/NV_geometry_shader4.java Modified: trunk/LWJGL/src/generated/org/lwjgl/opengl/ContextCapabilities.java =================================================================== --- trunk/LWJGL/src/generated/org/lwjgl/opengl/ContextCapabilities.java 2007-02-17 09:49:44 UTC (rev 2740) +++ trunk/LWJGL/src/generated/org/lwjgl/opengl/ContextCapabilities.java 2007-02-21 13:44:33 UTC (rev 2741) @@ -140,6 +140,7 @@ public final boolean GL_NV_fragment_program_option; public final boolean GL_NV_framebuffer_multisample_coverage; public final boolean GL_NV_geometry_program4; + public final boolean GL_NV_geometry_shader4; public final boolean GL_NV_gpu_program4; public final boolean GL_NV_half_float; public final boolean GL_NV_light_max_exponent; @@ -2736,6 +2737,7 @@ this.GL_NV_fragment_program_option = supported_extensions.contains("GL_NV_fragment_program_option"); this.GL_NV_framebuffer_multisample_coverage = supported_extensions.contains("GL_NV_framebuffer_multisample_coverage"); this.GL_NV_geometry_program4 = supported_extensions.contains("GL_NV_geometry_program4"); + this.GL_NV_geometry_shader4 = supported_extensions.contains("GL_NV_geometry_shader4"); this.GL_NV_gpu_program4 = supported_extensions.contains("GL_NV_gpu_program4"); this.GL_NV_half_float = supported_extensions.contains("GL_NV_half_float"); this.GL_NV_light_max_exponent = supported_extensions.contains("GL_NV_light_max_exponent"); Added: trunk/LWJGL/src/templates/org/lwjgl/opengl/NV_geometry_shader4.java =================================================================== --- trunk/LWJGL/src/templates/org/lwjgl/opengl/NV_geometry_shader4.java (rev 0) +++ trunk/LWJGL/src/templates/org/lwjgl/opengl/NV_geometry_shader4.java 2007-02-21 13:44:33 UTC (rev 2741) @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2002-2004 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions 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 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package org.lwjgl.opengl; + +public interface NV_geometry_shader4 { + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <eli...@us...> - 2007-02-23 10:14:20
|
Revision: 2744 http://svn.sourceforge.net/java-game-lib/?rev=2744&view=rev Author: elias_naur Date: 2007-02-23 02:14:18 -0800 (Fri, 23 Feb 2007) Log Message: ----------- Linux: When creating a window don't loop waiting for the MapNotify event. Instead, make sure we don't immediately go from fullscreen to minimized by checking if the window has been focused at least once before minimizing (and resetting display mode). Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2007-02-23 08:31:59 UTC (rev 2743) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2007-02-23 10:14:18 UTC (rev 2744) @@ -110,6 +110,7 @@ private boolean minimized; private boolean dirty; private boolean close_requested; + private boolean focused_at_least_once; private long current_cursor; private long blank_cursor; @@ -398,6 +399,7 @@ pointer_grabbed = false; keyboard_grabbed = false; close_requested = false; + focused_at_least_once = false; grab = false; minimized = false; dirty = true; @@ -750,8 +752,9 @@ private void checkInput() { focused = nGetInputFocus(getDisplay()) == getWindow(); if (focused) { + focused_at_least_once = true; acquireInput(); - } else { + } else if (focused_at_least_once) { releaseInput(); } } Modified: trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c =================================================================== --- trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c 2007-02-23 08:31:59 UTC (rev 2743) +++ trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c 2007-02-23 10:14:18 UTC (rev 2744) @@ -127,13 +127,6 @@ return atom; } -static void waitMapped(Display *disp, Window win) { - XEvent event; - do { - XMaskEvent(disp, StructureNotifyMask, &event); - } while ((event.type != MapNotify) || (event.xmap.event != win)); -} - static void __attribute__ ((destructor)) my_fini(void) { Display *disp = XOpenDisplay(NULL); if (disp == NULL) { @@ -294,7 +287,6 @@ XInternAtom(disp, "ATOM", False), 32, PropModeReplace, (const unsigned char*)&fullscreen_atom, 1); } XMapRaised(disp, win); - waitMapped(disp, win); if (!checkXError(env, disp)) { destroyWindow(env, disp, win); return 0; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <eli...@us...> - 2007-04-03 08:21:50
|
Revision: 2755 http://svn.sourceforge.net/java-game-lib/?rev=2755&view=rev Author: elias_naur Date: 2007-04-03 01:21:46 -0700 (Tue, 03 Apr 2007) Log Message: ----------- Updated generated files Modified Paths: -------------- trunk/LWJGL/src/generated/org/lwjgl/opengl/ContextCapabilities.java trunk/LWJGL/src/generated/org/lwjgl/opengl/EXTGpuProgramParameters.java trunk/LWJGL/src/native/generated/org_lwjgl_opengl_EXTGpuProgramParameters.c Modified: trunk/LWJGL/src/generated/org/lwjgl/opengl/ContextCapabilities.java =================================================================== --- trunk/LWJGL/src/generated/org/lwjgl/opengl/ContextCapabilities.java 2007-04-03 08:16:45 UTC (rev 2754) +++ trunk/LWJGL/src/generated/org/lwjgl/opengl/ContextCapabilities.java 2007-04-03 08:21:46 UTC (rev 2755) @@ -491,8 +491,8 @@ long EXT_geometry_shader4_glFramebufferTextureEXT_pointer; long EXT_geometry_shader4_glFramebufferTextureLayerEXT_pointer; long EXT_geometry_shader4_glFramebufferTextureFaceEXT_pointer; - long EXT_gpu_program_parameters_glProgramEnvParameter4fvEXT_pointer; - long EXT_gpu_program_parameters_glProgramLocalParameter4fvEXT_pointer; + long EXT_gpu_program_parameters_glProgramEnvParameters4fvEXT_pointer; + long EXT_gpu_program_parameters_glProgramLocalParameters4fvEXT_pointer; long EXT_gpu_shader4_glVertexAttribI1iEXT_pointer; long EXT_gpu_shader4_glVertexAttribI2iEXT_pointer; long EXT_gpu_shader4_glVertexAttribI3iEXT_pointer; @@ -1616,8 +1616,8 @@ private boolean EXT_gpu_program_parameters_initNativeFunctionAddresses() { return - (EXT_gpu_program_parameters_glProgramEnvParameter4fvEXT_pointer = GLContext.getFunctionAddress("glProgramEnvParameter4fvEXT")) != 0 && - (EXT_gpu_program_parameters_glProgramLocalParameter4fvEXT_pointer = GLContext.getFunctionAddress("glProgramLocalParameter4fvEXT")) != 0; + (EXT_gpu_program_parameters_glProgramEnvParameters4fvEXT_pointer = GLContext.getFunctionAddress("glProgramEnvParameters4fvEXT")) != 0 && + (EXT_gpu_program_parameters_glProgramLocalParameters4fvEXT_pointer = GLContext.getFunctionAddress("glProgramLocalParameters4fvEXT")) != 0; } private boolean EXT_gpu_shader4_initNativeFunctionAddresses() { Modified: trunk/LWJGL/src/generated/org/lwjgl/opengl/EXTGpuProgramParameters.java =================================================================== --- trunk/LWJGL/src/generated/org/lwjgl/opengl/EXTGpuProgramParameters.java 2007-04-03 08:16:45 UTC (rev 2754) +++ trunk/LWJGL/src/generated/org/lwjgl/opengl/EXTGpuProgramParameters.java 2007-04-03 08:21:46 UTC (rev 2755) @@ -12,21 +12,21 @@ } - public static void glProgramEnvParameter4EXT(int target, int index, int count, FloatBuffer params) { + public static void glProgramEnvParameters4EXT(int target, int index, int count, FloatBuffer params) { ContextCapabilities caps = GLContext.getCapabilities(); - long function_pointer = caps.EXT_gpu_program_parameters_glProgramEnvParameter4fvEXT_pointer; + long function_pointer = caps.EXT_gpu_program_parameters_glProgramEnvParameters4fvEXT_pointer; BufferChecks.checkFunctionAddress(function_pointer); BufferChecks.checkBuffer(params, count << 2); - nglProgramEnvParameter4fvEXT(target, index, count, params, params.position(), function_pointer); + nglProgramEnvParameters4fvEXT(target, index, count, params, params.position(), function_pointer); } - private static native void nglProgramEnvParameter4fvEXT(int target, int index, int count, FloatBuffer params, int params_position, long function_pointer); + private static native void nglProgramEnvParameters4fvEXT(int target, int index, int count, FloatBuffer params, int params_position, long function_pointer); - public static void glProgramLocalParameter4EXT(int target, int index, int count, FloatBuffer params) { + public static void glProgramLocalParameters4EXT(int target, int index, int count, FloatBuffer params) { ContextCapabilities caps = GLContext.getCapabilities(); - long function_pointer = caps.EXT_gpu_program_parameters_glProgramLocalParameter4fvEXT_pointer; + long function_pointer = caps.EXT_gpu_program_parameters_glProgramLocalParameters4fvEXT_pointer; BufferChecks.checkFunctionAddress(function_pointer); BufferChecks.checkBuffer(params, count << 2); - nglProgramLocalParameter4fvEXT(target, index, count, params, params.position(), function_pointer); + nglProgramLocalParameters4fvEXT(target, index, count, params, params.position(), function_pointer); } - private static native void nglProgramLocalParameter4fvEXT(int target, int index, int count, FloatBuffer params, int params_position, long function_pointer); + private static native void nglProgramLocalParameters4fvEXT(int target, int index, int count, FloatBuffer params, int params_position, long function_pointer); } Modified: trunk/LWJGL/src/native/generated/org_lwjgl_opengl_EXTGpuProgramParameters.c =================================================================== --- trunk/LWJGL/src/native/generated/org_lwjgl_opengl_EXTGpuProgramParameters.c 2007-04-03 08:16:45 UTC (rev 2754) +++ trunk/LWJGL/src/native/generated/org_lwjgl_opengl_EXTGpuProgramParameters.c 2007-04-03 08:21:46 UTC (rev 2755) @@ -3,18 +3,18 @@ #include <jni.h> #include "extgl.h" -typedef void (APIENTRY *glProgramEnvParameter4fvEXTPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat * params); -typedef void (APIENTRY *glProgramLocalParameter4fvEXTPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat * params); +typedef void (APIENTRY *glProgramEnvParameters4fvEXTPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat * params); +typedef void (APIENTRY *glProgramLocalParameters4fvEXTPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat * params); -JNIEXPORT void JNICALL Java_org_lwjgl_opengl_EXTGpuProgramParameters_nglProgramEnvParameter4fvEXT(JNIEnv *env, jclass clazz, jint target, jint index, jint count, jobject params, jint params_position, jlong function_pointer) { +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_EXTGpuProgramParameters_nglProgramEnvParameters4fvEXT(JNIEnv *env, jclass clazz, jint target, jint index, jint count, jobject params, jint params_position, jlong function_pointer) { const GLfloat *params_address = ((const GLfloat *)(*env)->GetDirectBufferAddress(env, params)) + params_position; - glProgramEnvParameter4fvEXTPROC glProgramEnvParameter4fvEXT = (glProgramEnvParameter4fvEXTPROC)((intptr_t)function_pointer); - glProgramEnvParameter4fvEXT(target, index, count, params_address); + glProgramEnvParameters4fvEXTPROC glProgramEnvParameters4fvEXT = (glProgramEnvParameters4fvEXTPROC)((intptr_t)function_pointer); + glProgramEnvParameters4fvEXT(target, index, count, params_address); } -JNIEXPORT void JNICALL Java_org_lwjgl_opengl_EXTGpuProgramParameters_nglProgramLocalParameter4fvEXT(JNIEnv *env, jclass clazz, jint target, jint index, jint count, jobject params, jint params_position, jlong function_pointer) { +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_EXTGpuProgramParameters_nglProgramLocalParameters4fvEXT(JNIEnv *env, jclass clazz, jint target, jint index, jint count, jobject params, jint params_position, jlong function_pointer) { const GLfloat *params_address = ((const GLfloat *)(*env)->GetDirectBufferAddress(env, params)) + params_position; - glProgramLocalParameter4fvEXTPROC glProgramLocalParameter4fvEXT = (glProgramLocalParameter4fvEXTPROC)((intptr_t)function_pointer); - glProgramLocalParameter4fvEXT(target, index, count, params_address); + glProgramLocalParameters4fvEXTPROC glProgramLocalParameters4fvEXT = (glProgramLocalParameters4fvEXTPROC)((intptr_t)function_pointer); + glProgramLocalParameters4fvEXT(target, index, count, params_address); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <eli...@us...> - 2007-04-15 19:33:05
|
Revision: 2767 http://svn.sourceforge.net/java-game-lib/?rev=2767&view=rev Author: elias_naur Date: 2007-04-15 12:33:03 -0700 (Sun, 15 Apr 2007) Log Message: ----------- Don't add border when checking image sizes Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/BufferUtils.java trunk/LWJGL/src/java/org/lwjgl/opengl/GLChecks.java trunk/LWJGL/src/templates/org/lwjgl/opengl/GL11.java trunk/LWJGL/src/templates/org/lwjgl/opengl/GL12.java Modified: trunk/LWJGL/src/java/org/lwjgl/BufferUtils.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/BufferUtils.java 2007-04-11 20:33:07 UTC (rev 2766) +++ trunk/LWJGL/src/java/org/lwjgl/BufferUtils.java 2007-04-15 19:33:03 UTC (rev 2767) @@ -133,7 +133,7 @@ else if (buf instanceof LongBuffer || buf instanceof DoubleBuffer) return 3; else - throw new IllegalStateException("Unsupported buffer type"); + throw new IllegalStateException("Unsupported buffer type: " + buf); } /** Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/GLChecks.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/GLChecks.java 2007-04-11 20:33:07 UTC (rev 2766) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/GLChecks.java 2007-04-15 19:33:03 UTC (rev 2767) @@ -148,16 +148,16 @@ return calculateImageStorage(format, type, width, height, depth) >> BufferUtils.getElementSizeExponent(buffer); } - static int calculateTexImage1DStorage(Buffer buffer, int format, int type, int width, int border) { - return calculateTexImage1DStorage(format, type, width, border) >> BufferUtils.getElementSizeExponent(buffer); + static int calculateTexImage1DStorage(Buffer buffer, int format, int type, int width) { + return calculateTexImage1DStorage(format, type, width) >> BufferUtils.getElementSizeExponent(buffer); } - static int calculateTexImage2DStorage(Buffer buffer, int format, int type, int width, int height, int border) { - return calculateTexImage2DStorage(format, type, width, height, border) >> BufferUtils.getElementSizeExponent(buffer); + static int calculateTexImage2DStorage(Buffer buffer, int format, int type, int width, int height) { + return calculateTexImage2DStorage(format, type, width, height) >> BufferUtils.getElementSizeExponent(buffer); } - static int calculateTexImage3DStorage(Buffer buffer, int format, int type, int width, int height, int depth, int border) { - return calculateTexImage3DStorage(format, type, width, height, depth, border) >> BufferUtils.getElementSizeExponent(buffer); + static int calculateTexImage3DStorage(Buffer buffer, int format, int type, int width, int height, int depth) { + return calculateTexImage3DStorage(format, type, width, height, depth) >> BufferUtils.getElementSizeExponent(buffer); } /** @@ -175,16 +175,16 @@ return calculateBytesPerPixel(format, type) * width * height * depth; } - private static int calculateTexImage1DStorage(int format, int type, int width, int border) { - return calculateBytesPerPixel(format, type) * (width + (border << 1)); + private static int calculateTexImage1DStorage(int format, int type, int width) { + return calculateBytesPerPixel(format, type) * width; } - private static int calculateTexImage2DStorage(int format, int type, int width, int height, int border) { - return calculateTexImage1DStorage(format, type, width, border) * (height + (border << 1)); + private static int calculateTexImage2DStorage(int format, int type, int width, int height) { + return calculateTexImage1DStorage(format, type, width) * height; } - private static int calculateTexImage3DStorage(int format, int type, int width, int height, int depth, int border) { - return calculateTexImage2DStorage(format, type, width, height, border) * (depth + (border << 1)); + private static int calculateTexImage3DStorage(int format, int type, int width, int height, int depth) { + return calculateTexImage2DStorage(format, type, width, height) * depth; } private static int calculateBytesPerPixel(int format, int type) { Modified: trunk/LWJGL/src/templates/org/lwjgl/opengl/GL11.java =================================================================== --- trunk/LWJGL/src/templates/org/lwjgl/opengl/GL11.java 2007-04-11 20:33:07 UTC (rev 2766) +++ trunk/LWJGL/src/templates/org/lwjgl/opengl/GL11.java 2007-04-15 19:33:03 UTC (rev 2767) @@ -1261,7 +1261,7 @@ void glTexImage1D(@GLenum int target, int level, int internalformat, @GLsizei int width, int border, @GLenum int format, @GLenum int type, @BufferObject(BufferKind.UnpackPBO) - @Check(value = "GLChecks.calculateTexImage1DStorage(pixels, format, type, width, border)", canBeNull = true) + @Check(value = "GLChecks.calculateTexImage1DStorage(pixels, format, type, width)", canBeNull = true) @Const @GLbyte @GLshort @@ -1271,7 +1271,7 @@ void glTexImage2D(@GLenum int target, int level, int internalformat, int width, int height, int border, @GLenum int format, @GLenum int type, @BufferObject(BufferKind.UnpackPBO) - @Check(value = "GLChecks.calculateTexImage2DStorage(pixels, format, type, width, height, border)", canBeNull = true) + @Check(value = "GLChecks.calculateTexImage2DStorage(pixels, format, type, width, height)", canBeNull = true) @Const @GLbyte @GLshort Modified: trunk/LWJGL/src/templates/org/lwjgl/opengl/GL12.java =================================================================== --- trunk/LWJGL/src/templates/org/lwjgl/opengl/GL12.java 2007-04-11 20:33:07 UTC (rev 2766) +++ trunk/LWJGL/src/templates/org/lwjgl/opengl/GL12.java 2007-04-15 19:33:03 UTC (rev 2767) @@ -97,7 +97,7 @@ void glTexImage3D(@GLenum int target, int level, int internalFormat, @GLsizei int width, @GLsizei int height, @GLsizei int depth, int border, @GLenum int format, @GLenum int type, @BufferObject(BufferKind.UnpackPBO) - @Check(value = "GLChecks.calculateTexImage3DStorage(pixels, format, type, width, height, depth, border)", canBeNull = true) + @Check(value = "GLChecks.calculateTexImage3DStorage(pixels, format, type, width, height, depth)", canBeNull = true) @Const @GLbyte @GLshort This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <eli...@us...> - 2007-04-23 20:17:47
|
Revision: 2797 http://svn.sourceforge.net/java-game-lib/?rev=2797&view=rev Author: elias_naur Date: 2007-04-23 13:17:42 -0700 (Mon, 23 Apr 2007) Log Message: ----------- Added support for non-direct in glGet* style functions Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/NondirectBufferWrapper.java trunk/LWJGL/src/java/org/lwjgl/util/generator/JavaMethodsGenerator.java trunk/LWJGL/src/templates/org/lwjgl/openal/AL10.java trunk/LWJGL/src/templates/org/lwjgl/openal/AL11.java trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_buffer_object.java trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_imaging.java trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_occlusion_query.java trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_program.java trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_shader_objects.java trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_texture_compression.java trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_vertex_program.java trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_vertex_shader.java trunk/LWJGL/src/templates/org/lwjgl/opengl/ATI_envmap_bumpmap.java trunk/LWJGL/src/templates/org/lwjgl/opengl/ATI_vertex_array_object.java trunk/LWJGL/src/templates/org/lwjgl/opengl/ATI_vertex_attrib_array_object.java trunk/LWJGL/src/templates/org/lwjgl/opengl/EXT_draw_buffers2.java trunk/LWJGL/src/templates/org/lwjgl/opengl/EXT_framebuffer_object.java trunk/LWJGL/src/templates/org/lwjgl/opengl/EXT_gpu_shader4.java trunk/LWJGL/src/templates/org/lwjgl/opengl/EXT_paletted_texture.java trunk/LWJGL/src/templates/org/lwjgl/opengl/EXT_texture_integer.java trunk/LWJGL/src/templates/org/lwjgl/opengl/EXT_timer_query.java trunk/LWJGL/src/templates/org/lwjgl/opengl/EXT_vertex_shader.java trunk/LWJGL/src/templates/org/lwjgl/opengl/GL11.java trunk/LWJGL/src/templates/org/lwjgl/opengl/GL13.java trunk/LWJGL/src/templates/org/lwjgl/opengl/GL15.java trunk/LWJGL/src/templates/org/lwjgl/opengl/GL20.java trunk/LWJGL/src/templates/org/lwjgl/opengl/NV_evaluators.java trunk/LWJGL/src/templates/org/lwjgl/opengl/NV_fence.java trunk/LWJGL/src/templates/org/lwjgl/opengl/NV_fragment_program.java trunk/LWJGL/src/templates/org/lwjgl/opengl/NV_gpu_program4.java trunk/LWJGL/src/templates/org/lwjgl/opengl/NV_occlusion_query.java trunk/LWJGL/src/templates/org/lwjgl/opengl/NV_program.java trunk/LWJGL/src/templates/org/lwjgl/opengl/NV_register_combiners.java trunk/LWJGL/src/templates/org/lwjgl/opengl/NV_register_combiners2.java trunk/LWJGL/src/templates/org/lwjgl/opengl/NV_transform_feedback.java trunk/LWJGL/src/templates/org/lwjgl/opengl/NV_vertex_program.java Added Paths: ----------- trunk/LWJGL/src/java/org/lwjgl/util/generator/OutParameter.java Modified: trunk/LWJGL/src/java/org/lwjgl/NondirectBufferWrapper.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/NondirectBufferWrapper.java 2007-04-23 16:47:25 UTC (rev 2796) +++ trunk/LWJGL/src/java/org/lwjgl/NondirectBufferWrapper.java 2007-04-23 20:17:42 UTC (rev 2797) @@ -67,6 +67,36 @@ return buffers; } + public static ByteBuffer wrapNoCopyBuffer(ByteBuffer buf, int size) { + BufferChecks.checkBufferSize(buf, size); + return wrapNoCopyDirect(buf); + } + + public static ShortBuffer wrapNoCopyBuffer(ShortBuffer buf, int size) { + BufferChecks.checkBufferSize(buf, size); + return wrapNoCopyDirect(buf); + } + + public static IntBuffer wrapNoCopyBuffer(IntBuffer buf, int size) { + BufferChecks.checkBufferSize(buf, size); + return wrapNoCopyDirect(buf); + } + + public static LongBuffer wrapNoCopyBuffer(LongBuffer buf, int size) { + BufferChecks.checkBufferSize(buf, size); + return wrapNoCopyDirect(buf); + } + + public static FloatBuffer wrapNoCopyBuffer(FloatBuffer buf, int size) { + BufferChecks.checkBufferSize(buf, size); + return wrapNoCopyDirect(buf); + } + + public static DoubleBuffer wrapNoCopyBuffer(DoubleBuffer buf, int size) { + BufferChecks.checkBufferSize(buf, size); + return wrapNoCopyDirect(buf); + } + public static ByteBuffer wrapBuffer(ByteBuffer buf, int size) { BufferChecks.checkBufferSize(buf, size); return wrapDirect(buf); @@ -133,8 +163,138 @@ return buffer; } + public static ByteBuffer wrapNoCopyDirect(ByteBuffer buffer) { + if (!buffer.isDirect()) + return doNoCopyWrap(buffer); + return buffer; + } + + public static ShortBuffer wrapNoCopyDirect(ShortBuffer buffer) { + if (!buffer.isDirect()) + return doNoCopyWrap(buffer); + return buffer; + } + + public static FloatBuffer wrapNoCopyDirect(FloatBuffer buffer) { + if (!buffer.isDirect()) + return doNoCopyWrap(buffer); + return buffer; + } + + public static IntBuffer wrapNoCopyDirect(IntBuffer buffer) { + if (!buffer.isDirect()) + return doNoCopyWrap(buffer); + return buffer; + } + + public static LongBuffer wrapNoCopyDirect(LongBuffer buffer) { + if (!buffer.isDirect()) + return doNoCopyWrap(buffer); + return buffer; + } + + public static DoubleBuffer wrapNoCopyDirect(DoubleBuffer buffer) { + if (!buffer.isDirect()) + return doNoCopyWrap(buffer); + return buffer; + } + + public static void copy(ByteBuffer src, ByteBuffer dst) { + if (dst != null && !dst.isDirect()) { + int saved_position = dst.position(); + dst.put(src); + dst.position(saved_position); + } + } + + public static void copy(ShortBuffer src, ShortBuffer dst) { + if (dst != null && !dst.isDirect()) { + int saved_position = dst.position(); + dst.put(src); + dst.position(saved_position); + } + } + + public static void copy(IntBuffer src, IntBuffer dst) { + if (dst != null && !dst.isDirect()) { + int saved_position = dst.position(); + dst.put(src); + dst.position(saved_position); + } + } + + public static void copy(FloatBuffer src, FloatBuffer dst) { + if (dst != null && !dst.isDirect()) { + int saved_position = dst.position(); + dst.put(src); + dst.position(saved_position); + } + } + + public static void copy(LongBuffer src, LongBuffer dst) { + if (dst != null && !dst.isDirect()) { + int saved_position = dst.position(); + dst.put(src); + dst.position(saved_position); + } + } + + public static void copy(DoubleBuffer src, DoubleBuffer dst) { + if (dst != null && !dst.isDirect()) { + int saved_position = dst.position(); + dst.put(src); + dst.position(saved_position); + } + } + + private static ByteBuffer doNoCopyWrap(ByteBuffer buffer) { + ByteBuffer direct_buffer = lookupBuffer(buffer); + direct_buffer.limit(buffer.limit()); + direct_buffer.position(buffer.position()); + return direct_buffer; + } + + private static ShortBuffer doNoCopyWrap(ShortBuffer buffer) { + ShortBuffer direct_buffer = lookupBuffer(buffer); + direct_buffer.limit(buffer.limit()); + direct_buffer.position(buffer.position()); + return direct_buffer; + } + + private static IntBuffer doNoCopyWrap(IntBuffer buffer) { + IntBuffer direct_buffer = lookupBuffer(buffer); + direct_buffer.limit(buffer.limit()); + direct_buffer.position(buffer.position()); + return direct_buffer; + } + + private static FloatBuffer doNoCopyWrap(FloatBuffer buffer) { + FloatBuffer direct_buffer = lookupBuffer(buffer); + direct_buffer.limit(buffer.limit()); + direct_buffer.position(buffer.position()); + return direct_buffer; + } + + private static LongBuffer doNoCopyWrap(LongBuffer buffer) { + LongBuffer direct_buffer = lookupBuffer(buffer); + direct_buffer.limit(buffer.limit()); + direct_buffer.position(buffer.position()); + return direct_buffer; + } + + private static DoubleBuffer doNoCopyWrap(DoubleBuffer buffer) { + DoubleBuffer direct_buffer = lookupBuffer(buffer); + direct_buffer.limit(buffer.limit()); + direct_buffer.position(buffer.position()); + return direct_buffer; + } + + private static ByteBuffer lookupBuffer(ByteBuffer buffer) { + return getCachedBuffers(buffer.remaining()).byte_buffer; + } + private static ByteBuffer doWrap(ByteBuffer buffer) { - ByteBuffer direct_buffer = getCachedBuffers(buffer.remaining()).byte_buffer; + ByteBuffer direct_buffer = lookupBuffer(buffer); direct_buffer.clear(); int saved_position = buffer.position(); direct_buffer.put(buffer); @@ -143,9 +303,13 @@ return direct_buffer; } + private static ShortBuffer lookupBuffer(ShortBuffer buffer) { + CachedBuffers buffers = getCachedBuffers(buffer.remaining()*2); + return buffer.order() == ByteOrder.LITTLE_ENDIAN ? buffers.short_buffer_little : buffers.short_buffer_big; + } + private static ShortBuffer doWrap(ShortBuffer buffer) { - CachedBuffers buffers = getCachedBuffers(buffer.remaining()*2); - ShortBuffer direct_buffer = buffer.order() == ByteOrder.LITTLE_ENDIAN ? buffers.short_buffer_little : buffers.short_buffer_big; + ShortBuffer direct_buffer = lookupBuffer(buffer); direct_buffer.clear(); int saved_position = buffer.position(); direct_buffer.put(buffer); @@ -154,9 +318,13 @@ return direct_buffer; } + private static FloatBuffer lookupBuffer(FloatBuffer buffer) { + CachedBuffers buffers = getCachedBuffers(buffer.remaining()*4); + return buffer.order() == ByteOrder.LITTLE_ENDIAN ? buffers.float_buffer_little : buffers.float_buffer_big; + } + private static FloatBuffer doWrap(FloatBuffer buffer) { - CachedBuffers buffers = getCachedBuffers(buffer.remaining()*4); - FloatBuffer direct_buffer = buffer.order() == ByteOrder.LITTLE_ENDIAN ? buffers.float_buffer_little : buffers.float_buffer_big; + FloatBuffer direct_buffer = lookupBuffer(buffer); direct_buffer.clear(); int saved_position = buffer.position(); direct_buffer.put(buffer); @@ -165,9 +333,13 @@ return direct_buffer; } + private static IntBuffer lookupBuffer(IntBuffer buffer) { + CachedBuffers buffers = getCachedBuffers(buffer.remaining()*4); + return buffer.order() == ByteOrder.LITTLE_ENDIAN ? buffers.int_buffer_little : buffers.int_buffer_big; + } + private static IntBuffer doWrap(IntBuffer buffer) { - CachedBuffers buffers = getCachedBuffers(buffer.remaining()*4); - IntBuffer direct_buffer = buffer.order() == ByteOrder.LITTLE_ENDIAN ? buffers.int_buffer_little : buffers.int_buffer_big; + IntBuffer direct_buffer = lookupBuffer(buffer); direct_buffer.clear(); int saved_position = buffer.position(); direct_buffer.put(buffer); @@ -176,9 +348,13 @@ return direct_buffer; } + private static LongBuffer lookupBuffer(LongBuffer buffer) { + CachedBuffers buffers = getCachedBuffers(buffer.remaining()*8); + return buffer.order() == ByteOrder.LITTLE_ENDIAN ? buffers.long_buffer_little : buffers.long_buffer_big; + } + private static LongBuffer doWrap(LongBuffer buffer) { - CachedBuffers buffers = getCachedBuffers(buffer.remaining()*8); - LongBuffer direct_buffer = buffer.order() == ByteOrder.LITTLE_ENDIAN ? buffers.long_buffer_little : buffers.long_buffer_big; + LongBuffer direct_buffer = lookupBuffer(buffer); direct_buffer.clear(); int saved_position = buffer.position(); direct_buffer.put(buffer); @@ -187,9 +363,13 @@ return direct_buffer; } + private static DoubleBuffer lookupBuffer(DoubleBuffer buffer) { + CachedBuffers buffers = getCachedBuffers(buffer.remaining()*8); + return buffer.order() == ByteOrder.LITTLE_ENDIAN ? buffers.double_buffer_little : buffers.double_buffer_big; + } + private static DoubleBuffer doWrap(DoubleBuffer buffer) { - CachedBuffers buffers = getCachedBuffers(buffer.remaining()*8); - DoubleBuffer direct_buffer = buffer.order() == ByteOrder.LITTLE_ENDIAN ? buffers.double_buffer_little : buffers.double_buffer_big; + DoubleBuffer direct_buffer = lookupBuffer(buffer); direct_buffer.clear(); int saved_position = buffer.position(); direct_buffer.put(buffer); Modified: trunk/LWJGL/src/java/org/lwjgl/util/generator/JavaMethodsGenerator.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/util/generator/JavaMethodsGenerator.java 2007-04-23 16:47:25 UTC (rev 2796) +++ trunk/LWJGL/src/java/org/lwjgl/util/generator/JavaMethodsGenerator.java 2007-04-23 20:17:42 UTC (rev 2797) @@ -50,6 +50,8 @@ import java.nio.*; public class JavaMethodsGenerator { + private final static String SAVED_PARAMETER_POSTFIX = "_saved"; + public static void generateMethodsJava(AnnotationProcessorEnvironment env, TypeMap type_map, PrintWriter writer, InterfaceDeclaration interface_decl, boolean generate_error_checks, boolean context_specific) { for (MethodDeclaration method : interface_decl.getMethods()) generateMethodJava(env, type_map, writer, interface_decl, method, generate_error_checks, context_specific); @@ -197,7 +199,7 @@ if (code_annotation != null) writer.println(code_annotation.value()); printBufferObjectChecks(writer, method, mode); - printParameterChecks(writer, method, mode); + printParameterChecks(writer, method, typeinfos_instance, mode); printParameterCaching(writer, interface_decl, method, mode); writer.print("\t\t"); boolean has_result = !result_type.equals(env.getTypeUtils().getVoidType()); @@ -218,6 +220,7 @@ writer.println(");"); if (generate_error_checks && method.getAnnotation(NoErrorCheck.class) == null) writer.println("\t\t" + type_map.getErrorCheckMethodName() + ";"); + printNondirectParameterCopies(writer, method, mode); if (has_result) writer.println("\t\treturn " + Utils.RESULT_VAR_NAME + ";"); writer.println("\t}"); @@ -409,13 +412,29 @@ } } - private static void printParameterChecks(PrintWriter writer, MethodDeclaration method, Mode mode) { + private static void printNondirectParameterCopies(PrintWriter writer, MethodDeclaration method, Mode mode) { for (ParameterDeclaration param : method.getParameters()) { Class java_type = Utils.getJavaType(param.getType()); if (Utils.isAddressableType(java_type) && (mode != Mode.BUFFEROBJECT || param.getAnnotation(BufferObject.class) == null) && (mode != Mode.AUTOS || getAutoTypeParameter(method, param) == null) && param.getAnnotation(Result.class) == null) { + if (Buffer.class.isAssignableFrom(java_type)) { + boolean out_parameter = param.getAnnotation(OutParameter.class) != null; + if (out_parameter) + writer.println("\t\tNondirectBufferWrapper.copy(" + param.getSimpleName() + ", " + param.getSimpleName() + SAVED_PARAMETER_POSTFIX + ");"); + } + } + } + } + + private static void printParameterChecks(PrintWriter writer, MethodDeclaration method, Map<ParameterDeclaration, TypeInfo> typeinfos, Mode mode) { + for (ParameterDeclaration param : method.getParameters()) { + Class java_type = Utils.getJavaType(param.getType()); + if (Utils.isAddressableType(java_type) && + (mode != Mode.BUFFEROBJECT || param.getAnnotation(BufferObject.class) == null) && + (mode != Mode.AUTOS || getAutoTypeParameter(method, param) == null) && + param.getAnnotation(Result.class) == null) { String check_value = null; boolean can_be_null = false; Check check_annotation = param.getAnnotation(Check.class); @@ -426,7 +445,9 @@ boolean null_terminated = param.getAnnotation(NullTerminated.class) != null; if (Buffer.class.isAssignableFrom(java_type)) { boolean indirect_buffer_allowed = param.getAnnotation(CachedReference.class) == null; - printParameterCheck(writer, param.getSimpleName(), check_value, can_be_null, null_terminated, indirect_buffer_allowed); + boolean out_parameter = param.getAnnotation(OutParameter.class) != null; + TypeInfo typeinfo = typeinfos.get(param); + printParameterCheck(writer, param.getSimpleName(), typeinfo.getType().getSimpleName(), check_value, can_be_null, null_terminated, indirect_buffer_allowed, out_parameter); } else if (String.class.equals(java_type)) { if (!can_be_null) writer.println("\t\tBufferChecks.checkNotNull(" + param.getSimpleName() + ");"); @@ -434,17 +455,22 @@ } } if (method.getAnnotation(CachedResult.class) != null) - printParameterCheck(writer, Utils.CACHED_BUFFER_NAME, null, true, false, false); + printParameterCheck(writer, Utils.CACHED_BUFFER_NAME, null, null, true, false, false, false); } - private static void printParameterCheck(PrintWriter writer, String name, String check_value, boolean can_be_null, boolean null_terminated, boolean indirect_buffer_allowed) { + private static void printParameterCheck(PrintWriter writer, String name, String type, String check_value, boolean can_be_null, boolean null_terminated, boolean indirect_buffer_allowed, boolean out_parameter) { + if (indirect_buffer_allowed && out_parameter) { + writer.println("\t\t" + type + " " + name + SAVED_PARAMETER_POSTFIX + " = " + name + ";"); + } if (can_be_null) { writer.println("\t\tif (" + name + " != null)"); writer.print("\t"); } - if (indirect_buffer_allowed) + if (indirect_buffer_allowed) { writer.print("\t\t" + name + " = NondirectBufferWrapper.wrap"); - else + if (out_parameter) + writer.print("NoCopy"); + } else writer.print("\t\tBufferChecks.check"); if (check_value != null && !"".equals(check_value) ) { writer.print("Buffer(" + name + ", " + check_value); Added: trunk/LWJGL/src/java/org/lwjgl/util/generator/OutParameter.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/util/generator/OutParameter.java (rev 0) +++ trunk/LWJGL/src/java/org/lwjgl/util/generator/OutParameter.java 2007-04-23 20:17:42 UTC (rev 2797) @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2002-2004 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions 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 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package org.lwjgl.util.generator; + +/** + * This annotation indicates that a parameter is written, + * not read. + * + * @author elias_naur <eli...@us...> + * @version $Revision: 2286 $ + * $Id: Check.java 2286 2006-03-23 19:32:21Z matzon $ + */ + +import java.lang.annotation.Target; +import java.lang.annotation.ElementType; + +@Target(ElementType.PARAMETER) +public @interface OutParameter { +} Modified: trunk/LWJGL/src/templates/org/lwjgl/openal/AL10.java =================================================================== --- trunk/LWJGL/src/templates/org/lwjgl/openal/AL10.java 2007-04-23 16:47:25 UTC (rev 2796) +++ trunk/LWJGL/src/templates/org/lwjgl/openal/AL10.java 2007-04-23 20:17:42 UTC (rev 2797) @@ -480,7 +480,7 @@ */ @StripPostfix("data") @ALvoid - void alGetIntegerv(@ALenum int pname, @Check("1") IntBuffer data); + void alGetIntegerv(@ALenum int pname, @OutParameter @Check("1") IntBuffer data); /** * Like OpenGL, AL uses a simplified interface for querying global state. @@ -498,7 +498,7 @@ */ @StripPostfix("data") @ALvoid - void alGetFloatv(@ALenum int pname, @Check("1") FloatBuffer data); + void alGetFloatv(@ALenum int pname, @OutParameter @Check("1") FloatBuffer data); /** * Like OpenGL, AL uses a simplified interface for querying global state. @@ -516,7 +516,7 @@ */ @StripPostfix("data") @ALvoid - void alGetDoublev(@ALenum int pname, @Check("1") DoubleBuffer data); + void alGetDoublev(@ALenum int pname, @OutParameter @Check("1") DoubleBuffer data); /** * The application can retrieve state information global to the current AL Context. @@ -711,7 +711,7 @@ // TODO: What's the real minimum number of elements? @StripPostfix("floatdata") @ALvoid - void alGetListenerfv(@ALenum int pname, @Check("1") FloatBuffer floatdata); + void alGetListenerfv(@ALenum int pname, @OutParameter @Check("1") FloatBuffer floatdata); /** * The application requests a number of Sources using GenSources. @@ -827,7 +827,7 @@ // TODO: What's the correct minimum value? @StripPostfix("floatdata") @ALvoid - void alGetSourcefv(@ALuint int source, @ALenum int pname, @Check("1") FloatBuffer floatdata); + void alGetSourcefv(@ALuint int source, @ALenum int pname, @OutParameter @Check("1") FloatBuffer floatdata); /** * Play() applied to an AL_INITIAL Source will promote the Source to AL_PLAYING, thus Modified: trunk/LWJGL/src/templates/org/lwjgl/openal/AL11.java =================================================================== --- trunk/LWJGL/src/templates/org/lwjgl/openal/AL11.java 2007-04-23 16:47:25 UTC (rev 2796) +++ trunk/LWJGL/src/templates/org/lwjgl/openal/AL11.java 2007-04-23 20:17:42 UTC (rev 2797) @@ -100,7 +100,7 @@ // TODO: What's the real minimum number of elements? @StripPostfix("intdata") @ALvoid - void alGetListeneriv(@ALenum int pname, @Check("1") FloatBuffer intdata); + void alGetListeneriv(@ALenum int pname, @OutParameter @Check("1") FloatBuffer intdata); /** * Specifies the position and other properties as taken into account during @@ -229,7 +229,7 @@ // TODO: What's the correct minimum value? @StripPostfix("values") @ALvoid - void alGetBufferiv(@ALuint int buffer, @ALenum int pname, @Check("1") IntBuffer values); + void alGetBufferiv(@ALuint int buffer, @ALenum int pname, @OutParameter @Check("1") IntBuffer values); /** * This function retrieves a floating point property of a buffer. @@ -254,7 +254,7 @@ // TODO: What's the correct minimum value? @StripPostfix("values") @ALvoid - void alGetBufferfv(@ALuint int buffer, @ALenum int pname, @Check("1") FloatBuffer values); + void alGetBufferfv(@ALuint int buffer, @ALenum int pname, @OutParameter @Check("1") FloatBuffer values); /** * <p> Modified: trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_buffer_object.java =================================================================== --- trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_buffer_object.java 2007-04-23 16:47:25 UTC (rev 2796) +++ trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_buffer_object.java 2007-04-23 20:17:42 UTC (rev 2797) @@ -94,6 +94,7 @@ @GLdouble Buffer data); void glGetBufferSubDataARB(@GLenum int target, @GLintptrARB long offset, @AutoSize("data") @GLsizeiptrARB long size, + @OutParameter @Check @GLbyte @GLshort @@ -121,7 +122,7 @@ boolean glUnmapBufferARB(@GLenum int target); @StripPostfix("params") - void glGetBufferParameterivARB(@GLenum int target, @GLenum int pname, @Check("4") IntBuffer params); + void glGetBufferParameterivARB(@GLenum int target, @GLenum int pname, @OutParameter @Check("4") IntBuffer params); @StripPostfix("pointer") @AutoResultSize("GLChecks.getBufferObjectSizeARB(caps, target)") Modified: trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_imaging.java =================================================================== --- trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_imaging.java 2007-04-23 16:47:25 UTC (rev 2796) +++ trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_imaging.java 2007-04-23 20:17:42 UTC (rev 2797) @@ -150,6 +150,7 @@ void glCopyColorTable(@GLenum int target, @GLenum int internalformat, int x, int y, @GLsizei int width); void glGetColorTable(@GLenum int target, @GLenum int format, @GLenum int type, + @OutParameter @Check("256") @GLbyte @GLfloat @@ -170,6 +171,7 @@ void glResetHistogram(@GLenum int target); void glGetHistogram(@GLenum int target, boolean reset, @GLenum int format, @GLenum int type, + @OutParameter @BufferObject(BufferKind.PackPBO) @Check("256") @GLbyte @@ -179,16 +181,17 @@ @GLdouble Buffer values); @StripPostfix("params") - void glGetHistogramParameterfv(@GLenum int target, @GLenum int pname, @Check("256") FloatBuffer params); + void glGetHistogramParameterfv(@GLenum int target, @GLenum int pname, @OutParameter @Check("256") FloatBuffer params); @StripPostfix("params") - void glGetHistogramParameteriv(@GLenum int target, @GLenum int pname, @Check("256") IntBuffer params); + void glGetHistogramParameteriv(@GLenum int target, @GLenum int pname, @OutParameter @Check("256") IntBuffer params); void glMinmax(@GLenum int target, @GLenum int internalformat, boolean sink); void glResetMinmax(@GLenum int target); void glGetMinmax(@GLenum int target, boolean reset, @GLenum int format, @GLenum int types, + @OutParameter @BufferObject(BufferKind.PackPBO) @Check("4") @GLbyte @@ -198,10 +201,10 @@ @GLdouble Buffer values); @StripPostfix("params") - void glGetMinmaxParameterfv(@GLenum int target, @GLenum int pname, @Check("4") FloatBuffer params); + void glGetMinmaxParameterfv(@GLenum int target, @GLenum int pname, @OutParameter @Check("4") FloatBuffer params); @StripPostfix("params") - void glGetMinmaxParameteriv(@GLenum int target, @GLenum int pname, @Check("4") IntBuffer params); + void glGetMinmaxParameteriv(@GLenum int target, @GLenum int pname, @OutParameter @Check("4") IntBuffer params); void glConvolutionFilter1D(@GLenum int target, @GLenum int internalformat, @GLsizei int width, @GLenum int format, @GLenum int type, @BufferObject(BufferKind.UnpackPBO) @@ -237,6 +240,7 @@ // TODO: check buffer size valid void glGetConvolutionFilter(@GLenum int target, @GLenum int format, @GLenum int type, + @OutParameter @BufferObject(BufferKind.PackPBO) @Check @GLbyte @@ -246,10 +250,10 @@ @GLdouble Buffer image); @StripPostfix("params") - void glGetConvolutionParameterfv(@GLenum int target, @GLenum int pname, @Check("4") FloatBuffer params); + void glGetConvolutionParameterfv(@GLenum int target, @GLenum int pname, @OutParameter @Check("4") FloatBuffer params); @StripPostfix("params") - void glGetConvolutionParameteriv(@GLenum int target, @GLenum int pname, @Check("4") IntBuffer params); + void glGetConvolutionParameteriv(@GLenum int target, @GLenum int pname, @OutParameter @Check("4") IntBuffer params); // TODO: check buffer size valid void glSeparableFilter2D(@GLenum int target, @GLenum int internalformat, @GLsizei int width, @GLsizei int height, @GLenum int format, @GLenum int type, @@ -272,6 +276,7 @@ // TODO: check buffer size valid void glGetSeparableFilter(@GLenum int target, @GLenum int format, @GLenum int type, + @OutParameter @BufferObject(BufferKind.PackPBO) @Check @GLbyte @@ -291,4 +296,4 @@ @GLshort @GLint @GLdouble Buffer span); -} \ No newline at end of file +} Modified: trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_occlusion_query.java =================================================================== --- trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_occlusion_query.java 2007-04-23 16:47:25 UTC (rev 2796) +++ trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_occlusion_query.java 2007-04-23 20:17:42 UTC (rev 2797) @@ -67,11 +67,11 @@ void glEndQueryARB(@GLenum int target); @StripPostfix("params") - void glGetQueryivARB(@GLenum int target, @GLenum int pname, @Check("1") IntBuffer params); + void glGetQueryivARB(@GLenum int target, @GLenum int pname, @OutParameter @Check("1") IntBuffer params); @StripPostfix("params") - void glGetQueryObjectivARB(@GLuint int id, @GLenum int pname, @Check("1") IntBuffer params); + void glGetQueryObjectivARB(@GLuint int id, @GLenum int pname, @OutParameter @Check("1") IntBuffer params); @StripPostfix("params") - void glGetQueryObjectuivARB(@GLuint int id, @GLenum int pname, @Check("1") IntBuffer params); -} \ No newline at end of file + void glGetQueryObjectuivARB(@GLuint int id, @GLenum int pname, @OutParameter @Check("1") IntBuffer params); +} Modified: trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_program.java =================================================================== --- trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_program.java 2007-04-23 16:47:25 UTC (rev 2796) +++ trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_program.java 2007-04-23 20:17:42 UTC (rev 2797) @@ -155,21 +155,21 @@ void glProgramLocalParameter4dvARB(@GLenum int target, @GLuint int index, @Check("4") @Const DoubleBuffer params); @StripPostfix("params") - void glGetProgramEnvParameterfvARB(@GLenum int target, @GLuint int index, @Check("4") FloatBuffer params); + void glGetProgramEnvParameterfvARB(@GLenum int target, @GLuint int index, @OutParameter @Check("4") FloatBuffer params); @StripPostfix("params") - void glGetProgramEnvParameterdvARB(@GLenum int target, @GLuint int index, @Check("4") DoubleBuffer params); + void glGetProgramEnvParameterdvARB(@GLenum int target, @GLuint int index, @OutParameter @Check("4") DoubleBuffer params); @StripPostfix("params") - void glGetProgramLocalParameterfvARB(@GLenum int target, @GLuint int index, @Check("4") FloatBuffer params); + void glGetProgramLocalParameterfvARB(@GLenum int target, @GLuint int index, @OutParameter @Check("4") FloatBuffer params); @StripPostfix("params") - void glGetProgramLocalParameterdvARB(@GLenum int target, @GLuint int index, @Check("4") DoubleBuffer params); + void glGetProgramLocalParameterdvARB(@GLenum int target, @GLuint int index, @OutParameter @Check("4") DoubleBuffer params); @StripPostfix("params") - void glGetProgramivARB(@GLenum int target, @GLenum int parameterName, @Check("4") IntBuffer params); + void glGetProgramivARB(@GLenum int target, @GLenum int parameterName, @OutParameter @Check("4") IntBuffer params); - void glGetProgramStringARB(@GLenum int target, @GLenum int parameterName, @Check @GLbyte Buffer paramString); + void glGetProgramStringARB(@GLenum int target, @GLenum int parameterName, @OutParameter @Check @GLbyte Buffer paramString); boolean glIsProgramARB(@GLuint int program); } Modified: trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_shader_objects.java =================================================================== --- trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_shader_objects.java 2007-04-23 16:47:25 UTC (rev 2796) +++ trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_shader_objects.java 2007-04-23 20:17:42 UTC (rev 2797) @@ -177,17 +177,19 @@ void glUniformMatrix4fvARB(int location, @AutoSize(value = "matrices", expression = " >> 4") @GLsizei int count, boolean transpose, FloatBuffer matrices); @StripPostfix("params") - void glGetObjectParameterfvARB(@GLhandleARB int obj, @GLenum int pname, @Check FloatBuffer params); + void glGetObjectParameterfvARB(@GLhandleARB int obj, @GLenum int pname, @OutParameter @Check FloatBuffer params); @StripPostfix("params") - void glGetObjectParameterivARB(@GLhandleARB int obj, @GLenum int pname, @Check IntBuffer params); + void glGetObjectParameterivARB(@GLhandleARB int obj, @GLenum int pname, @OutParameter @Check IntBuffer params); void glGetInfoLogARB(@GLhandleARB int obj, @AutoSize("infoLog") @GLsizei int maxLength, + @OutParameter @Check(value = "1", canBeNull = true) @GLsizei IntBuffer length, @GLcharARB ByteBuffer infoLog); void glGetAttachedObjectsARB(@GLhandleARB int containerObj, @AutoSize("obj") @GLsizei int maxCount, + @OutParameter @Check(value = "1", canBeNull = true) @GLsizei IntBuffer count, @GLhandleARB IntBuffer obj); @@ -201,6 +203,7 @@ int glGetUniformLocationARB(@GLhandleARB int programObj, @NullTerminated @Const @GLcharARB ByteBuffer name); void glGetActiveUniformARB(@GLhandleARB int programObj, @GLuint int index, @AutoSize("name") @GLsizei int maxLength, + @OutParameter @Check(value = "1", canBeNull = true) @GLsizei IntBuffer length, @Check("1") IntBuffer size, @@ -209,12 +212,13 @@ @GLcharARB ByteBuffer name); @StripPostfix("params") - void glGetUniformfvARB(@GLhandleARB int programObj, int location, @Check FloatBuffer params); + void glGetUniformfvARB(@GLhandleARB int programObj, int location, @OutParameter @Check FloatBuffer params); @StripPostfix("params") - void glGetUniformivARB(@GLhandleARB int programObj, int location, @Check IntBuffer params); + void glGetUniformivARB(@GLhandleARB int programObj, int location, @OutParameter @Check IntBuffer params); void glGetShaderSourceARB(@GLhandleARB int obj, @AutoSize("source") @GLsizei int maxLength, + @OutParameter @Check(value = "1", canBeNull = true) @GLsizei IntBuffer length, @GLcharARB ByteBuffer source); Modified: trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_texture_compression.java =================================================================== --- trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_texture_compression.java 2007-04-23 16:47:25 UTC (rev 2796) +++ trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_texture_compression.java 2007-04-23 20:17:42 UTC (rev 2797) @@ -91,6 +91,7 @@ ByteBuffer pData); void glGetCompressedTexImageARB(@GLenum int target, int lod, + @OutParameter @BufferObject(BufferKind.PackPBO) @Check @GLvoid Modified: trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_vertex_program.java =================================================================== --- trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_vertex_program.java 2007-04-23 16:47:25 UTC (rev 2796) +++ trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_vertex_program.java 2007-04-23 20:17:42 UTC (rev 2797) @@ -130,13 +130,13 @@ void glDisableVertexAttribArrayARB(@GLuint int index); @StripPostfix("params") - void glGetVertexAttribfvARB(@GLuint int index, @GLenum int pname, @Check FloatBuffer params); + void glGetVertexAttribfvARB(@GLuint int index, @GLenum int pname, @OutParameter @Check FloatBuffer params); @StripPostfix("params") - void glGetVertexAttribdvARB(@GLuint int index, @GLenum int pname, @Check DoubleBuffer params); + void glGetVertexAttribdvARB(@GLuint int index, @GLenum int pname, @OutParameter @Check DoubleBuffer params); @StripPostfix("params") - void glGetVertexAttribivARB(@GLuint int index, @GLenum int pname, @Check IntBuffer params); + void glGetVertexAttribivARB(@GLuint int index, @GLenum int pname, @OutParameter @Check IntBuffer params); @StripPostfix("result") void glGetVertexAttribPointervARB(@GLuint int index, @GLenum int pname, @Result @GLvoid ByteBuffer result); Modified: trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_vertex_shader.java =================================================================== --- trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_vertex_shader.java 2007-04-23 16:47:25 UTC (rev 2796) +++ trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_vertex_shader.java 2007-04-23 20:17:42 UTC (rev 2797) @@ -144,23 +144,27 @@ void glGetActiveAttribARB(@GLhandleARB int programObj, @GLuint int index, @AutoSize("name") @GLsizei int maxLength, + @OutParameter @Check(value = "1", canBeNull = true) @GLsizei IntBuffer length, + @OutParameter @Check("1") IntBuffer size, + @OutParameter @Check("1") @GLenum IntBuffer type, + @OutParameter @GLcharARB ByteBuffer name); int glGetAttribLocationARB(@GLhandleARB int programObj, @NullTerminated @Const @GLcharARB ByteBuffer name); @StripPostfix("params") - void glGetVertexAttribfvARB(@GLuint int index, @GLenum int pname, @Check FloatBuffer params); + void glGetVertexAttribfvARB(@GLuint int index, @GLenum int pname, @OutParameter @Check FloatBuffer params); @StripPostfix("params") - void glGetVertexAttribdvARB(@GLuint int index, @GLenum int pname, @Check DoubleBuffer params); + void glGetVertexAttribdvARB(@GLuint int index, @GLenum int pname, @OutParameter @Check DoubleBuffer params); @StripPostfix("params") - void glGetVertexAttribivARB(@GLuint int index, @GLenum int pname, @Check IntBuffer params); + void glGetVertexAttribivARB(@GLuint int index, @GLenum int pname, @OutParameter @Check IntBuffer params); @StripPostfix("result") void glGetVertexAttribPointervARB(@GLuint int index, @GLenum int pname, @Result @GLvoid ByteBuffer result); Modified: trunk/LWJGL/src/templates/org/lwjgl/opengl/ATI_envmap_bumpmap.java =================================================================== --- trunk/LWJGL/src/templates/org/lwjgl/opengl/ATI_envmap_bumpmap.java 2007-04-23 16:47:25 UTC (rev 2796) +++ trunk/LWJGL/src/templates/org/lwjgl/opengl/ATI_envmap_bumpmap.java 2007-04-23 20:17:42 UTC (rev 2797) @@ -52,8 +52,8 @@ void glTexBumpParameterivATI(@GLenum int pname, @Check("4") @Const IntBuffer param); @StripPostfix("param") - void glGetTexBumpParameterfvATI(@GLenum int pname, @Check("4") FloatBuffer param); + void glGetTexBumpParameterfvATI(@GLenum int pname, @OutParameter @Check("4") FloatBuffer param); @StripPostfix("param") - void glGetTexBumpParameterivATI(@GLenum int pname, @Check("4") IntBuffer param); + void glGetTexBumpParameterivATI(@GLenum int pname, @OutParameter @Check("4") IntBuffer param); } Modified: trunk/LWJGL/src/templates/org/lwjgl/opengl/ATI_vertex_array_object.java =================================================================== --- trunk/LWJGL/src/templates/org/lwjgl/opengl/ATI_vertex_array_object.java 2007-04-23 16:47:25 UTC (rev 2796) +++ trunk/LWJGL/src/templates/org/lwjgl/opengl/ATI_vertex_array_object.java 2007-04-23 20:17:42 UTC (rev 2797) @@ -66,26 +66,26 @@ @GLdouble Buffer pPointer, @GLenum int preserve); @StripPostfix("params") - void glGetObjectBufferfvATI(@GLuint int buffer, @GLenum int pname, @Check FloatBuffer params); + void glGetObjectBufferfvATI(@GLuint int buffer, @GLenum int pname, @OutParameter @Check FloatBuffer params); @StripPostfix("params") - void glGetObjectBufferivATI(@GLuint int buffer, @GLenum int pname, @Check IntBuffer params); + void glGetObjectBufferivATI(@GLuint int buffer, @GLenum int pname, @OutParameter @Check IntBuffer params); void glFreeObjectBufferATI(@GLuint int buffer); void glArrayObjectATI(@GLenum int array, int size, @GLenum int type, @GLsizei int stride, @GLuint int buffer, @GLuint int offset); @StripPostfix("params") - void glGetArrayObjectfvATI(@GLenum int array, @GLenum int pname, @Check("4") FloatBuffer params); + void glGetArrayObjectfvATI(@GLenum int array, @GLenum int pname, @OutParameter @Check("4") FloatBuffer params); @StripPostfix("params") - void glGetArrayObjectivATI(@GLenum int array, @GLenum int pname, @Check("4") IntBuffer params); + void glGetArrayObjectivATI(@GLenum int array, @GLenum int pname, @OutParameter @Check("4") IntBuffer params); void glVariantArrayObjectATI(@GLuint int id, @GLenum int type, @GLsizei int stride, @GLuint int buffer, @GLuint int offset); @StripPostfix("params") - void glGetVariantArrayObjectfvATI(@GLuint int id, @GLenum int pname, @Check("4") FloatBuffer params); + void glGetVariantArrayObjectfvATI(@GLuint int id, @GLenum int pname, @OutParameter @Check("4") FloatBuffer params); @StripPostfix("params") - void glGetVariantArrayObjectivATI(@GLuint int id, @GLenum int pname, @Check("4") IntBuffer params); + void glGetVariantArrayObjectivATI(@GLuint int id, @GLenum int pname, @OutParameter @Check("4") IntBuffer params); } Modified: trunk/LWJGL/src/templates/org/lwjgl/opengl/ATI_vertex_attrib_array_object.java =================================================================== --- trunk/LWJGL/src/templates/org/lwjgl/opengl/ATI_vertex_attrib_array_object.java 2007-04-23 16:47:25 UTC (rev 2796) +++ trunk/LWJGL/src/templates/org/lwjgl/opengl/ATI_vertex_attrib_array_object.java 2007-04-23 20:17:42 UTC (rev 2797) @@ -39,8 +39,8 @@ void glVertexAttribArrayObjectATI(@GLuint int index, int size, @GLenum int type, boolean normalized, @GLsizei int stride, @GLuint int buffer, @GLuint int offset); @StripPostfix("params") - void glGetVertexAttribArrayObjectfvATI(@GLuint int index, @GLenum int pname, @Check("4") FloatBuffer params); + void glGetVertexAttribArrayObjectfvATI(@GLuint int index, @GLenum int pname, @OutParameter @Check("4") FloatBuffer params); @StripPostfix("params") - void glGetVertexAttribArrayObjectivATI(@GLuint int index, @GLenum int pname, @Check("4") IntBuffer params); + void glGetVertexAttribArrayObjectivATI(@GLuint int index, @GLenum int pname, @OutParameter @Check("4") IntBuffer params); } Modified: trunk/LWJGL/src/templates/org/lwjgl/opengl/EXT_draw_buffers2.java =================================================================== --- trunk/LWJGL/src/templates/org/lwjgl/opengl/EXT_draw_buffers2.java 2007-04-23 16:47:25 UTC (rev 2796) +++ trunk/LWJGL/src/templates/org/lwjgl/opengl/EXT_draw_buffers2.java 2007-04-23 20:17:42 UTC (rev 2797) @@ -41,10 +41,10 @@ void glColorMaskIndexedEXT(@GLuint int buf, boolean r, boolean g, boolean b, boolean a); @StripPostfix("data") - void glGetBooleanIndexedvEXT(@GLenum int value, @GLuint int index, @Check("4") @GLboolean ByteBuffer data); + void glGetBooleanIndexedvEXT(@GLenum int value, @GLuint int index, @OutParameter @Check("4") @GLboolean ByteBuffer data); @StripPostfix("data") - void glGetIntegerIndexedvEXT(@GLenum int value, @GLuint int index, @Check("4") IntBuffer data); + void glGetIntegerIndexedvEXT(@GLenum int value, @GLuint int index, @OutParameter @Check("4") IntBuffer data); void glEnableIndexedEXT(@GLenum int target, @GLuint int index); @@ -52,4 +52,4 @@ boolean glIsEnabledIndexedEXT(@GLenum int target, @GLuint int index); -} \ No newline at end of file +} Modified: trunk/LWJGL/src/templates/org/lwjgl/opengl/EXT_framebuffer_object.java =================================================================== --- trunk/LWJGL/src/templates/org/lwjgl/opengl/EXT_framebuffer_object.java 2007-04-23 16:47:25 UTC (rev 2796) +++ trunk/LWJGL/src/templates/org/lwjgl/opengl/EXT_framebuffer_object.java 2007-04-23 20:17:42 UTC (rev 2797) @@ -143,7 +143,7 @@ void glRenderbufferStorageEXT(@GLenum int target, @GLenum int internalformat, @GLsizei int width, @GLsizei int height); @StripPostfix("params") - void glGetRenderbufferParameterivEXT(@GLenum int target, @GLenum int pname, @Check("4") IntBuffer params); + void glGetRenderbufferParameterivEXT(@GLenum int target, @GLenum int pname, @OutParameter @Check("4") IntBuffer params); boolean glIsFramebufferEXT(@GLuint int framebuffer); @@ -165,7 +165,7 @@ void glFramebufferRenderbufferEXT(@GLenum int target, @GLenum int attachment, @GLenum int renderbuffertarget, @GLuint int renderbuffer); @StripPostfix("params") - void glGetFramebufferAttachmentParameterivEXT(@GLenum int target, @GLenum int attachment, @GLenum int pname, @Check("4") IntBuffer params); + void glGetFramebufferAttachmentParameterivEXT(@GLenum int target, @GLenum int attachment, @GLenum int pname, @OutParameter @Check("4") IntBuffer params); void glGenerateMipmapEXT(@GLenum int target); } Modified: trunk/LWJGL/src/templates/org/lwjgl/opengl/EXT_gpu_shader4.java =================================================================== --- trunk/LWJGL/src/templates/org/lwjgl/opengl/EXT_gpu_shader4.java 2007-04-23 16:47:25 UTC (rev 2796) +++ trunk/LWJGL/src/templates/org/lwjgl/opengl/EXT_gpu_shader4.java 2007-04-23 20:17:42 UTC (rev 2797) @@ -148,10 +148,10 @@ @GLuint Buffer buffer); @StripPostfix("params") - void glGetVertexAttribIivEXT(@GLuint int index, @GLenum int pname, @Check("4")IntBuffer params); + void glGetVertexAttribIivEXT(@GLuint int index, @GLenum int pname, @OutParameter @Check("4")IntBuffer params); @StripPostfix("params") - void glGetVertexAttribIuivEXT(@GLuint int index, @GLenum int pname, @Check("4") @GLuint IntBuffer params); + void glGetVertexAttribIuivEXT(@GLuint int index, @GLenum int pname, @OutParameter @Check("4") @GLuint IntBuffer params); void glUniform1uiEXT(int location, @GLuint int v0); @@ -174,10 +174,10 @@ void glUniform4uivEXT(int location, @AutoSize(value = "value", expression = " >> 2") @GLsizei int count, @Const @GLuint IntBuffer value); @StripPostfix("params") - void glGetUniformuivEXT(@GLuint int program, int location, @Check @GLuint IntBuffer params); + void glGetUniformuivEXT(@GLuint int program, int location, @OutParameter @Check @GLuint IntBuffer params); void glBindFragDataLocationEXT(@GLuint int program, @GLuint int colorNumber, @NullTerminated @Const @GLchar ByteBuffer name); int glGetFragDataLocationEXT(@GLuint int program, @NullTerminated @Const @GLchar ByteBuffer name); -} \ No newline at end of file +} Modified: trunk/LWJGL/src/templates/org/lwjgl/opengl/EXT_paletted_texture.java =================================================================== --- trunk/LWJGL/src/templates/org/lwjgl/opengl/EXT_paletted_texture.java 2007-04-23 16:47:25 UTC (rev 2796) +++ trunk/LWJGL/src/templates/org/lwjgl/opengl/EXT_paletted_texture.java 2007-04-23 20:17:42 UTC (rev 2797) @@ -85,6 +85,7 @@ @GLdouble Buffer data); void glGetColorTableEXT(@GLenum int target, @GLenum int format, @GLenum int type, + @OutParameter @Check @GLbyte @GLshort @@ -93,8 +94,8 @@ @GLdouble Buffer data); @StripPostfix("params") - void glGetColorTableParameterivEXT(@GLenum int target, @GLenum int pname, @Check("4") IntBuffer params); + void glGetColorTableParameterivEXT(@GLenum int target, @GLenum int pname, @OutParameter @Check("4") IntBuffer params); @StripPostfix("params") - void glGetColorTableParameterfvEXT(@GLenum int target, @GLenum int pname, @Check("4") FloatBuffer params); + void glGetColorTableParameterfvEXT(@GLenum int target, @GLenum int pname, @OutParameter @Check("4") FloatBuffer params); } Modified: trunk/LWJGL/src/templates/org/lwjgl/opengl/EXT_texture_integer.java =================================================================== --- trunk/LWJGL/src/templates/org/lwjgl/opengl/EXT_texture_integer.java 2007-04-23 16:47:25 UTC (rev 2796) +++ trunk/LWJGL/src/templates/org/lwjgl/opengl/EXT_texture_integer.java 2007-04-23 20:17:42 UTC (rev 2797) @@ -35,6 +35,7 @@ import org.lwjgl.util.generator.GLenum; import org.lwjgl.util.generator.GLuint; import org.lwjgl.util.generator.StripPostfix; +import org.lwjgl.util.generator.OutParameter; import java.nio.IntBuffer; @@ -113,15 +114,15 @@ void glClearColorIuiEXT(@GLuint int r, @GLuint int g, @GLuint int b, @GLuint int a); @StripPostfix("params") - void glTexParameterIivEXT(@GLenum int target, @GLenum int pname, @Check("4")IntBuffer params); + void glTexParameterIivEXT(@GLenum int target, @GLenum int pname, @Check("4") IntBuffer params); @StripPostfix("params") void glTexParameterIuivEXT(@GLenum int target, @GLenum int pname, @Check("4") @GLuint IntBuffer params); @StripPostfix("params") - void glGetTexParameterIivEXT(@GLenum int target, @GLenum int pname, @Check("4")IntBuffer params); + void glGetTexParameterIivEXT(@GLenum int target, @GLenum int pname, @OutParameter @Check("4") IntBuffer params); @StripPostfix("params") - void glGetTexParameterIuivEXT(@GLenum int target, @GLenum int pname, @Check("4") @GLuint IntBuffer params); + void glGetTexParameterIuivEXT(@GLenum int target, @GLenum int pname, @OutParameter @Check("4") @GLuint IntBuffer params); -} \ No newline at end of file +} Modified: trunk/LWJGL/src/templates/org/lwjgl/opengl/EXT_timer_query.java =================================================================== --- trunk/LWJGL/src/templates/org/lwjgl/opengl/EXT_timer_query.java 2007-04-23 16:47:25 UTC (rev 2796) +++ trunk/LWJGL/src/templates/org/lwjgl/opengl/EXT_timer_query.java 2007-04-23 20:17:42 UTC (rev 2797) @@ -44,9 +44,9 @@ int GL_TIME_ELAPSED_EXT = 0x88BF; @StripPostfix("params") - void glGetQueryObjecti64vEXT(@GLuint int id, @GLenum int pname, @Check("1") @GLint64EXT LongBuffer params); + void glGetQueryObjecti64vEXT(@GLuint int id, @GLenum int pname, @OutParameter @Check("1") @GLint64EXT LongBuffer params); @StripPostfix("params") - void glGetQueryObjectui64vEXT(@GLuint int id, @GLenum int pname, @Check("1") @GLuint64EXT LongBuffer params); + void glGetQueryObjectui64vEXT(@GLuint int id, @GLenum int pname, @OutParameter @Check("1") @GLuint64EXT LongBuffer params); -} \ No newline at end of file +} Modified: trunk/LWJGL/src/templates/org/lwjgl/opengl/EXT_vertex_shader.java =================================================================== --- trunk/LWJGL/src/templates/org/lwjgl/opengl/EXT_vertex_shader.java 2007-04-23 16:47:25 UTC (rev 2796) +++ trunk/LWJGL/src/templates/org/lwjgl/opengl/EXT_vertex_shader.java 2007-04-23 20:17:42 UTC (rev 2797) @@ -259,32 +259,32 @@ boolean glIsVariantEnabledEXT(@GLuint int id, @GLenum int cap); @StripPostfix("pbData") - void glGetVariantBooleanvEXT(@GLuint int id, @GLenum int value, @Check("4") ByteBuffer pbData); + void glGetVariantBooleanvEXT(@GLuint int id, @GLenum int value, @OutParameter @Check("4") ByteBuffer pbData); @StripPostfix("pbData") - void glGetVariantIntegervEXT(@GLuint int id, @GLenum int value, @Check("4") IntBuffer pbData); + void glGetVariantIntegervEXT(@GLuint int id, @GLenum int value, @OutParameter @Check("4") IntBuffer pbData); @StripPostfix("pbData") - void glGetVariantFloatvEXT(@GLuint int id, @GLenum int value, @Check("4") FloatBuffer pbData); + void glGetVariantFloatvEXT(@GLuint int id, @GLenum int value, @OutParameter @Check("4") FloatBuffer pbData); @StripPostfix("pbData") - void glGetVariantPointervEXT(@GLuint int id, @GLenum int value, @Result @GLvoid ByteBuffer pbData); + void glGetVariantPointervEXT(@GLuint int id, @GLenum int value, @OutParameter @Result @GLvoid ByteBuffer pbData); @StripPostfix("pbData") - void glGetInvariantBooleanvEXT(@GLuint int id, @GLenum int value, @Check("4") ByteBuffer pbData); + void glGetInvariantBooleanvEXT(@GLuint int id, @GLenum int value, @OutParameter @Check("4") ByteBuffer pbData); @StripPostfix("pbData") - void glGetInvariantIntegervEXT(@GLuint int id, @GLenum int value, @Check("4") IntBuffer pbData); + void glGetInvariantIntegervEXT(@GLuint int id, @GLenum int value, @OutParameter @Check("4") IntBuffer pbData); @StripPostfix("pbData") - void glGetInvariantFloatvEXT(@GLuint int id, @GLenum int value, @Check("4") FloatBuffer pbData); + void glGetInvariantFloatvEXT(@GLuint int id, @GLenum int value, @OutParameter @Check("4") FloatBuffer pbData); @StripPostfix("pbData") - void glGetLocalConstantBooleanvEXT(@GLuint int id, @GLenum int value, @Check("4") ByteBuffer pbData); + void glGetLocalConstantBooleanvEXT(@GLuint int id, @GLenum int value, @OutParameter @Check("4") ByteBuffer pbData); @StripPostfix("pbData") - void glGetLocalConstantIntegervEXT(@GLuint int id, @GLenum int value, @Check("4") IntBuffer pbData); + void glGetLocalConstantIntegervEXT(@GLuint int id, @GLenum int value, @OutParameter @Check("4") IntBuffer pbData); @StripPostfix("pbData") - void glGetLocalConstantFloatvEXT(@GLuint int id, @GLenum int value, @Check("4") FloatBuffer pbData); + void glGetLocalConstantFloatvEXT(@GLuint int id, @GLenum int value, @OutParameter @Check("4") FloatBuffer pbData); } Modified: trunk/LWJGL/src/templates/org/lwjgl/opengl/GL11.java =================================================================== --- trunk/LWJGL/src/templates/org/lwjgl/opengl/GL11.java 2007-04-23 16:47:25 UTC (rev 2796) +++ trunk/LWJGL/src/templates/org/lwjgl/opengl/GL11.java 2007-04-23 20:17:42 UTC (rev 2797) @@ -886,51 +886,51 @@ void glFeedbackBuffer(@AutoSize("buffer") @GLsizei int size, @GLenum int type, FloatBuffer buffer); @StripPostfix("values") - void glGetPixelMapfv(@GLenum int map, @Check("256") @BufferObject(BufferKind.PackPBO) FloatBuffer values); + void glGetPixelMapfv(@GLenum int map, @OutParameter @Check("256") @BufferObject(BufferKind.PackPBO) FloatBuffer values); @StripPostfix("values") - void glGetPixelMapuiv(@GLenum int map, @Check("256") @BufferObject(BufferKind.PackPBO) @GLuint IntBuffer values); + void glGetPixelMapuiv(@GLenum int map, @OutParameter @Check("256") @BufferObject(BufferKind.PackPBO) @GLuint IntBuffer values); @StripPostfix("values") - void glGetPixelMapusv(@GLenum int map, @Check("256") @BufferObject(BufferKind.PackPBO) @GLushort ShortBuffer values); + void glGetPixelMapusv(@GLenum int map, @OutParameter @Check("256") @BufferObject(BufferKind.PackPBO) @GLushort ShortBuffer values); @StripPostfix("params") - void glGetMaterialfv(@GLenum int face, @GLenum int pname, @Check("4") FloatBuffer params); + void glGetMaterialfv(@GLenum int face, @GLenum int pname, @OutParameter @Check("4") FloatBuffer params); @StripPostfix("params") - void glGetMaterialiv(@GLenum int face, @GLenum int pname, @Check("4") IntBuffer params); + void glGetMaterialiv(@GLenum int face, @GLenum int pname, @OutParameter @Check("4") IntBuffer params); @StripPostfix("v") - void glGetMapfv(@GLenum int target, @GLenum int query, @Check("256") FloatBuffer v); + void glGetMapfv(@GLenum int target, @GLenum int query, @OutParameter @Check("256") FloatBuffer v); @StripPostfix("v") - void glGetMapdv(@GLenum int target, @GLenum int query, @Check("256") DoubleBuffer v); + void glGetMapdv(@GLenum int target, @GLenum int query, @OutParameter @Check("256") DoubleBuffer v); @StripPostfix("v") - void glGetMapiv(@GLenum int target, @GLenum int query, @Check("256") IntBuffer v); + void glGetMapiv(@GLenum int target, @GLenum int query, @OutParameter @Check("256") IntBuffer v); @StripPostfix("params") - void glGetLightfv(@GLenum int light, @GLenum int pname, @Check("4") FloatBuffer params); + void glGetLightfv(@GLenum int light, @GLenum int pname, @OutParameter @Check("4") FloatBuffer params); @StripPostfix("params") - void glGetLightiv(@GLenum int light, @GLenum int pname, @Check("4") IntBuffer params); + void glGetLightiv(@GLenum int light, @GLenum int pname, @OutParameter @Check("4") IntBuffer params); @NoErrorCheck int glGetError(); - void glGetClipPlane(@GLenum int plane, @Check("4") DoubleBuffer equation); + void glGetClipPlane(@GLenum int plane, @OutParameter @Check("4") DoubleBuffer equation); @StripPostfix("params") - void glGetBooleanv(@GLenum int pname, @Check("16") @GLboolean ByteBuffer params); + void glGetBooleanv(@GLenum int pname, @OutParameter @Check("16") @GLboolean ByteBuffer params); @StripPostfix("params") - void glGetDoublev(@GLenum int pname, @Check("16") DoubleBuffer params); + void glGetDoublev(@GLenum int pname, @OutParameter @Check("16") DoubleBuffer params); @StripPostfix("params") - void glGetFloatv(@GLenum int pname, @Check("16") FloatBuffer params); + void glGetFloatv(@GLenum int pname, @OutParameter @Check("16") FloatBuffer params); @StripPostfix("params") - void glGetIntegerv(@GLenum int pname, @Check("16") IntBuffer params); + void glGetIntegerv(@GLenum int pname, @OutParameter @Check("16") IntBuffer params); void glGenTextures(@AutoSize("textures") @GLsizei int n, @GLuint IntBuffer textures); @@ -975,18 +975,19 @@ void glHint(@GLenum int target, @GLenum int mode); @StripPostfix("params") - void glGetTexParameterfv(@GLenum int target, @GLenum int pname, @Check("4") FloatBuffer params); + void glGetTexParameterfv(@GLenum int target, @GLenum int pname, @OutParameter @Check("4") FloatBuffer params); @StripPostfix("params") - void glGetTexParameteriv(@GLenum int target, @GLenum int pname, @Check("4") IntBuffer params); + void glGetTexParameteriv(@GLenum int target, @GLenum int pname, @OutParameter @Check("4") IntBuffer params); @StripPostfix("params") - void glGetTexLevelParameterfv(@GLenum int target, int level, @GLenum int pname, @Check("4") FloatBuffer params); + void glGetTexLevelParameterfv(@GLenum int target, int level, @GLenum int pname, @OutParameter @Check("4") FloatBuffer params); @StripPostfix("params") - void glGetTexLevelParameteriv(@GLenum int target, int level, @GLenum int pname, @Check("4") IntBuffer params); + void glGetTexLevelParameteriv(@GLenum int target, int level, @GLenum int pname, @OutParameter @Check("4") IntBuffer params); void glGetTexImage(@GLenum int target, int level, @GLenum int format, @GLenum int type, + @OutParameter @BufferObject(BufferKind.PackPBO) @Check("GLChecks.calculateImageStorage(pixels, format, type, 1, 1, 1)") @GLbyte @@ -996,24 +997,24 @@ @GLdouble Buffer pixels); @StripPostfix("params") - void glGetTexGeniv(@GLenum int coord, @GLenum int pname, @Check("4") IntBuffer params); + void glGetTexGeniv(@GLenum int coord, @GLenum int pname, @OutParameter @Check("4") IntBuffer params); @StripPostfix("params") - void glGetTexGenfv(@GLenum int coord, @GLenum int pname, @Check("4") FloatBuffer params); + void glGetTexGenfv(@GLenum int coord, @GLenum int pname, @OutParameter @Check("4") FloatBuffer params); @StripPostfix("params") - void glGetTexGendv(@GLenum int coord, @GLenum int pname, @Check("4") DoubleBuffer params); + void glGetTexGendv(@GLenum int coord, @GLenum int pname, @OutParameter @Check("4") DoubleBuffer params); @StripPostfix("params") - void glGetTexEnviv(@GLenum int coord, @GLenum int pname, @Check("4") IntBuffer params); + void glGetTexEnviv(@GLenum int coord, @GLenum int pname, @OutParameter @Check("4") IntBuffer params); @StripPostfix("params") - void glGetTexEnvfv(@GLenum int coord, @GLenum int pname, @Check("4") FloatBuffer params); + void glGetTexEnvfv(@GLenum int coord, @GLenum int pname, @OutParameter @Check("4") FloatBuffer params); @Const String glGetString(int name); - void glGetPolygonStipple(@BufferObject(BufferKind.PackPBO) @Check("1024") @GLubyte ByteBuffer mask); + void glGetPolygonStipple(@OutParameter @BufferObject(BufferKind.PackPBO) @Check("1024") @GLubyte ByteBuffer mask); boolean glIsList(@GLuint int list); Modified: trunk/LWJGL/src/templates/org/lwjgl/opengl/GL13.java =================================================================== --- trunk/LWJGL/src/templates/org/lwjgl/opengl/GL13.java 2007-04-23 16:47:25 UTC (rev 2796) +++ trunk/LWJGL/src/templates/org/lwjgl/opengl/GL13.java 2007-04-23 20:17:42 UTC (rev 2797) @@ -194,6 +194,7 @@ // TODO: check buffer size valid void glGetCompressedTexImage(@GLenum int target, int lod, + ... [truncated message content] |
From: <eli...@us...> - 2007-04-24 09:30:08
|
Revision: 2799 http://svn.sourceforge.net/java-game-lib/?rev=2799&view=rev Author: elias_naur Date: 2007-04-24 02:30:03 -0700 (Tue, 24 Apr 2007) Log Message: ----------- Windows: Remove dependency on DirectInput for WindowsMouse used by WindowsDisplay. Keyboard conversion coming up. Reasons: 1. DirectInput is deprecated (http://en.wikipedia.org/wiki/DirectInput). Specifically, Microsoft recommends using regular windows messages for keyboard and mouse input. 2. Not using DirectInput enable us to use the Raw Input JInput plugin to access multiple mice (and keyboards). 3. We're already using windows messages for features DirectInput never supported, so by removing DirectInput dependency, we get rid of some special case code. 4. When we're only using windows messages for input, we're (theoretically) more compatible than with a dependency on a properly working DirectInput. Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/Sys.java trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsAWTInput.java trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsMouse.java trunk/LWJGL/src/native/common/common_tools.c trunk/LWJGL/src/native/common/common_tools.h trunk/LWJGL/src/native/windows/org_lwjgl_input_Cursor.c trunk/LWJGL/src/native/windows/org_lwjgl_opengl_Display.c Added Paths: ----------- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDirectInputMouse.java Modified: trunk/LWJGL/src/java/org/lwjgl/Sys.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/Sys.java 2007-04-23 20:50:44 UTC (rev 2798) +++ trunk/LWJGL/src/java/org/lwjgl/Sys.java 2007-04-24 09:30:03 UTC (rev 2799) @@ -57,7 +57,7 @@ private static final String VERSION = "1.1"; /** Current version of the JNI library */ - static final int JNI_VERSION = 8; + static final int JNI_VERSION = 9; /** The implementation instance to delegate platform specific behavior to */ private final static SysImplementation implementation; Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsAWTInput.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsAWTInput.java 2007-04-23 20:50:44 UTC (rev 2798) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsAWTInput.java 2007-04-24 09:30:03 UTC (rev 2799) @@ -53,7 +53,7 @@ private Cursor cached_cursor; private long cached_hwnd; - private WindowsMouse cached_mouse; + private WindowsDirectInputMouse cached_mouse; // private WindowsKeyboard cached_keyboard; private boolean has_grabbed; @@ -96,7 +96,7 @@ cached_keyboard.destroy(); }*/ WindowsDirectInput dinput = WindowsDisplay.createDirectInput(); - cached_mouse = new WindowsMouse(dinput, hwnd); + cached_mouse = new WindowsDirectInputMouse(dinput, hwnd); // cached_keyboard = new WindowsKeyboard(dinput, hwnd); } if (isGrabbed()) { @@ -105,7 +105,7 @@ * task bar and clicking on it. So we'll use ClipCursor to * contain it while the cursor is grabbed. */ - WindowsDisplay.setupCursorClipping(hwnd); + WindowsDisplay.setupCursorClipping(hwnd, true); // Just clip it to a fullscreen window if (getCanvas().getCursor() != blank_cursor) { cached_cursor = getCanvas().getCursor(); /** Added: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDirectInputMouse.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDirectInputMouse.java (rev 0) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDirectInputMouse.java 2007-04-24 09:30:03 UTC (rev 2799) @@ -0,0 +1,353 @@ +/* + * Copyright (c) 2002-2004 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions 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 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package org.lwjgl.opengl; + +/** + * This is the Windows implementation of the Mouse. + * @author elias_naur + */ + +import java.nio.ByteBuffer; +import java.nio.IntBuffer; +import java.nio.CharBuffer; + +import org.lwjgl.LWJGLException; +import org.lwjgl.LWJGLUtil; +import org.lwjgl.BufferUtils; +import org.lwjgl.input.Mouse; + +final class WindowsDirectInputMouse { + private final static int BUFFER_SIZE = 50; + private final static int BUTTON_STATES_SIZE = 7; + + private final static int DIMOFS_X = 0; + private final static int DIMOFS_Y = 4; + private final static int DIMOFS_Z = 8; + private final static int DIMOFS_BUTTON0 = 12; + private final static int DIMOFS_BUTTON1 = 13; + private final static int DIMOFS_BUTTON2 = 14; + private final static int DIMOFS_BUTTON3 = 15; + + private final long hwnd; + private final WindowsDirectInput dinput; + private final WindowsDirectInputDevice mouse; + + private final int mouse_button_count; + private final boolean has_wheel; + + private final EventQueue event_queue = new EventQueue(Mouse.EVENT_SIZE); + /* Buffer to hold a DIMOUSESTATE */ + private final ByteBuffer mouse_state; + private final IntBuffer temp_data_buffer; + + private final ByteBuffer mouse_event = ByteBuffer.allocate(Mouse.EVENT_SIZE); + + private boolean mouse_grabbed; + private byte[] win32_message_button_states = new byte[BUTTON_STATES_SIZE]; + private int accum_dwheel; + private int last_x; + private int last_y; + + public WindowsDirectInputMouse(WindowsDirectInput dinput, long hwnd) throws LWJGLException { + this.hwnd = hwnd; + this.dinput = dinput; + try { + mouse = dinput.createDevice(WindowsDirectInput.MOUSE_TYPE); + try { + mouse.setDataFormat(WindowsDirectInput.MOUSE_TYPE); + mouse.setBufferSize(BUFFER_SIZE); + if (!acquireNonExclusive()) + throw new LWJGLException("Failed to acquire mouse non-exclusive"); + } catch (LWJGLException e) { + mouse.release(); + throw e; + } + } catch (LWJGLException e) { + dinput.release(); + throw e; + } + MouseEnumerator enumerator = new MouseEnumerator(); + mouse.enumObjects(enumerator); + this.mouse_button_count = Math.min(enumerator.getButtonCount(), 4); + this.has_wheel = enumerator.hasWheel(); + mouse_state = BufferUtils.createByteBuffer(3*4 + 4); + temp_data_buffer = BufferUtils.createIntBuffer(BUFFER_SIZE*WindowsDirectInputDevice.DATA_SIZE); + } + + public boolean hasWheel() { + return has_wheel; + } + + public int getButtonCount() { + return mouse_button_count; + } + + private boolean acquire(int flags) { + try { + mouse.setCooperateLevel(hwnd, flags); + mouse.acquire(); + return true; + } catch (LWJGLException e) { + LWJGLUtil.log("Failed to acquire mouse: " + e); + return false; + } + } + + private boolean acquireNonExclusive() { + return acquire(WindowsDirectInputDevice.DISCL_NONEXCLUSIVE | WindowsDirectInputDevice.DISCL_FOREGROUND) || + acquire(WindowsDirectInputDevice.DISCL_NONEXCLUSIVE | WindowsDirectInputDevice.DISCL_BACKGROUND); + } + + public void destroy() { + mouse.unacquire(); + mouse.release(); + dinput.release(); + } + + public void poll(IntBuffer coord_buffer, ByteBuffer buttons) { + int ret = mouse.acquire(); + if (ret != WindowsDirectInput.DI_OK && ret != WindowsDirectInput.DI_NOEFFECT) + return; + mouse.poll(); + for (int i = 0; i < coord_buffer.remaining(); i++) + coord_buffer.put(coord_buffer.position() + i, 0); + mouse_state.clear(); + ret = mouse.getDeviceState(mouse_state); + int mouse_state_lx = mouse_state.getInt(); + int mouse_state_ly = mouse_state.getInt(); + int mouse_state_lz = mouse_state.getInt(); + int num_buttons = mouse_button_count; + if (mouse_grabbed || ret == WindowsDirectInput.DI_OK) { + if (ret != WindowsDirectInput.DI_OK) { + LWJGLUtil.log("Error getting mouse state: (0x" + Integer.toHexString(ret) + ")"); + return; + } + + coord_buffer.put(coord_buffer.position() + 2, mouse_state_lz); + if (num_buttons > buttons.remaining()) + num_buttons = buttons.remaining(); + for (int j = 0; j < num_buttons; j++) { + byte button_state = (mouse_state.get() & 0x80) != 0 ? (byte)1 : (byte)0; + buttons.put(buttons.position() + j, button_state); + // track the button state in the windows message buffer state array + // to get accurate button information when releasing a grab + win32_message_button_states[j] = button_state; + } + } else { + coord_buffer.put(coord_buffer.position() + 2, accum_dwheel); + if (num_buttons > win32_message_button_states.length) + num_buttons = win32_message_button_states.length; + for (int j = 0; j < num_buttons; j++) { + buttons.put(buttons.position() + j, win32_message_button_states[j]); + } + } + accum_dwheel = 0; + if (mouse_grabbed) { + coord_buffer.put(coord_buffer.position() + 0, mouse_state_lx); + coord_buffer.put(coord_buffer.position() + 1, -mouse_state_ly); + } else { + coord_buffer.put(coord_buffer.position() + 0, last_x); + coord_buffer.put(coord_buffer.position() + 1, last_y); + } + } + + private void putMouseEventWithCoords(byte button, byte state, int coord1, int coord2, int dz, long nanos) { + mouse_event.clear(); + mouse_event.put(button).put(state).putInt(coord1).putInt(coord2).putInt(dz).putLong(nanos); + mouse_event.flip(); + event_queue.putEvent(mouse_event); + } + + private void putMouseEvent(byte button, byte state, int dz, long nanos) { + if (mouse_grabbed) + putMouseEventWithCoords(button, state, 0, 0, dz, nanos); + else + putMouseEventWithCoords(button, state, last_x, last_y, dz, nanos); + } + + private void copyDXEvents(IntBuffer buffer) { + int buffer_index = 0; + int dx = 0, dy = 0, dwheel = 0; + byte button_state; + int i; + long nanos = 0; + while (buffer.hasRemaining()) { + int dwOfs = buffer.get(); + int dwData = buffer.get(); + long dwTimeStamp = ((long)buffer.get()) & 0xFFFFFFFF; + nanos = dwTimeStamp*1000000; + button_state = (dwData & 0x80) != 0 ? (byte)1 : (byte)0; + switch (dwOfs) { + case DIMOFS_BUTTON0: + putMouseEventWithCoords((byte)0, button_state, dx, -dy, dwheel, nanos); + dx = dy = dwheel = 0; + break; + case DIMOFS_BUTTON1: + putMouseEventWithCoords((byte)1, button_state, dx, -dy, dwheel, nanos); + dx = dy = dwheel = 0; + break; + case DIMOFS_BUTTON2: + putMouseEventWithCoords((byte)2, button_state, dx, -dy, dwheel, nanos); + dx = dy = dwheel = 0; + break; + case DIMOFS_BUTTON3: + putMouseEventWithCoords((byte)3, button_state, dx, -dy, dwheel, nanos); + dx = dy = dwheel = 0; + break; + case DIMOFS_X: + dx += dwData; + break; + case DIMOFS_Y: + dy += dwData; + break; + case DIMOFS_Z: + dwheel += dwData; + break; + } + } + if (dx != 0 || dy != 0 || dwheel != 0) + putMouseEventWithCoords((byte)-1, (byte)0, dx, -dy, dwheel, nanos); + } + + private void readDXBuffer() { + int ret = mouse.acquire(); + if (ret != WindowsDirectInput.DI_OK && ret != WindowsDirectInput.DI_NOEFFECT) + return; + mouse.poll(); + temp_data_buffer.clear(); + ret = mouse.getDeviceData(temp_data_buffer); + + switch (ret) { + case WindowsDirectInput.DI_OK: + break; + case WindowsDirectInput.DI_BUFFEROVERFLOW: + LWJGLUtil.log("Mouse buffer overflowed"); + break; + case WindowsDirectInput.DIERR_INPUTLOST: + LWJGLUtil.log("Mouse input lost"); + break; + case WindowsDirectInput.DIERR_NOTACQUIRED: + LWJGLUtil.log("Mouse not acquired"); + break; + default: + LWJGLUtil.log("unknown mouse error (" + Integer.toHexString(ret) + ")"); + break; + } + } + + public final void flush() { + readDXBuffer(); + temp_data_buffer.clear(); + } + + public void read(ByteBuffer buffer) { + readDXBuffer(); + if (mouse_grabbed) { + temp_data_buffer.flip(); + copyDXEvents(temp_data_buffer); + } + event_queue.copyEvents(buffer); + } + + public void grab(boolean grab) { + if(grab) { + if (!mouse_grabbed) { + flush(); + mouse_grabbed = true; + mouse.unacquire(); + if (!acquire(WindowsDirectInputDevice.DISCL_EXCLUSIVE | WindowsDirectInputDevice.DISCL_FOREGROUND)) + LWJGLUtil.log("Failed to reset cooperative mode"); + } + } else { + if (mouse_grabbed) { + mouse_grabbed = false; + mouse.unacquire(); + acquireNonExclusive(); + } + } + event_queue.clearEvents(); + } + + public void handleMouseScrolled(int event_dwheel, long millis) { + accum_dwheel += event_dwheel; + putMouseEvent((byte)-1, (byte)0, event_dwheel, millis*1000000); + } + + public void handleMouseMoved(int x, int y, long millis) { + int dx; + int dy; + dx = x - last_x; + dy = y - last_y; + last_x = x; + last_y = y; + long nanos = millis*1000000; + if (mouse_grabbed) { + putMouseEventWithCoords((byte)-1, (byte)0, dx, dy, 0, nanos); + } else { + putMouseEventWithCoords((byte)-1, (byte)0, x, y, 0, nanos); + } + } + + public void handleMouseButton(byte button, byte state, long millis) { + putMouseEvent(button, state, 0, millis*1000000); + if (button < BUTTON_STATES_SIZE) + win32_message_button_states[button] = state != 0 ? (byte)1 : (byte)0; + } + + private static class MouseEnumerator implements WindowsDirectInputDeviceObjectCallback { + private int button_count; + private boolean has_wheel; + + public int getButtonCount() { + return button_count; + } + + public boolean hasWheel() { + return has_wheel; + } + + public boolean nextObject(int type, String name) { + LWJGLUtil.log("Found mouse object: " + name); + switch (type) { + case WindowsDirectInputDevice.GUID_ZAxis: + has_wheel = true; + break; + case WindowsDirectInputDevice.GUID_Button: + button_count++; + break; + default: + break; + } + return true; + } + } +} Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java 2007-04-23 20:50:44 UTC (rev 2798) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java 2007-04-24 09:30:03 UTC (rev 2799) @@ -44,6 +44,7 @@ import org.lwjgl.LWJGLException; import org.lwjgl.LWJGLUtil; +import org.lwjgl.BufferUtils; import org.lwjgl.input.Cursor; final class WindowsDisplay implements DisplayImplementation { @@ -85,7 +86,10 @@ private final static int SC_CONTEXTHELP = 0xF180; private final static int SC_SEPARATOR = 0xF00F; - private final static int SM_CXCURSOR = 13; + final static int SM_CXCURSOR = 13; + final static int SM_CYCURSOR = 14; + final static int SM_CMOUSEBUTTONS = 43; + final static int SM_MOUSEWHEELPRESENT = 75; private final static int SIZE_RESTORED = 0; private final static int SIZE_MINIMIZED = 1; @@ -99,9 +103,14 @@ private final static int SW_SHOWDEFAULT = 10; private final static int SW_RESTORE = 9; + private final static IntBuffer rect_buffer = BufferUtils.createIntBuffer(4); + private final static Rect rect = new Rect(); + private final static Rect rect2 = new Rect(); private static WindowsDisplay current_display; + private static boolean cursor_clipped; private WindowsDisplayPeerInfo peer_info; + private Object current_cursor; private WindowsKeyboard keyboard; private WindowsMouse mouse; @@ -141,13 +150,38 @@ public void destroyWindow() { nDestroyWindow(); - if (isFullscreen) - resetCursorClipping(); + resetCursorClipping(); } private static native void nDestroyWindow(); - static native void resetCursorClipping(); - static native void setupCursorClipping(long hwnd) throws LWJGLException; + static void resetCursorClipping() { + if (cursor_clipped) { + try { + clipCursor(0, null); + } catch (LWJGLException e) { + LWJGLUtil.log("Failed to reset cursor clipping: " + e); + } + cursor_clipped = false; + } + } + private static void getGlobalClientRect(long hwnd, Rect rect) { + rect_buffer.put(0, 0).put(1, 0); + clientToScreen(hwnd, rect_buffer); + int offset_x = rect_buffer.get(0); + int offset_y = rect_buffer.get(1); + getClientRect(hwnd, rect_buffer); + rect.copyFromBuffer(rect_buffer); + rect.offset(offset_x, offset_y); + } + + static void setupCursorClipping(long hwnd) throws LWJGLException { + cursor_clipped = true; + getGlobalClientRect(hwnd, rect); + rect.copyToBuffer(rect_buffer); + clipCursor(hwnd, rect_buffer); + } + private static native void clipCursor(long hwnd, IntBuffer rect) throws LWJGLException; + public void switchDisplayMode(DisplayMode mode) throws LWJGLException { nSwitchDisplayMode(mode); current_mode = mode; @@ -330,11 +364,12 @@ } public void createMouse() throws LWJGLException { - mouse = new WindowsMouse(createDirectInput(), getHwnd()); + mouse = new WindowsMouse(getHwnd()); } public void destroyMouse() { - mouse.destroy(); + if (mouse != null) + mouse.destroy(); mouse = null; } @@ -349,7 +384,12 @@ } public void grabMouse(boolean grab) { - mouse.grab(grab); + mouse.grab(grab, shouldGrab()); + try { + updateCursor(); + } catch (LWJGLException e) { + LWJGLUtil.log("Failed to update cursor: " + e); + } } public int getNativeCursorCapabilities() { @@ -357,12 +397,27 @@ } public void setCursorPosition(int x, int y) { - nSetCursorPosition(x, y, isFullscreen); + getGlobalClientRect(getHwnd(), rect); + int transformed_x = rect.left + x; + int transformed_y = rect.bottom - 1 - y; + nSetCursorPosition(transformed_x, transformed_y); + setMousePosition(x, y); } - private static native void nSetCursorPosition(int x, int y, boolean fullscreen); + private static native void nSetCursorPosition(int x, int y); - public native void setNativeCursor(Object handle) throws LWJGLException; + public void setNativeCursor(Object handle) throws LWJGLException { + current_cursor = handle; + updateCursor(); + } + private void updateCursor() throws LWJGLException { + if (mouse != null && mouse.isGrabbed()) + nSetNativeCursor(getHwnd(), mouse.getBlankCursor()); + else + nSetNativeCursor(getHwnd(), current_cursor); + } + static native void nSetNativeCursor(long hwnd, Object handle) throws LWJGLException; + public int getMinCursorSize() { return getSystemMetrics(SM_CXCURSOR); } @@ -371,11 +426,31 @@ return getSystemMetrics(SM_CXCURSOR); } - public native int getSystemMetrics(int index); + static native int getSystemMetrics(int index); private static native long getDllInstance(); private static native long getHwnd(); + private static native long getDesktopWindow(); + static void centerCursor(long hwnd) { + getGlobalClientRect(getHwnd(), rect); + int local_offset_x = rect.left; + int local_offset_y = rect.top; + getGlobalClientRect(getDesktopWindow(), rect2); + Rect.intersect(rect, rect2, rect); + int center_x = (rect.left + rect.right)/2; + int center_y = (rect.top + rect.bottom)/2; + nSetCursorPosition(center_x, center_y); + int local_x = center_x - local_offset_x; + int local_y = center_y - local_offset_y; + if (current_display != null) + current_display.setMousePosition(local_x, transformY(getHwnd(), local_y)); + } + private void setMousePosition(int x, int y) { + if (mouse != null) + mouse.setPosition(x, y); + } + /* Keyboard */ public void createKeyboard() throws LWJGLException { keyboard = new WindowsKeyboard(createDirectInput(), getHwnd()); @@ -398,13 +473,21 @@ // public native int isStateKeySet(int key); - public native ByteBuffer nCreateCursor(int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, int images_offset, IntBuffer delays, int delays_offset) throws LWJGLException; + public static native ByteBuffer nCreateCursor(int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, int images_offset, IntBuffer delays, int delays_offset) throws LWJGLException; public Object createCursor(int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, IntBuffer delays) throws LWJGLException { + return doCreateCursor(width, height, xHotspot, yHotspot, numImages, images, delays); + } + + static Object doCreateCursor(int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, IntBuffer delays) throws LWJGLException { return nCreateCursor(width, height, xHotspot, yHotspot, numImages, images, images.position(), delays, delays != null ? delays.position() : -1); } - public native void destroyCursor(Object cursorHandle); + public void destroyCursor(Object cursorHandle) { + doDestroyCursor(cursorHandle); + } + static native void doDestroyCursor(Object cursorHandle); + public int getPbufferCapabilities() { try { // Return the capabilities of a minimum pixel format @@ -483,9 +566,13 @@ mouse.handleMouseButton((byte)button, (byte)state, millis); } + private boolean shouldGrab() { + return !isMinimized && isFocused; + } + private void handleMouseMoved(int x, int y, long millis) { if (mouse != null) - mouse.handleMouseMoved(x, y, millis); + mouse.handleMouseMoved(x, y, millis, shouldGrab()); } private void handleMouseScrolled(int amount, long millis) { @@ -493,8 +580,16 @@ mouse.handleMouseScrolled(amount, millis); } - private static native int transformY(long hwnd, int y); + private static native void getClientRect(long hwnd, IntBuffer rect); + private static int transformY(long hwnd, int y) { + getClientRect(hwnd, rect_buffer); + rect.copyFromBuffer(rect_buffer); + return (rect.bottom - rect.top) - 1 - y; + } + + private static native void clientToScreen(long hwnd, IntBuffer point); + private static boolean handleMessage(long hwnd, int msg, long wParam, long lParam, long millis) { if (current_display != null) return current_display.doHandleMessage(hwnd, msg, wParam, lParam, millis); @@ -503,12 +598,14 @@ } private boolean doHandleMessage(long hwnd, int msg, long wParam, long lParam, long millis) { - if (isFullscreen && !isMinimized && isFocused) { + if ((isFullscreen || (mouse != null && mouse.isGrabbed())) && !isMinimized && isFocused) { try { setupCursorClipping(getHwnd()); } catch (LWJGLException e) { LWJGLUtil.log("setupCursorClipping failed: " + e.getMessage()); } + } else { + resetCursorClipping(); } switch (msg) { // disable screen saver and monitor power down messages which wreak havoc @@ -602,4 +699,40 @@ public int getHeight() { return Display.getDisplayMode().getHeight(); } + + private static final class Rect { + public int top; + public int bottom; + public int left; + public int right; + + public void copyToBuffer(IntBuffer buffer) { + buffer.put(0, top).put(1, bottom).put(2, left).put(3, right); + } + + public void copyFromBuffer(IntBuffer buffer) { + top = buffer.get(0); + bottom = buffer.get(1); + left = buffer.get(2); + right = buffer.get(3); + } + + public void offset(int offset_x, int offset_y) { + left += offset_x; + right += offset_x; + top += offset_y; + bottom += offset_y; + } + + public static void intersect(Rect r1, Rect r2, Rect dst) { + dst.top = Math.max(r1.top, r2.top); + dst.bottom = Math.min(r1.bottom, r2.bottom); + dst.left = Math.max(r1.left, r2.left); + dst.right = Math.min(r1.right, r2.right); + } + + public String toString() { + return "Rect: top = " + top + " bottom = " + bottom + " left = " + left + " right = " + right; + } + } } Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsMouse.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsMouse.java 2007-04-23 20:50:44 UTC (rev 2798) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsMouse.java 2007-04-24 09:30:03 UTC (rev 2799) @@ -44,65 +44,46 @@ import org.lwjgl.LWJGLUtil; import org.lwjgl.BufferUtils; import org.lwjgl.input.Mouse; +import org.lwjgl.input.Cursor; final class WindowsMouse { - private final static int BUFFER_SIZE = 50; - private final static int BUTTON_STATES_SIZE = 7; - - private final static int DIMOFS_X = 0; - private final static int DIMOFS_Y = 4; - private final static int DIMOFS_Z = 8; - private final static int DIMOFS_BUTTON0 = 12; - private final static int DIMOFS_BUTTON1 = 13; - private final static int DIMOFS_BUTTON2 = 14; - private final static int DIMOFS_BUTTON3 = 15; - private final long hwnd; - private final WindowsDirectInput dinput; - private final WindowsDirectInputDevice mouse; private final int mouse_button_count; private final boolean has_wheel; private final EventQueue event_queue = new EventQueue(Mouse.EVENT_SIZE); - /* Buffer to hold a DIMOUSESTATE */ - private final ByteBuffer mouse_state; - private final IntBuffer temp_data_buffer; private final ByteBuffer mouse_event = ByteBuffer.allocate(Mouse.EVENT_SIZE); + private final Object blank_cursor; private boolean mouse_grabbed; - private byte[] win32_message_button_states = new byte[BUTTON_STATES_SIZE]; + private byte[] button_states; + private int accum_dx; + private int accum_dy; private int accum_dwheel; private int last_x; private int last_y; - public WindowsMouse(WindowsDirectInput dinput, long hwnd) throws LWJGLException { + public WindowsMouse(long hwnd) throws LWJGLException { this.hwnd = hwnd; - this.dinput = dinput; - try { - mouse = dinput.createDevice(WindowsDirectInput.MOUSE_TYPE); - try { - mouse.setDataFormat(WindowsDirectInput.MOUSE_TYPE); - mouse.setBufferSize(BUFFER_SIZE); - if (!acquireNonExclusive()) - throw new LWJGLException("Failed to acquire mouse non-exclusive"); - } catch (LWJGLException e) { - mouse.release(); - throw e; - } - } catch (LWJGLException e) { - dinput.release(); - throw e; - } - MouseEnumerator enumerator = new MouseEnumerator(); - mouse.enumObjects(enumerator); - this.mouse_button_count = Math.min(enumerator.getButtonCount(), 4); - this.has_wheel = enumerator.hasWheel(); - mouse_state = BufferUtils.createByteBuffer(3*4 + 4); - temp_data_buffer = BufferUtils.createIntBuffer(BUFFER_SIZE*WindowsDirectInputDevice.DATA_SIZE); + this.mouse_button_count = WindowsDisplay.getSystemMetrics(WindowsDisplay.SM_CMOUSEBUTTONS); + this.has_wheel = WindowsDisplay.getSystemMetrics(WindowsDisplay.SM_MOUSEWHEELPRESENT) != 0; + this.blank_cursor = createBlankCursor(); + this.button_states = new byte[mouse_button_count]; } + private Object createBlankCursor() throws LWJGLException { + int width = WindowsDisplay.getSystemMetrics(WindowsDisplay.SM_CXCURSOR); + int height = WindowsDisplay.getSystemMetrics(WindowsDisplay.SM_CYCURSOR); + IntBuffer pixels = BufferUtils.createIntBuffer(width*height); + return WindowsDisplay.doCreateCursor(width, height, 0, 0, 1, pixels, null); + } + + public boolean isGrabbed() { + return mouse_grabbed; + } + public boolean hasWheel() { return has_wheel; } @@ -111,73 +92,24 @@ return mouse_button_count; } - private boolean acquire(int flags) { - try { - mouse.setCooperateLevel(hwnd, flags); - mouse.acquire(); - return true; - } catch (LWJGLException e) { - LWJGLUtil.log("Failed to acquire mouse: " + e); - return false; - } - } - - private boolean acquireNonExclusive() { - return acquire(WindowsDirectInputDevice.DISCL_NONEXCLUSIVE | WindowsDirectInputDevice.DISCL_FOREGROUND) || - acquire(WindowsDirectInputDevice.DISCL_NONEXCLUSIVE | WindowsDirectInputDevice.DISCL_BACKGROUND); - } - - public void destroy() { - mouse.unacquire(); - mouse.release(); - dinput.release(); - } - public void poll(IntBuffer coord_buffer, ByteBuffer buttons) { - int ret = mouse.acquire(); - if (ret != WindowsDirectInput.DI_OK && ret != WindowsDirectInput.DI_NOEFFECT) - return; - mouse.poll(); for (int i = 0; i < coord_buffer.remaining(); i++) coord_buffer.put(coord_buffer.position() + i, 0); - mouse_state.clear(); - ret = mouse.getDeviceState(mouse_state); - int mouse_state_lx = mouse_state.getInt(); - int mouse_state_ly = mouse_state.getInt(); - int mouse_state_lz = mouse_state.getInt(); int num_buttons = mouse_button_count; - if (mouse_grabbed || ret == WindowsDirectInput.DI_OK) { - if (ret != WindowsDirectInput.DI_OK) { - LWJGLUtil.log("Error getting mouse state: (0x" + Integer.toHexString(ret) + ")"); - return; - } - - coord_buffer.put(coord_buffer.position() + 2, mouse_state_lz); - if (num_buttons > buttons.remaining()) - num_buttons = buttons.remaining(); - for (int j = 0; j < num_buttons; j++) { - byte button_state = (mouse_state.get() & 0x80) != 0 ? (byte)1 : (byte)0; - buttons.put(buttons.position() + j, button_state); - // track the button state in the windows message buffer state array - // to get accurate button information when releasing a grab - win32_message_button_states[j] = button_state; - } - } else { - coord_buffer.put(coord_buffer.position() + 2, accum_dwheel); - if (num_buttons > win32_message_button_states.length) - num_buttons = win32_message_button_states.length; - for (int j = 0; j < num_buttons; j++) { - buttons.put(buttons.position() + j, win32_message_button_states[j]); - } + coord_buffer.put(coord_buffer.position() + 2, accum_dwheel); + if (num_buttons > button_states.length) + num_buttons = button_states.length; + for (int j = 0; j < num_buttons; j++) { + buttons.put(buttons.position() + j, button_states[j]); } - accum_dwheel = 0; - if (mouse_grabbed) { - coord_buffer.put(coord_buffer.position() + 0, mouse_state_lx); - coord_buffer.put(coord_buffer.position() + 1, -mouse_state_ly); + if (isGrabbed()) { + coord_buffer.put(coord_buffer.position() + 0, accum_dx); + coord_buffer.put(coord_buffer.position() + 1, accum_dy); } else { coord_buffer.put(coord_buffer.position() + 0, last_x); coord_buffer.put(coord_buffer.position() + 1, last_y); } + accum_dx = accum_dy = accum_dwheel = 0; } private void putMouseEventWithCoords(byte button, byte state, int coord1, int coord2, int dz, long nanos) { @@ -194,104 +126,30 @@ putMouseEventWithCoords(button, state, last_x, last_y, dz, nanos); } - private void copyDXEvents(IntBuffer buffer) { - int buffer_index = 0; - int dx = 0, dy = 0, dwheel = 0; - byte button_state; - int i; - long nanos = 0; - while (buffer.hasRemaining()) { - int dwOfs = buffer.get(); - int dwData = buffer.get(); - long dwTimeStamp = ((long)buffer.get()) & 0xFFFFFFFF; - nanos = dwTimeStamp*1000000; - button_state = (dwData & 0x80) != 0 ? (byte)1 : (byte)0; - switch (dwOfs) { - case DIMOFS_BUTTON0: - putMouseEventWithCoords((byte)0, button_state, dx, -dy, dwheel, nanos); - dx = dy = dwheel = 0; - break; - case DIMOFS_BUTTON1: - putMouseEventWithCoords((byte)1, button_state, dx, -dy, dwheel, nanos); - dx = dy = dwheel = 0; - break; - case DIMOFS_BUTTON2: - putMouseEventWithCoords((byte)2, button_state, dx, -dy, dwheel, nanos); - dx = dy = dwheel = 0; - break; - case DIMOFS_BUTTON3: - putMouseEventWithCoords((byte)3, button_state, dx, -dy, dwheel, nanos); - dx = dy = dwheel = 0; - break; - case DIMOFS_X: - dx += dwData; - break; - case DIMOFS_Y: - dy += dwData; - break; - case DIMOFS_Z: - dwheel += dwData; - break; - } - } - if (dx != 0 || dy != 0 || dwheel != 0) - putMouseEventWithCoords((byte)-1, (byte)0, dx, -dy, dwheel, nanos); + public void read(ByteBuffer buffer) { + event_queue.copyEvents(buffer); } - private void readDXBuffer() { - int ret = mouse.acquire(); - if (ret != WindowsDirectInput.DI_OK && ret != WindowsDirectInput.DI_NOEFFECT) - return; - mouse.poll(); - temp_data_buffer.clear(); - ret = mouse.getDeviceData(temp_data_buffer); - - switch (ret) { - case WindowsDirectInput.DI_OK: - break; - case WindowsDirectInput.DI_BUFFEROVERFLOW: - LWJGLUtil.log("Mouse buffer overflowed"); - break; - case WindowsDirectInput.DIERR_INPUTLOST: - LWJGLUtil.log("Mouse input lost"); - break; - case WindowsDirectInput.DIERR_NOTACQUIRED: - LWJGLUtil.log("Mouse not acquired"); - break; - default: - LWJGLUtil.log("unknown mouse error (" + Integer.toHexString(ret) + ")"); - break; - } + public Object getBlankCursor() { + return blank_cursor; } - public final void flush() { - readDXBuffer(); - temp_data_buffer.clear(); - } - - public void read(ByteBuffer buffer) { - readDXBuffer(); - if (mouse_grabbed) { - temp_data_buffer.flip(); - copyDXEvents(temp_data_buffer); - } - event_queue.copyEvents(buffer); - } - - public void grab(boolean grab) { - if(grab) { + public void grab(boolean grab, boolean should_center) { + if (grab) { if (!mouse_grabbed) { - flush(); mouse_grabbed = true; - mouse.unacquire(); - if (!acquire(WindowsDirectInputDevice.DISCL_EXCLUSIVE | WindowsDirectInputDevice.DISCL_FOREGROUND)) - LWJGLUtil.log("Failed to reset cooperative mode"); + try { + WindowsDisplay.setupCursorClipping(hwnd); + } catch (LWJGLException e) { + LWJGLUtil.log("Failed to setup cursor clipping: " + e); + } + if (should_center) + centerCursor(); } } else { if (mouse_grabbed) { mouse_grabbed = false; - mouse.unacquire(); - acquireNonExclusive(); + WindowsDisplay.resetCursorClipping(); } } event_queue.clearEvents(); @@ -302,52 +160,41 @@ putMouseEvent((byte)-1, (byte)0, event_dwheel, millis*1000000); } - public void handleMouseMoved(int x, int y, long millis) { - int dx; - int dy; - dx = x - last_x; - dy = y - last_y; - last_x = x; - last_y = y; - long nanos = millis*1000000; - if (mouse_grabbed) { - putMouseEventWithCoords((byte)-1, (byte)0, dx, dy, 0, nanos); - } else { - putMouseEventWithCoords((byte)-1, (byte)0, x, y, 0, nanos); - } + private void centerCursor() { + WindowsDisplay.centerCursor(hwnd); } - public void handleMouseButton(byte button, byte state, long millis) { - putMouseEvent(button, state, 0, millis*1000000); - if (button < BUTTON_STATES_SIZE) - win32_message_button_states[button] = state != 0 ? (byte)1 : (byte)0; + public void setPosition(int x, int y) { + this.last_x = x; + this.last_y = y; } - private static class MouseEnumerator implements WindowsDirectInputDeviceObjectCallback { - private int button_count; - private boolean has_wheel; + public void destroy() { + WindowsDisplay.doDestroyCursor(blank_cursor); + } - public int getButtonCount() { - return button_count; - } - - public boolean hasWheel() { - return has_wheel; - } - - public boolean nextObject(int type, String name) { - LWJGLUtil.log("Found mouse object: " + name); - switch (type) { - case WindowsDirectInputDevice.GUID_ZAxis: - has_wheel = true; - break; - case WindowsDirectInputDevice.GUID_Button: - button_count++; - break; - default: - break; + public void handleMouseMoved(int x, int y, long millis, boolean should_center) { + int dx = x - last_x; + int dy = y - last_y; + if (dx != 0 || dy != 0) { + accum_dx += dx; + accum_dy += dy; + last_x = x; + last_y = y; + long nanos = millis*1000000; + if (mouse_grabbed) { + putMouseEventWithCoords((byte)-1, (byte)0, dx, dy, 0, nanos); + if (should_center) + centerCursor(); + } else { + putMouseEventWithCoords((byte)-1, (byte)0, x, y, 0, nanos); } - return true; } } + + public void handleMouseButton(byte button, byte state, long millis) { + putMouseEvent(button, state, 0, millis*1000000); + if (button < button_states.length) + button_states[button] = state != 0 ? (byte)1 : (byte)0; + } } Modified: trunk/LWJGL/src/native/common/common_tools.c =================================================================== --- trunk/LWJGL/src/native/common/common_tools.c 2007-04-23 20:50:44 UTC (rev 2798) +++ trunk/LWJGL/src/native/common/common_tools.c 2007-04-24 09:30:03 UTC (rev 2799) @@ -141,6 +141,13 @@ throwGeneralException(env, "org/lwjgl/fmod3/FMODException", err); } +void throwFormattedRuntimeException(JNIEnv * env, const char *format, ...) { + va_list ap; + va_start(ap, format); + throwFormattedGeneralException(env, "java/lang/RuntimeException", format, ap); + va_end(ap); +} + void throwFormattedException(JNIEnv * env, const char *format, ...) { va_list ap; va_start(ap, format); Modified: trunk/LWJGL/src/native/common/common_tools.h =================================================================== --- trunk/LWJGL/src/native/common/common_tools.h 2007-04-23 20:50:44 UTC (rev 2798) +++ trunk/LWJGL/src/native/common/common_tools.h 2007-04-24 09:30:03 UTC (rev 2799) @@ -130,6 +130,7 @@ extern bool isDebugEnabled(void); extern jstring getVersionString(JNIEnv *env); extern void throwGeneralException(JNIEnv * env, const char *exception_name, const char * err); +extern void throwFormattedRuntimeException(JNIEnv * env, const char *format, ...); extern void throwException(JNIEnv *env, const char *msg); extern void throwFormattedException(JNIEnv * env, const char *format, ...); extern void throwFMODException(JNIEnv * env, const char * err); Modified: trunk/LWJGL/src/native/windows/org_lwjgl_input_Cursor.c =================================================================== --- trunk/LWJGL/src/native/windows/org_lwjgl_input_Cursor.c 2007-04-23 20:50:44 UTC (rev 2798) +++ trunk/LWJGL/src/native/windows/org_lwjgl_input_Cursor.c 2007-04-24 09:30:03 UTC (rev 2799) @@ -45,7 +45,7 @@ #include "common_tools.h" JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nCreateCursor -(JNIEnv *env, jobject self, jint width, jint height, jint x_hotspot, jint y_hotspot, jint num_images, jobject image_buffer, jint images_offset, jobject delay_buffer, jint delays_offset) +(JNIEnv *env, jclass unused, jint width, jint height, jint x_hotspot, jint y_hotspot, jint num_images, jobject image_buffer, jint images_offset, jobject delay_buffer, jint delays_offset) { unsigned char col0, col1, col2, col3, col4, col5, col6, col7; unsigned char mask; @@ -154,8 +154,8 @@ return handle_buffer; } -JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_destroyCursor -(JNIEnv *env, jobject self, jobject handle_buffer) +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_doDestroyCursor +(JNIEnv *env, jclass unused, jobject handle_buffer) { HCURSOR *cursor_handle = (HCURSOR *)(*env)->GetDirectBufferAddress(env, handle_buffer); DestroyCursor(*cursor_handle); Modified: trunk/LWJGL/src/native/windows/org_lwjgl_opengl_Display.c =================================================================== --- trunk/LWJGL/src/native/windows/org_lwjgl_opengl_Display.c 2007-04-23 20:50:44 UTC (rev 2798) +++ trunk/LWJGL/src/native/windows/org_lwjgl_opengl_Display.c 2007-04-24 09:30:03 UTC (rev 2799) @@ -210,19 +210,65 @@ freeSmallIcon(); } -JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_resetCursorClipping(JNIEnv *env, jclass unused) { - ClipCursor(NULL); +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_clientToScreen(JNIEnv *env, jclass unused, jlong hwnd_int, jobject buffer_handle) { + HWND hwnd = (HWND)(INT_PTR)hwnd_int; + POINT point; + jint *buffer = (jint *)(*env)->GetDirectBufferAddress(env, buffer_handle); + jlong size = (*env)->GetDirectBufferCapacity(env, buffer_handle); + if (size < 2) { + throwFormattedRuntimeException(env, "Buffer size < 2", size); + return; + } + point.x = buffer[0]; + point.y = buffer[1]; + ClientToScreen(hwnd, &point); + buffer[0] = point.x; + buffer[1] = point.y; } -JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_setupCursorClipping(JNIEnv *env, jclass unused, jlong hwnd_ptr) { - HWND hwnd = (HWND)(INT_PTR)hwnd_ptr; - RECT hwnd_client; - if (hwnd != NULL && GetWindowRect(hwnd, &hwnd_client) != 0) { - if (ClipCursor(&hwnd_client) == 0) - throwFormattedException(env, "ClipCursor failed (%d)", GetLastError()); +JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_WindowsDisplay_getDesktopWindow(JNIEnv *env, jclass unused) { + return (INT_PTR)GetDesktopWindow(); +} + +static void copyBufferToRect(JNIEnv *env, jobject buffer_handle, RECT *rect) { + jint *buffer = (jint *)(*env)->GetDirectBufferAddress(env, buffer_handle); + jlong size = (*env)->GetDirectBufferCapacity(env, buffer_handle); + if (size < 4) { + throwFormattedRuntimeException(env, "Buffer size < 4", size); + return; } + rect->top = buffer[0]; + rect->bottom = buffer[1]; + rect->left = buffer[2]; + rect->right = buffer[3]; } +static void copyRectToBuffer(JNIEnv *env, RECT *rect, jobject buffer_handle) { + jint *buffer = (jint *)(*env)->GetDirectBufferAddress(env, buffer_handle); + jlong size = (*env)->GetDirectBufferCapacity(env, buffer_handle); + if (size < 4) { + throwFormattedRuntimeException(env, "Buffer size < 4", size); + return; + } + buffer[0] = rect->top; + buffer[1] = rect->bottom; + buffer[2] = rect->left; + buffer[3] = rect->right; +} + +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_clipCursor(JNIEnv *env, jclass unused, jlong hwnd_ptr, jobject handle_buffer) { + HWND hwnd = (HWND)(INT_PTR)hwnd_ptr; + RECT clip_rect; + LPRECT clip_rect_ptr; + if (handle_buffer != NULL) { + copyBufferToRect(env, handle_buffer, &clip_rect); + clip_rect_ptr = &clip_rect; + } else + clip_rect_ptr = NULL; + if (ClipCursor(clip_rect_ptr) == 0) + throwFormattedException(env, "ClipCursor failed (%d)", GetLastError()); +} + JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nSwitchDisplayMode(JNIEnv *env, jobject self, jobject mode) { switchDisplayMode(env, mode); } @@ -452,64 +498,36 @@ } JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nSetCursorPosition -(JNIEnv * env, jclass unused, jint x, jint y, jboolean fullscreen) { - DWORD windowflags, exstyle; - int transformed_x, transformed_y; - RECT window_rect; - RECT client_rect; - RECT adjusted_client_rect; - - int left_border_width; - int bottom_border_width; - - getWindowFlags(&windowflags, &exstyle, fullscreen, getBooleanProperty(env, "org.lwjgl.opengl.Window.undecorated")); - if (!GetClientRect(getCurrentHWND(), &client_rect)) { - printfDebugJava(env, "GetClientRect failed"); - return; - } - - adjusted_client_rect = client_rect; - if (!AdjustWindowRectEx(&adjusted_client_rect, windowflags, FALSE, exstyle)) { - printfDebugJava(env, "AdjustWindowRectEx failed"); - return; - } - - if (!GetWindowRect(getCurrentHWND(), &window_rect)) { - printfDebugJava(env, "GetWindowRect failed"); - return; - } - left_border_width = -adjusted_client_rect.left; - bottom_border_width = adjusted_client_rect.bottom - client_rect.bottom; - - transformed_x = window_rect.left + left_border_width + x; - transformed_y = window_rect.bottom - bottom_border_width - 1 - y; - if (!SetCursorPos(transformed_x, transformed_y)) +(JNIEnv * env, jclass unused, jint x, jint y) { + if (!SetCursorPos(x, y)) printfDebugJava(env, "SetCursorPos failed"); } -JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_setNativeCursor - (JNIEnv *env, jobject self, jobject handle_buffer) +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_getClientRect + (JNIEnv *env, jclass unused, jlong hwnd_int, jobject rect_buffer) { + HWND hwnd = (HWND)(INT_PTR)hwnd_int; + RECT clientRect; + GetClientRect(hwnd, &clientRect); + copyRectToBuffer(env, &clientRect, rect_buffer); +} + +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nSetNativeCursor + (JNIEnv *env, jclass unused, jlong hwnd_int, jobject handle_buffer) { + HWND hwnd = (HWND)(INT_PTR)hwnd_int; HCURSOR *cursor_handle; HCURSOR cursor; if (handle_buffer != NULL) { cursor_handle = (HCURSOR *)(*env)->GetDirectBufferAddress(env, handle_buffer); cursor = *cursor_handle; - SetClassLongPtr(getCurrentHWND(), GCL_HCURSOR, (LONG_PTR)cursor); + SetClassLongPtr(hwnd, GCL_HCURSOR, (LONG_PTR)cursor); SetCursor(cursor); } else { - SetClassLongPtr(getCurrentHWND(), GCL_HCURSOR, (LONG_PTR)NULL); + SetClassLongPtr(hwnd, GCL_HCURSOR, (LONG_PTR)NULL); SetCursor(LoadCursor(NULL, IDC_ARROW)); } } -JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_WindowsDisplay_transformY(JNIEnv *env, jclass unused, jlong hwnd_int, jint y) { - HWND hwnd = (HWND)(INT_PTR)hwnd_int; - RECT clientRect; - GetClientRect(hwnd, &clientRect); - return (clientRect.bottom - clientRect.top) - 1 - y; -} - JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_WindowsDisplay_getSystemMetrics(JNIEnv *env, jclass unused, jint index) { return GetSystemMetrics(index); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <eli...@us...> - 2007-04-24 13:40:16
|
Revision: 2801 http://svn.sourceforge.net/java-game-lib/?rev=2801&view=rev Author: elias_naur Date: 2007-04-24 06:40:13 -0700 (Tue, 24 Apr 2007) Log Message: ----------- Windows: Convert WindowsKeyboard to use windows messages instead of DirectInput. Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsKeyboard.java trunk/LWJGL/src/native/windows/org_lwjgl_opengl_WindowsKeyboard.c Added Paths: ----------- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsKeycodes.java Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java 2007-04-24 13:22:35 UTC (rev 2800) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java 2007-04-24 13:40:13 UTC (rev 2801) @@ -60,6 +60,10 @@ private final static int WM_MBUTTONUP = 0x0208; private final static int WM_MBUTTONDBLCLK = 0x0209; private final static int WM_MOUSEWHEEL = 0x020A; + private final static int WM_KEYDOWN = 256; + private final static int WM_KEYUP = 257; + private final static int WM_SYSKEYUP = 261; + private final static int WM_SYSKEYDOWN = 260; private final static int WM_QUIT = 0x0012; private final static int WM_SYSCOMMAND = 0x0112; @@ -174,6 +178,15 @@ rect.offset(offset_x, offset_y); } + static WindowsDirectInput createDirectInput() throws LWJGLException { + try { + return new WindowsDirectInput8(getDllInstance()); + } catch (LWJGLException e) { + LWJGLUtil.log("Failed to create DirectInput 8 interface, falling back to DirectInput 3"); + return new WindowsDirectInput3(getDllInstance()); + } + } + static void setupCursorClipping(long hwnd) throws LWJGLException { cursor_clipped = true; getGlobalClientRect(hwnd, rect); @@ -453,7 +466,7 @@ /* Keyboard */ public void createKeyboard() throws LWJGLException { - keyboard = new WindowsKeyboard(createDirectInput(), getHwnd()); + keyboard = new WindowsKeyboard(getHwnd()); } public void destroyKeyboard() { @@ -582,6 +595,17 @@ private static native void getClientRect(long hwnd, IntBuffer rect); + private void handleKeyButton(long wParam, long lParam, long millis) { + byte previous_state = (byte)((lParam >>> 30) & 0x1); + byte state = (byte)(1 - ((lParam >>> 31) & 0x1)); + if (state == previous_state) + return; // Auto-repeat message + byte extended = (byte)((lParam >>> 24) & 0x1); + int scan_code = (int)((lParam >>> 16) & 0xFF); + if (keyboard != null) + keyboard.handleKey((int)wParam, scan_code, extended != 0, state, millis); + } + private static int transformY(long hwnd, int y) { getClientRect(hwnd, rect_buffer); rect.copyFromBuffer(rect_buffer); @@ -658,6 +682,12 @@ case WM_MBUTTONUP: handleMouseButton(2, 0, millis); return true; + case WM_SYSKEYDOWN: /* Fall through */ + case WM_SYSKEYUP: /* Fall through */ + case WM_KEYUP: /* Fall through */ + case WM_KEYDOWN: + handleKeyButton(wParam, lParam, millis); + return true; case WM_QUIT: close_requested = true; return true; @@ -683,15 +713,6 @@ } } - static WindowsDirectInput createDirectInput() throws LWJGLException { - try { - return new WindowsDirectInput8(getDllInstance()); - } catch (LWJGLException e) { - LWJGLUtil.log("Failed to create DirectInput 8 interface, falling back to DirectInput 3"); - return new WindowsDirectInput3(getDllInstance()); - } - } - public int getWidth() { return Display.getDisplayMode().getWidth(); } Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsKeyboard.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsKeyboard.java 2007-04-24 13:22:35 UTC (rev 2800) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsKeyboard.java 2007-04-24 13:40:13 UTC (rev 2801) @@ -43,40 +43,26 @@ import org.lwjgl.LWJGLException; import org.lwjgl.LWJGLUtil; import org.lwjgl.BufferUtils; +import org.lwjgl.input.Keyboard; final class WindowsKeyboard { + private final static int MAPVK_VK_TO_VSC = 0; + private final static int BUFFER_SIZE = 50; private final long hwnd; - private final WindowsDirectInput dinput; - private final WindowsDirectInputDevice keyboard; - private final IntBuffer temp_data_buffer; private final ByteBuffer keyboard_state; + private final byte[] key_down_buffer = new byte[Keyboard.KEYBOARD_SIZE]; + private final EventQueue event_queue = new EventQueue(Keyboard.EVENT_SIZE); + private final ByteBuffer tmp_event = ByteBuffer.allocate(Keyboard.EVENT_SIZE); private final boolean unicode; private final CharBuffer unicode_buffer; private final ByteBuffer ascii_buffer; private boolean grabbed; - public WindowsKeyboard(WindowsDirectInput dinput, long hwnd) throws LWJGLException { + public WindowsKeyboard(long hwnd) throws LWJGLException { this.hwnd = hwnd; - this.dinput = dinput; - try { - keyboard = dinput.createDevice(WindowsDirectInput.KEYBOARD_TYPE); - try { - keyboard.setDataFormat(WindowsDirectInput.KEYBOARD_TYPE); - keyboard.setBufferSize(BUFFER_SIZE); - acquireNonExclusive(); - } catch (LWJGLException e) { - keyboard.release(); - throw e; - } - } catch (LWJGLException e) { - dinput.release(); - throw e; - } - keyboard.acquire(); - temp_data_buffer = BufferUtils.createIntBuffer(BUFFER_SIZE*WindowsDirectInputDevice.DATA_SIZE); keyboard_state = BufferUtils.createByteBuffer(256); unicode = isWindowsNT(); if (unicode) { @@ -90,165 +76,136 @@ } private static native boolean isWindowsNT(); - private boolean acquire(int flags) { - try { - keyboard.setCooperateLevel(hwnd, flags); - keyboard.acquire(); - return true; - } catch (LWJGLException e) { - LWJGLUtil.log("Failed to acquire keyboard: " + e); - return false; - } - } - - private boolean acquireNonExclusive() { - return acquire(WindowsDirectInputDevice.DISCL_NONEXCLUSIVE | WindowsDirectInputDevice.DISCL_FOREGROUND) || - acquire(WindowsDirectInputDevice.DISCL_NONEXCLUSIVE | WindowsDirectInputDevice.DISCL_BACKGROUND); - } - public void destroy() { - keyboard.unacquire(); - keyboard.release(); - dinput.release(); } public void grab(boolean grab) { if(grab) { if (!grabbed) { - flush(); grabbed = true; - keyboard.unacquire(); - if (!acquire(WindowsDirectInputDevice.DISCL_EXCLUSIVE | WindowsDirectInputDevice.DISCL_FOREGROUND)) - LWJGLUtil.log("Failed to reset cooperative mode"); } } else { if (grabbed) { grabbed = false; - keyboard.unacquire(); - acquireNonExclusive(); } } } public void poll(ByteBuffer keyDownBuffer) { - int ret = keyboard.acquire(); - if (ret != WindowsDirectInput.DI_OK && ret != WindowsDirectInput.DI_NOEFFECT) - return; - keyboard.poll(); - ret = keyboard.getDeviceState(keyDownBuffer); - switch (ret) { - case WindowsDirectInput.DI_OK: - break; - case WindowsDirectInput.DI_BUFFEROVERFLOW: - LWJGLUtil.log("Keyboard buffer overflow"); - break; - case WindowsDirectInput.DIERR_INPUTLOST: - break; - case WindowsDirectInput.DIERR_NOTACQUIRED: - break; - default: - LWJGLUtil.log("Failed to poll keyboard (0x" + Integer.toHexString(ret) + ")"); - break; - } + int old_position = keyDownBuffer.position(); + keyDownBuffer.put(key_down_buffer); + keyDownBuffer.position(old_position); } - private void translateData(IntBuffer src, ByteBuffer dst) { - while (dst.hasRemaining() && src.hasRemaining()) { - int dwOfs = src.get(); - dst.putInt(dwOfs); - byte dwData = (byte)src.get(); - boolean key_down = (dwData & 0x80) != 0; - dst.put(key_down ? (byte)1 : (byte)0); - long dwTimeStamp = ((long)src.get()) & 0xFFFFFFFF; - long nanos = dwTimeStamp*1000000; - if (key_down) { - int virt_key = MapVirtualKey(dwOfs, 1); - if (virt_key != 0 && GetKeyboardState(keyboard_state) != 0) { - // Mark key down in the scan code - dwOfs = dwOfs & 0x7fff; - int num_chars; - if (unicode) { - unicode_buffer.clear(); - num_chars = ToUnicode(virt_key, - dwOfs, + private void translate(int virt_key, byte state, long nanos) { + int keycode = MapVirtualKey(virt_key, MAPVK_VK_TO_VSC); + if (state != 0) { + if (virt_key != 0 && GetKeyboardState(keyboard_state) != 0) { + // Mark key down in the scan code + int key_down_code = keycode & 0x7fff; + int num_chars; + if (unicode) { + unicode_buffer.clear(); + num_chars = ToUnicode(virt_key, + key_down_code, keyboard_state, unicode_buffer, unicode_buffer.capacity(), 0); - } else { - ascii_buffer.clear(); - num_chars = ToAscii(virt_key, - dwOfs, + } else { + ascii_buffer.clear(); + num_chars = ToAscii(virt_key, + key_down_code, keyboard_state, ascii_buffer, 0); - } - if (num_chars > 0) { - int current_char = 0; - do { - if (current_char >= 1) { - dst.putInt(0); - dst.put((byte)0); - } - int char_int; - if (unicode) { - char_int = ((int)unicode_buffer.get()) & 0xFFFF; - } else { - char_int = ((int)ascii_buffer.get()) & 0xFF; - } - dst.putInt(char_int); - dst.putLong(nanos); - current_char++; - } while (dst.hasRemaining() && current_char < num_chars); - } else { - dst.putInt(0); - dst.putLong(nanos); - } + } + if (num_chars > 0) { + int current_char = 0; + do { + int char_int; + if (unicode) { + char_int = ((int)unicode_buffer.get()) & 0xFFFF; + } else { + char_int = ((int)ascii_buffer.get()) & 0xFF; + } + if (current_char >= 1) { + putEvent(0, (byte)0, char_int, nanos); + } else { + putEvent(virt_key, state, char_int, nanos); + } + current_char++; + } while (current_char < num_chars); } else { - dst.putInt(0); - dst.putLong(nanos); + putEvent(virt_key, state, 0, nanos); } } else { - dst.putInt(0); - dst.putLong(nanos); + putEvent(virt_key, state, 0, nanos); } + } else { + putEvent(virt_key, state, 0, nanos); } } private static native int MapVirtualKey(int uCode, int uMapType); private static native int ToUnicode(int wVirtKey, int wScanCode, ByteBuffer lpKeyState, CharBuffer pwszBuff, int cchBuff, int flags); private static native int ToAscii(int wVirtKey, int wScanCode, ByteBuffer lpKeyState, ByteBuffer lpChar, int flags); private static native int GetKeyboardState(ByteBuffer lpKeyState); + private static native int GetKeyState(int virt_key); - public void flush() { - processEvents(); - temp_data_buffer.clear(); + private void putEvent(int virt_key, byte state, int ch, long nanos) { + int keycode = WindowsKeycodes.mapVirtualKeyToLWJGLCode(virt_key); +System.out.println("virt_key = " + Integer.toHexString(virt_key) + " = " + virt_key + " | keycode = " + Keyboard.getKeyName(keycode)); + if (keycode < key_down_buffer.length) + key_down_buffer[keycode] = state; + tmp_event.clear(); + tmp_event.putInt(keycode).put(state).putInt(ch).putLong(nanos); + tmp_event.flip(); + event_queue.putEvent(tmp_event); } - private void processEvents() { - int ret = keyboard.acquire(); - if (ret != WindowsDirectInput.DI_OK && ret != WindowsDirectInput.DI_NOEFFECT) - return; - keyboard.poll(); - temp_data_buffer.clear(); - ret = keyboard.getDeviceData(temp_data_buffer); - switch (ret) { - case WindowsDirectInput.DI_OK: - break; - case WindowsDirectInput.DI_BUFFEROVERFLOW: - LWJGLUtil.log("Keyboard buffer overflow"); - break; - case WindowsDirectInput.DIERR_INPUTLOST: - break; - case WindowsDirectInput.DIERR_NOTACQUIRED: - break; + private boolean checkShiftKey(int virt_key, byte state) { + int key_state = (GetKeyState(virt_key) >>> 15) & 0x1; + int lwjgl_code = WindowsKeycodes.mapVirtualKeyToLWJGLCode(virt_key); + return (key_down_buffer[lwjgl_code] == 1 - state) && (key_state == state); + } + + private int translateShift(int scan_code, byte state) { + int state_mask = state != 0 ? 0x8000 : 0x0000; + if (checkShiftKey(WindowsKeycodes.VK_LSHIFT, state)) { + return WindowsKeycodes.VK_LSHIFT; + } else if (checkShiftKey(WindowsKeycodes.VK_RSHIFT, state)) { + return WindowsKeycodes.VK_RSHIFT; + } else { + if (scan_code== 0x2A) + return WindowsKeycodes.VK_LSHIFT; + else { + if (scan_code == 0x36) + return WindowsKeycodes.VK_RSHIFT; + else + return WindowsKeycodes.VK_LSHIFT; + } + } + } + + private int translateExtended(int virt_key, int scan_code, byte state, boolean extended) { + switch (virt_key) { + case WindowsKeycodes.VK_SHIFT: + return translateShift(scan_code, state); + case WindowsKeycodes.VK_CONTROL: + return extended ? WindowsKeycodes.VK_RCONTROL : WindowsKeycodes.VK_LCONTROL; + case WindowsKeycodes.VK_MENU: + return extended ? WindowsKeycodes.VK_RMENU : WindowsKeycodes.VK_LMENU; default: - LWJGLUtil.log("Failed to read keyboard (0x" + Integer.toHexString(ret) + ")"); - break; + return virt_key; } } + public void handleKey(int virt_key, int scan_code, boolean extended, byte event_state, long millis) { + if (isWindowsNT()) + virt_key = translateExtended(virt_key, scan_code, event_state, extended); + translate(virt_key, event_state, millis*1000000); + } + public void read(ByteBuffer buffer) { - processEvents(); - temp_data_buffer.flip(); - translateData(temp_data_buffer, buffer); + event_queue.copyEvents(buffer); } } Added: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsKeycodes.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsKeycodes.java (rev 0) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsKeycodes.java 2007-04-24 13:40:13 UTC (rev 2801) @@ -0,0 +1,577 @@ +/* + * Copyright (c) 2002-2004 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions 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 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package org.lwjgl.opengl; + +/** + * @author elias_naur + */ + +import org.lwjgl.input.Keyboard; + +final class WindowsKeycodes { + public final static int VK_LBUTTON = 0x01; + public final static int VK_RBUTTON = 0x02; + public final static int VK_CANCEL = 0x03; + public final static int VK_MBUTTON = 0x04; /* NOT contiguous with L & RBUTTON */ + + public final static int VK_XBUTTON1 = 0x05; /* NOT contiguous with L & RBUTTON */ + public final static int VK_XBUTTON2 = 0x06; /* NOT contiguous with L & RBUTTON */ + +/* + * 0x07 : unassigned + */ + + public final static int VK_BACK = 0x08; + public final static int VK_TAB = 0x09; + +/* + * 0x0A - 0x0B : reserved + */ + + public final static int VK_CLEAR = 0x0C; + public final static int VK_RETURN = 0x0D; + + public final static int VK_SHIFT = 0x10; + public final static int VK_CONTROL = 0x11; + public final static int VK_MENU = 0x12; + public final static int VK_PAUSE = 0x13; + public final static int VK_CAPITAL = 0x14; + + public final static int VK_KANA = 0x15; + public final static int VK_HANGEUL = 0x15; /* old name - should be here for compatibility */ + public final static int VK_HANGUL = 0x15; + public final static int VK_JUNJA = 0x17; + public final static int VK_FINAL = 0x18; + public final static int VK_HANJA = 0x19; + public final static int VK_KANJI = 0x19; + + public final static int VK_ESCAPE = 0x1B; + + public final static int VK_CONVERT = 0x1C; + public final static int VK_NONCONVERT = 0x1D; + public final static int VK_ACCEPT = 0x1E; + public final static int VK_MODECHANGE = 0x1F; + + public final static int VK_SPACE = 0x20; + public final static int VK_PRIOR = 0x21; + public final static int VK_NEXT = 0x22; + public final static int VK_END = 0x23; + public final static int VK_HOME = 0x24; + public final static int VK_LEFT = 0x25; + public final static int VK_UP = 0x26; + public final static int VK_RIGHT = 0x27; + public final static int VK_DOWN = 0x28; + public final static int VK_SELECT = 0x29; + public final static int VK_PRINT = 0x2A; + public final static int VK_EXECUTE = 0x2B; + public final static int VK_SNAPSHOT = 0x2C; + public final static int VK_INSERT = 0x2D; + public final static int VK_DELETE = 0x2E; + public final static int VK_HELP = 0x2F; +/* + * VK_0 - VK_9 are the same as ASCII '0' - '9' (0x30 - 0x39) + * 0x40 : unassigned + * VK_A - VK_Z are the same as ASCII 'A' - 'Z' (0x41 - 0x5A) + */ + public final static int VK_0 = 0x30; + public final static int VK_1 = 0x31; + public final static int VK_2 = 0x32; + public final static int VK_3 = 0x33; + public final static int VK_4 = 0x34; + public final static int VK_5 = 0x35; + public final static int VK_6 = 0x36; + public final static int VK_7 = 0x37; + public final static int VK_8 = 0x38; + public final static int VK_9 = 0x39; + + public final static int VK_A = 0x41; + public final static int VK_B = 0x42; + public final static int VK_C = 0x43; + public final static int VK_D = 0x44; + public final static int VK_E = 0x45; + public final static int VK_F = 0x46; + public final static int VK_G = 0x47; + public final static int VK_H = 0x48; + public final static int VK_I = 0x49; + public final static int VK_J = 0x4A; + public final static int VK_K = 0x4B; + public final static int VK_L = 0x4C; + public final static int VK_M = 0x4D; + public final static int VK_N = 0x4E; + public final static int VK_O = 0x4F; + public final static int VK_P = 0x50; + public final static int VK_Q = 0x51; + public final static int VK_R = 0x52; + public final static int VK_S = 0x53; + public final static int VK_T = 0x54; + public final static int VK_U = 0x55; + public final static int VK_V = 0x56; + public final static int VK_W = 0x57; + public final static int VK_X = 0x58; + public final static int VK_Y = 0x59; + public final static int VK_Z = 0x5A; + + public final static int VK_LWIN = 0x5B; + public final static int VK_RWIN = 0x5C; + public final static int VK_APPS = 0x5D; +/* + * 0x5E : reserved; + */ + + public final static int VK_SLEEP = 0x5F; + + public final static int VK_NUMPAD0 = 0x60; + public final static int VK_NUMPAD1 = 0x61; + public final static int VK_NUMPAD2 = 0x62; + public final static int VK_NUMPAD3 = 0x63; + public final static int VK_NUMPAD4 = 0x64; + public final static int VK_NUMPAD5 = 0x65; + public final static int VK_NUMPAD6 = 0x66; + public final static int VK_NUMPAD7 = 0x67; + public final static int VK_NUMPAD8 = 0x68; + public final static int VK_NUMPAD9 = 0x69; + public final static int VK_MULTIPLY = 0x6A; + public final static int VK_ADD = 0x6B; + public final static int VK_SEPARATOR = 0x6C; + public final static int VK_SUBTRACT = 0x6D; + public final static int VK_DECIMAL = 0x6E; + public final static int VK_DIVIDE = 0x6F; + public final static int VK_F1 = 0x70; + public final static int VK_F2 = 0x71; + public final static int VK_F3 = 0x72; + public final static int VK_F4 = 0x73; + public final static int VK_F5 = 0x74; + public final static int VK_F6 = 0x75; + public final static int VK_F7 = 0x76; + public final static int VK_F8 = 0x77; + public final static int VK_F9 = 0x78; + public final static int VK_F10 = 0x79; + public final static int VK_F11 = 0x7A; + public final static int VK_F12 = 0x7B; + public final static int VK_F13 = 0x7C; + public final static int VK_F14 = 0x7D; + public final static int VK_F15 = 0x7E; + public final static int VK_F16 = 0x7F; + public final static int VK_F17 = 0x80; + public final static int VK_F18 = 0x81; + public final static int VK_F19 = 0x82; + public final static int VK_F20 = 0x83; + public final static int VK_F21 = 0x84; + public final static int VK_F22 = 0x85; + public final static int VK_F23 = 0x86; + public final static int VK_F24 = 0x87; + +/* + * 0x88 - 0x8F : unassigned; + */ + + public final static int VK_NUMLOCK = 0x90; + public final static int VK_SCROLL = 0x91; + +/* + * NEC PC-9800 kbd definitions + */ + public final static int VK_OEM_NEC_EQUAL = 0x92; // '=' key on numpad +/* + * Fujitsu/OASYS kbd definitions + */ + public final static int VK_OEM_FJ_JISHO = 0x92; // 'Dictionary' key + public final static int VK_OEM_FJ_MASSHOU = 0x93; // 'Unregister word' key + public final static int VK_OEM_FJ_TOUROKU = 0x94; // 'Register word' key + public final static int VK_OEM_FJ_LOYA = 0x95; // 'Left OYAYUBI' key + public final static int VK_OEM_FJ_ROYA = 0x96; // 'Right OYAYUBI' key + +/* + * 0x97 - 0x9F : unassigned + */ + +/* + * VK_L* & VK_R* - left and right Alt, Ctrl and Shift virtual keys. + * Used only as parameters to GetAsyncKeyState() and GetKeyState(). + * No other API or message will distinguish left and right keys in this way. + */ + public final static int VK_LSHIFT = 0xA0; + public final static int VK_RSHIFT = 0xA1; + public final static int VK_LCONTROL = 0xA2; + public final static int VK_RCONTROL = 0xA3; + public final static int VK_LMENU = 0xA4; + public final static int VK_RMENU = 0xA5; + + public final static int VK_BROWSER_BACK = 0xA6; + public final static int VK_BROWSER_FORWARD = 0xA7; + public final static int VK_BROWSER_REFRESH = 0xA8; + public final static int VK_BROWSER_STOP = 0xA9; + public final static int VK_BROWSER_SEARCH = 0xAA; + public final static int VK_BROWSER_FAVORITES = 0xAB; + public final static int VK_BROWSER_HOME = 0xAC; + + public final static int VK_VOLUME_MUTE = 0xAD; + public final static int VK_VOLUME_DOWN = 0xAE; + public final static int VK_VOLUME_UP = 0xAF; + public final static int VK_MEDIA_NEXT_TRACK = 0xB0; + public final static int VK_MEDIA_PREV_TRACK = 0xB1; + public final static int VK_MEDIA_STOP = 0xB2; + public final static int VK_MEDIA_PLAY_PAUSE = 0xB3; + public final static int VK_LAUNCH_MAIL = 0xB4; + public final static int VK_LAUNCH_MEDIA_SELECT = 0xB5; + public final static int VK_LAUNCH_APP1 = 0xB6; + public final static int VK_LAUNCH_APP2 = 0xB7; + +/* + * 0xB8 - 0xB9 : reserved + */ + + public final static int VK_OEM_1 = 0xBA; // ';:' for US + public final static int VK_OEM_PLUS = 0xBB; // '+' any country + public final static int VK_OEM_COMMA = 0xBC; // ',' any country + public final static int VK_OEM_MINUS = 0xBD; // '-' any country + public final static int VK_OEM_PERIOD = 0xBE; // '.' any country + public final static int VK_OEM_2 = 0xBF; // '/?' for US + public final static int VK_OEM_3 = 0xC0; // '`~' for US + +/* + * 0xC1 - 0xD7 : reserved + */ + +/* + * 0xD8 - 0xDA : unassigned + */ + + public final static int VK_OEM_4 = 0xDB; // '[{' for US + public final static int VK_OEM_5 = 0xDC; // '\|' for US + public final static int VK_OEM_6 = 0xDD; // ']}' for US + public final static int VK_OEM_7 = 0xDE; // ''"' for US + public final static int VK_OEM_8 = 0xDF; + +/* + * 0xE0 : reserved + */ + +/* + * Various extended or enhanced keyboards + */ + public final static int VK_OEM_AX = 0xE1; // 'AX' key on Japanese AX kbd + public final static int VK_OEM_102 = 0xE2; // "<>" or "\|" on RT 102-key kbd. + public final static int VK_ICO_HELP = 0xE3; // Help key on ICO + public final static int VK_ICO_00 = 0xE4; // 00 key on ICO + + public final static int VK_PROCESSKEY = 0xE5; + + public final static int VK_ICO_CLEAR = 0xE6; + + + public final static int VK_PACKET = 0xE7; + +/* + * 0xE8 : unassigned + */ + +/* + * Nokia/Ericsson definitions + */ + public final static int VK_OEM_RESET = 0xE9; + public final static int VK_OEM_JUMP = 0xEA; + public final static int VK_OEM_PA1 = 0xEB; + public final static int VK_OEM_PA2 = 0xEC; + public final static int VK_OEM_PA3 = 0xED; + public final static int VK_OEM_WSCTRL = 0xEE; + public final static int VK_OEM_CUSEL = 0xEF; + public final static int VK_OEM_ATTN = 0xF0; + public final static int VK_OEM_FINISH = 0xF1; + public final static int VK_OEM_COPY = 0xF2; + public final static int VK_OEM_AUTO = 0xF3; + public final static int VK_OEM_ENLW = 0xF4; + public final static int VK_OEM_BACKTAB = 0xF5; + + public final static int VK_ATTN = 0xF6; + public final static int VK_CRSEL = 0xF7; + public final static int VK_EXSEL = 0xF8; + public final static int VK_EREOF = 0xF9; + public final static int VK_PLAY = 0xFA; + public final static int VK_ZOOM = 0xFB; + public final static int VK_NONAME = 0xFC; + public final static int VK_PA1 = 0xFD; + public final static int VK_OEM_CLEAR = 0xFE; + + public static int mapVirtualKeyToLWJGLCode(int virt_key) { + switch (virt_key) { + case VK_ESCAPE: + return Keyboard.KEY_ESCAPE; + case VK_1: + return Keyboard.KEY_1; + case VK_2: + return Keyboard.KEY_2; + case VK_3: + return Keyboard.KEY_3; + case VK_4: + return Keyboard.KEY_4; + case VK_5: + return Keyboard.KEY_5; + case VK_6: + return Keyboard.KEY_6; + case VK_7: + return Keyboard.KEY_7; + case VK_8: + return Keyboard.KEY_8; + case VK_9: + return Keyboard.KEY_9; + case VK_0: + return Keyboard.KEY_0; + case VK_OEM_MINUS: + return Keyboard.KEY_MINUS; +/* case VK_EQUALS: + return Keyboard.KEY_EQUALS;*/ + case VK_BACK: + return Keyboard.KEY_BACK; + case VK_TAB: + return Keyboard.KEY_TAB; + case VK_Q: + return Keyboard.KEY_Q; + case VK_W: + return Keyboard.KEY_W; + case VK_E: + return Keyboard.KEY_E; + case VK_R: + return Keyboard.KEY_R; + case VK_T: + return Keyboard.KEY_T; + case VK_Y: + return Keyboard.KEY_Y; + case VK_U: + return Keyboard.KEY_U; + case VK_I: + return Keyboard.KEY_I; + case VK_O: + return Keyboard.KEY_O; + case VK_P: + return Keyboard.KEY_P; + case VK_OEM_4: + return Keyboard.KEY_LBRACKET; + case VK_OEM_6: + return Keyboard.KEY_RBRACKET; + case VK_RETURN: + return Keyboard.KEY_RETURN; + case VK_LCONTROL: + return Keyboard.KEY_LCONTROL; + case VK_A: + return Keyboard.KEY_A; + case VK_S: + return Keyboard.KEY_S; + case VK_D: + return Keyboard.KEY_D; + case VK_F: + return Keyboard.KEY_F; + case VK_G: + return Keyboard.KEY_G; + case VK_H: + return Keyboard.KEY_H; + case VK_J: + return Keyboard.KEY_J; + case VK_K: + return Keyboard.KEY_K; + case VK_L: + return Keyboard.KEY_L; + case VK_OEM_1: + return Keyboard.KEY_SEMICOLON; + case VK_OEM_7: + return Keyboard.KEY_APOSTROPHE; + case VK_OEM_3: + return Keyboard.KEY_GRAVE; + case VK_LSHIFT: + return Keyboard.KEY_LSHIFT; + case VK_OEM_5: + return Keyboard.KEY_BACKSLASH; + case VK_Z: + return Keyboard.KEY_Z; + case VK_X: + return Keyboard.KEY_X; + case VK_C: + return Keyboard.KEY_C; + case VK_V: + return Keyboard.KEY_V; + case VK_B: + return Keyboard.KEY_B; + case VK_N: + return Keyboard.KEY_N; + case VK_M: + return Keyboard.KEY_M; + case VK_OEM_COMMA: + return Keyboard.KEY_COMMA; + case VK_OEM_PERIOD: + return Keyboard.KEY_PERIOD; + case VK_OEM_2: + return Keyboard.KEY_SLASH; + case VK_RSHIFT: + return Keyboard.KEY_RSHIFT; + case VK_MULTIPLY: + return Keyboard.KEY_MULTIPLY; + case VK_LMENU: + return Keyboard.KEY_LMENU; + case VK_SPACE: + return Keyboard.KEY_SPACE; + case VK_CAPITAL: + return Keyboard.KEY_CAPITAL; + case VK_F1: + return Keyboard.KEY_F1; + case VK_F2: + return Keyboard.KEY_F2; + case VK_F3: + return Keyboard.KEY_F3; + case VK_F4: + return Keyboard.KEY_F4; + case VK_F5: + return Keyboard.KEY_F5; + case VK_F6: + return Keyboard.KEY_F6; + case VK_F7: + return Keyboard.KEY_F7; + case VK_F8: + return Keyboard.KEY_F8; + case VK_F9: + return Keyboard.KEY_F9; + case VK_F10: + return Keyboard.KEY_F10; + case VK_NUMLOCK: + return Keyboard.KEY_NUMLOCK; + case VK_SCROLL: + return Keyboard.KEY_SCROLL; + case VK_NUMPAD7: + return Keyboard.KEY_NUMPAD7; + case VK_NUMPAD8: + return Keyboard.KEY_NUMPAD8; + case VK_NUMPAD9: + return Keyboard.KEY_NUMPAD9; + case VK_SUBTRACT: + return Keyboard.KEY_SUBTRACT; + case VK_NUMPAD4: + return Keyboard.KEY_NUMPAD4; + case VK_NUMPAD5: + return Keyboard.KEY_NUMPAD5; + case VK_NUMPAD6: + return Keyboard.KEY_NUMPAD6; + case VK_ADD: + return Keyboard.KEY_ADD; + case VK_NUMPAD1: + return Keyboard.KEY_NUMPAD1; + case VK_NUMPAD2: + return Keyboard.KEY_NUMPAD2; + case VK_NUMPAD3: + return Keyboard.KEY_NUMPAD3; + case VK_NUMPAD0: + return Keyboard.KEY_NUMPAD0; + case VK_DECIMAL: + return Keyboard.KEY_DECIMAL; + case VK_F11: + return Keyboard.KEY_F11; + case VK_F12: + return Keyboard.KEY_F12; + case VK_F13: + return Keyboard.KEY_F13; + case VK_F14: + return Keyboard.KEY_F14; + case VK_F15: + return Keyboard.KEY_F15; + case VK_KANA: + return Keyboard.KEY_KANA; + case VK_CONVERT: + return Keyboard.KEY_CONVERT; + case VK_NONCONVERT: + return Keyboard.KEY_NOCONVERT; +/* case VK_YEN: + return Keyboard.KEY_YEN; + case VK_NUMPADEQUALS: + return Keyboard.KEY_NUMPADEQUALS; + case VK_CIRCUMFLEX: + return Keyboard.KEY_CIRCUMFLEX; + case VK_AT: + return Keyboard.KEY_AT; + case VK_COLON: + return Keyboard.KEY_COLON; + case VK_UNDERLINE: + return Keyboard.KEY_UNDERLINE;*/ + case VK_KANJI: + return Keyboard.KEY_KANJI; +/* case VK_STOP: + return Keyboard.KEY_STOP; + case VK_AX: + return Keyboard.KEY_AX; + case VK_UNLABELED: + return Keyboard.KEY_UNLABELED; + case VK_NUMPADENTER: + return Keyboard.KEY_NUMPADENTER;*/ + case VK_RCONTROL: + return Keyboard.KEY_RCONTROL; + case VK_SEPARATOR: + return Keyboard.KEY_NUMPADCOMMA; + case VK_DIVIDE: + return Keyboard.KEY_DIVIDE; + case VK_PRINT: + return Keyboard.KEY_SYSRQ; + case VK_RMENU: + return Keyboard.KEY_RMENU; + case VK_PAUSE: + return Keyboard.KEY_PAUSE; + case VK_HOME: + return Keyboard.KEY_HOME; + case VK_UP: + return Keyboard.KEY_UP; + case VK_PRIOR: + return Keyboard.KEY_PRIOR; + case VK_LEFT: + return Keyboard.KEY_LEFT; + case VK_RIGHT: + return Keyboard.KEY_RIGHT; + case VK_END: + return Keyboard.KEY_END; + case VK_DOWN: + return Keyboard.KEY_DOWN; + case VK_NEXT: + return Keyboard.KEY_NEXT; + case VK_INSERT: + return Keyboard.KEY_INSERT; + case VK_DELETE: + return Keyboard.KEY_DELETE; + case VK_LWIN: + return Keyboard.KEY_LWIN; + case VK_RWIN: + return Keyboard.KEY_RWIN; + case VK_APPS: + return Keyboard.KEY_APPS; +/* case VK_POWER: + return Keyboard.KEY_POWER;*/ + case VK_SLEEP: + return Keyboard.KEY_SLEEP; + default: + return Keyboard.KEY_NONE; + } + } +} Property changes on: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsKeycodes.java ___________________________________________________________________ Name: svn:executable + * Modified: trunk/LWJGL/src/native/windows/org_lwjgl_opengl_WindowsKeyboard.c =================================================================== --- trunk/LWJGL/src/native/windows/org_lwjgl_opengl_WindowsKeyboard.c 2007-04-24 13:22:35 UTC (rev 2800) +++ trunk/LWJGL/src/native/windows/org_lwjgl_opengl_WindowsKeyboard.c 2007-04-24 13:40:13 UTC (rev 2801) @@ -41,6 +41,10 @@ #include <jni.h> #include "org_lwjgl_opengl_WindowsKeyboard.h" +JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_WindowsKeyboard_GetKeyState(JNIEnv *env, jclass unused, jint virt_key) { + return GetKeyState(virt_key); +} + JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_WindowsKeyboard_MapVirtualKey(JNIEnv *env, jclass unused, jint uCode, jint uMapType) { return MapVirtualKey(uCode, uMapType); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <eli...@us...> - 2007-04-24 14:41:20
|
Revision: 2804 http://svn.sourceforge.net/java-game-lib/?rev=2804&view=rev Author: elias_naur Date: 2007-04-24 07:41:17 -0700 (Tue, 24 Apr 2007) Log Message: ----------- Windows: Use TranslateMessage and WM_CHAR to receive character input instead of manual translation. This change fixes composed characters. Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsKeyboard.java trunk/LWJGL/src/native/windows/org_lwjgl_opengl_Display.c Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java 2007-04-24 14:13:42 UTC (rev 2803) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java 2007-04-24 14:41:17 UTC (rev 2804) @@ -62,8 +62,9 @@ private final static int WM_MOUSEWHEEL = 0x020A; private final static int WM_KEYDOWN = 256; private final static int WM_KEYUP = 257; - private final static int WM_SYSKEYUP = 261; - private final static int WM_SYSKEYDOWN = 260; + private final static int WM_SYSKEYUP = 261; + private final static int WM_SYSKEYDOWN = 260; + private final static int WM_CHAR = 258; private final static int WM_QUIT = 0x0012; private final static int WM_SYSCOMMAND = 0x0112; @@ -595,6 +596,15 @@ private static native void getClientRect(long hwnd, IntBuffer rect); + private void handleChar(long wParam, long lParam, long millis) { + byte previous_state = (byte)((lParam >>> 30) & 0x1); + byte state = (byte)(1 - ((lParam >>> 31) & 0x1)); + if (state == previous_state) + return; // Auto-repeat message + if (keyboard != null) + keyboard.handleChar((int)(wParam & 0xFF), millis); + } + private void handleKeyButton(long wParam, long lParam, long millis) { byte previous_state = (byte)((lParam >>> 30) & 0x1); byte state = (byte)(1 - ((lParam >>> 31) & 0x1)); @@ -682,6 +692,9 @@ case WM_MBUTTONUP: handleMouseButton(2, 0, millis); return true; + case WM_CHAR: + handleChar(wParam, lParam, millis); + return true; case WM_SYSKEYDOWN: /* Fall through */ case WM_SYSKEYUP: /* Fall through */ case WM_KEYUP: /* Fall through */ Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsKeyboard.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsKeyboard.java 2007-04-24 14:13:42 UTC (rev 2803) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsKeyboard.java 2007-04-24 14:41:17 UTC (rev 2804) @@ -55,24 +55,18 @@ private final byte[] key_down_buffer = new byte[Keyboard.KEYBOARD_SIZE]; private final EventQueue event_queue = new EventQueue(Keyboard.EVENT_SIZE); private final ByteBuffer tmp_event = ByteBuffer.allocate(Keyboard.EVENT_SIZE); - private final boolean unicode; - private final CharBuffer unicode_buffer; - private final ByteBuffer ascii_buffer; private boolean grabbed; + private boolean has_retained_event; // Indicates if we're waiting for a WM_CHAR + private int retained_key_code; + private byte retained_state; + private int retained_char; + private long retained_millis; + public WindowsKeyboard(long hwnd) throws LWJGLException { this.hwnd = hwnd; keyboard_state = BufferUtils.createByteBuffer(256); - unicode = isWindowsNT(); - if (unicode) { - unicode_buffer = BufferUtils.createCharBuffer(BUFFER_SIZE); - ascii_buffer = null; - } else { - unicode_buffer = null; - // ToAscii returns at most 2 characters - ascii_buffer = BufferUtils.createByteBuffer(2); - } } private static native boolean isWindowsNT(); @@ -97,66 +91,15 @@ keyDownBuffer.position(old_position); } - private void translate(int virt_key, byte state, long nanos) { - int keycode = MapVirtualKey(virt_key, MAPVK_VK_TO_VSC); - if (state != 0) { - if (virt_key != 0 && GetKeyboardState(keyboard_state) != 0) { - // Mark key down in the scan code - int key_down_code = keycode & 0x7fff; - int num_chars; - if (unicode) { - unicode_buffer.clear(); - num_chars = ToUnicode(virt_key, - key_down_code, - keyboard_state, - unicode_buffer, - unicode_buffer.capacity(), 0); - } else { - ascii_buffer.clear(); - num_chars = ToAscii(virt_key, - key_down_code, - keyboard_state, - ascii_buffer, - 0); - } - if (num_chars > 0) { - int current_char = 0; - do { - int char_int; - if (unicode) { - char_int = ((int)unicode_buffer.get()) & 0xFFFF; - } else { - char_int = ((int)ascii_buffer.get()) & 0xFF; - } - if (current_char >= 1) { - putEvent(0, (byte)0, char_int, nanos); - } else { - putEvent(virt_key, state, char_int, nanos); - } - current_char++; - } while (current_char < num_chars); - } else { - putEvent(virt_key, state, 0, nanos); - } - } else { - putEvent(virt_key, state, 0, nanos); - } - } else { - putEvent(virt_key, state, 0, nanos); - } - } private static native int MapVirtualKey(int uCode, int uMapType); private static native int ToUnicode(int wVirtKey, int wScanCode, ByteBuffer lpKeyState, CharBuffer pwszBuff, int cchBuff, int flags); private static native int ToAscii(int wVirtKey, int wScanCode, ByteBuffer lpKeyState, ByteBuffer lpChar, int flags); private static native int GetKeyboardState(ByteBuffer lpKeyState); private static native int GetKeyState(int virt_key); - private void putEvent(int virt_key, byte state, int ch, long nanos) { - int keycode = WindowsKeycodes.mapVirtualKeyToLWJGLCode(virt_key); - if (keycode < key_down_buffer.length) - key_down_buffer[keycode] = state; + private void putEvent(int keycode, byte state, int ch, long millis) { tmp_event.clear(); - tmp_event.putInt(keycode).put(state).putInt(ch).putLong(nanos); + tmp_event.putInt(keycode).put(state).putInt(ch).putLong(millis*1000000); tmp_event.flip(); event_queue.putEvent(tmp_event); } @@ -198,13 +141,36 @@ } } + private void flushRetained() { + if (has_retained_event) { + has_retained_event = false; + putEvent(retained_key_code, retained_state, retained_char, retained_millis); + } + } + public void handleKey(int virt_key, int scan_code, boolean extended, byte event_state, long millis) { - if (isWindowsNT()) - virt_key = translateExtended(virt_key, scan_code, event_state, extended); - translate(virt_key, event_state, millis*1000000); + virt_key = translateExtended(virt_key, scan_code, event_state, extended); + flushRetained(); + has_retained_event = true; + int keycode = WindowsKeycodes.mapVirtualKeyToLWJGLCode(virt_key); + if (keycode < key_down_buffer.length) + key_down_buffer[keycode] = event_state; + retained_key_code = keycode; + retained_state = event_state; + retained_millis = millis; + retained_char = 0; +// translate(virt_key, event_state, millis*1000000); } + public void handleChar(int event_char, long millis) { + if (!has_retained_event) { + putEvent(0, (byte)0, event_char, millis); + } else + retained_char = event_char; + } + public void read(ByteBuffer buffer) { + flushRetained(); event_queue.copyEvents(buffer); } } Modified: trunk/LWJGL/src/native/windows/org_lwjgl_opengl_Display.c =================================================================== --- trunk/LWJGL/src/native/windows/org_lwjgl_opengl_Display.c 2007-04-24 14:13:42 UTC (rev 2803) +++ trunk/LWJGL/src/native/windows/org_lwjgl_opengl_Display.c 2007-04-24 14:41:17 UTC (rev 2804) @@ -148,6 +148,7 @@ )) { DispatchMessage(&msg); + TranslateMessage(&msg); } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <eli...@us...> - 2007-04-29 20:22:26
|
Revision: 2812 http://svn.sourceforge.net/java-game-lib/?rev=2812&view=rev Author: elias_naur Date: 2007-04-29 13:22:25 -0700 (Sun, 29 Apr 2007) Log Message: ----------- Re-implemented VBO buffer binding caches to speed up gl*Pointer calls. Patch by MatthiasM. Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/opengl/GLChecks.java trunk/LWJGL/src/java/org/lwjgl/opengl/StateTracker.java trunk/LWJGL/src/java/org/lwjgl/util/generator/ReferencesGeneratorProcessorFactory.java trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_buffer_object.java trunk/LWJGL/src/templates/org/lwjgl/opengl/GL15.java Added Paths: ----------- trunk/LWJGL/src/java/org/lwjgl/opengl/BaseReferences.java Added: trunk/LWJGL/src/java/org/lwjgl/opengl/BaseReferences.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/BaseReferences.java (rev 0) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/BaseReferences.java 2007-04-29 20:22:25 UTC (rev 2812) @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2002-2004 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions 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 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package org.lwjgl.opengl; + +class BaseReferences { + + int elementArrayBuffer; + int arrayBuffer; + + void clear() { + this.elementArrayBuffer = 0; + this.arrayBuffer = 0; + } + + void copy(BaseReferences references) { + this.elementArrayBuffer = references.elementArrayBuffer; + this.arrayBuffer = references.arrayBuffer; + } +} Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/GLChecks.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/GLChecks.java 2007-04-29 19:38:04 UTC (rev 2811) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/GLChecks.java 2007-04-29 20:22:25 UTC (rev 2812) @@ -80,25 +80,25 @@ /** Helper method to ensure that array buffer objects are disabled. If they are enabled, we'll throw an OpenGLException */ static void ensureArrayVBOdisabled(ContextCapabilities caps) { - if ((caps.OpenGL15 || caps.GL_ARB_vertex_buffer_object) && !checkBufferObject(caps, GL15.GL_ARRAY_BUFFER_BINDING, false)) + if(StateTracker.getReferencesStack(caps).getReferences().arrayBuffer != 0) throw new OpenGLException("Cannot use Buffers when Array Buffer Object is enabled"); } /** Helper method to ensure that array buffer objects are enabled. If they are disabled, we'll throw an OpenGLException */ static void ensureArrayVBOenabled(ContextCapabilities caps) { - if ((caps.OpenGL15 || caps.GL_ARB_vertex_buffer_object) && !checkBufferObject(caps, GL15.GL_ARRAY_BUFFER_BINDING, true)) + if(StateTracker.getReferencesStack(caps).getReferences().arrayBuffer == 0) throw new OpenGLException("Cannot use offsets when Array Buffer Object is disabled"); } /** Helper method to ensure that element array buffer objects are disabled. If they are enabled, we'll throw an OpenGLException */ static void ensureElementVBOdisabled(ContextCapabilities caps) { - if ((caps.OpenGL15 || caps.GL_ARB_vertex_buffer_object) && !checkBufferObject(caps, GL15.GL_ELEMENT_ARRAY_BUFFER_BINDING, false)) + if(StateTracker.getReferencesStack(caps).getReferences().elementArrayBuffer != 0) throw new OpenGLException("Cannot use Buffers when Element Array Buffer Object is enabled"); } /** Helper method to ensure that element array buffer objects are enabled. If they are disabled, we'll throw an OpenGLException */ static void ensureElementVBOenabled(ContextCapabilities caps) { - if ((caps.OpenGL15 || caps.GL_ARB_vertex_buffer_object) && !checkBufferObject(caps, GL15.GL_ELEMENT_ARRAY_BUFFER_BINDING, true)) + if(StateTracker.getReferencesStack(caps).getReferences().elementArrayBuffer == 0) throw new OpenGLException("Cannot use offsets when Element Array Buffer Object is disabled"); } Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/StateTracker.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/StateTracker.java 2007-04-29 19:38:04 UTC (rev 2811) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/StateTracker.java 2007-04-29 20:22:25 UTC (rev 2812) @@ -64,4 +64,16 @@ static ReferencesStack getReferencesStack(ContextCapabilities caps) { return caps.tracker.references_stack; } + + static void bindBuffer(ContextCapabilities caps, int target, int buffer) { + ReferencesStack references_stack = getReferencesStack(caps); + switch(target) { + case GL15.GL_ELEMENT_ARRAY_BUFFER: + references_stack.getReferences().elementArrayBuffer = buffer; + break; + case GL15.GL_ARRAY_BUFFER: + references_stack.getReferences().arrayBuffer = buffer; + break; + } + } } Modified: trunk/LWJGL/src/java/org/lwjgl/util/generator/ReferencesGeneratorProcessorFactory.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/util/generator/ReferencesGeneratorProcessorFactory.java 2007-04-29 19:38:04 UTC (rev 2811) +++ trunk/LWJGL/src/java/org/lwjgl/util/generator/ReferencesGeneratorProcessorFactory.java 2007-04-29 20:22:25 UTC (rev 2812) @@ -166,7 +166,7 @@ writer.println(); writer.println("package org.lwjgl.opengl;"); writer.println(); - writer.println("class " + REFERENCES_CLASS_NAME + " {"); + writer.println("class " + REFERENCES_CLASS_NAME + " extends BaseReferences {"); DeclarationFilter filter = DeclarationFilter.getFilter(InterfaceDeclaration.class); Collection<TypeDeclaration> interface_decls = filter.filter(env.getSpecifiedTypeDeclarations()); for (TypeDeclaration typedecl : interface_decls) { @@ -175,12 +175,14 @@ } writer.println(); writer.println("\tvoid copy(" + REFERENCES_CLASS_NAME + " " + REFERENCES_PARAMETER_NAME + ") {"); + writer.println("\t\tsuper.copy(" + REFERENCES_PARAMETER_NAME + ");"); for (TypeDeclaration typedecl : interface_decls) { InterfaceDeclaration interface_decl = (InterfaceDeclaration)typedecl; generateCopiesFromMethods(writer, interface_decl); } writer.println("\t}"); writer.println("\tvoid clear() {"); + writer.println("\t\tsuper.clear();"); for (TypeDeclaration typedecl : interface_decls) { InterfaceDeclaration interface_decl = (InterfaceDeclaration)typedecl; generateClearsFromMethods(writer, interface_decl); Modified: trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_buffer_object.java =================================================================== --- trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_buffer_object.java 2007-04-29 19:38:04 UTC (rev 2811) +++ trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_buffer_object.java 2007-04-29 20:22:25 UTC (rev 2812) @@ -67,6 +67,7 @@ int GL_BUFFER_MAPPED_ARB = 0x88BC; int GL_BUFFER_MAP_POINTER_ARB = 0x88BD; + @Code(" StateTracker.bindBuffer(caps, target, buffer);") void glBindBufferARB(@GLenum int target, @GLuint int buffer); void glDeleteBuffersARB(@AutoSize("buffers") @GLsizei int n, @Const @GLuint IntBuffer buffers); Modified: trunk/LWJGL/src/templates/org/lwjgl/opengl/GL15.java =================================================================== --- trunk/LWJGL/src/templates/org/lwjgl/opengl/GL15.java 2007-04-29 19:38:04 UTC (rev 2811) +++ trunk/LWJGL/src/templates/org/lwjgl/opengl/GL15.java 2007-04-29 20:22:25 UTC (rev 2812) @@ -72,6 +72,7 @@ int GL_BUFFER_MAPPED = 0x88BC; int GL_BUFFER_MAP_POINTER = 0x88BD; + @Code(" StateTracker.bindBuffer(caps, target, buffer);") void glBindBuffer(@GLenum int target, @GLuint int buffer); void glDeleteBuffers(@AutoSize("buffers") @GLsizei int n, @Const @GLuint IntBuffer buffers); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <eli...@us...> - 2007-05-13 21:12:10
|
Revision: 2817 http://svn.sourceforge.net/java-game-lib/?rev=2817&view=rev Author: elias_naur Date: 2007-05-13 14:11:53 -0700 (Sun, 13 May 2007) Log Message: ----------- Use event timestamp to detect key repeat events in KeyboardEventQueue Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/opengl/KeyboardEventQueue.java trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxAWTInput.java trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/KeyboardEventQueue.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/KeyboardEventQueue.java 2007-05-13 20:13:37 UTC (rev 2816) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/KeyboardEventQueue.java 2007-05-13 21:11:53 UTC (rev 2817) @@ -53,6 +53,13 @@ private final Component component; + private boolean has_deferred_event; + private long deferred_nanos; + private int deferred_key_code; + private int deferred_key_location; + private byte deferred_key_state; + private int deferred_character; + static { KEY_MAP[KeyEvent.VK_0] = Keyboard.KEY_0; KEY_MAP[KeyEvent.VK_1] = Keyboard.KEY_1; @@ -265,14 +272,50 @@ } public synchronized void poll(ByteBuffer key_down_buffer) { + flushDeferredEvent(); int old_position = key_down_buffer.position(); key_down_buffer.put(key_states); key_down_buffer.position(old_position); } - private synchronized void handleKey(int key_code_mapped, byte state, int character, long nanos) { - if ( character == KeyEvent.CHAR_UNDEFINED ) + public synchronized void copyEvents(ByteBuffer dest) { + flushDeferredEvent(); + super.copyEvents(dest); + } + + private synchronized void handleKey(int key_code, int key_location, byte state, int character, long nanos) { + if (character == KeyEvent.CHAR_UNDEFINED) character = Keyboard.CHAR_NONE; + if (state == 1) { + if (has_deferred_event) { + if ((nanos == deferred_nanos && deferred_key_code == key_code && + deferred_key_location == key_location)) { + has_deferred_event = false; + return; // Ignore repeated key down, key up event pair + } + flushDeferredEvent(); + } + putKeyEvent(key_code, key_location, state, character, nanos); + } else { + flushDeferredEvent(); + has_deferred_event = true; + deferred_nanos = nanos; + deferred_key_code = key_code; + deferred_key_location = key_location; + deferred_key_state = state; + deferred_character = character; + } + } + + private void flushDeferredEvent() { + if (has_deferred_event) { + putKeyEvent(deferred_key_code, deferred_key_location, deferred_key_state, deferred_character, deferred_nanos); + has_deferred_event = false; + } + } + + private void putKeyEvent(int key_code, int key_location, byte state, int character, long nanos) { + int key_code_mapped = getMappedKeyCode(key_code, key_location); /* Ignore repeating presses */ if ( key_states[key_code_mapped] == state ) return; @@ -306,11 +349,11 @@ } public void keyPressed(KeyEvent e) { - handleKey(getMappedKeyCode(e.getKeyCode(), e.getKeyLocation()), (byte)1, e.getKeyChar(), e.getWhen()*1000000); + handleKey(e.getKeyCode(), e.getKeyLocation(), (byte)1, e.getKeyChar(), e.getWhen()*1000000); } public void keyReleased(KeyEvent e) { - handleKey(getMappedKeyCode(e.getKeyCode(), e.getKeyLocation()), (byte)0, Keyboard.CHAR_NONE, e.getWhen()*1000000); + handleKey(e.getKeyCode(), e.getKeyLocation(), (byte)0, Keyboard.CHAR_NONE, e.getWhen()*1000000); } public void keyTyped(KeyEvent e) { Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxAWTInput.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxAWTInput.java 2007-05-13 20:13:37 UTC (rev 2816) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxAWTInput.java 2007-05-13 21:11:53 UTC (rev 2817) @@ -92,7 +92,6 @@ if (input_grabbed) { // LinuxDisplay.nUngrabKeyboard(display); LinuxDisplay.nUngrabPointer(display); - LinuxDisplay.nSetRepeatMode(display, LinuxDisplay.AutoRepeatModeDefault); input_grabbed = false; } } @@ -100,7 +99,6 @@ private void grabInput(long window) { if (!input_grabbed) { // int res1 = LinuxDisplay.nGrabKeyboard(display, window); - LinuxDisplay.nSetRepeatMode(display, LinuxDisplay.AutoRepeatModeOff); int res2 = LinuxDisplay.nGrabPointer(display, window, blank_cursor); if (/*res1 == LinuxDisplay.GrabSuccess && */res2 == LinuxDisplay.GrabSuccess) input_grabbed = true; Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2007-05-13 20:13:37 UTC (rev 2816) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2007-05-13 21:11:53 UTC (rev 2817) @@ -789,7 +789,6 @@ } } } - static native void nSetRepeatMode(long display, int mode); public void grabMouse(boolean new_grab) { lockAWT(); Modified: trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c =================================================================== --- trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c 2007-05-13 20:13:37 UTC (rev 2816) +++ trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c 2007-05-13 21:11:53 UTC (rev 2817) @@ -469,13 +469,6 @@ return win; } -JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nSetRepeatMode(JNIEnv *env, jclass unused, jlong display_ptr, jint mode) { - Display *disp = (Display *)(intptr_t)display_ptr; - XKeyboardControl repeat_mode; - repeat_mode.auto_repeat_mode = mode; - XChangeKeyboardControl(disp, KBAutoRepeatMode, &repeat_mode); -} - JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nIconifyWindow(JNIEnv *env, jclass unused, jlong display_ptr, jlong window_ptr, jint screen) { Display *disp = (Display *)(intptr_t)display_ptr; Window win = (Window)window_ptr; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <eli...@us...> - 2007-05-22 22:30:24
|
Revision: 2827 http://svn.sourceforge.net/java-game-lib/?rev=2827&view=rev Author: elias_naur Date: 2007-05-22 15:30:21 -0700 (Tue, 22 May 2007) Log Message: ----------- Implemented proper buffer reference retaining for complicated functions like glVertexAttribPointer and glTexCoordPointer. Patch by MatthiasM. Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/opengl/BaseReferences.java trunk/LWJGL/src/java/org/lwjgl/opengl/ReferencesStack.java trunk/LWJGL/src/java/org/lwjgl/util/generator/CachedReference.java trunk/LWJGL/src/java/org/lwjgl/util/generator/JavaMethodsGenerator.java trunk/LWJGL/src/java/org/lwjgl/util/generator/ReferencesGeneratorProcessorFactory.java trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_vertex_program.java trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_vertex_shader.java trunk/LWJGL/src/templates/org/lwjgl/opengl/GL11.java trunk/LWJGL/src/templates/org/lwjgl/opengl/GL13.java trunk/LWJGL/src/templates/org/lwjgl/opengl/GL20.java trunk/LWJGL/src/templates/org/lwjgl/opengl/NV_vertex_program.java Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/BaseReferences.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/BaseReferences.java 2007-05-20 17:51:28 UTC (rev 2826) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/BaseReferences.java 2007-05-22 22:30:21 UTC (rev 2827) @@ -31,18 +31,41 @@ */ package org.lwjgl.opengl; +import java.nio.Buffer; +import java.nio.IntBuffer; +import java.util.Arrays; + class BaseReferences { int elementArrayBuffer; int arrayBuffer; + Buffer[] glVertexAttribPointer_buffer; + Buffer[] glTexCoordPointer_buffer; + int glClientActiveTexture; + BaseReferences(ContextCapabilities caps) { + IntBuffer temp = caps.scratch_int_buffer; + + GL11.glGetInteger(ARBVertexShader.GL_MAX_VERTEX_ATTRIBS_ARB, temp); + glVertexAttribPointer_buffer = new Buffer[temp.get(0)]; + + GL11.glGetInteger(GL13.GL_MAX_TEXTURE_UNITS, temp); + glTexCoordPointer_buffer = new Buffer[temp.get(0)]; + } + void clear() { this.elementArrayBuffer = 0; this.arrayBuffer = 0; + this.glClientActiveTexture = 0; + Arrays.fill(glVertexAttribPointer_buffer, null); + Arrays.fill(glTexCoordPointer_buffer, null); } void copy(BaseReferences references) { this.elementArrayBuffer = references.elementArrayBuffer; this.arrayBuffer = references.arrayBuffer; + this.glClientActiveTexture = references.glClientActiveTexture; + System.arraycopy(references.glVertexAttribPointer_buffer, 0, glVertexAttribPointer_buffer, 0, glVertexAttribPointer_buffer.length); + System.arraycopy(references.glTexCoordPointer_buffer, 0, glTexCoordPointer_buffer, 0, glTexCoordPointer_buffer.length); } } Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/ReferencesStack.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/ReferencesStack.java 2007-05-20 17:51:28 UTC (rev 2826) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/ReferencesStack.java 2007-05-22 22:30:21 UTC (rev 2827) @@ -57,13 +57,14 @@ References[] new_references_stack = new References[references_stack.length + 1]; System.arraycopy(references_stack, 0, new_references_stack, 0, references_stack.length); references_stack = new_references_stack; - references_stack[references_stack.length - 1] = new References(); + references_stack[references_stack.length - 1] = new References(GLContext.getCapabilities()); } ReferencesStack() { + ContextCapabilities caps = GLContext.getCapabilities(); references_stack = new References[1]; stack_pos = 0; for (int i = 0; i < references_stack.length; i++) - references_stack[i] = new References(); + references_stack[i] = new References(caps); } } Modified: trunk/LWJGL/src/java/org/lwjgl/util/generator/CachedReference.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/util/generator/CachedReference.java 2007-05-20 17:51:28 UTC (rev 2826) +++ trunk/LWJGL/src/java/org/lwjgl/util/generator/CachedReference.java 2007-05-22 22:30:21 UTC (rev 2827) @@ -46,4 +46,9 @@ @Target(ElementType.PARAMETER) public @interface CachedReference { + /** If set then this will be used as array index for accessing the stored reference. */ + String index() default ""; + + /** If set then this name will be used for the reference and the reference field will not be auto generated in References. */ + String name() default ""; } Modified: trunk/LWJGL/src/java/org/lwjgl/util/generator/JavaMethodsGenerator.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/util/generator/JavaMethodsGenerator.java 2007-05-20 17:51:28 UTC (rev 2826) +++ trunk/LWJGL/src/java/org/lwjgl/util/generator/JavaMethodsGenerator.java 2007-05-22 22:30:21 UTC (rev 2827) @@ -401,13 +401,21 @@ private static void printParameterCaching(PrintWriter writer, InterfaceDeclaration interface_decl, MethodDeclaration method, Mode mode) { for (ParameterDeclaration param : method.getParameters()) { Class java_type = Utils.getJavaType(param.getType()); + CachedReference cachedReference = param.getAnnotation(CachedReference.class); if (Buffer.class.isAssignableFrom(java_type) && - param.getAnnotation(CachedReference.class) != null && + cachedReference != null && (mode != Mode.BUFFEROBJECT || param.getAnnotation(BufferObject.class) == null) && param.getAnnotation(Result.class) == null) { writer.print("\t\t" + Utils.CHECKS_CLASS_NAME + ".getReferences(caps)."); - writer.print(Utils.getReferenceName(interface_decl, method, param) + " = "); - writer.println(param.getSimpleName() + ";"); + if(cachedReference.name().length() > 0) { + writer.print(cachedReference.name()); + } else { + writer.print(Utils.getReferenceName(interface_decl, method, param)); + } + if(cachedReference.index().length() > 0) { + writer.print("[" + cachedReference.index() + "]"); + } + writer.println(" = " + param.getSimpleName() + ";"); } } } Modified: trunk/LWJGL/src/java/org/lwjgl/util/generator/ReferencesGeneratorProcessorFactory.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/util/generator/ReferencesGeneratorProcessorFactory.java 2007-05-20 17:51:28 UTC (rev 2826) +++ trunk/LWJGL/src/java/org/lwjgl/util/generator/ReferencesGeneratorProcessorFactory.java 2007-05-22 22:30:21 UTC (rev 2827) @@ -108,7 +108,7 @@ private static void generateClearsFromParameters(PrintWriter writer, InterfaceDeclaration interface_decl, MethodDeclaration method) { for (ParameterDeclaration param : method.getParameters()) { CachedReference cached_reference_annotation = param.getAnnotation(CachedReference.class); - if (cached_reference_annotation != null) { + if (cached_reference_annotation != null && cached_reference_annotation.name().length() == 0) { Class nio_type = Utils.getNIOBufferType(param.getType()); String reference_name = Utils.getReferenceName(interface_decl, method, param); writer.println("\t\tthis." + reference_name + " = null;"); @@ -119,7 +119,7 @@ private static void generateCopiesFromParameters(PrintWriter writer, InterfaceDeclaration interface_decl, MethodDeclaration method) { for (ParameterDeclaration param : method.getParameters()) { CachedReference cached_reference_annotation = param.getAnnotation(CachedReference.class); - if (cached_reference_annotation != null) { + if (cached_reference_annotation != null && cached_reference_annotation.name().length() == 0) { Class nio_type = Utils.getNIOBufferType(param.getType()); String reference_name = Utils.getReferenceName(interface_decl, method, param); writer.print("\t\tthis." + reference_name + " = "); @@ -143,7 +143,7 @@ private static void generateReferencesFromParameters(PrintWriter writer, InterfaceDeclaration interface_decl, MethodDeclaration method) { for (ParameterDeclaration param : method.getParameters()) { CachedReference cached_reference_annotation = param.getAnnotation(CachedReference.class); - if (cached_reference_annotation != null) { + if (cached_reference_annotation != null && cached_reference_annotation.name().length() == 0) { Class nio_type = Utils.getNIOBufferType(param.getType()); if (nio_type == null) throw new RuntimeException(param + " in method " + method + " in " + interface_decl + " is annotated with " @@ -167,6 +167,9 @@ writer.println("package org.lwjgl.opengl;"); writer.println(); writer.println("class " + REFERENCES_CLASS_NAME + " extends BaseReferences {"); + writer.println("\t" + REFERENCES_CLASS_NAME + "(ContextCapabilities caps) {"); + writer.println("\t\tsuper(caps);"); + writer.println("\t}"); DeclarationFilter filter = DeclarationFilter.getFilter(InterfaceDeclaration.class); Collection<TypeDeclaration> interface_decls = filter.filter(env.getSpecifiedTypeDeclarations()); for (TypeDeclaration typedecl : interface_decls) { Modified: trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_vertex_program.java =================================================================== --- trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_vertex_program.java 2007-05-20 17:51:28 UTC (rev 2826) +++ trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_vertex_program.java 2007-05-22 22:30:21 UTC (rev 2827) @@ -112,7 +112,7 @@ void glVertexAttrib4NubARB(@GLuint int index, @GLubyte byte x, @GLubyte byte y, @GLubyte byte z, @GLubyte byte w); void glVertexAttribPointerARB(@GLuint int index, int size, @AutoType("buffer") @GLenum int type, boolean normalized, @GLsizei int stride, - @CachedReference + @CachedReference(index="index",name="glVertexAttribPointer_buffer") @BufferObject(BufferKind.ArrayVBO) @Check @Const Modified: trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_vertex_shader.java =================================================================== --- trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_vertex_shader.java 2007-05-20 17:51:28 UTC (rev 2826) +++ trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_vertex_shader.java 2007-05-22 22:30:21 UTC (rev 2827) @@ -122,7 +122,7 @@ void glVertexAttrib4NubARB(@GLuint int index, @GLubyte byte x, @GLubyte byte y, @GLubyte byte z, @GLubyte byte w); void glVertexAttribPointerARB(@GLuint int index, int size, @AutoType("buffer") @GLenum int type, boolean normalized, @GLsizei int stride, - @CachedReference + @CachedReference(index="index",name="glVertexAttribPointer_buffer") @BufferObject(BufferKind.ArrayVBO) @Check @Const Modified: trunk/LWJGL/src/templates/org/lwjgl/opengl/GL11.java =================================================================== --- trunk/LWJGL/src/templates/org/lwjgl/opengl/GL11.java 2007-05-20 17:51:28 UTC (rev 2826) +++ trunk/LWJGL/src/templates/org/lwjgl/opengl/GL11.java 2007-05-22 22:30:21 UTC (rev 2827) @@ -1336,7 +1336,7 @@ void glTexEnviv(@GLenum int target, @GLenum int pname, @Check("4") @Const IntBuffer params); void glTexCoordPointer(int size, @AutoType("pointer") @GLenum int type, @GLsizei int stride, - @CachedReference + @CachedReference(index="GLChecks.getReferences(caps).glClientActiveTexture", name="glTexCoordPointer_buffer") @BufferObject(BufferKind.ArrayVBO) @Check @Const Modified: trunk/LWJGL/src/templates/org/lwjgl/opengl/GL13.java =================================================================== --- trunk/LWJGL/src/templates/org/lwjgl/opengl/GL13.java 2007-05-20 17:51:28 UTC (rev 2826) +++ trunk/LWJGL/src/templates/org/lwjgl/opengl/GL13.java 2007-05-22 22:30:21 UTC (rev 2827) @@ -148,6 +148,7 @@ void glActiveTexture(@GLenum int texture); + @Code("\t\tGLChecks.getReferences(caps).glClientActiveTexture = texture - GL_TEXTURE0;") void glClientActiveTexture(@GLenum int texture); void glCompressedTexImage1D(@GLenum int target, int level, @GLenum int internalformat, @GLsizei int width, int border, @AutoSize("data") @GLsizei int imageSize, Modified: trunk/LWJGL/src/templates/org/lwjgl/opengl/GL20.java =================================================================== --- trunk/LWJGL/src/templates/org/lwjgl/opengl/GL20.java 2007-05-20 17:51:28 UTC (rev 2826) +++ trunk/LWJGL/src/templates/org/lwjgl/opengl/GL20.java 2007-05-22 22:30:21 UTC (rev 2827) @@ -278,7 +278,7 @@ void glVertexAttrib4Nub(@GLuint int index, @GLubyte byte x, @GLubyte byte y, @GLubyte byte z, @GLubyte byte w); void glVertexAttribPointer(@GLuint int index, int size, @AutoType("buffer") @GLenum int type, boolean normalized, @GLsizei int stride, - @CachedReference + @CachedReference(index="index",name="glVertexAttribPointer_buffer") @BufferObject(BufferKind.ArrayVBO) @Check @Const Modified: trunk/LWJGL/src/templates/org/lwjgl/opengl/NV_vertex_program.java =================================================================== --- trunk/LWJGL/src/templates/org/lwjgl/opengl/NV_vertex_program.java 2007-05-20 17:51:28 UTC (rev 2826) +++ trunk/LWJGL/src/templates/org/lwjgl/opengl/NV_vertex_program.java 2007-05-22 22:30:21 UTC (rev 2827) @@ -228,7 +228,7 @@ void glTrackMatrixNV(@GLenum int target, @GLuint int address, @GLenum int matrix, @GLenum int transform); void glVertexAttribPointerNV(@GLuint int index, int size, @GLenum int type, @GLsizei int stride, - @CachedReference + @CachedReference(index="index",name="glVertexAttribPointer_buffer") @BufferObject(BufferKind.ArrayVBO) @Check @Const This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <eli...@us...> - 2007-05-27 05:20:00
|
Revision: 2828 http://svn.sourceforge.net/java-game-lib/?rev=2828&view=rev Author: elias_naur Date: 2007-05-26 22:19:19 -0700 (Sat, 26 May 2007) Log Message: ----------- Windows: Check for gl errors after setting swap interval Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/Sys.java trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsContextImplementation.java trunk/LWJGL/src/native/windows/org_lwjgl_opengl_WindowsContextImplementation.c Modified: trunk/LWJGL/src/java/org/lwjgl/Sys.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/Sys.java 2007-05-22 22:30:21 UTC (rev 2827) +++ trunk/LWJGL/src/java/org/lwjgl/Sys.java 2007-05-27 05:19:19 UTC (rev 2828) @@ -57,7 +57,7 @@ private static final String VERSION = "1.1"; /** Current version of the JNI library */ - static final int JNI_VERSION = 9; + static final int JNI_VERSION = 10; /** The implementation instance to delegate platform specific behavior to */ private final static SysImplementation implementation; Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsContextImplementation.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsContextImplementation.java 2007-05-22 22:30:21 UTC (rev 2827) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsContextImplementation.java 2007-05-27 05:19:19 UTC (rev 2828) @@ -34,6 +34,7 @@ import java.nio.ByteBuffer; import org.lwjgl.LWJGLException; +import org.lwjgl.LWJGLUtil; /** * @@ -96,14 +97,12 @@ private static native boolean nIsCurrent(ByteBuffer context_handle) throws LWJGLException; public void setSwapInterval(int value) { - Context current_context = Context.getCurrentContext(); - if (current_context == null) - throw new IllegalStateException("No context is current"); - synchronized (current_context) { - nSetSwapInterval(current_context.getHandle(), value); - } + boolean success = nSetSwapInterval(value) == GL11.GL_TRUE ? true : false; + if (!success) + LWJGLUtil.log("Failed to set swap interval"); + Util.checkGLError(); } - private static native void nSetSwapInterval(ByteBuffer context_handle, int value); + private static native int nSetSwapInterval(int value); public void destroy(PeerInfo peer_info, ByteBuffer handle) throws LWJGLException { nDestroy(handle); Modified: trunk/LWJGL/src/native/windows/org_lwjgl_opengl_WindowsContextImplementation.c =================================================================== --- trunk/LWJGL/src/native/windows/org_lwjgl_opengl_WindowsContextImplementation.c 2007-05-22 22:30:21 UTC (rev 2827) +++ trunk/LWJGL/src/native/windows/org_lwjgl_opengl_WindowsContextImplementation.c 2007-05-27 05:19:19 UTC (rev 2828) @@ -105,8 +105,8 @@ return wglGetCurrentContext() == context_info->context; } -JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsContextImplementation_nSetSwapInterval - (JNIEnv *env, jclass clazz, jobject context_handle, jint value) { +JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_WindowsContextImplementation_nSetSwapInterval + (JNIEnv *env, jclass clazz, jint value) { WGLExtensions extensions; extgl_InitWGL(&extensions); if (extensions.WGL_EXT_swap_control) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <eli...@us...> - 2007-05-27 15:32:28
|
Revision: 2832 http://svn.sourceforge.net/java-game-lib/?rev=2832&view=rev Author: elias_naur Date: 2007-05-27 08:32:25 -0700 (Sun, 27 May 2007) Log Message: ----------- Windows: Fix up WindowsContextImplementation.nSetSwapInterval Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsContextImplementation.java trunk/LWJGL/src/native/windows/org_lwjgl_opengl_WindowsContextImplementation.c Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsContextImplementation.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsContextImplementation.java 2007-05-27 13:17:35 UTC (rev 2831) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsContextImplementation.java 2007-05-27 15:32:25 UTC (rev 2832) @@ -97,12 +97,12 @@ private static native boolean nIsCurrent(ByteBuffer context_handle) throws LWJGLException; public void setSwapInterval(int value) { - boolean success = nSetSwapInterval(value) == GL11.GL_TRUE ? true : false; + boolean success = nSetSwapInterval(value); if (!success) LWJGLUtil.log("Failed to set swap interval"); Util.checkGLError(); } - private static native int nSetSwapInterval(int value); + private static native boolean nSetSwapInterval(int value); public void destroy(PeerInfo peer_info, ByteBuffer handle) throws LWJGLException { nDestroy(handle); Modified: trunk/LWJGL/src/native/windows/org_lwjgl_opengl_WindowsContextImplementation.c =================================================================== --- trunk/LWJGL/src/native/windows/org_lwjgl_opengl_WindowsContextImplementation.c 2007-05-27 13:17:35 UTC (rev 2831) +++ trunk/LWJGL/src/native/windows/org_lwjgl_opengl_WindowsContextImplementation.c 2007-05-27 15:32:25 UTC (rev 2832) @@ -105,13 +105,14 @@ return wglGetCurrentContext() == context_info->context; } -JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_WindowsContextImplementation_nSetSwapInterval +JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_WindowsContextImplementation_nSetSwapInterval (JNIEnv *env, jclass clazz, jint value) { WGLExtensions extensions; extgl_InitWGL(&extensions); if (extensions.WGL_EXT_swap_control) { - extensions.wglSwapIntervalEXT(value); - } + return extensions.wglSwapIntervalEXT(value) ? JNI_TRUE : JNI_FALSE; + } else + return JNI_FALSE; } JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsContextImplementation_nDestroy This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <eli...@us...> - 2007-07-28 20:46:22
|
Revision: 2858 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=2858&view=rev Author: elias_naur Date: 2007-07-28 13:46:17 -0700 (Sat, 28 Jul 2007) Log Message: ----------- Windows: Removed an unused parameter from WindowsDisplay.clipCursor Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java trunk/LWJGL/src/native/windows/org_lwjgl_opengl_Display.c Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java 2007-07-20 21:24:03 UTC (rev 2857) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java 2007-07-28 20:46:17 UTC (rev 2858) @@ -161,7 +161,7 @@ static void resetCursorClipping() { if (cursor_clipped) { try { - clipCursor(0, null); + clipCursor(null); } catch (LWJGLException e) { LWJGLUtil.log("Failed to reset cursor clipping: " + e); } @@ -192,9 +192,9 @@ cursor_clipped = true; getGlobalClientRect(hwnd, rect); rect.copyToBuffer(rect_buffer); - clipCursor(hwnd, rect_buffer); + clipCursor(rect_buffer); } - private static native void clipCursor(long hwnd, IntBuffer rect) throws LWJGLException; + private static native void clipCursor(IntBuffer rect) throws LWJGLException; public void switchDisplayMode(DisplayMode mode) throws LWJGLException { nSwitchDisplayMode(mode); Modified: trunk/LWJGL/src/native/windows/org_lwjgl_opengl_Display.c =================================================================== --- trunk/LWJGL/src/native/windows/org_lwjgl_opengl_Display.c 2007-07-20 21:24:03 UTC (rev 2857) +++ trunk/LWJGL/src/native/windows/org_lwjgl_opengl_Display.c 2007-07-28 20:46:17 UTC (rev 2858) @@ -257,8 +257,7 @@ buffer[3] = rect->right; } -JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_clipCursor(JNIEnv *env, jclass unused, jlong hwnd_ptr, jobject handle_buffer) { - HWND hwnd = (HWND)(INT_PTR)hwnd_ptr; +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_clipCursor(JNIEnv *env, jclass unused, jobject handle_buffer) { RECT clip_rect; LPRECT clip_rect_ptr; if (handle_buffer != NULL) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <eli...@us...> - 2007-12-13 09:29:42
|
Revision: 2928 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=2928&view=rev Author: elias_naur Date: 2007-12-13 01:29:36 -0800 (Thu, 13 Dec 2007) Log Message: ----------- Windows: Pulled DefWindowProc calling to java side Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/Sys.java trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java trunk/LWJGL/src/native/windows/org_lwjgl_opengl_Display.c Modified: trunk/LWJGL/src/java/org/lwjgl/Sys.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/Sys.java 2007-12-04 11:47:08 UTC (rev 2927) +++ trunk/LWJGL/src/java/org/lwjgl/Sys.java 2007-12-13 09:29:36 UTC (rev 2928) @@ -57,7 +57,7 @@ private static final String VERSION = "1.1.3"; /** Current version of the JNI library */ - static final int JNI_VERSION = 11; + static final int JNI_VERSION = 12; /** The implementation instance to delegate platform specific behavior to */ private final static SysImplementation implementation; Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java 2007-12-04 11:47:08 UTC (rev 2927) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java 2007-12-13 09:29:36 UTC (rev 2928) @@ -627,12 +627,14 @@ private static native void clientToScreen(long hwnd, IntBuffer point); - private static boolean handleMessage(long hwnd, int msg, long wParam, long lParam, long millis) { + private static int handleMessage(long hwnd, int msg, long wParam, long lParam, long millis) { if (current_display != null) return current_display.doHandleMessage(hwnd, msg, wParam, lParam, millis); else - return false; + return defWindowProc(hwnd, msg, wParam, lParam); } + + private static native int defWindowProc(long hwnd, int msg, long wParam, long lParam); private void checkCursorState() { updateCursor(); @@ -656,7 +658,7 @@ checkCursorState(); } - private boolean doHandleMessage(long hwnd, int msg, long wParam, long lParam, long millis) { + private int doHandleMessage(long hwnd, int msg, long wParam, long lParam, long millis) { switch (msg) { // disable screen saver and monitor power down messages which wreak havoc case WM_ACTIVATE: @@ -669,7 +671,7 @@ appActivate(false); break; } - return true; + return 0; case WM_SIZE: switch ((int)wParam) { case SIZE_RESTORED: @@ -680,39 +682,39 @@ setMinimized(true); break; } - return false; + return defWindowProc(hwnd, msg, wParam, lParam); case WM_MOUSEMOVE: int xPos = (int)(short)(lParam & 0xFFFF); int yPos = transformY(getHwnd(), (int)(short)((lParam >> 16) & 0xFFFF)); handleMouseMoved(xPos, yPos, millis); checkCursorState(); - return true; + return 0; case WM_MOUSEWHEEL: int dwheel = (int)(short)((wParam >> 16) & 0xFFFF); handleMouseScrolled(dwheel, millis); - return true; + return 0; case WM_LBUTTONDOWN: handleMouseButton(0, 1, millis); - return true; + return 0; case WM_LBUTTONUP: handleMouseButton(0, 0, millis); - return true; + return 0; case WM_RBUTTONDOWN: handleMouseButton(1, 1, millis); - return true; + return 0; case WM_RBUTTONUP: handleMouseButton(1, 0, millis); - return true; + return 0; case WM_MBUTTONDOWN: handleMouseButton(2, 1, millis); - return true; + return 0; case WM_MBUTTONUP: handleMouseButton(2, 0, millis); - return true; + return 0; case WM_SYSCHAR: case WM_CHAR: handleChar(wParam, lParam, millis); - return true; + return 0; case WM_SYSKEYUP: /* Fall through */ case WM_KEYUP: @@ -730,29 +732,29 @@ /* Fall through */ case WM_KEYDOWN: handleKeyButton(wParam, lParam, millis); - return false; + return defWindowProc(hwnd, msg, wParam, lParam); case WM_QUIT: close_requested = true; - return true; + return 0; case WM_SYSCOMMAND: switch ((int)(wParam & 0xfff0)) { case SC_KEYMENU: case SC_MOUSEMENU: case SC_SCREENSAVE: case SC_MONITORPOWER: - return true; + return 0; case SC_CLOSE: close_requested = true; - return true; + return 0; default: break; } - return false; + return defWindowProc(hwnd, msg, wParam, lParam); case WM_PAINT: is_dirty = true; - return false; + return defWindowProc(hwnd, msg, wParam, lParam); default: - return false; + return defWindowProc(hwnd, msg, wParam, lParam); } } Modified: trunk/LWJGL/src/native/windows/org_lwjgl_opengl_Display.c =================================================================== --- trunk/LWJGL/src/native/windows/org_lwjgl_opengl_Display.c 2007-12-04 11:47:08 UTC (rev 2927) +++ trunk/LWJGL/src/native/windows/org_lwjgl_opengl_Display.c 2007-12-13 09:29:36 UTC (rev 2928) @@ -117,15 +117,16 @@ } if (display_class_global != NULL) { message_time = GetMessageTime(); - handleMessage_method = (*env)->GetStaticMethodID(env, display_class_global, "handleMessage", "(JIJJJ)Z"); + handleMessage_method = (*env)->GetStaticMethodID(env, display_class_global, "handleMessage", "(JIJJJ)I"); if (handleMessage_method != NULL) - if ((*env)->CallStaticBooleanMethod(env, display_class_global, handleMessage_method, (jlong)(intptr_t)hWnd, (jint)msg, (jlong)wParam, (jlong)lParam, (jlong)message_time)) - return 0; + return (*env)->CallStaticIntMethod(env, display_class_global, handleMessage_method, (jlong)(intptr_t)hWnd, (jint)msg, (jlong)wParam, (jlong)lParam, (jlong)message_time); } } + return DefWindowProc(hWnd, msg, wParam, lParam); +} - // default action - return DefWindowProc(hWnd, msg, wParam, lParam); +JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_WindowsDisplay_defWindowProc(JNIEnv *env, jclass unused, jlong hWnd, jint msg, jlong wParam, jlong lParam) { + return DefWindowProc((HWND)(INT_PTR)hWnd, msg, wParam, lParam); } /* This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <eli...@us...> - 2008-01-07 18:29:06
|
Revision: 2930 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=2930&view=rev Author: elias_naur Date: 2008-01-07 10:29:04 -0800 (Mon, 07 Jan 2008) Log Message: ----------- Linux: use XkbSetDetectableAutoRepeat to detect repeated key events more reliably Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxKeyboard.java trunk/LWJGL/src/native/linux/org_lwjgl_opengl_LinuxKeyboard.c Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2008-01-06 21:33:34 UTC (rev 2929) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2008-01-07 18:29:04 UTC (rev 2930) @@ -857,7 +857,7 @@ public void destroyKeyboard() { lockAWT(); try { - keyboard.destroy(); + keyboard.destroy(getDisplay()); keyboard = null; } finally { unlockAWT(); Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxKeyboard.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxKeyboard.java 2008-01-06 21:33:34 UTC (rev 2929) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxKeyboard.java 2008-01-07 18:29:04 UTC (rev 2930) @@ -41,6 +41,7 @@ import java.nio.charset.CharsetDecoder; import org.lwjgl.BufferUtils; +import org.lwjgl.LWJGLUtil; import org.lwjgl.input.Keyboard; final class LinuxKeyboard { @@ -122,13 +123,14 @@ modeswitch_mask = tmp_modeswitch_mask; caps_lock_mask = tmp_caps_lock_mask; shift_lock_mask = tmp_shift_lock_mask; + setDetectableKeyRepeat(display, true); xim = openIM(display); if (xim != 0) { xic = createIC(xim, window); if (xic != 0) { setupIMEventMask(display, window, xic); } else { - destroy(); + destroy(display); } } else { xic = 0; @@ -146,11 +148,19 @@ private static native void setupIMEventMask(long display, long window, long xic); private static native ByteBuffer allocateComposeStatus(); - public void destroy() { + private static void setDetectableKeyRepeat(long display, boolean enabled) { + boolean success = nSetDetectableKeyRepeat(display, enabled); + if (!success) + LWJGLUtil.log("Failed to set detectable key repeat"); + } + private static native boolean nSetDetectableKeyRepeat(long display, boolean enabled); + + public void destroy(long display) { if (xic != 0) destroyIC(xic); if (xim != 0) closeIM(xim); + setDetectableKeyRepeat(display, false); } private static native void destroyIC(long xic); private static native void closeIM(long xim); @@ -300,10 +310,10 @@ private void handleKeyEvent(long event_ptr, long millis, int event_type, int event_keycode, int event_state) { int keycode = getKeycode(event_ptr, event_state); byte key_state = getKeyState(event_type); + boolean repeat = key_state == key_down_buffer[keycode]; key_down_buffer[keycode] = key_state; long nanos = millis*1000000; if (event_type == LinuxEvent.KeyPress) { - boolean repeat = false; if (has_deferred_event) { if (nanos == deferred_nanos && event_keycode == deferred_event_keycode) { has_deferred_event = false; Modified: trunk/LWJGL/src/native/linux/org_lwjgl_opengl_LinuxKeyboard.c =================================================================== --- trunk/LWJGL/src/native/linux/org_lwjgl_opengl_LinuxKeyboard.c 2008-01-06 21:33:34 UTC (rev 2929) +++ trunk/LWJGL/src/native/linux/org_lwjgl_opengl_LinuxKeyboard.c 2008-01-07 18:29:04 UTC (rev 2930) @@ -41,6 +41,7 @@ #include <X11/X.h> #include <X11/Xlib.h> +#include <X11/XKBlib.h> #include <X11/Xutil.h> #include <X11/keysym.h> #include "common_tools.h" @@ -52,6 +53,14 @@ return (intptr_t)modifier_map; } +JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_LinuxKeyboard_nSetDetectableKeyRepeat(JNIEnv *env, jclass unused, jlong display_ptr, jboolean set_enabled) { + Display *disp = (Display *)(intptr_t)display_ptr; + Bool result; + Bool enabled = set_enabled == JNI_TRUE ? True : False; + Bool success = XkbSetDetectableAutoRepeat(disp, enabled, &result); + return success && enabled == result ? JNI_TRUE : JNI_FALSE; +} + JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxKeyboard_freeModifierMapping(JNIEnv *env, jclass unused, jlong mapping_ptr) { XModifierKeymap *modifier_map = (XModifierKeymap *)(intptr_t)mapping_ptr; XFreeModifiermap(modifier_map); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <eli...@us...> - 2008-01-19 08:57:43
|
Revision: 2933 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=2933&view=rev Author: elias_naur Date: 2008-01-19 00:57:20 -0800 (Sat, 19 Jan 2008) Log Message: ----------- Linux: Fixed test for XkbSetDetectableAutoRepeat success Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxKeyboard.java trunk/LWJGL/src/native/linux/org_lwjgl_opengl_LinuxKeyboard.c Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxKeyboard.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxKeyboard.java 2008-01-19 08:49:10 UTC (rev 2932) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxKeyboard.java 2008-01-19 08:57:20 UTC (rev 2933) @@ -151,7 +151,7 @@ private static void setDetectableKeyRepeat(long display, boolean enabled) { boolean success = nSetDetectableKeyRepeat(display, enabled); if (!success) - LWJGLUtil.log("Failed to set detectable key repeat"); + LWJGLUtil.log("Failed to set detectable key repeat to " + enabled); } private static native boolean nSetDetectableKeyRepeat(long display, boolean enabled); Modified: trunk/LWJGL/src/native/linux/org_lwjgl_opengl_LinuxKeyboard.c =================================================================== --- trunk/LWJGL/src/native/linux/org_lwjgl_opengl_LinuxKeyboard.c 2008-01-19 08:49:10 UTC (rev 2932) +++ trunk/LWJGL/src/native/linux/org_lwjgl_opengl_LinuxKeyboard.c 2008-01-19 08:57:20 UTC (rev 2933) @@ -55,10 +55,9 @@ JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_LinuxKeyboard_nSetDetectableKeyRepeat(JNIEnv *env, jclass unused, jlong display_ptr, jboolean set_enabled) { Display *disp = (Display *)(intptr_t)display_ptr; - Bool result; Bool enabled = set_enabled == JNI_TRUE ? True : False; - Bool success = XkbSetDetectableAutoRepeat(disp, enabled, &result); - return success && enabled == result ? JNI_TRUE : JNI_FALSE; + Bool result = XkbSetDetectableAutoRepeat(disp, enabled, NULL); + return result == enabled ? JNI_TRUE : JNI_FALSE; } JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxKeyboard_freeModifierMapping(JNIEnv *env, jclass unused, jlong mapping_ptr) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <eli...@us...> - 2008-01-21 22:15:13
|
Revision: 2954 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=2954&view=rev Author: elias_naur Date: 2008-01-21 14:15:12 -0800 (Mon, 21 Jan 2008) Log Message: ----------- javdoc fixes Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/input/Keyboard.java trunk/LWJGL/src/java/org/lwjgl/input/Mouse.java trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java trunk/LWJGL/src/templates/org/lwjgl/openal/AL11.java trunk/LWJGL/src/templates/org/lwjgl/opengl/GL20.java Modified: trunk/LWJGL/src/java/org/lwjgl/input/Keyboard.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/input/Keyboard.java 2008-01-21 22:11:01 UTC (rev 2953) +++ trunk/LWJGL/src/java/org/lwjgl/input/Keyboard.java 2008-01-21 22:15:12 UTC (rev 2954) @@ -192,14 +192,14 @@ /** * The left windows key, mapped to KEY_LMETA * - * @Deprecated Use KEY_LMETA instead + * @deprecated Use KEY_LMETA instead */ public static final int KEY_LWIN = KEY_LMETA; /* Left Windows key */ public static final int KEY_RMETA = 0xDC; /* Right Windows/Option key */ /** * The right windows key, mapped to KEY_RMETA * - * @Deprecated Use KEY_RMETA instead + * @deprecated Use KEY_RMETA instead */ public static final int KEY_RWIN = KEY_RMETA; /* Right Windows key */ public static final int KEY_APPS = 0xDD; /* AppMenu key */ @@ -563,7 +563,7 @@ } /** - * @see org.lwjgl.input.Keyboard#enableRepeatEvents() + * @see org.lwjgl.input.Keyboard#enableRepeatEvents(boolean) * @return true if the current event is a repeat event, false if * the current event is not a repeat even or if repeat events are disabled. */ Modified: trunk/LWJGL/src/java/org/lwjgl/input/Mouse.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/input/Mouse.java 2008-01-21 22:11:01 UTC (rev 2953) +++ trunk/LWJGL/src/java/org/lwjgl/input/Mouse.java 2008-01-21 22:15:12 UTC (rev 2954) @@ -186,9 +186,9 @@ * Set the position of the cursor. If the cursor is not grabbed, * the native cursor is moved to the new position. * - * @param x The x coordinate of the new cursor position in OpenGL coordinates relative + * @param new_x The x coordinate of the new cursor position in OpenGL coordinates relative * to the window origin. - * @param y The y coordinate of the new cursor position in OpenGL coordinates relative + * @param new_y The y coordinate of the new cursor position in OpenGL coordinates relative * to the window origin. */ public static void setCursorPosition(int new_x, int new_y) { Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java 2008-01-21 22:11:01 UTC (rev 2953) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java 2008-01-21 22:15:12 UTC (rev 2954) @@ -899,7 +899,7 @@ * * A video frame period is the time required to display a full frame of video data. * - * @param sync true to synchronize; false to ignore synchronization + * @param value The swap interval in frames, 0 to disable */ public static void setSwapInterval(int value) { synchronized (GlobalLock.lock) { @@ -926,9 +926,9 @@ * The window is clamped to remain entirely on the screen. If you attempt * to position the window such that it would extend off the screen, the window * is simply placed as close to the edge as possible. - * <br><b>note</b>If no location has been specified (or x == y == -1) the window will be centered - * @param x The new window location on the x axis - * @param y The new window location on the y axis + * <br><b>note</b>If no location has been specified (or x == y == -1) the window will be centered + * @param new_x The new window location on the x axis + * @param new_y The new window location on the y axis */ public static void setLocation(int new_x, int new_y) { synchronized (GlobalLock.lock) { Modified: trunk/LWJGL/src/templates/org/lwjgl/openal/AL11.java =================================================================== --- trunk/LWJGL/src/templates/org/lwjgl/openal/AL11.java 2008-01-21 22:11:01 UTC (rev 2953) +++ trunk/LWJGL/src/templates/org/lwjgl/openal/AL11.java 2008-01-21 22:15:12 UTC (rev 2954) @@ -68,7 +68,7 @@ /** Type of source: when it has the NULL buffer attached */ public static final int AL_UNDETERMINED = 0x1030; - /** @see AL10.AL_INVALID_OPERATION */ + /** @see AL10#AL_INVALID_OPERATION */ public static final int AL_ILLEGAL_COMMAND = 0xA004; /** Speed of Sound in units per second */ Modified: trunk/LWJGL/src/templates/org/lwjgl/opengl/GL20.java =================================================================== --- trunk/LWJGL/src/templates/org/lwjgl/opengl/GL20.java 2008-01-21 22:11:01 UTC (rev 2953) +++ trunk/LWJGL/src/templates/org/lwjgl/opengl/GL20.java 2008-01-21 22:15:12 UTC (rev 2954) @@ -223,7 +223,6 @@ * @param program * @param name * - * @return */ int glGetUniformLocation(@GLuint int program, @NullTerminated @Check("1") @Const @GLchar ByteBuffer name); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <eli...@us...> - 2008-04-01 19:46:29
|
Revision: 2966 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=2966&view=rev Author: elias_naur Date: 2008-04-01 12:46:20 -0700 (Tue, 01 Apr 2008) Log Message: ----------- Linux: Added alpha mask support to Display.setIcon Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2008-03-23 15:51:10 UTC (rev 2965) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2008-04-01 19:46:20 UTC (rev 2966) @@ -962,8 +962,7 @@ throw new UnsupportedOperationException(); } - private static ByteBuffer convertIcon(ByteBuffer icon, int width, int height) { - ByteBuffer icon_copy = BufferUtils.createByteBuffer(icon.capacity()); + private static void convertIcon(ByteBuffer icon, int width, int height, ByteBuffer icon_rgb, ByteBuffer icon_mask) { int x = 0; int y = 5; byte r,g,b,a; @@ -977,13 +976,14 @@ b = icon.get((x*4)+(y*width*4)+2); a = icon.get((x*4)+(y*width*4)+3); - icon_copy.put((x*depth)+(y*width*depth), b); // blue - icon_copy.put((x*depth)+(y*width*depth)+1, g); // green - icon_copy.put((x*depth)+(y*width*depth)+2, r); - icon_copy.put((x*depth)+(y*width*depth)+3, a); + icon_rgb.put((x*depth)+(y*width*depth), b); // blue + icon_rgb.put((x*depth)+(y*width*depth)+1, g); // green + icon_rgb.put((x*depth)+(y*width*depth)+2, r); + icon_mask.put((x*depth)+(y*width*depth), a); + icon_mask.put((x*depth)+(y*width*depth)+1, a); + icon_mask.put((x*depth)+(y*width*depth)+2, a); } } - return icon_copy; } /** @@ -1006,8 +1006,11 @@ for (int i=0;i<icons.length;i++) { int size = icons[i].limit() / 4; int dimension = (int)Math.sqrt(size); - ByteBuffer icon = convertIcon(icons[i], dimension, dimension); - nSetWindowIcon(getDisplay(), getWindow(), icon, icon.capacity(), dimension, dimension); + int cap = icons[i].capacity(); + ByteBuffer icon_rgb = BufferUtils.createByteBuffer(cap); + ByteBuffer icon_mask = BufferUtils.createByteBuffer(cap); + convertIcon(icons[i], dimension, dimension, icon_rgb, icon_mask); + nSetWindowIcon(getDisplay(), getWindow(), icon_rgb, icon_mask, cap, dimension, dimension); return 1; } return 0; @@ -1022,7 +1025,7 @@ } } - private static native void nSetWindowIcon(long display, long window, ByteBuffer icon, int icons_size, int width, int height); + private static native void nSetWindowIcon(long display, long window, ByteBuffer icon_rgb, ByteBuffer icon_mask, int icon_size, int width, int height); public int getWidth() { return Display.getDisplayMode().getWidth(); Modified: trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c =================================================================== --- trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c 2008-03-23 15:51:10 UTC (rev 2965) +++ trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c 2008-04-01 19:46:20 UTC (rev 2966) @@ -72,6 +72,7 @@ static Colormap cmap; static int current_depth; static Pixmap current_icon_pixmap; +static Pixmap current_icon_mask_pixmap; static Visual *current_visual; @@ -185,6 +186,10 @@ } static void freeIconPixmap(Display *disp) { + if (current_icon_mask_pixmap != 0) { + XFreePixmap(disp, current_icon_mask_pixmap); + current_icon_mask_pixmap = 0; + } if (current_icon_pixmap != 0) { XFreePixmap(disp, current_icon_pixmap); current_icon_pixmap = 0; @@ -349,33 +354,46 @@ jawt.Unlock(env); } -static void setIcon(JNIEnv *env, Display *disp, Window window, char *data, int icon_size, int width,int height) { - XWMHints* win_hints; - freeIconPixmap(disp); - current_icon_pixmap = XCreatePixmap(disp, window, width, height, current_depth); +static Pixmap createPixmapFromBuffer(JNIEnv *env, Display *disp, Window window, char *data, int data_size, int width, int height) { + Pixmap pixmap = XCreatePixmap(disp, window, width, height, current_depth); /* We need to copy the image data since XDestroyImage will also free its data buffer, which can't be allowed * since the data buffer is managed by the jvm (it's the storage for the direct ByteBuffer) */ - char *icon_copy = (char *)malloc(sizeof(*icon_copy)*icon_size); + char *icon_copy = (char *)malloc(sizeof(*icon_copy)*data_size); if (icon_copy == NULL) { + XFreePixmap(disp, pixmap); throwException(env, "malloc failed"); - return; + return 0; } - memcpy(icon_copy, data, icon_size); + memcpy(icon_copy, data, data_size); XImage *image = XCreateImage(disp, current_visual, current_depth, ZPixmap, 0, icon_copy, width, height, 32, 0); if (image == NULL) { - freeIconPixmap(disp); + XFreePixmap(disp, pixmap); free(icon_copy); throwException(env, "XCreateImage failed"); - return; + return 0; } - GC gc = XCreateGC(disp, current_icon_pixmap, 0, NULL); - XPutImage(disp, current_icon_pixmap, gc, image, 0, 0, 0, 0, width, height); + GC gc = XCreateGC(disp, pixmap, 0, NULL); + XPutImage(disp, pixmap, gc, image, 0, 0, 0, 0, width, height); XFreeGC(disp, gc); XDestroyImage(image); // We won't free icon_copy because it is freed by XDestroyImage + return pixmap; +} + +static void setIcon(JNIEnv *env, Display *disp, Window window, char *rgb_data, char *mask_data, int icon_size, int width, int height) { + XWMHints* win_hints; + freeIconPixmap(disp); + current_icon_pixmap = createPixmapFromBuffer(env, disp, window, rgb_data, icon_size, width, height); + if ((*env)->ExceptionCheck(env)) + return; + current_icon_mask_pixmap = createPixmapFromBuffer(env, disp, window, mask_data, icon_size, width, height); + if ((*env)->ExceptionCheck(env)) { + freeIconPixmap(disp); + return; + } win_hints = XAllocWMHints(); if (win_hints == NULL) { @@ -383,8 +401,9 @@ return; } - win_hints->flags = IconPixmapHint; + win_hints->flags = IconPixmapHint | IconMaskHint; win_hints->icon_pixmap = current_icon_pixmap; + win_hints->icon_mask = current_icon_mask_pixmap; XSetWMHints(disp, window, win_hints); XFree(win_hints); @@ -392,13 +411,14 @@ } JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nSetWindowIcon - (JNIEnv *env, jclass clazz, jlong display, jlong window_ptr, jobject iconBuffer, jint icon_size, jint width, jint height) + (JNIEnv *env, jclass clazz, jlong display, jlong window_ptr, jobject icon_rgb_buffer, jobject icon_mask_buffer, jint icon_size, jint width, jint height) { Display *disp = (Display *)(intptr_t)display; Window window = (Window)window_ptr; - char *imgData = (char *)(*env)->GetDirectBufferAddress(env, iconBuffer); + char *rgb_data= (char *)(*env)->GetDirectBufferAddress(env, icon_rgb_buffer); + char *mask_data= (char *)(*env)->GetDirectBufferAddress(env, icon_mask_buffer); - setIcon(env, disp, window, imgData, icon_size, width, height); + setIcon(env, disp, window, rgb_data, mask_data, icon_size, width, height); } JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nUngrabKeyboard(JNIEnv *env, jclass unused, jlong display_ptr) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <eli...@us...> - 2008-04-01 20:45:26
|
Revision: 2967 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=2967&view=rev Author: elias_naur Date: 2008-04-01 13:45:24 -0700 (Tue, 01 Apr 2008) Log Message: ----------- Windows: Moved Display.setIcon logic to java Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java trunk/LWJGL/src/native/windows/org_lwjgl_opengl_Display.c Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java 2008-04-01 19:46:20 UTC (rev 2966) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java 2008-04-01 20:45:24 UTC (rev 2967) @@ -550,31 +550,33 @@ * @return number of icons used. */ public int setIcon(ByteBuffer[] icons) { - boolean done16 = false; - boolean done32 = false; + boolean done_small = false; + boolean done_large = false; int used = 0; + int small_icon_size = 16; + int large_icon_size = 32; for (int i=0;i<icons.length;i++) { int size = icons[i].limit() / 4; - if ((((int) Math.sqrt(size)) == 16) && (!done16)) { - nSetWindowIcon16(icons[i].asIntBuffer()); + if ((((int) Math.sqrt(size)) == small_icon_size) && (!done_small)) { + nSetWindowIconSmall(small_icon_size, small_icon_size, icons[i].asIntBuffer()); used++; - done16 = true; + done_small = true; } - if ((((int) Math.sqrt(size)) == 32) && (!done32)) { - nSetWindowIcon32(icons[i].asIntBuffer()); + if ((((int) Math.sqrt(size)) == large_icon_size) && (!done_large)) { + nSetWindowIconLarge(large_icon_size, large_icon_size, icons[i].asIntBuffer()); used++; - done32 = true; + done_large = true; } } return used; } - private static native int nSetWindowIcon16(IntBuffer icon); + private static native int nSetWindowIconSmall(int width, int height, IntBuffer icon); - private static native int nSetWindowIcon32(IntBuffer icon); + private static native int nSetWindowIconLarge(int width, int height, IntBuffer icon); private void handleMouseButton(int button, int state, long millis) { if (mouse != null) Modified: trunk/LWJGL/src/native/windows/org_lwjgl_opengl_Display.c =================================================================== --- trunk/LWJGL/src/native/windows/org_lwjgl_opengl_Display.c 2008-04-01 19:46:20 UTC (rev 2966) +++ trunk/LWJGL/src/native/windows/org_lwjgl_opengl_Display.c 2008-04-01 20:45:24 UTC (rev 2967) @@ -462,13 +462,13 @@ return icon; } -JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nSetWindowIcon16 - (JNIEnv *env, jclass clazz, jobject iconBuffer) +JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nSetWindowIconSmall + (JNIEnv *env, jclass clazz, jint width, jint height, jobject iconBuffer) { jint *imgData = (jint *)(*env)->GetDirectBufferAddress(env, iconBuffer); freeSmallIcon(); - small_icon = createWindowIcon(env, imgData, 16, 16); + small_icon = createWindowIcon(env, imgData, width, height); if (small_icon != NULL) { if (display_hwnd != NULL) { SendMessage(display_hwnd, WM_SETICON, ICON_SMALL, (LPARAM) (small_icon)); @@ -480,13 +480,13 @@ return -1; } -JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nSetWindowIcon32 - (JNIEnv *env, jclass clazz, jobject iconBuffer) +JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nSetWindowIconLarge + (JNIEnv *env, jclass clazz, jint width, jint height, jobject iconBuffer) { jint *imgData = (jint *)(*env)->GetDirectBufferAddress(env, iconBuffer); freeLargeIcon(); - large_icon = createWindowIcon(env, imgData, 32, 32); + large_icon = createWindowIcon(env, imgData, width, height); if (large_icon != NULL) { if (display_hwnd != NULL) { SendMessage(display_hwnd, WM_SETICON, ICON_BIG, (LPARAM) (large_icon)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <eli...@us...> - 2008-04-06 20:56:54
|
Revision: 2969 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=2969&view=rev Author: elias_naur Date: 2008-04-06 13:56:52 -0700 (Sun, 06 Apr 2008) Log Message: ----------- Added experimental Display.setParent to allow Display to be embedded in an AWT Canvas. Added basic linux implementation and test. Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/opengl/AWTCanvasImplementation.java trunk/LWJGL/src/java/org/lwjgl/opengl/AWTSurfaceLock.java trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java trunk/LWJGL/src/java/org/lwjgl/opengl/DisplayImplementation.java trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxAWTGLCanvasPeerInfo.java trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxCanvasImplementation.java trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXAWTGLCanvasPeerInfo.java trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXCanvasImplementation.java trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXCanvasPeerInfo.java trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsAWTGLCanvasPeerInfo.java trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsCanvasImplementation.java trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c Added Paths: ----------- trunk/LWJGL/src/java/org/lwjgl/test/opengl/awt/DisplayParentTest.java Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/AWTCanvasImplementation.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/AWTCanvasImplementation.java 2008-04-06 14:39:32 UTC (rev 2968) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/AWTCanvasImplementation.java 2008-04-06 20:56:52 UTC (rev 2969) @@ -33,7 +33,7 @@ import java.awt.GraphicsConfiguration; import java.awt.GraphicsDevice; -import java.awt.Component; +import java.awt.Canvas; import org.lwjgl.LWJGLException; @@ -47,7 +47,7 @@ /** * Return an opaque handle to the canvas peer information required to create a context from it. */ - PeerInfo createPeerInfo(Component component, PixelFormat pixel_format) throws LWJGLException; + PeerInfo createPeerInfo(Canvas component, PixelFormat pixel_format) throws LWJGLException; /** * Find a proper GraphicsConfiguration from the given GraphicsDevice and PixelFormat. Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/AWTSurfaceLock.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/AWTSurfaceLock.java 2008-04-06 14:39:32 UTC (rev 2968) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/AWTSurfaceLock.java 2008-04-06 20:56:52 UTC (rev 2969) @@ -31,7 +31,7 @@ */ package org.lwjgl.opengl; -import java.awt.Component; +import java.awt.Canvas; import java.nio.ByteBuffer; import java.security.AccessController; import java.security.PrivilegedActionException; @@ -60,7 +60,7 @@ private static native ByteBuffer createHandle(); - public ByteBuffer lockAndGetHandle(Component component) throws LWJGLException { + public ByteBuffer lockAndGetHandle(Canvas component) throws LWJGLException { while (!privilegedLockAndInitHandle(component)) { LWJGLUtil.log("Could not get drawing surface info, retrying..."); try { @@ -73,12 +73,12 @@ return lock_buffer; } - private boolean privilegedLockAndInitHandle(final Component component) throws LWJGLException { + private boolean privilegedLockAndInitHandle(final Canvas component) throws LWJGLException { // Workaround for Sun JDK bug 4796548 which still exists in java for OS X // We need to elevate privileges because of an AWT bug. Please see // http://192.18.37.44/forums/index.php?topic=10572 for a discussion. // It is only needed on first call, so we avoid it on all subsequent calls - // due to performance. + // due to performance. if (firstLockSucceeded) return lockAndInitHandle(lock_buffer, component); else @@ -96,7 +96,7 @@ } } - private static native boolean lockAndInitHandle(ByteBuffer lock_buffer, Component component) throws LWJGLException; + private static native boolean lockAndInitHandle(ByteBuffer lock_buffer, Canvas component) throws LWJGLException; protected void unlock() throws LWJGLException { nUnlock(lock_buffer); Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java 2008-04-06 14:39:32 UTC (rev 2968) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java 2008-04-06 20:56:52 UTC (rev 2969) @@ -49,6 +49,7 @@ import java.security.PrivilegedAction; import java.util.Arrays; import java.util.HashSet; +import java.awt.Canvas; import org.lwjgl.BufferUtils; import org.lwjgl.LWJGLException; @@ -71,6 +72,9 @@ /** The initial display mode */ private static final DisplayMode initial_mode; + /** The parent, if any */ + private static Canvas parent; + /** The current display mode, if created */ private static DisplayMode current_mode; @@ -244,7 +248,7 @@ } int window_x; int window_y; - if (!fullscreen) { + if (!fullscreen && parent == null) { // if no display location set, center window if (x == -1 && y == -1) { window_x = Math.max(0, (initial_mode.getWidth() - current_mode.getWidth()) / 2); @@ -257,7 +261,10 @@ window_x = 0; window_y = 0; } - display_impl.createWindow(current_mode, fullscreen, window_x, window_y); + Canvas tmp_parent = fullscreen ? null : parent; + if (tmp_parent != null && !tmp_parent.isDisplayable()) // Only a best effort check, since the parent can turn undisplayable hereafter + throw new LWJGLException("Parent.isDisplayable() must be true"); + display_impl.createWindow(current_mode, fullscreen, tmp_parent, window_x, window_y); window_created = true; setTitle(title); @@ -465,6 +472,50 @@ } /** + * Return the last parent set with setParent(). + */ + public static Canvas getParent() { + synchronized (GlobalLock.lock) { + return parent; + } + } + + /** + * Set the parent of the Display. If parent is null, the Display will appear as a top level window. + * If parent is not null, the Display is made a child of the parent. A parent's isDisplayable() must be true when + * setParent() is called and remain true until setParent() is called again with + * null or a different parent. This generally means that the parent component must remain added to it's parent container.<p> + * It is not advisable to call this method from an AWT thread, since the context will be made current on the thread + * and it is difficult to predict which AWT thread will process any given AWT event.<p> + * If the Display is in fullscreen mode, the current parent will be ignored. + * + */ + public static void setParent(Canvas parent) throws LWJGLException { + synchronized (GlobalLock.lock) { + if (Display.parent != parent) { + Display.parent = parent; + if (!isCreated()) + return; + destroyWindow(); + try { + if (fullscreen) { + switchDisplayMode(); + } else { + display_impl.resetDisplayMode(); + } + createWindow(); + makeCurrentAndSetSwapInterval(); + } catch (LWJGLException e) { + destroyContext(); + destroyPeerInfo(); + display_impl.resetDisplayMode(); + throw e; + } + } + } + } + + /** * Set the fullscreen mode of the context. If no context has been created through create(), * the mode will apply when create() is called. If fullscreen is true, the context will become * a fullscreen context and the display mode is switched to the mode given by getDisplayMode(). If @@ -914,7 +965,7 @@ } /** - * Set the window's location. This is a no-op on fullscreen windows. + * Set the window's location. This is a no-op on fullscreen windows or when getParent() != null. * The window is clamped to remain entirely on the screen. If you attempt * to position the window such that it would extend off the screen, the window * is simply placed as close to the edge as possible. Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/DisplayImplementation.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/DisplayImplementation.java 2008-04-06 14:39:32 UTC (rev 2968) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/DisplayImplementation.java 2008-04-06 20:56:52 UTC (rev 2969) @@ -41,12 +41,13 @@ import java.nio.ByteBuffer; import java.nio.FloatBuffer; import java.nio.IntBuffer; +import java.awt.Canvas; import org.lwjgl.LWJGLException; interface DisplayImplementation extends InputImplementation { - void createWindow(DisplayMode mode, boolean fullscreen, int x, int y) throws LWJGLException; + void createWindow(DisplayMode mode, boolean fullscreen, Canvas parent, int x, int y) throws LWJGLException; void destroyWindow(); Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxAWTGLCanvasPeerInfo.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxAWTGLCanvasPeerInfo.java 2008-04-06 14:39:32 UTC (rev 2968) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxAWTGLCanvasPeerInfo.java 2008-04-06 20:56:52 UTC (rev 2969) @@ -35,7 +35,7 @@ import org.lwjgl.LWJGLException; import org.lwjgl.LWJGLUtil; -import java.awt.Component; +import java.awt.Canvas; /** * @@ -44,11 +44,11 @@ * $Id$ */ final class LinuxAWTGLCanvasPeerInfo extends LinuxPeerInfo { - private final Component component; + private final Canvas component; private final AWTSurfaceLock awt_surface = new AWTSurfaceLock(); private int screen = -1; - public LinuxAWTGLCanvasPeerInfo(Component component) { + public LinuxAWTGLCanvasPeerInfo(Canvas component) { this.component = component; } Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxCanvasImplementation.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxCanvasImplementation.java 2008-04-06 14:39:32 UTC (rev 2968) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxCanvasImplementation.java 2008-04-06 20:56:52 UTC (rev 2969) @@ -33,7 +33,7 @@ import java.awt.GraphicsConfiguration; import java.awt.GraphicsDevice; -import java.awt.Component; +import java.awt.Canvas; import java.lang.reflect.Method; import java.security.AccessController; import java.security.PrivilegedExceptionAction; @@ -76,7 +76,7 @@ } } - public PeerInfo createPeerInfo(Component component, PixelFormat pixel_format) throws LWJGLException { + public PeerInfo createPeerInfo(Canvas component, PixelFormat pixel_format) throws LWJGLException { return new LinuxAWTGLCanvasPeerInfo(component); } Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2008-04-06 14:39:32 UTC (rev 2968) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2008-04-06 20:56:52 UTC (rev 2969) @@ -42,6 +42,8 @@ import java.nio.FloatBuffer; import java.nio.IntBuffer; +import java.awt.Canvas; + import org.lwjgl.BufferUtils; import org.lwjgl.LWJGLException; import org.lwjgl.LWJGLUtil; @@ -103,6 +105,7 @@ private boolean focused_at_least_once; private long current_cursor; private long blank_cursor; + private Canvas parent; private LinuxKeyboard keyboard; private LinuxMouse mouse; @@ -357,7 +360,7 @@ ungrabKeyboard(); } - public void createWindow(DisplayMode mode, boolean fullscreen, int x, int y) throws LWJGLException { + public void createWindow(DisplayMode mode, boolean fullscreen, Canvas parent, int x, int y) throws LWJGLException { lockAWT(); try { incDisplay(); @@ -365,7 +368,10 @@ ByteBuffer handle = peer_info.lockAndGetHandle(); try { current_window_mode = getWindowMode(fullscreen); - current_window = nCreateWindow(getDisplay(), getDefaultScreen(), handle, mode, current_window_mode, x, y); + boolean undecorated = Display.getPrivilegedBoolean("org.lwjgl.opengl.Window.undecorated") || current_window_mode != WINDOWED; + this.parent = parent; + long parent_window = parent != null ? getHandle(parent) : getRootWindow(getDisplay(), getDefaultScreen()); + current_window = nCreateWindow(getDisplay(), getDefaultScreen(), handle, mode, current_window_mode, x, y, undecorated, parent_window); blank_cursor = createBlankCursor(); current_cursor = None; focused = true; @@ -388,8 +394,20 @@ unlockAWT(); } } - private static native long nCreateWindow(long display, int screen, ByteBuffer peer_info_handle, DisplayMode mode, int window_mode, int x, int y) throws LWJGLException; + private static native long nCreateWindow(long display, int screen, ByteBuffer peer_info_handle, DisplayMode mode, int window_mode, int x, int y, boolean undecorated, long parent_handle) throws LWJGLException; + private static native long getRootWindow(long display, int screen); + private static long getHandle(Canvas parent) throws LWJGLException { + AWTCanvasImplementation awt_impl = AWTGLCanvas.createImplementation(); + LinuxPeerInfo parent_peer_info = (LinuxPeerInfo)awt_impl.createPeerInfo(parent, null); + ByteBuffer parent_peer_info_handle = parent_peer_info.lockAndGetHandle(); + try { + return parent_peer_info.getDrawable(); + } finally { + parent_peer_info.unlock(); + } + } + private void updateInputGrab() { updatePointerGrab(); updateKeyboardGrab(); @@ -602,7 +620,11 @@ return peer_info; } + private native static void setInputFocus(long display, long window); + private void processEvents() { + if (!focused && parent != null && parent.isFocusOwner()) + setInputFocus(getDisplay(), getWindow()); while (LinuxEvent.getPending(getDisplay()) > 0) { event_buffer.nextEvent(getDisplay()); long event_window = event_buffer.getWindow(); Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXAWTGLCanvasPeerInfo.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXAWTGLCanvasPeerInfo.java 2008-04-06 14:39:32 UTC (rev 2968) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXAWTGLCanvasPeerInfo.java 2008-04-06 20:56:52 UTC (rev 2969) @@ -33,7 +33,7 @@ import org.lwjgl.LWJGLException; -import java.awt.Component; +import java.awt.Canvas; /** * @@ -42,9 +42,9 @@ * $Id$ */ final class MacOSXAWTGLCanvasPeerInfo extends MacOSXCanvasPeerInfo { - private final Component component; + private final Canvas component; - public MacOSXAWTGLCanvasPeerInfo(Component component, PixelFormat pixel_format, boolean support_pbuffer) throws LWJGLException { + public MacOSXAWTGLCanvasPeerInfo(Canvas component, PixelFormat pixel_format, boolean support_pbuffer) throws LWJGLException { super(pixel_format, support_pbuffer); this.component = component; } Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXCanvasImplementation.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXCanvasImplementation.java 2008-04-06 14:39:32 UTC (rev 2968) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXCanvasImplementation.java 2008-04-06 20:56:52 UTC (rev 2969) @@ -33,7 +33,7 @@ import java.awt.GraphicsConfiguration; import java.awt.GraphicsDevice; -import java.awt.Component; +import java.awt.Canvas; import org.lwjgl.LWJGLException; @@ -44,7 +44,7 @@ * $Id$ */ final class MacOSXCanvasImplementation implements AWTCanvasImplementation { - public PeerInfo createPeerInfo(Component component, PixelFormat pixel_format) throws LWJGLException { + public PeerInfo createPeerInfo(Canvas component, PixelFormat pixel_format) throws LWJGLException { try { return new MacOSXAWTGLCanvasPeerInfo(component, pixel_format, true); } catch (LWJGLException e) { Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXCanvasPeerInfo.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXCanvasPeerInfo.java 2008-04-06 14:39:32 UTC (rev 2968) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXCanvasPeerInfo.java 2008-04-06 20:56:52 UTC (rev 2969) @@ -31,7 +31,7 @@ */ package org.lwjgl.opengl; -import java.awt.Component; +import java.awt.Canvas; import java.nio.ByteBuffer; import org.lwjgl.LWJGLException; @@ -49,7 +49,7 @@ super(pixel_format, true, true, support_pbuffer, true); } - protected void initHandle(Component component) throws LWJGLException { + protected void initHandle(Canvas component) throws LWJGLException { nInitHandle(awt_surface.lockAndGetHandle(component), getHandle()); } private static native void nInitHandle(ByteBuffer surface_buffer, ByteBuffer peer_info_handle) throws LWJGLException; Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java 2008-04-06 14:39:32 UTC (rev 2968) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java 2008-04-06 20:56:52 UTC (rev 2969) @@ -39,6 +39,7 @@ */ import java.awt.Cursor; +import java.awt.Canvas; import java.awt.Robot; import java.lang.reflect.InvocationHandler; import java.lang.reflect.Method; @@ -73,7 +74,7 @@ new MacOSXApplicationListener(); } - public void createWindow(DisplayMode mode, boolean fullscreen, int x, int y) throws LWJGLException { + public void createWindow(DisplayMode mode, boolean fullscreen, Canvas parent, int x, int y) throws LWJGLException { hideUI(fullscreen); close_requested = false; try { Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsAWTGLCanvasPeerInfo.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsAWTGLCanvasPeerInfo.java 2008-04-06 14:39:32 UTC (rev 2968) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsAWTGLCanvasPeerInfo.java 2008-04-06 20:56:52 UTC (rev 2969) @@ -35,7 +35,7 @@ import org.lwjgl.LWJGLException; -import java.awt.Component; +import java.awt.Canvas; /** * @@ -44,12 +44,12 @@ * $Id$ */ final class WindowsAWTGLCanvasPeerInfo extends WindowsPeerInfo { - private final Component component; + private final Canvas component; private final AWTSurfaceLock awt_surface = new AWTSurfaceLock(); private final PixelFormat pixel_format; private boolean has_pixel_format= false; - public WindowsAWTGLCanvasPeerInfo(Component component, PixelFormat pixel_format) { + public WindowsAWTGLCanvasPeerInfo(Canvas component, PixelFormat pixel_format) { this.component = component; this.pixel_format = pixel_format; } Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsCanvasImplementation.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsCanvasImplementation.java 2008-04-06 14:39:32 UTC (rev 2968) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsCanvasImplementation.java 2008-04-06 20:56:52 UTC (rev 2969) @@ -34,7 +34,7 @@ import java.awt.GraphicsConfiguration; import java.awt.GraphicsDevice; import java.awt.Toolkit; -import java.awt.Component; +import java.awt.Canvas; import java.security.PrivilegedAction; import java.security.AccessController; @@ -70,7 +70,7 @@ return new WindowsAWTInput(canvas); } - public PeerInfo createPeerInfo(Component component, PixelFormat pixel_format) throws LWJGLException { + public PeerInfo createPeerInfo(Canvas component, PixelFormat pixel_format) throws LWJGLException { return new WindowsAWTGLCanvasPeerInfo(component, pixel_format); } Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java 2008-04-06 14:39:32 UTC (rev 2968) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java 2008-04-06 20:56:52 UTC (rev 2969) @@ -41,6 +41,7 @@ import java.nio.ByteBuffer; import java.nio.FloatBuffer; import java.nio.IntBuffer; +import java.awt.Canvas; import org.lwjgl.LWJGLException; import org.lwjgl.LWJGLUtil; @@ -139,7 +140,7 @@ current_display = this; } - public void createWindow(DisplayMode mode, boolean fullscreen, int x, int y) throws LWJGLException { + public void createWindow(DisplayMode mode, boolean fullscreen, Canvas container, int x, int y) throws LWJGLException { close_requested = false; is_dirty = false; isFullscreen = fullscreen; Copied: trunk/LWJGL/src/java/org/lwjgl/test/opengl/awt/DisplayParentTest.java (from rev 2967, trunk/LWJGL/src/java/org/lwjgl/test/opengl/awt/AWTTest.java) =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/test/opengl/awt/DisplayParentTest.java (rev 0) +++ trunk/LWJGL/src/java/org/lwjgl/test/opengl/awt/DisplayParentTest.java 2008-04-06 20:56:52 UTC (rev 2969) @@ -0,0 +1,122 @@ +/* + * Copyright (c) 2002-2005 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions 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 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package org.lwjgl.test.opengl.awt; + +import java.awt.Frame; +import java.awt.Graphics; +import java.awt.GridLayout; +import java.awt.Container; +import java.awt.Component; +import java.awt.Canvas; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; + +import org.lwjgl.LWJGLException; +import org.lwjgl.opengl.AWTGLCanvas; +import org.lwjgl.opengl.GL11; +import org.lwjgl.input.Keyboard; +import org.lwjgl.input.Mouse; +import org.lwjgl.util.glu.GLU; +import org.lwjgl.opengl.Display; +import org.lwjgl.opengl.DisplayMode; + +/** + * <p> + * Tests Display.setParent() + * <p> + * @version $Revision$ + * @author $Author$ + * $Id$ + */ +public class DisplayParentTest extends Frame { + public DisplayParentTest() throws LWJGLException { + setTitle("LWJGL Display Parent Test"); + setSize(640, 320); + setLayout(new GridLayout(1, 2)); + final Canvas display_parent = new Canvas(); + display_parent.setFocusable(true); + add(display_parent); + addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent e) { + dispose(); + } + }); + setResizable(true); + setVisible(true); + Display.setParent(display_parent); + Display.create(); + float angle = 0f; + + int current_height = 0; + int current_width = 0; + while (isVisible()) { + angle += 1.0f; + if (getWidth() != current_width || getHeight() != current_height) { + current_width = getWidth(); + current_height = getHeight(); + Display.setDisplayMode(new DisplayMode(getWidth(), getHeight())); + GL11.glViewport(0, 0, current_width, current_height); + } + GL11.glViewport(0, 0, getWidth(), getHeight()); + GL11.glClearColor(0.0f, 1.0f, 0.0f, 1.0f); + GL11.glClear(GL11.GL_COLOR_BUFFER_BIT); + GL11.glMatrixMode(GL11.GL_PROJECTION); + GL11.glLoadIdentity(); + GLU.gluOrtho2D(0.0f, (float) getWidth(), 0.0f, (float) getHeight()); + GL11.glMatrixMode(GL11.GL_MODELVIEW); + GL11.glPushMatrix(); + GL11.glTranslatef(getWidth() / 2.0f, getHeight() / 2.0f, 0.0f); + GL11.glRotatef(2*angle, 0f, 0f, -1.0f); + GL11.glRectf(-50.0f, -50.0f, 50.0f, 50.0f); + GL11.glPopMatrix(); + Display.update(); + while(Keyboard.next()) { + // closing on ESCAPE + if(Keyboard.getEventKey() == Keyboard.KEY_ESCAPE && Keyboard.getEventKeyState()) { + dispose(); + } + + if(Keyboard.getEventKey() == Keyboard.KEY_SPACE && Keyboard.getEventKeyState()) { + Mouse.setGrabbed(!Mouse.isGrabbed()); + } + } +/* while (Mouse.next()) { +System.out.println(" Mouse.getEventX() = " + Mouse.getEventX() + " | Mouse.getEventY() = " + Mouse.getEventY()); + }*/ + } + System.exit(0); + } + + public static void main(String[] args) throws LWJGLException { + new DisplayParentTest(); + } +} Modified: trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c =================================================================== --- trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c 2008-04-06 14:39:32 UTC (rev 2968) +++ trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c 2008-04-06 20:56:52 UTC (rev 2969) @@ -242,18 +242,44 @@ XMoveWindow(disp, window, x, y); } -static Window createWindow(JNIEnv* env, Display *disp, int screen, jint window_mode, X11PeerInfo *peer_info, int x, int y, int width, int height) { - bool undecorated = getBooleanProperty(env, "org.lwjgl.opengl.Window.undecorated"); - Window root_win; +JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxDisplay_getRootWindow(JNIEnv *env, jclass clazz, jlong display, jint screen) { + Display *disp = (Display *)(intptr_t)display; + return RootWindow(disp, screen); +} + +static void updateWindowHints(JNIEnv *env, Display *disp, Window window) { + XWMHints* win_hints = XAllocWMHints(); + if (win_hints == NULL) { + throwException(env, "XAllocWMHints failed"); + return; + } + + win_hints->flags = InputHint; + win_hints->input = True; + if (current_icon_pixmap != 0) { + win_hints->flags |= IconPixmapHint; + win_hints->icon_pixmap = current_icon_pixmap; + } + if (current_icon_mask_pixmap != 0) { + win_hints->flags |= IconMaskHint; + win_hints->icon_mask = current_icon_mask_pixmap; + } + + XSetWMHints(disp, window, win_hints); + XFree(win_hints); + XFlush(disp); +} + +static Window createWindow(JNIEnv* env, Display *disp, int screen, jint window_mode, X11PeerInfo *peer_info, int x, int y, int width, int height, jboolean undecorated, long parent_handle) { + Window parent = (Window)parent_handle; Window win; XSetWindowAttributes attribs; int attribmask; - root_win = RootWindow(disp, screen); XVisualInfo *vis_info = getVisualInfoFromPeerInfo(env, peer_info); if (vis_info == NULL) return false; - cmap = XCreateColormap(disp, root_win, vis_info->visual, AllocNone); + cmap = XCreateColormap(disp, parent, vis_info->visual, AllocNone); attribs.colormap = cmap; attribs.event_mask = ExposureMask | /*FocusChangeMask | */VisibilityChangeMask | StructureNotifyMask | KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask | PointerMotionMask; attribmask = CWColormap | CWEventMask; @@ -261,7 +287,7 @@ attribmask |= CWOverrideRedirect; attribs.override_redirect = True; } - win = XCreateWindow(disp, root_win, x, y, width, height, 0, vis_info->depth, InputOutput, vis_info->visual, attribmask, &attribs); + win = XCreateWindow(disp, parent, x, y, width, height, 0, vis_info->depth, InputOutput, vis_info->visual, attribmask, &attribs); current_depth = vis_info->depth; current_visual = vis_info->visual; @@ -271,8 +297,8 @@ XFreeColormap(disp, cmap); return false; } - printfDebugJava(env, "Created window"); - if (window_mode != org_lwjgl_opengl_LinuxDisplay_WINDOWED || undecorated) { +// printfDebugJava(env, "Created window"); + if (undecorated) { // Use Motif decoration hint property and hope the window manager respects them setDecorations(disp, win, 0); } @@ -283,9 +309,11 @@ size_hints->min_height = height; size_hints->max_height = height; XSetWMNormalHints(disp, win, size_hints); + updateWindowHints(env, disp, win); XFree(size_hints); - Atom delete_atom = XInternAtom(disp, "WM_DELETE_WINDOW", False); - XSetWMProtocols(disp, win, &delete_atom, 1); +#define NUM_ATOMS 1 + Atom protocol_atoms[NUM_ATOMS] = {XInternAtom(disp, "WM_DELETE_WINDOW", False)/*, XInternAtom(disp, "WM_TAKE_FOCUS", False)*/}; + XSetWMProtocols(disp, win, protocol_atoms, NUM_ATOMS); if (window_mode == org_lwjgl_opengl_LinuxDisplay_FULLSCREEN_NETWM) { Atom fullscreen_atom = XInternAtom(disp, "_NET_WM_STATE_FULLSCREEN", False); XChangeProperty(disp, win, XInternAtom(disp, "_NET_WM_STATE", False), @@ -299,8 +327,18 @@ return win; } -JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nCreateWindow(JNIEnv *env, jclass clazz, jlong display, jint screen, jobject peer_info_handle, jobject mode, jint window_mode, jint x, jint y) { +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_setInputFocus(JNIEnv *env, jclass clazz, jlong display, jlong window_ptr) { Display *disp = (Display *)(intptr_t)display; + Window window = (Window)window_ptr; + // Normally, a real time stamp from an event should be passed instead of CurrentTime, but we don't get timestamps + // from awt. Instead we grab the server before and ungrab it after the request + XGrabServer(disp); + XSetInputFocus(disp, window, RevertToParent, CurrentTime); + XUngrabServer(disp); +} + +JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nCreateWindow(JNIEnv *env, jclass clazz, jlong display, jint screen, jobject peer_info_handle, jobject mode, jint window_mode, jint x, jint y, jboolean undecorated, jlong parent_handle) { + Display *disp = (Display *)(intptr_t)display; X11PeerInfo *peer_info = (*env)->GetDirectBufferAddress(env, peer_info_handle); GLXFBConfig *fb_config = NULL; if (peer_info->glx13) { @@ -313,7 +351,7 @@ jfieldID fid_height = (*env)->GetFieldID(env, cls_displayMode, "height", "I"); int width = (*env)->GetIntField(env, mode, fid_width); int height = (*env)->GetIntField(env, mode, fid_height); - Window win = createWindow(env, disp, screen, window_mode, peer_info, x, y, width, height); + Window win = createWindow(env, disp, screen, window_mode, peer_info, x, y, width, height, undecorated, parent_handle); if ((*env)->ExceptionOccurred(env)) { return 0; } @@ -384,7 +422,6 @@ } static void setIcon(JNIEnv *env, Display *disp, Window window, char *rgb_data, char *mask_data, int icon_size, int width, int height) { - XWMHints* win_hints; freeIconPixmap(disp); current_icon_pixmap = createPixmapFromBuffer(env, disp, window, rgb_data, icon_size, width, height); if ((*env)->ExceptionCheck(env)) @@ -395,19 +432,7 @@ return; } - win_hints = XAllocWMHints(); - if (win_hints == NULL) { - throwException(env, "XAllocWMHints failed"); - return; - } - - win_hints->flags = IconPixmapHint | IconMaskHint; - win_hints->icon_pixmap = current_icon_pixmap; - win_hints->icon_mask = current_icon_mask_pixmap; - - XSetWMHints(disp, window, win_hints); - XFree(win_hints); - XFlush(disp); + updateWindowHints(env, disp, window); } JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nSetWindowIcon This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <eli...@us...> - 2008-04-06 21:34:32
|
Revision: 2970 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=2970&view=rev Author: elias_naur Date: 2008-04-06 14:34:22 -0700 (Sun, 06 Apr 2008) Log Message: ----------- Linux: Attempt to avoid race condition when tracking Display parent focus Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2008-04-06 20:56:52 UTC (rev 2969) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2008-04-06 21:34:22 UTC (rev 2970) @@ -623,8 +623,6 @@ private native static void setInputFocus(long display, long window); private void processEvents() { - if (!focused && parent != null && parent.isFocusOwner()) - setInputFocus(getDisplay(), getWindow()); while (LinuxEvent.getPending(getDisplay()) > 0) { event_buffer.nextEvent(getDisplay()); long event_window = event_buffer.getWindow(); @@ -742,15 +740,30 @@ } private void checkInput() { - focused = nGetInputFocus(getDisplay()) == getWindow(); + long current_focus = nGetInputFocus(getDisplay()); + focused = current_focus == getWindow(); if (focused) { focused_at_least_once = true; acquireInput(); - } else if (focused_at_least_once) { - releaseInput(); + } else { + if (focused_at_least_once) + releaseInput(); + if (parent != null && parent.isFocusOwner()) { + // Normally, a real time stamp from an event should be passed to XSetInputFocus instead of CurrentTime, but we don't get timestamps + // from awt. Instead we grab the server and check if the focus changed to avoid a race where our window is made unviewable while focusing it. + grabServer(getDisplay()); + try { + if (nGetInputFocus(getDisplay()) == current_focus) + setInputFocus(getDisplay(), getWindow()); + } finally { + ungrabServer(getDisplay()); + } + } } } static native long nGetInputFocus(long display); + private static native void grabServer(long display); + private static native void ungrabServer(long display); private void releaseInput() { if (isLegacyFullscreen() || input_released) Modified: trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c =================================================================== --- trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c 2008-04-06 20:56:52 UTC (rev 2969) +++ trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c 2008-04-06 21:34:22 UTC (rev 2970) @@ -327,14 +327,20 @@ return win; } +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_grabServer(JNIEnv *env, jclass unused, jlong display) { + Display *disp = (Display *)(intptr_t)display; + XGrabServer(disp); +} + +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_ungrabServer(JNIEnv *env, jclass unused, jlong display) { + Display *disp = (Display *)(intptr_t)display; + XUngrabServer(disp); +} + JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_setInputFocus(JNIEnv *env, jclass clazz, jlong display, jlong window_ptr) { Display *disp = (Display *)(intptr_t)display; Window window = (Window)window_ptr; - // Normally, a real time stamp from an event should be passed instead of CurrentTime, but we don't get timestamps - // from awt. Instead we grab the server before and ungrab it after the request - XGrabServer(disp); XSetInputFocus(disp, window, RevertToParent, CurrentTime); - XUngrabServer(disp); } JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nCreateWindow(JNIEnv *env, jclass clazz, jlong display, jint screen, jobject peer_info_handle, jobject mode, jint window_mode, jint x, jint y, jboolean undecorated, jlong parent_handle) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <eli...@us...> - 2008-04-07 09:23:34
|
Revision: 2972 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=2972&view=rev Author: elias_naur Date: 2008-04-07 02:23:27 -0700 (Mon, 07 Apr 2008) Log Message: ----------- Linux: Use icon mask as monochrome to please some xorg versions Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2008-04-06 22:15:16 UTC (rev 2971) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2008-04-07 09:23:27 UTC (rev 2972) @@ -997,10 +997,11 @@ throw new UnsupportedOperationException(); } - private static void convertIcon(ByteBuffer icon, int width, int height, ByteBuffer icon_rgb, ByteBuffer icon_mask) { - int x = 0; - int y = 5; - byte r,g,b,a; + private static ByteBuffer convertIcon(ByteBuffer icon, int width, int height) { + ByteBuffer icon_rgb = BufferUtils.createByteBuffer(icon.capacity()); + int x; + int y; + byte r,g,b; int depth = 4; @@ -1009,18 +1010,38 @@ r = icon.get((x*4)+(y*width*4)); g = icon.get((x*4)+(y*width*4)+1); b = icon.get((x*4)+(y*width*4)+2); - a = icon.get((x*4)+(y*width*4)+3); icon_rgb.put((x*depth)+(y*width*depth), b); // blue icon_rgb.put((x*depth)+(y*width*depth)+1, g); // green icon_rgb.put((x*depth)+(y*width*depth)+2, r); - icon_mask.put((x*depth)+(y*width*depth), a); - icon_mask.put((x*depth)+(y*width*depth)+1, a); - icon_mask.put((x*depth)+(y*width*depth)+2, a); } } + return icon_rgb; } + private static ByteBuffer convertIconMask(ByteBuffer icon, int width, int height) { + ByteBuffer icon_mask = BufferUtils.createByteBuffer((icon.capacity()/4)/8); + int x; + int y; + byte a; + + int depth = 4; + + for (y = 0; y < height; y++) { + for (x = 0; x < width; x++) { + a = icon.get((x*4)+(y*width*4)+3); + + int mask_index = x + y*width; + int mask_byte_index = mask_index/8; + int mask_bit_index = mask_index%8; + byte bit = (((int)a) & 0xff) >= 127 ? (byte)1 : (byte)0; + byte new_byte = (byte)((icon_mask.get(mask_byte_index) | (bit<<mask_bit_index)) & 0xff); + icon_mask.put(mask_byte_index, new_byte); + } + } + return icon_mask; + } + /** * Sets one or more icons for the Display. * <ul> @@ -1041,11 +1062,9 @@ for (int i=0;i<icons.length;i++) { int size = icons[i].limit() / 4; int dimension = (int)Math.sqrt(size); - int cap = icons[i].capacity(); - ByteBuffer icon_rgb = BufferUtils.createByteBuffer(cap); - ByteBuffer icon_mask = BufferUtils.createByteBuffer(cap); - convertIcon(icons[i], dimension, dimension, icon_rgb, icon_mask); - nSetWindowIcon(getDisplay(), getWindow(), icon_rgb, icon_mask, cap, dimension, dimension); + ByteBuffer icon_rgb = convertIcon(icons[i], dimension, dimension); + ByteBuffer icon_mask = convertIconMask(icons[i], dimension, dimension); + nSetWindowIcon(getDisplay(), getWindow(), icon_rgb, icon_rgb.capacity(), icon_mask, icon_mask.capacity(), dimension, dimension); return 1; } return 0; @@ -1060,7 +1079,7 @@ } } - private static native void nSetWindowIcon(long display, long window, ByteBuffer icon_rgb, ByteBuffer icon_mask, int icon_size, int width, int height); + private static native void nSetWindowIcon(long display, long window, ByteBuffer icon_rgb, int icon_rgb_size, ByteBuffer icon_mask, int icon_mask_size, int width, int height); public int getWidth() { return Display.getDisplayMode().getWidth(); Modified: trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c =================================================================== --- trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c 2008-04-06 22:15:16 UTC (rev 2971) +++ trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c 2008-04-07 09:23:27 UTC (rev 2972) @@ -398,8 +398,8 @@ jawt.Unlock(env); } -static Pixmap createPixmapFromBuffer(JNIEnv *env, Display *disp, Window window, char *data, int data_size, int width, int height) { - Pixmap pixmap = XCreatePixmap(disp, window, width, height, current_depth); +static Pixmap createPixmapFromBuffer(JNIEnv *env, Display *disp, Window window, char *data, int data_size, int width, int height, int format, int depth) { + Pixmap pixmap = XCreatePixmap(disp, window, width, height, depth); /* We need to copy the image data since XDestroyImage will also free its data buffer, which can't be allowed * since the data buffer is managed by the jvm (it's the storage for the direct ByteBuffer) */ @@ -408,15 +408,15 @@ if (icon_copy == NULL) { XFreePixmap(disp, pixmap); throwException(env, "malloc failed"); - return 0; + return None; } memcpy(icon_copy, data, data_size); - XImage *image = XCreateImage(disp, current_visual, current_depth, ZPixmap, 0, icon_copy, width, height, 32, 0); + XImage *image = XCreateImage(disp, current_visual, depth, format, 0, icon_copy, width, height, 32, 0); if (image == NULL) { XFreePixmap(disp, pixmap); free(icon_copy); throwException(env, "XCreateImage failed"); - return 0; + return None; } GC gc = XCreateGC(disp, pixmap, 0, NULL); @@ -427,12 +427,12 @@ return pixmap; } -static void setIcon(JNIEnv *env, Display *disp, Window window, char *rgb_data, char *mask_data, int icon_size, int width, int height) { +static void setIcon(JNIEnv *env, Display *disp, Window window, char *rgb_data, int rgb_size, char *mask_data, int mask_size, int width, int height) { freeIconPixmap(disp); - current_icon_pixmap = createPixmapFromBuffer(env, disp, window, rgb_data, icon_size, width, height); + current_icon_pixmap = createPixmapFromBuffer(env, disp, window, rgb_data, rgb_size, width, height, ZPixmap, current_depth); if ((*env)->ExceptionCheck(env)) return; - current_icon_mask_pixmap = createPixmapFromBuffer(env, disp, window, mask_data, icon_size, width, height); + current_icon_mask_pixmap = createPixmapFromBuffer(env, disp, window, mask_data, mask_size, width, height, XYPixmap, 1); if ((*env)->ExceptionCheck(env)) { freeIconPixmap(disp); return; @@ -442,14 +442,14 @@ } JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nSetWindowIcon - (JNIEnv *env, jclass clazz, jlong display, jlong window_ptr, jobject icon_rgb_buffer, jobject icon_mask_buffer, jint icon_size, jint width, jint height) + (JNIEnv *env, jclass clazz, jlong display, jlong window_ptr, jobject icon_rgb_buffer, jint rgb_size, jobject icon_mask_buffer, jint mask_size, jint width, jint height) { Display *disp = (Display *)(intptr_t)display; Window window = (Window)window_ptr; char *rgb_data= (char *)(*env)->GetDirectBufferAddress(env, icon_rgb_buffer); char *mask_data= (char *)(*env)->GetDirectBufferAddress(env, icon_mask_buffer); - setIcon(env, disp, window, rgb_data, mask_data, icon_size, width, height); + setIcon(env, disp, window, rgb_data, rgb_size, mask_data, mask_size, width, height); } JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nUngrabKeyboard(JNIEnv *env, jclass unused, jlong display_ptr) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <eli...@us...> - 2008-04-07 10:18:13
|
Revision: 2973 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=2973&view=rev Author: elias_naur Date: 2008-04-07 03:18:09 -0700 (Mon, 07 Apr 2008) Log Message: ----------- Windows: Implemented Display.setParent support Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java trunk/LWJGL/src/java/org/lwjgl/test/opengl/awt/DisplayParentTest.java trunk/LWJGL/src/native/windows/context.c trunk/LWJGL/src/native/windows/context.h trunk/LWJGL/src/native/windows/org_lwjgl_opengl_Display.c Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java 2008-04-07 09:23:27 UTC (rev 2972) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java 2008-04-07 10:18:09 UTC (rev 2973) @@ -71,6 +71,8 @@ private final static int WM_QUIT = 0x0012; private final static int WM_SYSCOMMAND = 0x0112; private final static int WM_PAINT = 0x000F; + private final static int WM_KILLFOCUS = 8; + private final static int WM_SETFOCUS = 7; private final static int SC_SIZE = 0xF000; private final static int SC_MOVE = 0xF010; @@ -118,6 +120,7 @@ private static boolean cursor_clipped; private WindowsDisplayPeerInfo peer_info; private Object current_cursor; + private Canvas parent; private WindowsKeyboard keyboard; private WindowsMouse mouse; @@ -140,21 +143,41 @@ current_display = this; } - public void createWindow(DisplayMode mode, boolean fullscreen, Canvas container, int x, int y) throws LWJGLException { + public void createWindow(DisplayMode mode, boolean fullscreen, Canvas parent, int x, int y) throws LWJGLException { close_requested = false; is_dirty = false; isFullscreen = fullscreen; isMinimized = false; isFocused = false; did_maximize = false; - nCreateWindow(mode, fullscreen, x, y); + this.parent = parent; + long parent_hwnd = parent != null ? getHwnd(parent) : 0; + boolean isUndecorated = isUndecorated(); + nCreateWindow(mode, fullscreen, x, y, isUndecorated, parent_hwnd); peer_info.initDC(); showWindow(getHwnd(), SW_SHOWDEFAULT); - setForegroundWindow(getHwnd()); - setFocus(getHwnd()); + if (parent == null) { + setForegroundWindow(getHwnd()); + setFocus(getHwnd()); + } } - private native void nCreateWindow(DisplayMode mode, boolean fullscreen, int x, int y) throws LWJGLException; + private native void nCreateWindow(DisplayMode mode, boolean fullscreen, int x, int y, boolean undecorated, long parent_hwnd) throws LWJGLException; + private static boolean isUndecorated() { + return Display.getPrivilegedBoolean("org.lwjgl.opengl.Window.undecorated"); + } + + private static long getHwnd(Canvas parent) throws LWJGLException { + AWTCanvasImplementation awt_impl = AWTGLCanvas.createImplementation(); + WindowsPeerInfo parent_peer_info = (WindowsPeerInfo)awt_impl.createPeerInfo(parent, null); + ByteBuffer parent_peer_info_handle = parent_peer_info.lockAndGetHandle(); + try { + return parent_peer_info.getHwnd(); + } finally { + parent_peer_info.unlock(); + } + } + public void destroyWindow() { nDestroyWindow(); resetCursorClipping(); @@ -213,7 +236,6 @@ return; } inAppActivate = true; - isFocused = active; if (active) { if (isFullscreen) { restoreDisplayMode(); @@ -350,6 +372,9 @@ public void update() { nUpdate(); + if (parent != null && parent.isFocusOwner()) { + setFocus(getHwnd()); + } if (did_maximize) { did_maximize = false; /** @@ -369,9 +394,9 @@ public void reshape(int x, int y, int width, int height) { if (!isFullscreen) - nReshape(getHwnd(), x, y, width, height); + nReshape(getHwnd(), x, y, width, height, isUndecorated(), parent != null); } - private static native void nReshape(long hwnd, int x, int y, int width, int height); + private static native void nReshape(long hwnd, int x, int y, int width, int height, boolean undecorated, boolean child); public native DisplayMode[] getAvailableDisplayModes() throws LWJGLException; /* Mouse */ @@ -682,6 +707,12 @@ break; } return defWindowProc(hwnd, msg, wParam, lParam); + case WM_KILLFOCUS: + isFocused = false; + return 0; + case WM_SETFOCUS: + isFocused = true; + return 0; case WM_MOUSEMOVE: int xPos = (int)(short)(lParam & 0xFFFF); int yPos = transformY(getHwnd(), (int)(short)((lParam >> 16) & 0xFFFF)); Modified: trunk/LWJGL/src/java/org/lwjgl/test/opengl/awt/DisplayParentTest.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/test/opengl/awt/DisplayParentTest.java 2008-04-07 09:23:27 UTC (rev 2972) +++ trunk/LWJGL/src/java/org/lwjgl/test/opengl/awt/DisplayParentTest.java 2008-04-07 10:18:09 UTC (rev 2973) @@ -65,11 +65,12 @@ final Canvas display_parent = new Canvas(); display_parent.setFocusable(true); add(display_parent); - addWindowListener(new WindowAdapter() { +/* addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { + Display.destroy(); dispose(); } - }); + });*/ setResizable(true); setVisible(true); Display.setParent(display_parent); @@ -102,7 +103,9 @@ while(Keyboard.next()) { // closing on ESCAPE if(Keyboard.getEventKey() == Keyboard.KEY_ESCAPE && Keyboard.getEventKeyState()) { + Display.destroy(); dispose(); + break; } if(Keyboard.getEventKey() == Keyboard.KEY_SPACE && Keyboard.getEventKeyState()) { Modified: trunk/LWJGL/src/native/windows/context.c =================================================================== --- trunk/LWJGL/src/native/windows/context.c 2008-04-07 09:23:27 UTC (rev 2972) +++ trunk/LWJGL/src/native/windows/context.c 2008-04-07 10:18:09 UTC (rev 2973) @@ -112,7 +112,7 @@ } } -void getWindowFlags(DWORD *windowflags_return, DWORD *exstyle_return, bool fullscreen, bool undecorated) { +void getWindowFlags(DWORD *windowflags_return, DWORD *exstyle_return, bool fullscreen, bool undecorated, bool child_window) { DWORD exstyle, windowflags; if (fullscreen) { exstyle = WS_EX_APPWINDOW; @@ -120,6 +120,9 @@ } else if (undecorated) { exstyle = WS_EX_APPWINDOW; windowflags = WS_POPUP; + } else if (child_window) { + exstyle = 0; + windowflags = WS_CHILDWINDOW; } else { exstyle = WS_EX_APPWINDOW; windowflags = WS_OVERLAPPED | WS_BORDER | WS_CAPTION | WS_MINIMIZEBOX | WS_SYSMENU; @@ -136,13 +139,13 @@ * * Returns true for success, or false for failure */ -HWND createWindow(LPCTSTR window_class_name, int x, int y, int width, int height, bool fullscreen, bool undecorated) +HWND createWindow(LPCTSTR window_class_name, int x, int y, int width, int height, bool fullscreen, bool undecorated, HWND parent) { RECT clientSize; DWORD exstyle, windowflags; HWND new_hwnd; - getWindowFlags(&windowflags, &exstyle, fullscreen, undecorated); + getWindowFlags(&windowflags, &exstyle, fullscreen, undecorated, parent != NULL); // If we're not a fullscreen window, adjust the height to account for the // height of the title bar (unless undecorated) @@ -164,8 +167,8 @@ "", windowflags, x, y, clientSize.right - clientSize.left, clientSize.bottom - clientSize.top, + parent, NULL, - NULL, dll_handle, NULL); @@ -462,5 +465,5 @@ HWND createDummyWindow(int origin_x, int origin_y) { if (!registerDummyWindow()) return NULL; - return createWindow(_CONTEXT_PRIVATE_CLASS_NAME, origin_x, origin_y, 1, 1, false, false); + return createWindow(_CONTEXT_PRIVATE_CLASS_NAME, origin_x, origin_y, 1, 1, false, false, NULL); } Modified: trunk/LWJGL/src/native/windows/context.h =================================================================== --- trunk/LWJGL/src/native/windows/context.h 2008-04-07 09:23:27 UTC (rev 2972) +++ trunk/LWJGL/src/native/windows/context.h 2008-04-07 10:18:09 UTC (rev 2973) @@ -80,7 +80,7 @@ /** * Return appropriate window and extended style flags from the given fullscreen and undecorated property */ -extern void getWindowFlags(DWORD *windowflags_return, DWORD *exstyle_return, bool fullscreen, bool undecorated); +extern void getWindowFlags(DWORD *windowflags_return, DWORD *exstyle_return, bool fullscreen, bool undecorated, bool child_window); /* * Create a window with the specified position, size, and @@ -89,7 +89,7 @@ * * Returns true for success, or false for failure */ -extern HWND createWindow(LPCTSTR window_class_name, int x, int y, int width, int height, bool fullscreen, bool undecorated); +extern HWND createWindow(LPCTSTR window_class_name, int x, int y, int width, int height, bool fullscreen, bool undecorated, HWND parent); extern int findPixelFormatOnDC(JNIEnv *env, HDC hdc, int origin_x, int origin_y, jobject pixel_format, jobject pixelFormatCaps, bool use_hdc_bpp, bool window, bool pbuffer, bool double_buffer, bool floating_point); Modified: trunk/LWJGL/src/native/windows/org_lwjgl_opengl_Display.c =================================================================== --- trunk/LWJGL/src/native/windows/org_lwjgl_opengl_Display.c 2008-04-07 09:23:27 UTC (rev 2972) +++ trunk/LWJGL/src/native/windows/org_lwjgl_opengl_Display.c 2008-04-07 10:18:09 UTC (rev 2973) @@ -178,13 +178,12 @@ return getAvailableDisplayModes(env); } -JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nCreateWindow(JNIEnv *env, jobject self, jobject mode, jboolean fullscreen, jint x, jint y) { +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nCreateWindow(JNIEnv *env, jobject self, jobject mode, jboolean fullscreen, jint x, jint y, jboolean undecorated, jlong parent_hwnd) { jclass cls_displayMode = (*env)->GetObjectClass(env, mode); jfieldID fid_width = (*env)->GetFieldID(env, cls_displayMode, "width", "I"); jfieldID fid_height = (*env)->GetFieldID(env, cls_displayMode, "height", "I"); int width = (*env)->GetIntField(env, mode, fid_width); int height = (*env)->GetIntField(env, mode, fid_height); - bool isUndecorated; // Whether we're undecorated or not static bool oneShotInitialised = false; if (!oneShotInitialised) { if (!registerWindow(lwjglWindowProc, WINDOWCLASSNAME)) { @@ -194,8 +193,7 @@ oneShotInitialised = true; } - isUndecorated = getBooleanProperty(env, "org.lwjgl.opengl.Window.undecorated"); - display_hwnd = createWindow(WINDOWCLASSNAME, x, y, width, height, fullscreen, isUndecorated); + display_hwnd = createWindow(WINDOWCLASSNAME, x, y, width, height, fullscreen, undecorated, (HWND)parent_hwnd); if (display_hwnd == NULL) { throwException(env, "Failed to create the window."); return; @@ -320,12 +318,12 @@ return result; } -JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nReshape(JNIEnv *env, jclass unused, jlong hwnd_ptr, jint x, jint y, jint width, jint height) { +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nReshape(JNIEnv *env, jclass unused, jlong hwnd_ptr, jint x, jint y, jint width, jint height, jboolean undecorated, jboolean child) { HWND hwnd = (HWND)(INT_PTR)hwnd_ptr; DWORD exstyle, windowflags; RECT clientSize; - getWindowFlags(&windowflags, &exstyle, false, getBooleanProperty(env, "org.lwjgl.opengl.Window.undecorated")); + getWindowFlags(&windowflags, &exstyle, false, undecorated, child); // If we're not a fullscreen window, adjust the height to account for the // height of the title bar: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |