|
From: <sp...@us...> - 2011-08-16 22:17:39
|
Revision: 3616
http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3616&view=rev
Author: spasi
Date: 2011-08-16 22:17:32 +0000 (Tue, 16 Aug 2011)
Log Message:
-----------
Added unicode support on Windows.
Fixed AL and GLES native stub bindings.
Replaced many GetStringNativeChars usages with a Java implementation.
Modified Paths:
--------------
trunk/LWJGL/src/java/org/lwjgl/MemoryUtil.java
trunk/LWJGL/src/java/org/lwjgl/WindowsSysImplementation.java
trunk/LWJGL/src/java/org/lwjgl/openal/ALC10.java
trunk/LWJGL/src/java/org/lwjgl/openal/ALC11.java
trunk/LWJGL/src/java/org/lwjgl/opencl/CL.java
trunk/LWJGL/src/java/org/lwjgl/opengl/GLContext.java
trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java
trunk/LWJGL/src/java/org/lwjgl/util/generator/SignatureTranslator.java
trunk/LWJGL/src/native/common/opengl/org_lwjgl_opengl_GLContext.c
trunk/LWJGL/src/native/common/org_lwjgl_openal_ALC10.c
trunk/LWJGL/src/native/common/org_lwjgl_openal_ALC11.c
trunk/LWJGL/src/native/common/org_lwjgl_opencl_CL.c
trunk/LWJGL/src/native/windows/Window.h
trunk/LWJGL/src/native/windows/opengl/context.c
trunk/LWJGL/src/native/windows/opengl/context.h
trunk/LWJGL/src/native/windows/opengles/context.c
trunk/LWJGL/src/native/windows/opengles/context.h
trunk/LWJGL/src/native/windows/org_lwjgl_Sys.c
trunk/LWJGL/src/native/windows/org_lwjgl_opengl_Display.c
Modified: trunk/LWJGL/src/java/org/lwjgl/MemoryUtil.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/MemoryUtil.java 2011-08-15 19:24:39 UTC (rev 3615)
+++ trunk/LWJGL/src/java/org/lwjgl/MemoryUtil.java 2011-08-16 22:17:32 UTC (rev 3616)
@@ -33,6 +33,8 @@
import java.lang.reflect.Field;
import java.nio.*;
+import java.nio.charset.Charset;
+import java.nio.charset.CharsetEncoder;
/**
* [INTERNAL USE ONLY]
@@ -43,6 +45,16 @@
*/
public final class MemoryUtil {
+ private static final CharsetEncoder textEncoder;
+
+ static {
+ CharsetEncoder encoder = Charset.defaultCharset().newEncoder();
+ if ( 1.0f < encoder.maxBytesPerChar() )
+ encoder = Charset.forName("ISO-8859-1").newEncoder();
+
+ textEncoder = encoder;
+ }
+
private static final Accessor memUtil;
static {
@@ -92,10 +104,6 @@
private MemoryUtil() {
}
- public static String wrap(final String test) {
- return "MemoryUtil.getAddress(" + test + ")";
- }
-
/**
* Returns the memory address of the specified buffer. [INTERNAL USE ONLY]
*
@@ -179,6 +187,66 @@
public static long getAddressSafe(PointerBuffer buffer, int position) { return buffer == null ? 0L : getAddress(buffer, position); }
+ // --- [ String utilities ] ---
+
+ /**
+ * Returns the specified text as a null-terminated CharBuffer.
+ *
+ * @param text the text to encode
+ *
+ * @return the encoded text
+ */
+ public static CharBuffer encodeUTF16(final CharSequence text) {
+ CharBuffer buffer = BufferUtils.createCharBuffer(text.length() + 1);
+ buffer.append(text).append('\0');
+ buffer.flip();
+ return buffer;
+ }
+
+ /**
+ * Returns the specified text array as a CharBuffer. The CharBuffer is packed
+ * and each text is null-terminated.
+ *
+ * @param text the text array to encode
+ *
+ * @return the encoded text
+ */
+ public static CharBuffer encodeUTF16(final CharSequence... text) {
+ int len = 0;
+ for ( CharSequence cs : text )
+ len += cs.length();
+
+ final CharBuffer buffer = BufferUtils.createCharBuffer(len + text.length);
+ for ( CharSequence cs : text )
+ buffer.append(cs).append('\0');
+
+ buffer.flip();
+ return buffer;
+ }
+
+ /**
+ * Encodes and null-terminated the specified text and returns a ByteBuffer.
+ * If text is null, null is returned.
+ *
+ * @param text the text to encode
+ *
+ * @return the encoded text or null
+ *
+ * @see String#getBytes()
+ */
+ public static ByteBuffer encodeASCII(final CharSequence text) {
+ if ( text == null )
+ return null;
+
+ final ByteBuffer buffer = BufferUtils.createByteBuffer(text.length() + 1);
+
+ textEncoder.encode(CharBuffer.wrap(text), buffer, true);
+ buffer.put((byte)0);
+ buffer.flip();
+
+ return buffer;
+ }
+
interface Accessor {
long getAddress(Buffer buffer);
Modified: trunk/LWJGL/src/java/org/lwjgl/WindowsSysImplementation.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/WindowsSysImplementation.java 2011-08-15 19:24:39 UTC (rev 3615)
+++ trunk/LWJGL/src/java/org/lwjgl/WindowsSysImplementation.java 2011-08-16 22:17:32 UTC (rev 3616)
@@ -31,6 +31,7 @@
*/
package org.lwjgl;
+import java.nio.CharBuffer;
import java.security.PrivilegedExceptionAction;
import java.security.PrivilegedActionException;
import java.security.AccessController;
@@ -95,9 +96,15 @@
if(!Display.isCreated()) {
initCommonControls();
}
- nAlert(getHwnd(), title, message);
+
+ LWJGLUtil.log(String.format("*** Alert *** %s\n%s\n", title, message));
+
+ // Pack both strings in the same buffer
+ final CharBuffer buffer = MemoryUtil.encodeUTF16(title, message);
+ final long address = MemoryUtil.getAddress0(buffer);
+ nAlert(getHwnd(), address, address + (title.length() + 1) * 2);
}
- private static native void nAlert(long parent_hwnd, String title, String message);
+ private static native void nAlert(long parent_hwnd, long title, long message);
private static native void initCommonControls();
public boolean openURL(final String url) {
Modified: trunk/LWJGL/src/java/org/lwjgl/openal/ALC10.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/openal/ALC10.java 2011-08-15 19:24:39 UTC (rev 3615)
+++ trunk/LWJGL/src/java/org/lwjgl/openal/ALC10.java 2011-08-16 22:17:32 UTC (rev 3616)
@@ -31,7 +31,7 @@
*/
package org.lwjgl.openal;
-import java.nio.Buffer;
+import java.nio.ByteBuffer;
import java.nio.IntBuffer;
import java.util.HashMap;
@@ -199,7 +199,8 @@
* @return opened device, or null
*/
public static ALCdevice alcOpenDevice(String devicename) {
- long device_address = nalcOpenDevice(devicename);
+ ByteBuffer buffer = MemoryUtil.encodeASCII(devicename);
+ long device_address = nalcOpenDevice(MemoryUtil.getAddressSafe(buffer));
if(device_address != 0) {
ALCdevice device = new ALCdevice(device_address);
synchronized (ALC10.devices) {
@@ -209,7 +210,7 @@
}
return null;
}
- static native long nalcOpenDevice(String devicename);
+ static native long nalcOpenDevice(long devicename);
/**
* The <code>alcCloseDevice</code> function allows the application (i.e. the client program) to
@@ -395,11 +396,12 @@
* @return true if extension is available, false if not
*/
public static boolean alcIsExtensionPresent(ALCdevice device, String extName) {
- boolean result = nalcIsExtensionPresent(getDevice(device), extName);
+ ByteBuffer buffer = MemoryUtil.encodeASCII(extName);
+ boolean result = nalcIsExtensionPresent(getDevice(device), MemoryUtil.getAddress(buffer));
Util.checkALCError(device);
return result;
}
- static native boolean nalcIsExtensionPresent(long device, String extName);
+ private static native boolean nalcIsExtensionPresent(long device, long extName);
/**
* Enumeration/token values are device independend, but tokens defined for
@@ -412,11 +414,12 @@
* @return value of enumeration
*/
public static int alcGetEnumValue(ALCdevice device, String enumName) {
- int result = nalcGetEnumValue(getDevice(device), enumName);
+ ByteBuffer buffer = MemoryUtil.encodeASCII(enumName);
+ int result = nalcGetEnumValue(getDevice(device), MemoryUtil.getAddress(buffer));
Util.checkALCError(device);
return result;
}
- static native int nalcGetEnumValue(long device, String enumName);
+ private static native int nalcGetEnumValue(long device, long enumName);
static long getDevice(ALCdevice device) {
if(device != null) {
Modified: trunk/LWJGL/src/java/org/lwjgl/openal/ALC11.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/openal/ALC11.java 2011-08-15 19:24:39 UTC (rev 3615)
+++ trunk/LWJGL/src/java/org/lwjgl/openal/ALC11.java 2011-08-16 22:17:32 UTC (rev 3616)
@@ -92,7 +92,8 @@
* @return ALCdevice if it was possible to open a device
*/
public static ALCdevice alcCaptureOpenDevice(String devicename, int frequency, int format, int buffersize) {
- long device_address = nalcCaptureOpenDevice(devicename, frequency, format, buffersize);
+ ByteBuffer buffer = MemoryUtil.encodeASCII(devicename);
+ long device_address = nalcCaptureOpenDevice(MemoryUtil.getAddress(buffer), frequency, format, buffersize);
if(device_address != 0) {
ALCdevice device = new ALCdevice(device_address);
synchronized (ALC10.devices) {
@@ -102,7 +103,7 @@
}
return null;
}
- static native long nalcCaptureOpenDevice( String devicename, int frequency, int format, int buffersize);
+ private static native long nalcCaptureOpenDevice(long devicename, int frequency, int format, int buffersize);
/**
* The alcCaptureCloseDevice function allows the application to disconnect from a capture
Modified: trunk/LWJGL/src/java/org/lwjgl/opencl/CL.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opencl/CL.java 2011-08-15 19:24:39 UTC (rev 3615)
+++ trunk/LWJGL/src/java/org/lwjgl/opencl/CL.java 2011-08-16 22:17:32 UTC (rev 3616)
@@ -33,6 +33,7 @@
import org.lwjgl.LWJGLException;
import org.lwjgl.LWJGLUtil;
+import org.lwjgl.MemoryUtil;
import org.lwjgl.Sys;
import java.nio.ByteBuffer;
@@ -143,7 +144,12 @@
return 0;
}
- static native long getFunctionAddress(String name);
+ /** Helper method to get a pointer to a named function in the OpenCL library. */
+ static long getFunctionAddress(String name) {
+ ByteBuffer buffer = MemoryUtil.encodeASCII(name);
+ return ngetFunctionAddress(MemoryUtil.getAddress(buffer));
+ }
+ private static native long ngetFunctionAddress(long name);
static native ByteBuffer getHostBuffer(final long address, final int size);
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/GLContext.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/GLContext.java 2011-08-15 19:24:39 UTC (rev 3615)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/GLContext.java 2011-08-16 22:17:32 UTC (rev 3616)
@@ -33,9 +33,11 @@
import org.lwjgl.LWJGLException;
import org.lwjgl.LWJGLUtil;
+import org.lwjgl.MemoryUtil;
import org.lwjgl.Sys;
import java.lang.reflect.Method;
+import java.nio.ByteBuffer;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.security.PrivilegedExceptionAction;
@@ -187,8 +189,12 @@
return 0;
}
- /** Helper method to get a pointer to a named function in the OpenGL library */
- static native long getFunctionAddress(String name);
+ /** Helper method to get a pointer to a named function in the OpenGL library. */
+ static long getFunctionAddress(String name) {
+ ByteBuffer buffer = MemoryUtil.encodeASCII(name);
+ return ngetFunctionAddress(MemoryUtil.getAddress(buffer));
+ }
+ private static native long ngetFunctionAddress(long name);
/**
* Determine which extensions are available and returns the context profile mask. Helper method to ContextCapabilities.
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java 2011-08-15 19:24:39 UTC (rev 3615)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java 2011-08-16 22:17:32 UTC (rev 3616)
@@ -38,15 +38,13 @@
* @author elias_naur
*/
-import java.nio.ByteBuffer;
-import java.nio.FloatBuffer;
-import java.nio.IntBuffer;
-import java.nio.LongBuffer;
+import java.nio.*;
import java.awt.Canvas;
import org.lwjgl.LWJGLException;
import org.lwjgl.LWJGLUtil;
import org.lwjgl.BufferUtils;
+import org.lwjgl.MemoryUtil;
import org.lwjgl.input.Cursor;
import org.lwjgl.input.Mouse;
import org.lwjgl.opengles.EGL;
@@ -141,11 +139,11 @@
private static final int SWP_FRAMECHANGED = 0x0020;
private static final int GWL_STYLE = -16;
- private static final int GWL_EXSTYLE = -20;
-
+ private static final int GWL_EXSTYLE = -20;
+
private static final int WS_THICKFRAME = 0x00040000;
-
+
private static WindowsDisplay current_display;
private static boolean cursor_clipped;
@@ -217,9 +215,9 @@
}
peer_info.initDC(getHwnd(), getHdc());
showWindow(getHwnd(), SW_SHOWDEFAULT);
-
+
updateWidthAndHeight();
-
+
if ( parent == null ) {
if(Display.isResizable()) {
setResizable(true);
@@ -233,7 +231,7 @@
throw e;
}
}
-
+
private void updateWidthAndHeight() {
getClientRect(hwnd, rect_buffer);
rect.copyFromBuffer(rect_buffer);
@@ -440,9 +438,10 @@
private static native DisplayMode getCurrentDisplayMode() throws LWJGLException;
public void setTitle(String title) {
- nSetTitle(hwnd, title);
+ CharBuffer buffer = MemoryUtil.encodeUTF16(title);
+ nSetTitle(hwnd, MemoryUtil.getAddress0(buffer));
}
- private static native void nSetTitle(long hwnd, String title);
+ private static native void nSetTitle(long hwnd, long title);
public boolean isCloseRequested() {
boolean saved = close_requested;
@@ -786,7 +785,7 @@
byte state = (byte)(1 - ((lParam >>> 31) & 0x1));
boolean repeat = state == previous_state;
if (keyboard != null)
- keyboard.handleChar((int)(wParam & 0xFF), millis, repeat);
+ keyboard.handleChar((int)(wParam & 0xFFFF), millis, repeat);
}
private void handleKeyButton(long wParam, long lParam, long millis) {
@@ -991,12 +990,12 @@
public boolean isInsideWindow() {
return mouseInside;
}
-
+
public void setResizable(boolean resizable) {
if(this.resizable != resizable) {
long style = getWindowLongPtr(hwnd, GWL_STYLE);
long styleex = getWindowLongPtr(hwnd, GWL_EXSTYLE);
-
+
// update frame style
if(resizable) {
setWindowLongPtr(hwnd, GWL_STYLE, style |= WS_THICKFRAME);
@@ -1010,16 +1009,16 @@
rect.copyFromBuffer(rect_buffer);
adjustWindowRectEx(rect_buffer, style, false, styleex);
rect.copyFromBuffer(rect_buffer);
-
+
// force a frame update and resize accordingly
setWindowPos(hwnd, HWND_TOP, 0, 0, rect.right - rect.left, rect.bottom - rect.top, SWP_NOMOVE | SWP_NOZORDER | SWP_FRAMECHANGED);
-
+
updateWidthAndHeight();
resized = false;
}
- this.resizable = resizable;
+ this.resizable = resizable;
}
-
+
private native boolean adjustWindowRectEx(IntBuffer rectBuffer, long style, boolean menu, long styleex);
public boolean wasResized() {
Modified: trunk/LWJGL/src/java/org/lwjgl/util/generator/SignatureTranslator.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/util/generator/SignatureTranslator.java 2011-08-15 19:24:39 UTC (rev 3615)
+++ trunk/LWJGL/src/java/org/lwjgl/util/generator/SignatureTranslator.java 2011-08-16 22:17:32 UTC (rev 3616)
@@ -91,11 +91,13 @@
} else
type_name = t.getDeclaration().getQualifiedName();
- signature.append("L");
- signature.append(getNativeNameFromClassName(type_name));
- signature.append(";");
- if ( add_position_signature && Utils.isAddressableType(type) && !String.class.equals(type) )
- signature.append("I");
+ if ( Utils.isAddressableType(type) && !String.class.equals(type) )
+ signature.append("J");
+ else {
+ signature.append("L");
+ signature.append(getNativeNameFromClassName(type_name));
+ signature.append(";");
+ }
}
public void visitDeclaredType(DeclaredType t) {
Modified: trunk/LWJGL/src/native/common/opengl/org_lwjgl_opengl_GLContext.c
===================================================================
--- trunk/LWJGL/src/native/common/opengl/org_lwjgl_opengl_GLContext.c 2011-08-15 19:24:39 UTC (rev 3615)
+++ trunk/LWJGL/src/native/common/opengl/org_lwjgl_opengl_GLContext.c 2011-08-16 22:17:32 UTC (rev 3616)
@@ -1,31 +1,31 @@
-/*
+/*
* Copyright (c) 2002-2008 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
+ * modification, are permitted provided that the following conditions are
* met:
- *
- * * Redistributions of source code must retain the above copyright
+ *
+ * * 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
+ * * 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
+ * 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
+ * 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.
*/
@@ -35,13 +35,8 @@
#include "org_lwjgl_opengl_GLContext.h"
#include "extgl.h"
-JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_GLContext_getFunctionAddress(JNIEnv *env, jclass clazz, jstring function_name) {
- jlong address_jlong;
- char *function_name_pointer = GetStringNativeChars(env, function_name);
- void *address = extgl_GetProcAddress(function_name_pointer);
- free(function_name_pointer);
- address_jlong = (jlong)(intptr_t)address;
- return address_jlong;
+JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_GLContext_ngetFunctionAddress(JNIEnv *env, jclass clazz, jlong function_name) {
+ return (jlong)(intptr_t)extgl_GetProcAddress((char *)(intptr_t)function_name);
}
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_GLContext_nLoadOpenGLLibrary(JNIEnv * env, jclass clazz) {
Modified: trunk/LWJGL/src/native/common/org_lwjgl_openal_ALC10.c
===================================================================
--- trunk/LWJGL/src/native/common/org_lwjgl_openal_ALC10.c 2011-08-15 19:24:39 UTC (rev 3615)
+++ trunk/LWJGL/src/native/common/org_lwjgl_openal_ALC10.c 2011-08-16 22:17:32 UTC (rev 3616)
@@ -131,24 +131,8 @@
* C Specification:
* ALCdevice *alcOpenDevice( const ALubyte *tokstr );
*/
-static jlong JNICALL Java_org_lwjgl_openal_ALC10_nalcOpenDevice (JNIEnv *env, jclass clazz, jstring tokstr) {
- char * tokenstring;
- ALCdevice* device;
-
- if(tokstr != NULL) {
- tokenstring = GetStringNativeChars(env, tokstr);
- } else {
- tokenstring = NULL;
- }
-
- /* get device */
- device = alcOpenDevice((ALubyte *) tokenstring);
-
- if(tokenstring != NULL) {
- free(tokenstring);
- }
-
- return (jlong)((intptr_t)device);
+static jlong JNICALL Java_org_lwjgl_openal_ALC10_nalcOpenDevice (JNIEnv *env, jclass clazz, jlong tokstr) {
+ return (jlong)(intptr_t)alcOpenDevice((ALubyte *)(intptr_t)tokstr);
}
/**
@@ -255,15 +239,8 @@
* C Specification:
* ALboolean alcIsExtensionPresent(ALCdevice *device, ALubyte *extName);
*/
-static jboolean JNICALL Java_org_lwjgl_openal_ALC10_nalcIsExtensionPresent (JNIEnv *env, jclass clazz, jlong deviceaddress, jstring extName) {
- /* get extension */
- ALubyte* functionname = (ALubyte*) GetStringNativeChars(env, extName);
-
- jboolean result = (jboolean) alcIsExtensionPresent((ALCdevice*)((intptr_t)deviceaddress), functionname);
-
- free(functionname);
-
- return result;
+static jboolean JNICALL Java_org_lwjgl_openal_ALC10_nalcIsExtensionPresent (JNIEnv *env, jclass clazz, jlong deviceaddress, jlong extName) {
+ return (jboolean) alcIsExtensionPresent((ALCdevice*)((intptr_t)deviceaddress), (ALubyte*)(intptr_t)extName);
}
/**
@@ -272,15 +249,8 @@
* C Specification:
* ALenum alcGetEnumValue(ALCdevice *device, ALubyte *enumName);
*/
-static jint JNICALL Java_org_lwjgl_openal_ALC10_nalcGetEnumValue (JNIEnv *env, jclass clazz, jlong deviceaddress, jstring enumName) {
- /* get extension */
- ALubyte* enumerationname = (ALubyte*) GetStringNativeChars(env, enumName);
-
- jint result = (jint) alcGetEnumValue((ALCdevice*)((intptr_t)deviceaddress), enumerationname);
-
- free(enumerationname);
-
- return result;
+static jint JNICALL Java_org_lwjgl_openal_ALC10_nalcGetEnumValue (JNIEnv *env, jclass clazz, jlong deviceaddress, jlong enumName) {
+ return (jint) alcGetEnumValue((ALCdevice*)((intptr_t)deviceaddress), (ALubyte*)(intptr_t)enumName);
}
/**
@@ -294,10 +264,10 @@
JNIEXPORT void JNICALL Java_org_lwjgl_openal_ALC10_initNativeStubs(JNIEnv *env, jclass clazz) {
JavaMethodAndExtFunction functions[] = {
{"nalcGetString", "(JI)Ljava/lang/String;", (void*)&Java_org_lwjgl_openal_ALC10_nalcGetString, "alcGetString", (void*)&alcGetString},
- {"nalcGetIntegerv", "(JIILjava/nio/Buffer;I)V", (void*)&Java_org_lwjgl_openal_ALC10_nalcGetIntegerv, "alcGetIntegerv", (void*)&alcGetIntegerv},
- {"nalcOpenDevice", "(Ljava/lang/String;)J", (void*)&Java_org_lwjgl_openal_ALC10_nalcOpenDevice, "alcOpenDevice", (void*)&alcOpenDevice},
+ {"nalcGetIntegerv", "(JIIJ)V", (void*)&Java_org_lwjgl_openal_ALC10_nalcGetIntegerv, "alcGetIntegerv", (void*)&alcGetIntegerv},
+ {"nalcOpenDevice", "(J)J", (void*)&Java_org_lwjgl_openal_ALC10_nalcOpenDevice, "alcOpenDevice", (void*)&alcOpenDevice},
{"nalcCloseDevice", "(J)Z", (void*)&Java_org_lwjgl_openal_ALC10_nalcCloseDevice, "alcCloseDevice", (void*)&alcCloseDevice},
- {"nalcCreateContext", "(JLjava/nio/IntBuffer;)J", (void*)&Java_org_lwjgl_openal_ALC10_nalcCreateContext, "alcCreateContext", (void*)&alcCreateContext},
+ {"nalcCreateContext", "(JJ)J", (void*)&Java_org_lwjgl_openal_ALC10_nalcCreateContext, "alcCreateContext", (void*)&alcCreateContext},
{"nalcMakeContextCurrent", "(J)I", (void*)&Java_org_lwjgl_openal_ALC10_nalcMakeContextCurrent, "alcMakeContextCurrent", (void*)&alcMakeContextCurrent},
{"nalcProcessContext", "(J)V", (void*)&Java_org_lwjgl_openal_ALC10_nalcProcessContext, "alcProcessContext", (void*)&alcProcessContext},
{"nalcGetCurrentContext", "()J", (void*)&Java_org_lwjgl_openal_ALC10_nalcGetCurrentContext, "alcGetCurrentContext", (void*)&alcGetCurrentContext},
@@ -305,8 +275,8 @@
{"nalcSuspendContext", "(J)V", (void*)&Java_org_lwjgl_openal_ALC10_nalcSuspendContext, "alcSuspendContext", (void*)&alcSuspendContext},
{"nalcDestroyContext", "(J)V", (void*)&Java_org_lwjgl_openal_ALC10_nalcDestroyContext, "alcDestroyContext", (void*)&alcDestroyContext},
{"nalcGetError", "(J)I", (void*)&Java_org_lwjgl_openal_ALC10_nalcGetError, "alcGetError", (void*)&alcGetError},
- {"nalcIsExtensionPresent", "(JLjava/lang/String;)Z", (void*)&Java_org_lwjgl_openal_ALC10_nalcIsExtensionPresent, "alcIsExtensionPresent", (void*)&alcIsExtensionPresent},
- {"nalcGetEnumValue", "(JLjava/lang/String;)I", (void*)&Java_org_lwjgl_openal_ALC10_nalcGetEnumValue, "alcGetEnumValue", (void*)&alcGetEnumValue}
+ {"nalcIsExtensionPresent", "(JJ)Z", (void*)&Java_org_lwjgl_openal_ALC10_nalcIsExtensionPresent, "alcIsExtensionPresent", (void*)&alcIsExtensionPresent},
+ {"nalcGetEnumValue", "(JJ)I", (void*)&Java_org_lwjgl_openal_ALC10_nalcGetEnumValue, "alcGetEnumValue", (void*)&alcGetEnumValue}
};
int num_functions = NUMFUNCTIONS(functions);
extal_InitializeClass(env, clazz, num_functions, functions);
Modified: trunk/LWJGL/src/native/common/org_lwjgl_openal_ALC11.c
===================================================================
--- trunk/LWJGL/src/native/common/org_lwjgl_openal_ALC11.c 2011-08-15 19:24:39 UTC (rev 3615)
+++ trunk/LWJGL/src/native/common/org_lwjgl_openal_ALC11.c 2011-08-16 22:17:32 UTC (rev 3616)
@@ -60,18 +60,8 @@
* Method: nalcCaptureOpenDevice
* Signature: (Ljava/lang/String;III)J
*/
-static jlong JNICALL Java_org_lwjgl_openal_ALC11_nalcCaptureOpenDevice(JNIEnv *env, jclass clazz, jstring devicename, jint frequency, jint format, jint buffersize) {
- ALubyte* dev_name = NULL;
- ALCdevice* device = NULL;
-
- if(devicename != NULL) {
- dev_name = (ALubyte*) GetStringNativeChars(env, devicename);
- }
-
- device = alcCaptureOpenDevice((const char *)dev_name, (unsigned int) frequency, format, buffersize);
-
- free(dev_name);
- return (jlong) ((intptr_t)device);
+static jlong JNICALL Java_org_lwjgl_openal_ALC11_nalcCaptureOpenDevice(JNIEnv *env, jclass clazz, jlong devicename, jint frequency, jint format, jint buffersize) {
+ return (jlong)(intptr_t)alcCaptureOpenDevice((const char *)(intptr_t)devicename, (unsigned int) frequency, format, buffersize);
}
/*
@@ -121,11 +111,11 @@
#endif
JNIEXPORT void JNICALL Java_org_lwjgl_openal_ALC11_initNativeStubs(JNIEnv *env, jclass clazz) {
JavaMethodAndExtFunction functions[] = {
- {"nalcCaptureOpenDevice", "(Ljava/lang/String;III)J", (void*)&Java_org_lwjgl_openal_ALC11_nalcCaptureOpenDevice, "alcCaptureOpenDevice", (void*)&alcCaptureOpenDevice},
+ {"nalcCaptureOpenDevice", "(JIII)J", (void*)&Java_org_lwjgl_openal_ALC11_nalcCaptureOpenDevice, "alcCaptureOpenDevice", (void*)&alcCaptureOpenDevice},
{"nalcCaptureCloseDevice", "(J)Z", (void*)&Java_org_lwjgl_openal_ALC11_nalcCaptureCloseDevice, "alcCaptureCloseDevice", (void*)&alcCaptureCloseDevice},
{"nalcCaptureStart", "(J)V", (void*)&Java_org_lwjgl_openal_ALC11_nalcCaptureStart, "alcCaptureStart", (void*)&alcCaptureStart},
{"nalcCaptureStop", "(J)V", (void*)&Java_org_lwjgl_openal_ALC11_nalcCaptureStop, "alcCaptureStop", (void*)&alcCaptureStop},
- {"nalcCaptureSamples", "(JLjava/nio/ByteBuffer;II)V", (void*)&Java_org_lwjgl_openal_ALC11_nalcCaptureSamples, "alcCaptureSamples", (void*)&alcCaptureSamples}
+ {"nalcCaptureSamples", "(JJI)V", (void*)&Java_org_lwjgl_openal_ALC11_nalcCaptureSamples, "alcCaptureSamples", (void*)&alcCaptureSamples}
};
int num_functions = NUMFUNCTIONS(functions);
extal_InitializeClass(env, clazz, num_functions, functions);
Modified: trunk/LWJGL/src/native/common/org_lwjgl_opencl_CL.c
===================================================================
--- trunk/LWJGL/src/native/common/org_lwjgl_opencl_CL.c 2011-08-15 19:24:39 UTC (rev 3615)
+++ trunk/LWJGL/src/native/common/org_lwjgl_opencl_CL.c 2011-08-16 22:17:32 UTC (rev 3616)
@@ -42,13 +42,8 @@
extcl_UnloadLibrary();
}
-JNIEXPORT jlong JNICALL Java_org_lwjgl_opencl_CL_getFunctionAddress(JNIEnv *env, jclass clazz, jstring function_name) {
- jlong address_jlong;
- char *function_name_pointer = GetStringNativeChars(env, function_name);
- void *address = extcl_GetProcAddress(function_name_pointer);
- free(function_name_pointer);
- address_jlong = (jlong)(intptr_t)address;
- return address_jlong;
+JNIEXPORT jlong JNICALL Java_org_lwjgl_opencl_CL_ngetFunctionAddress(JNIEnv *env, jclass clazz, jlong function_name) {
+ return (jlong)(intptr_t)extcl_GetProcAddress((char *)(intptr_t)function_name);
}
JNIEXPORT jobject JNICALL Java_org_lwjgl_opencl_CL_getHostBuffer(JNIEnv *env, jclass clazz, jlong address, jint size) {
Modified: trunk/LWJGL/src/native/windows/Window.h
===================================================================
--- trunk/LWJGL/src/native/windows/Window.h 2011-08-15 19:24:39 UTC (rev 3615)
+++ trunk/LWJGL/src/native/windows/Window.h 2011-08-16 22:17:32 UTC (rev 3616)
@@ -1,35 +1,35 @@
-/*
+/*
* Copyright (c) 2002-2008 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
+ * modification, are permitted provided that the following conditions are
* met:
- *
- * * Redistributions of source code must retain the above copyright
+ *
+ * * 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
+ * * 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
+ * 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
+ * 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.
*/
-
+
/**
* $Id$
*
@@ -52,6 +52,10 @@
#define _WIN32_WINNT 0x0400
#endif
+ #define _UNICODE
+ #include <tchar.h>
+
+ #define UNICODE
#include <windows.h>
#include <jni.h>
#include "common_tools.h"
Modified: trunk/LWJGL/src/native/windows/opengl/context.c
===================================================================
--- trunk/LWJGL/src/native/windows/opengl/context.c 2011-08-15 19:24:39 UTC (rev 3615)
+++ trunk/LWJGL/src/native/windows/opengl/context.c 2011-08-16 22:17:32 UTC (rev 3616)
@@ -1,31 +1,31 @@
-/*
+/*
* Copyright (c) 2002-2008 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
+ * modification, are permitted provided that the following conditions are
* met:
- *
- * * Redistributions of source code must retain the above copyright
+ *
+ * * 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
+ * * 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
+ * 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
+ * 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.
*/
@@ -38,15 +38,14 @@
*/
#include <malloc.h>
-#include <jni.h>
-#include "common_tools.h"
+#include "Window.h"
#include "extgl.h"
#include "extgl_wgl.h"
#include "context.h"
extern HINSTANCE dll_handle; // Handle to the LWJGL dll
-#define _CONTEXT_PRIVATE_CLASS_NAME "__lwjgl_context_class_name"
+#define _CONTEXT_PRIVATE_CLASS_NAME _T("__lwjgl_context_class_name")
/*
* Register the LWJGL window class.
@@ -85,7 +84,7 @@
return false;
}
- // make that the pixel format of the device context
+ // make that the pixel format of the device context
if (SetPixelFormat(hdc, iPixelFormat, &desc) == FALSE) {
throwFormattedException(env, "SetPixelFormat failed (%d)", GetLastError());
return false;
@@ -134,14 +133,14 @@
RECT clientSize;
DWORD exstyle, windowflags;
HWND new_hwnd;
-
+
getWindowFlags(&windowflags, &exstyle, undecorated, child_window);
clientSize.bottom = height;
clientSize.left = 0;
clientSize.right = width;
clientSize.top = 0;
-
+
AdjustWindowRectEx(
&clientSize, // client-rectangle structure
windowflags, // window styles
@@ -150,9 +149,9 @@
);
// Create the window now, using that class:
new_hwnd = CreateWindowEx (
- exstyle,
+ exstyle,
window_class_name,
- "",
+ _T(""),
windowflags,
x, y, clientSize.right - clientSize.left, clientSize.bottom - clientSize.top,
parent,
@@ -191,12 +190,12 @@
int num_aux_buffers = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "num_aux_buffers", "I"));
int accum_bpp = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "accum_bpp", "I"));
int accum_alpha = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "accum_alpha", "I"));
-
+
jboolean stereo = (*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "stereo", "Z"));
jboolean floating_point = (*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "floating_point", "Z"));
jboolean floating_point_packed = (*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "floating_point_packed", "Z"));
jboolean sRGB = (*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "sRGB", "Z"));
-
+
int pixel_type;
int iPixelFormat;
unsigned int num_formats_returned;
@@ -206,18 +205,18 @@
BOOL result;
jlong i;
int bpe = convertToBPE(bpp);
-
+
if ( floating_point )
pixel_type = WGL_TYPE_RGBA_FLOAT_ARB;
else if ( floating_point_packed )
pixel_type = WGL_TYPE_RGBA_UNSIGNED_FLOAT_EXT;
else
pixel_type = WGL_TYPE_RGBA_ARB;
-
+
initAttribList(&attrib_list);
if (window) {
putAttrib(&attrib_list, WGL_DRAW_TO_WINDOW_ARB); putAttrib(&attrib_list, TRUE);
- }
+ }
if (pbuffer) {
putAttrib(&attrib_list, WGL_DRAW_TO_PBUFFER_ARB); putAttrib(&attrib_list, TRUE);
}
@@ -299,31 +298,31 @@
int accum_bpp = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "accum_bpp", "I"));
int accum_alpha = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "accum_alpha", "I"));
jboolean stereo = (*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "stereo", "Z"));
- unsigned int flags = PFD_DRAW_TO_WINDOW | // support window
+ unsigned int flags = PFD_DRAW_TO_WINDOW | // support window
PFD_SUPPORT_OPENGL |
(double_buffer ? PFD_DOUBLEBUFFER : 0) |
(stereo ? PFD_STEREO : 0);
PIXELFORMATDESCRIPTOR desc;
int iPixelFormat;
- PIXELFORMATDESCRIPTOR pfd = {
- sizeof(PIXELFORMATDESCRIPTOR), // size of this pfd
- 1, // version number
- flags, // RGBA type
+ PIXELFORMATDESCRIPTOR pfd = {
+ sizeof(PIXELFORMATDESCRIPTOR), // size of this pfd
+ 1, // version number
+ flags, // RGBA type
PFD_TYPE_RGBA,
- (BYTE)bpp,
- 0, 0, 0, 0, 0, 0, // color bits ignored
- (BYTE)alpha,
- 0, // shift bit ignored
- accum_bpp + accum_alpha, // no accumulation buffer
- 0, 0, 0, 0, // accum bits ignored
- (BYTE)depth,
- (BYTE)stencil,
- num_aux_buffers,
+ (BYTE)bpp,
+ 0, 0, 0, 0, 0, 0, // color bits ignored
+ (BYTE)alpha,
+ 0, // shift bit ignored
+ accum_bpp + accum_alpha, // no accumulation buffer
+ 0, 0, 0, 0, // accum bits ignored
+ (BYTE)depth,
+ (BYTE)stencil,
+ num_aux_buffers,
PFD_MAIN_PLANE, // main layer
- 0, // reserved
+ 0, // reserved
0, 0, 0 // layer masks ignored
};
- // get the best available match of pixel format for the device context
+ // get the best available match of pixel format for the device context
iPixelFormat = ChoosePixelFormat(hdc, &pfd);
if (iPixelFormat == 0) {
throwException(env, "Failed to choose pixel format");
@@ -442,14 +441,14 @@
HDC dummy_hdc;
int pixel_format_id;
jclass cls_pixel_format = (*env)->GetObjectClass(env, pixel_format);
-
+
int samples = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "samples", "I"));
int colorSamples = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "colorSamples", "I"));
bool floating_point = (bool)(*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "floating_point", "Z"));
bool floating_point_packed = (bool)(*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "floating_point_packed", "Z"));
bool sRGB = (bool)(*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "sRGB", "Z"));
bool use_arb_selection = samples > 0 || floating_point || floating_point_packed || sRGB || pbuffer || pixelFormatCaps != NULL;
-
+
pixel_format_id = findPixelFormatDefault(env, hdc, pixel_format, use_hdc_bpp, double_buffer);
if (!(*env)->ExceptionOccurred(env) && use_arb_selection) {
dummy_hwnd = createDummyWindow(origin_x, origin_y);
Modified: trunk/LWJGL/src/native/windows/opengl/context.h
===================================================================
--- trunk/LWJGL/src/native/windows/opengl/context.h 2011-08-15 19:24:39 UTC (rev 3615)
+++ trunk/LWJGL/src/native/windows/opengl/context.h 2011-08-16 22:17:32 UTC (rev 3616)
@@ -40,9 +40,7 @@
#ifndef __LWJGL_CONTEXT_H
#define __LWJGL_CONTEXT_H
-#include <windows.h>
-#include <jni.h>
-#include "common_tools.h"
+#include "Window.h"
#include "extgl.h"
#include "extgl_wgl.h"
Modified: trunk/LWJGL/src/native/windows/opengles/context.c
===================================================================
--- trunk/LWJGL/src/native/windows/opengles/context.c 2011-08-15 19:24:39 UTC (rev 3615)
+++ trunk/LWJGL/src/native/windows/opengles/context.c 2011-08-16 22:17:32 UTC (rev 3616)
@@ -38,15 +38,14 @@
*/
#include <malloc.h>
-#include <jni.h>
-#include "common_tools.h"
+#include "Window.h"
#include "extgl.h"
/*#include "extgl_wgl.h"*/
#include "context.h"
extern HINSTANCE dll_handle; // Handle to the LWJGL dll
-#define _CONTEXT_PRIVATE_CLASS_NAME "__lwjgl_context_class_name"
+#define _CONTEXT_PRIVATE_CLASS_NAME _T("__lwjgl_context_class_name")
/*
* Register the LWJGL window class.
@@ -154,7 +153,7 @@
new_hwnd = CreateWindowEx (
exstyle,
window_class_name,
- "",
+ _T(""),
windowflags,
x, y, clientSize.right - clientSize.left, clientSize.bottom - clientSize.top,
parent,
Modified: trunk/LWJGL/src/native/windows/opengles/context.h
===================================================================
--- trunk/LWJGL/src/native/windows/opengles/context.h 2011-08-15 19:24:39 UTC (rev 3615)
+++ trunk/LWJGL/src/native/windows/opengles/context.h 2011-08-16 22:17:32 UTC (rev 3616)
@@ -40,9 +40,7 @@
#ifndef __LWJGL_CONTEXT_H
#define __LWJGL_CONTEXT_H
-#include <windows.h>
-#include <jni.h>
-#include "common_tools.h"
+#include "Window.h"
#include "extgl.h"
typedef struct {
Modified: trunk/LWJGL/src/native/windows/org_lwjgl_Sys.c
===================================================================
--- trunk/LWJGL/src/native/windows/org_lwjgl_Sys.c 2011-08-15 19:24:39 UTC (rev 3615)
+++ trunk/LWJGL/src/native/windows/org_lwjgl_Sys.c 2011-08-16 22:17:32 UTC (rev 3616)
@@ -1,35 +1,35 @@
-/*
+/*
* Copyright (c) 2002-2008 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
+ * modification, are permitted provided that the following conditions are
* met:
- *
- * * Redistributions of source code must retain the above copyright
+ *
+ * * 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
+ * * 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
+ * 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
+ * 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.
*/
-
+
/**
* $Id$
*
@@ -56,16 +56,9 @@
return time;
}
-JNIEXPORT void JNICALL Java_org_lwjgl_WindowsSysImplementation_nAlert(JNIEnv * env, jclass unused, jlong hwnd_ptr, jstring title, jstring message) {
+JNIEXPORT void JNICALL Java_org_lwjgl_WindowsSysImplementation_nAlert(JNIEnv * env, jclass unused, jlong hwnd_ptr, jlong title, jlong message) {
HWND hwnd = (HWND)(INT_PTR)hwnd_ptr;
- char * eMessageText = GetStringNativeChars(env, message);
- char * cTitleBarText = GetStringNativeChars(env, title);
- MessageBox(hwnd, eMessageText, cTitleBarText, MB_OK | MB_TOPMOST);
-
- printfDebugJava(env, "*** Alert ***%s\n%s\n", cTitleBarText, eMessageText);
-
- free(eMessageText);
- free(cTitleBarText);
+ MessageBox(hwnd, (LPCTSTR)(intptr_t)message, (LPCTSTR)(intptr_t)title, MB_OK | MB_TOPMOST);
}
JNIEXPORT void JNICALL Java_org_lwjgl_WindowsSysImplementation_initCommonControls(JNIEnv * env, jclass unused) {
Modified: trunk/LWJGL/src/native/windows/org_lwjgl_opengl_Display.c
===================================================================
--- trunk/LWJGL/src/native/windows/org_lwjgl_opengl_Display.c 2011-08-15 19:24:39 UTC (rev 3615)
+++ trunk/LWJGL/src/native/windows/org_lwjgl_opengl_Display.c 2011-08-16 22:17:32 UTC (rev 3616)
@@ -40,9 +40,9 @@
*/
#define _PRIVATE_WINDOW_H_
-#include <windowsx.h>
#include <malloc.h>
#include "Window.h"
+#include <windowsx.h>
/*#include "extgl_wgl.h"*/
#include "common_tools.h"
#include "display.h"
@@ -51,7 +51,7 @@
#include "context.h"
#include <commctrl.h>
-#define WINDOWCLASSNAME "LWJGL"
+#define WINDOWCLASSNAME _T("LWJGL")
/*
* WindowProc for the GL window.
@@ -134,11 +134,9 @@
}
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nSetTitle
- (JNIEnv * env, jclass unused, jlong hwnd_ptr, jstring title_obj) {
+ (JNIEnv * env, jclass unused, jlong hwnd_ptr, jlong title) {
HWND hwnd = (HWND)(INT_PTR)hwnd_ptr;
- char * title = GetStringNativeChars(env, title_obj);
- SetWindowText(hwnd, title);
- free(title);
+ SetWindowText(hwnd, (LPCTSTR)(intptr_t)title);
}
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nUpdate(JNIEnv * env, jclass class) {
@@ -429,22 +427,19 @@
JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_WindowsDisplay_setWindowLongPtr
(JNIEnv *env, jclass clazz, jlong hwnd_ptr, jint nindex, jlong longPtr) {
-
HWND hwnd = (HWND)(INT_PTR)hwnd_ptr;
return SetWindowLongPtr(hwnd, nindex, (LONG_PTR) longPtr);
}
JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_WindowsDisplay_getWindowLongPtr
(JNIEnv *env, jclass clazz, jlong hwnd_ptr, jint nindex) {
-
HWND hwnd = (HWND)(INT_PTR)hwnd_ptr;
jlong result = GetWindowLongPtr(hwnd, nindex);
return result;
}
JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_WindowsDisplay_setWindowPos
- (JNIEnv *env, jclass clazz, jlong hwnd_ptr, jlong hwnd_after_ptr, jint x, jint y, jint width, jint height, jlong uflags) {
-
+ (JNIEnv *env, jclass clazz, jlong hwnd_ptr, jlong hwnd_after_ptr, jint x, jint y, jint width, jint height, jlong uflags) {
jboolean result;
HWND hwnd = (HWND)(INT_PTR)hwnd_ptr;
HWND hwnd_after = (HWND)(INT_PTR)hwnd_after_ptr;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|