You can subscribe to this list here.
| 2002 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(134) |
Sep
(52) |
Oct
(13) |
Nov
(342) |
Dec
(163) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2003 |
Jan
(44) |
Feb
(62) |
Mar
(158) |
Apr
(38) |
May
(70) |
Jun
(58) |
Jul
(104) |
Aug
(207) |
Sep
(83) |
Oct
(122) |
Nov
(23) |
Dec
(49) |
| 2004 |
Jan
(119) |
Feb
(132) |
Mar
(192) |
Apr
(140) |
May
(77) |
Jun
(74) |
Jul
(201) |
Aug
(63) |
Sep
(102) |
Oct
(70) |
Nov
(173) |
Dec
(78) |
| 2005 |
Jan
(174) |
Feb
(197) |
Mar
(105) |
Apr
(59) |
May
(77) |
Jun
(43) |
Jul
(21) |
Aug
(18) |
Sep
(47) |
Oct
(37) |
Nov
(74) |
Dec
(50) |
| 2006 |
Jan
(44) |
Feb
(19) |
Mar
(32) |
Apr
(24) |
May
(31) |
Jun
(55) |
Jul
(138) |
Aug
(28) |
Sep
(12) |
Oct
(41) |
Nov
(58) |
Dec
(24) |
| 2007 |
Jan
(28) |
Feb
(14) |
Mar
(10) |
Apr
(68) |
May
(30) |
Jun
(26) |
Jul
(18) |
Aug
(63) |
Sep
(19) |
Oct
(29) |
Nov
(20) |
Dec
(10) |
| 2008 |
Jan
(38) |
Feb
(7) |
Mar
(37) |
Apr
(120) |
May
(41) |
Jun
(36) |
Jul
(39) |
Aug
(24) |
Sep
(28) |
Oct
(30) |
Nov
(36) |
Dec
(75) |
| 2009 |
Jan
(46) |
Feb
(22) |
Mar
(50) |
Apr
(70) |
May
(134) |
Jun
(105) |
Jul
(75) |
Aug
(34) |
Sep
(38) |
Oct
(34) |
Nov
(19) |
Dec
(20) |
| 2010 |
Jan
(11) |
Feb
(20) |
Mar
(65) |
Apr
(83) |
May
(104) |
Jun
(73) |
Jul
(78) |
Aug
(57) |
Sep
(43) |
Oct
(35) |
Nov
(9) |
Dec
(4) |
| 2011 |
Jan
(21) |
Feb
(11) |
Mar
(18) |
Apr
(10) |
May
(18) |
Jun
(15) |
Jul
(48) |
Aug
(25) |
Sep
(17) |
Oct
(45) |
Nov
(15) |
Dec
(12) |
| 2012 |
Jan
(21) |
Feb
(9) |
Mar
(12) |
Apr
(9) |
May
(9) |
Jun
(5) |
Jul
(1) |
Aug
(10) |
Sep
(12) |
Oct
(1) |
Nov
(28) |
Dec
(5) |
| 2013 |
Jan
(4) |
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2014 |
Jan
|
Feb
(1) |
Mar
(1) |
Apr
|
May
(2) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(1) |
Nov
|
Dec
|
| 2015 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
(2) |
Nov
|
Dec
|
| 2016 |
Jan
(2) |
Feb
(1) |
Mar
(1) |
Apr
(1) |
May
(2) |
Jun
|
Jul
(1) |
Aug
(2) |
Sep
|
Oct
|
Nov
(1) |
Dec
|
| 2017 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| S | M | T | W | T | F | S |
|---|---|---|---|---|---|---|
|
|
|
|
1
|
2
(1) |
3
(2) |
4
|
|
5
(1) |
6
|
7
(11) |
8
(4) |
9
(2) |
10
(6) |
11
(14) |
|
12
(10) |
13
(13) |
14
(8) |
15
|
16
|
17
(2) |
18
|
|
19
|
20
|
21
|
22
|
23
|
24
|
25
|
|
26
|
27
(3) |
28
(1) |
29
|
30
|
31
|
|
|
From: Mark B. <cap...@us...> - 2004-12-11 01:56:07
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/devil In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6568/src/java/org/lwjgl/devil Modified Files: IL.java Log Message: Added load methods to read from a stream and URL Index: IL.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/devil/IL.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- IL.java 8 Dec 2004 19:16:28 -0000 1.5 +++ IL.java 11 Dec 2004 01:55:49 -0000 1.6 @@ -31,6 +31,10 @@ */ package org.lwjgl.devil; +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.net.URL; import java.nio.ByteBuffer; import java.nio.IntBuffer; @@ -45,7 +49,7 @@ * @version $Revision$ */ public class IL { - + private static final int BUFFER_LENGTH = 1000; /** Have we been created? */ protected static boolean created; @@ -62,11 +66,11 @@ public static final int IL_LUMINANCE = 0x1909; public static final int IL_BYTE = 0x1400; - public static final int IL_UNSIGNED_BYTE = 0x1401; +// public static final int IL_UNSIGNED_BYTE = 0x1401; public static final int IL_SHORT = 0x1402; - public static final int IL_UNSIGNED_SHORT = 0x1403; +// public static final int IL_UNSIGNED_SHORT = 0x1403; public static final int IL_INT = 0x1404; - public static final int IL_UNSIGNED_INT = 0x1405; +// public static final int IL_UNSIGNED_INT = 0x1405; public static final int IL_FLOAT = 0x1406; public static final int IL_DOUBLE = 0x140A; @@ -374,6 +378,123 @@ //ilLoadF() uses a Windows file handle so will not be implemented // public static native boolean ilLoadF(int Type, ILHANDLE File); public static native boolean ilLoadImage(String fileName); + public static boolean ilLoadFromURL(URL url) { + boolean result = false; + int type = IL_TYPE_UNKNOWN; + + String file = url.toString(); + int index = file.lastIndexOf('.'); + if(index != -1) { + String extension = file.substring(index + 1); + if(extension.equalsIgnoreCase("bmp")) { + type = IL_BMP; + } + else if(extension.equalsIgnoreCase("cut")) { + type = IL_CUT; + } + else if(extension.equalsIgnoreCase("gif")) { + type = IL_GIF; + } + else if(extension.equalsIgnoreCase("ico")) { + type = IL_ICO; + } + else if(extension.equalsIgnoreCase("jpg")) { + type = IL_JPG; + } + else if(extension.equalsIgnoreCase("lif")) { + type = IL_LIF; + } + else if(extension.equalsIgnoreCase("mng")) { + type = IL_MNG; + } + else if(extension.equalsIgnoreCase("pcd")) { + type = IL_PCD; + } + else if(extension.equalsIgnoreCase("pcx")) { + type = IL_PCX; + } + else if(extension.equalsIgnoreCase("pic")) { + type = IL_PIC; + } + else if(extension.equalsIgnoreCase("png")) { + type = IL_PNG; + } + else if(extension.equalsIgnoreCase("pbm") || + extension.equalsIgnoreCase("pgm") || + extension.equalsIgnoreCase("ppm")) { + type = IL_PNM; + } + else if(extension.equalsIgnoreCase("psd")) { + type = IL_PSD; + } + else if(extension.equalsIgnoreCase("psp")) { + type = IL_PSP; + } + else if(extension.equalsIgnoreCase("bw") || + extension.equalsIgnoreCase("rgb") || + extension.equalsIgnoreCase("rgba") || + extension.equalsIgnoreCase("sgi")) { + type = IL_SGI; + } + else if(extension.equalsIgnoreCase("tga")) { + type = IL_TGA; + } + else if(extension.equalsIgnoreCase("tif") || + extension.equalsIgnoreCase("tiff")) { + type = IL_TIF; + } + } + + try { + result = ilLoadFromStream(url.openStream(), type); + } + catch(IOException e) { + e.printStackTrace(); + result = false; + } + + return result; + } + public static boolean ilLoadFromStream(InputStream stream, int type) { + boolean result = false; + int bufferLength = BUFFER_LENGTH; + int lastRead = 0; + byte read[] = new byte[bufferLength]; + byte block[] = new byte[0]; + + BufferedInputStream buf = new BufferedInputStream(stream); + try { + do { + lastRead = buf.read(read); + if(lastRead != -1) { + block = appendByteArray(block, read, lastRead); + } + } while(lastRead != -1); + ByteBuffer lump = ByteBuffer.allocateDirect(block.length); + lump.put(block); + lump.flip(); + result = ilLoadL(type, lump, block.length); + } + catch(IOException e) { + e.printStackTrace(); + result = false; + } + + return result; + } + private static byte[] appendByteArray(byte oldArray[], byte copyArray[], int length) { + int oldLength = oldArray.length; + byte newArray[] = new byte[oldLength + length]; + + for(int i=0;i<oldLength;i++) { + newArray[i] = oldArray[i]; + } + for(int i=0;i<length;i++) { + newArray[i + oldLength] = copyArray[i]; + } + + return newArray; + } public static boolean ilLoadL(int Type, ByteBuffer Lump, int Size) { BufferChecks.checkDirect(Lump); return nilLoadL(Type, Lump, Lump.position(), Size); |
|
From: Elias N. <eli...@us...> - 2004-12-10 19:49:28
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/linux In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24280 Modified Files: Window.h org_lwjgl_input_Mouse.c org_lwjgl_opengl_Display.c Log Message: Index: Window.h =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/linux/Window.h,v retrieving revision 1.21 retrieving revision 1.22 diff -u -d -r1.21 -r1.22 --- Window.h 22 Sep 2004 09:28:09 -0000 1.21 +++ Window.h 10 Dec 2004 19:49:11 -0000 1.22 @@ -122,6 +122,11 @@ /* * Return true if we are in fullscreen mode */ + extern bool isFullscreen(void); + + /* + * Return true if we are in exclusive fullscreen mode + */ extern bool isLegacyFullscreen(void); /* Index: org_lwjgl_opengl_Display.c =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- org_lwjgl_opengl_Display.c 13 Nov 2004 21:06:36 -0000 1.11 +++ org_lwjgl_opengl_Display.c 10 Dec 2004 19:49:11 -0000 1.12 @@ -223,6 +223,10 @@ } } +bool isFullscreen(void) { + return current_window_mode == FULLSCREEN_LEGACY || current_window_mode == FULLSCREEN_NETWM; +} + bool isLegacyFullscreen(void) { return current_window_mode == FULLSCREEN_LEGACY; } Index: org_lwjgl_input_Mouse.c =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/linux/org_lwjgl_input_Mouse.c,v retrieving revision 1.21 retrieving revision 1.22 diff -u -d -r1.21 -r1.22 --- org_lwjgl_input_Mouse.c 12 Nov 2004 15:43:14 -0000 1.21 +++ org_lwjgl_input_Mouse.c 10 Dec 2004 19:49:11 -0000 1.22 @@ -168,7 +168,7 @@ void updatePointerGrab(void) { if (!created) return; - if (isLegacyFullscreen() || shouldGrab()) { + if (isFullscreen() || shouldGrab()) { grabPointer(); } else { ungrabPointer(); |
|
From: Mark B. <cap...@us...> - 2004-12-10 19:34:09
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/common/devil In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20979/src/native/common/devil Modified Files: org_lwjgl_devil_IL.c Log Message: Dynamic loading temporarily removed. Index: org_lwjgl_devil_IL.c =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/common/devil/org_lwjgl_devil_IL.c,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- org_lwjgl_devil_IL.c 10 Dec 2004 01:42:35 -0000 1.12 +++ org_lwjgl_devil_IL.c 10 Dec 2004 19:33:56 -0000 1.13 @@ -723,6 +723,7 @@ extern "C" { #endif JNIEXPORT void JNICALL Java_org_lwjgl_devil_IL_initNativeStubs(JNIEnv *env, jclass clazz) { +/* JavaMethodAndExtFunction functions[] = { {"ilActiveImage", "(I)Z", (void*)&Java_org_lwjgl_devil_IL_ilActiveImage, "ilActiveImage", (void*)&ilActiveImage}, {"ilActiveLayer", "(I)Z", (void*)&Java_org_lwjgl_devil_IL_ilActiveLayer, "ilActiveLayer", (void*)&ilActiveLayer}, @@ -795,6 +796,7 @@ }; int num_functions = NUMFUNCTIONS(functions); extil_InitializeClass(env, clazz, num_functions, functions); +*/ } #ifdef __cplusplus |
|
From: Elias N. <eli...@us...> - 2004-12-10 10:01:36
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27155/src/java/org/lwjgl/opengl Modified Files: KeyboardEventQueue.java Log Message: MacOSX: improved key mapping Index: KeyboardEventQueue.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl/KeyboardEventQueue.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- KeyboardEventQueue.java 25 Nov 2004 22:31:38 -0000 1.5 +++ KeyboardEventQueue.java 10 Dec 2004 10:01:21 -0000 1.6 @@ -70,7 +70,7 @@ // KEY_MAP[KeyEvent.VK_AGAIN] = Keyboard.KEY_AGAIN; // KEY_MAP[KeyEvent.VK_ALL_CANDIDATES] = Keyboard.KEY_ALL_CANDIDATES; // KEY_MAP[KeyEvent.VK_ALPHANUMERIC] = Keyboard.KEY_ALPHANUMERIC; - KEY_MAP[KeyEvent.VK_ALT] = Keyboard.KEY_LMENU; +// KEY_MAP[KeyEvent.VK_ALT] = Keyboard.KEY_LMENU; manually mapped KEY_MAP[KeyEvent.VK_ALT_GRAPH] = Keyboard.KEY_RMENU; // KEY_MAP[KeyEvent.VK_AMPERSAND] = Keyboard.KEY_AMPERSAND; // KEY_MAP[KeyEvent.VK_ASTERISK] = Keyboard.KEY_ASTERISK; @@ -91,7 +91,7 @@ KEY_MAP[KeyEvent.VK_COLON] = Keyboard.KEY_COLON; KEY_MAP[KeyEvent.VK_COMMA] = Keyboard.KEY_COMMA; // KEY_MAP[KeyEvent.VK_COMPOSE] = Keyboard.KEY_COMPOSE; - KEY_MAP[KeyEvent.VK_CONTROL] = Keyboard.KEY_LCONTROL; +// KEY_MAP[KeyEvent.VK_CONTROL] = Keyboard.KEY_LCONTROL; manually mapped KEY_MAP[KeyEvent.VK_CONVERT] = Keyboard.KEY_CONVERT; // KEY_MAP[KeyEvent.VK_COPY] = Keyboard.KEY_COPY; // KEY_MAP[KeyEvent.VK_CUT] = Keyboard.KEY_CUT; @@ -181,7 +181,7 @@ // KEY_MAP[KeyEvent.VK_LEFT_PARENTHESIS] = Keyboard.KEY_LEFT_PARENTHESIS; // KEY_MAP[KeyEvent.VK_LESS] = Keyboard.KEY_LESS; KEY_MAP[KeyEvent.VK_M] = Keyboard.KEY_M; -// KEY_MAP[KeyEvent.VK_META] = Keyboard.KEY_META; +// KEY_MAP[KeyEvent.VK_META] = Keyboard.KEY_LMENU; manually mapped KEY_MAP[KeyEvent.VK_MINUS] = Keyboard.KEY_MINUS; // KEY_MAP[KeyEvent.VK_MODECHANGE] = Keyboard.KEY_MODECHANGE; KEY_MAP[KeyEvent.VK_MULTIPLY] = Keyboard.KEY_MULTIPLY; @@ -222,7 +222,7 @@ KEY_MAP[KeyEvent.VK_SCROLL_LOCK] = Keyboard.KEY_SCROLL; KEY_MAP[KeyEvent.VK_SEMICOLON] = Keyboard.KEY_SEMICOLON; KEY_MAP[KeyEvent.VK_SEPARATOR] = Keyboard.KEY_DECIMAL; - KEY_MAP[KeyEvent.VK_SHIFT] = Keyboard.KEY_LSHIFT; +// KEY_MAP[KeyEvent.VK_SHIFT] = Keyboard.KEY_LSHIFT; manually mapped KEY_MAP[KeyEvent.VK_SLASH] = Keyboard.KEY_SLASH; KEY_MAP[KeyEvent.VK_SPACE] = Keyboard.KEY_SPACE; KEY_MAP[KeyEvent.VK_STOP] = Keyboard.KEY_STOP; @@ -257,8 +257,7 @@ key_down_buffer.position(old_position); } - private synchronized void handleKey(int key_code, byte state, char character) { - int key_code_mapped = KEY_MAP[key_code]; + private synchronized void handleKey(int key_code_mapped, byte state, char character) { if ( character == KeyEvent.CHAR_UNDEFINED ) character = Keyboard.CHAR_NONE; /* Ignore repeating presses */ @@ -269,12 +268,36 @@ putKeyboardEvent(key_code_mapped, state, key_int_char); } + private int getMappedKeyCode(int key_code, int position) { + // manually map positioned keys + switch (key_code) { + case KeyEvent.VK_ALT: // fall through + case KeyEvent.VK_META: + if (position == KeyEvent.KEY_LOCATION_RIGHT) + return Keyboard.KEY_RMENU; + else + return Keyboard.KEY_LMENU; + case KeyEvent.VK_SHIFT: + if (position == KeyEvent.KEY_LOCATION_RIGHT) + return Keyboard.KEY_RSHIFT; + else + return Keyboard.KEY_LSHIFT; + case KeyEvent.VK_CONTROL: + if (position == KeyEvent.KEY_LOCATION_RIGHT) + return Keyboard.KEY_RCONTROL; + else + return Keyboard.KEY_LCONTROL; + default: + return KEY_MAP[key_code]; + } + } + public void keyPressed(KeyEvent e) { - handleKey(e.getKeyCode(), (byte)1, e.getKeyChar()); + handleKey(getMappedKeyCode(e.getKeyCode(), e.getKeyLocation()), (byte)1, e.getKeyChar()); } public void keyReleased(KeyEvent e) { - handleKey(e.getKeyCode(), (byte)0, Keyboard.CHAR_NONE); + handleKey(getMappedKeyCode(e.getKeyCode(), e.getKeyLocation()), (byte)0, Keyboard.CHAR_NONE); } public void keyTyped(KeyEvent e) { |
|
From: Mark B. <cap...@us...> - 2004-12-10 01:42:51
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/common/devil In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3182/src/native/common/devil Modified Files: org_lwjgl_devil_IL.c Log Message: Dynamic loading Index: org_lwjgl_devil_IL.c =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/common/devil/org_lwjgl_devil_IL.c,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- org_lwjgl_devil_IL.c 8 Dec 2004 19:27:12 -0000 1.11 +++ org_lwjgl_devil_IL.c 10 Dec 2004 01:42:35 -0000 1.12 @@ -794,8 +794,7 @@ {"ilSaveData", "(Ljava/lang/String;)Z", (void*)&Java_org_lwjgl_devil_IL_ilSaveData, "ilSaveData", (void*)&ilSaveData} }; int num_functions = NUMFUNCTIONS(functions); - extil_InitializeFunctions(env, clazz, num_functions, functions); - printf("\r\ninitNativeStubs"); + extil_InitializeClass(env, clazz, num_functions, functions); } #ifdef __cplusplus |
|
From: Mark B. <cap...@us...> - 2004-12-10 01:42:16
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/common/devil In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3015/src/native/common/devil Modified Files: extil.h Log Message: Change to ASCII. Index: extil.h =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/common/devil/extil.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- extil.h 8 Dec 2004 19:15:49 -0000 1.1 +++ extil.h 10 Dec 2004 01:42:00 -0000 1.2 @@ -1,48 +1,48 @@ -#ifndef __EXTIL_H__ -#define __EXTIL_H__ - -#include <jni.h> -#include <stdio.h> -#include <string.h> -#include <IL\il.h> -#include "org_lwjgl_devil_IL.h" -#include "common_tools.h" - - -/*-----------------------------------------*/ -/*-----------------------------------------*/ - -#if defined(_WIN32) && !defined(APIENTRY) -#define WIN32_LEAN_AND_MEAN 1 -#include <windows.h> - -#endif - -#define __ilext_h_ -#define __ILEXT_H_ -#define __il_h_ -#define __IL_H__ - -#include <string.h> - -#ifndef APIENTRY -#define APIENTRY -#endif - -#include "common_tools.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/* initializes everything, call this right after the rc is created. the function returns 0 if successful */ -extern bool extil_Open(JNIEnv *env); -extern void extil_Close(void); -extern void extil_InitializeClass(JNIEnv *env, jclass clazz, int num_functions, JavaMethodAndExtFunction *functions); -extern bool extil_InitializeFunctions(int num_functions, ExtFunction *functions); - -#ifdef __cplusplus -} -#endif - -#endif /* __EXTIL_H__ */ +#ifndef __EXTIL_H__ +#define __EXTIL_H__ + +#include <jni.h> +#include <stdio.h> +#include <string.h> +#include <IL\il.h> +#include "org_lwjgl_devil_IL.h" +#include "common_tools.h" + + +/*-----------------------------------------*/ +/*-----------------------------------------*/ + +#if defined(_WIN32) && !defined(APIENTRY) +#define WIN32_LEAN_AND_MEAN 1 +#include <windows.h> + +#endif + +#define __ilext_h_ +#define __ILEXT_H_ +#define __il_h_ +#define __IL_H__ + +#include <string.h> + +#ifndef APIENTRY +#define APIENTRY +#endif + +#include "common_tools.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* initializes everything, call this right after the rc is created. the function returns 0 if successful */ +extern bool extil_Open(JNIEnv *env); +extern void extil_Close(void); +extern void extil_InitializeClass(JNIEnv *env, jclass clazz, int num_functions, JavaMethodAndExtFunction *functions); +extern bool extil_InitializeFunctions(int num_functions, ExtFunction *functions); + +#ifdef __cplusplus +} +#endif + +#endif /* __EXTIL_H__ */ |
|
From: Mark B. <cap...@us...> - 2004-12-10 01:41:36
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/common/devil In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2924/src/native/common/devil Modified Files: extil.c Log Message: Change to ASCII. Index: extil.c =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/common/devil/extil.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- extil.c 8 Dec 2004 19:15:50 -0000 1.1 +++ extil.c 10 Dec 2004 01:41:25 -0000 1.2 @@ -1,69 +1,67 @@ -#include "extil.h" - -/* turn off the warning for the borland compiler*/ -#ifdef __BORLANDC__ -#pragma warn -8064 -#pragma warn -8065 -#endif /* __BORLANDC__ */ - -#ifdef _WIN32 -HMODULE devILhandle = NULL; -#endif - -/* getProcAddress */ - -void *extil_GetProcAddress(const char *name) { -#ifdef _WIN32 - void *t = GetProcAddress(devILhandle, name); - - - if (t == NULL) { - printfDebug("Could not locate symbol %s\n", name); - } - - printf("\r\nget proc address %s %d", name, t); - - return t; -#endif -} - -void extil_InitializeClass(JNIEnv *env, jclass clazz, int num_functions, JavaMethodAndExtFunction *functions) { - ext_InitializeClass(env, clazz, &extil_GetProcAddress, num_functions, functions); -} - - -bool extil_InitializeFunctions(int num_functions, ExtFunction *functions) { - return ext_InitializeFunctions(&extil_GetProcAddress, num_functions, functions); -} - -#ifdef _WIN32 -bool extil_Open(JNIEnv *env) { - bool result = true; - - if (devILhandle == NULL) { - // load the dynamic libraries for DevIL - printf("\r\nattempting to load F:\\Apps\\DevIL\\lib\\DevIL.dll"); - devILhandle = LoadLibrary("F:\\Apps\\DevIL\\lib\\DevIL.dll"); - if (devILhandle == NULL) { - printf("\r\nfailed to load DevIL"); - result = false; - } - } - - return result; -} -#endif /* WIN32 */ - -void extgl_Close(void) { -#ifdef _WIN32 - FreeLibrary(devILhandle); - devILhandle = NULL; -#endif -} - -/* turn on the warning for the borland compiler*/ -#ifdef __BORLANDC__ -#pragma warn .8064 -#pragma warn .8065 -#endif /* __BORLANDC__ */ - +#include "extil.h" + +/* turn off the warning for the borland compiler*/ +#ifdef __BORLANDC__ +#pragma warn -8064 +#pragma warn -8065 +#endif /* __BORLANDC__ */ + +#ifdef _WIN32 +HMODULE devILhandle = NULL; +#endif + +/* getProcAddress */ + +void *extil_GetProcAddress(const char *name) { +#ifdef _WIN32 + void *t = GetProcAddress(devILhandle, name); + + + if (t == NULL) { + printfDebug("Could not locate symbol %s\n", name); + } + + + return t; +#endif +} + +void extil_InitializeClass(JNIEnv *env, jclass clazz, int num_functions, JavaMethodAndExtFunction *functions) { + ext_InitializeClass(env, clazz, &extil_GetProcAddress, num_functions, functions); +} + + +bool extil_InitializeFunctions(int num_functions, ExtFunction *functions) { + return ext_InitializeFunctions(&extil_GetProcAddress, num_functions, functions); +} + +#ifdef _WIN32 +bool extil_Open(JNIEnv *env) { + bool result = true; + + if (devILhandle == NULL) { + // load the dynamic libraries for DevIL + devILhandle = LoadLibrary("DevIL.dll"); + if (devILhandle == NULL) { + printf("\r\nfailed to load DevIL"); + result = false; + } + } + + return result; +} +#endif /* WIN32 */ + +void extgl_Close(void) { +#ifdef _WIN32 + FreeLibrary(devILhandle); + devILhandle = NULL; +#endif +} + +/* turn on the warning for the borland compiler*/ +#ifdef __BORLANDC__ +#pragma warn .8064 +#pragma warn .8065 +#endif /* __BORLANDC__ */ + |
|
From: Elias N. <eli...@us...> - 2004-12-09 15:49:02
|
Update of /cvsroot/java-game-lib/LWJGL/platform_build/win32_ms_cmdline In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19989/platform_build/win32_ms_cmdline Modified Files: build.bat Log Message: Fix win32 build script Index: build.bat =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/platform_build/win32_ms_cmdline/build.bat,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- build.bat 24 Oct 2004 20:42:20 -0000 1.8 +++ build.bat 9 Dec 2004 15:48:49 -0000 1.9 @@ -10,7 +10,7 @@ set LINKEROPTS=/link /LIBPATH:"%ALHOME%\libs" /LIBPATH:"%EAXHOME%\Libs" /LIBPATH:"%DXHOME%\Lib" /LIBPATH:"%PLTSDKHOME%\Lib" /LIBPATH:"%CHOME%\Lib" set LIBS=dinput.lib dxguid.lib OpenAL32.lib alut.lib eaxguid.lib OpenGL32.Lib Version.lib user32.lib Gdi32.lib Advapi32.lib -for %%x in (..\..\src\native\win32\*.cpp) do cl %COPTIONS% %%x +for %%x in (..\..\src\native\win32\*.c) do cl %COPTIONS% %%x for %%x in (..\..\src\native\common\*.c) do cl %COPTIONS% %%x for %%x in (..\..\src\native\common\arb\*.c) do cl %COPTIONS% %%x for %%x in (..\..\src\native\common\nv\*.c) do cl %COPTIONS% %%x |
Update of /cvsroot/java-game-lib/LWJGL/src/native/win32 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17551/src/native/win32 Added Files: LWJGL.c display.c extgl_wgl.c org_lwjgl_Sys.c org_lwjgl_input_Controller.c org_lwjgl_input_Cursor.c org_lwjgl_input_Keyboard.c org_lwjgl_input_Mouse.c org_lwjgl_opengl_Display.c org_lwjgl_opengl_Pbuffer.c Removed Files: LWJGL.cpp display.cpp extgl_wgl.cpp org_lwjgl_Sys.cpp org_lwjgl_input_Controller.cpp org_lwjgl_input_Cursor.cpp org_lwjgl_input_Keyboard.cpp org_lwjgl_input_Mouse.cpp org_lwjgl_opengl_Display.cpp org_lwjgl_opengl_Pbuffer.cpp Log Message: Converted win32 specific native source from C++->C (removes the strange debug flag behaviour exhibited by SourceLimitTest.java) --- NEW FILE: LWJGL.c --- /* * 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. */ /** * $Id: LWJGL.c,v 1.1 2004/12/09 15:36:13 elias_naur Exp $ * * Basic DLL stub. * * @author cix_foo <ci...@us...> * @version $Revision: 1.1 $ */ #define WIN32_LEAN_AND_MEAN #include <windows.h> #include <stdio.h> HINSTANCE dll_handle; /* * DLL entry point for Windows. Called when Java loads the .dll */ BOOL WINAPI DllMain( HINSTANCE hinstDLL, // handle to DLL module DWORD fdwReason, // reason for calling function LPVOID lpvReserved // reserved ) { dll_handle = hinstDLL; return TRUE; // Success } --- org_lwjgl_opengl_Display.cpp DELETED --- --- NEW FILE: org_lwjgl_input_Controller.c --- /* * 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. */ /** * $Id: org_lwjgl_input_Controller.c,v 1.1 2004/12/09 15:36:13 elias_naur Exp $ * * Win32 controller handling. * * @author Brian Matzon <br...@ma...> * @version $Revision: 1.1 $ */ #undef DIRECTINPUT_VERSION #define DIRECTINPUT_VERSION 0x0500 #include "Window.h" #include "org_lwjgl_input_Controller.h" #include <dinput.h> #include "common_tools.h" #define CONTROLLER_AXISMAX 1000 // Maxmimum range to which we'll gauge the swing #define CONTROLLER_AXISMIN -1000 // Minimum range to which we'll gauge the swing extern HINSTANCE dll_handle; static IDirectInput* cDI; // DI instance static IDirectInputDevice2* cDIDevice; // DI Device instance static DIJOYSTATE2 cJS; // State of Controller static int cButtoncount = 0; // Temporary buttoncount static bool cHasx; // Temporary xaxis check static bool cHasrx; // Temporary rotational xaxis check static bool cHasy; // Temporary yaxis check static bool cHasry; // Temporary rotational yaxis check static bool cHasz; // Temporary zaxis check static bool cHasrz; // Temporary rotational zaxis check static bool cHaspov; // Temporary pov check static bool cHasslider; // Temporary slider check static bool cCreate_success; // bool used to determine successfull creation static bool cFirstTimeInitialization = true; // boolean to determine first time initialization // Cached fields of Controller.java static jfieldID fidCButtonCount; static jfieldID fidCHasXAxis; static jfieldID fidCHasRXAxis; static jfieldID fidCHasYAxis; static jfieldID fidCHasRYAxis; static jfieldID fidCHasZAxis; static jfieldID fidCHasRZAxis; static jfieldID fidCHasPOV; static jfieldID fidCHasSlider; static jfieldID fidCButtons; static jfieldID fidCX; static jfieldID fidCRX; static jfieldID fidCY; static jfieldID fidCRY; static jfieldID fidCZ; static jfieldID fidCRZ; static jfieldID fidCPOV; static jfieldID fidCSlider; // Function prototypes (defined in the cpp file, since header file is generic across platforms void EnumerateControllerCapabilities(); void EnumerateControllers(); BOOL CALLBACK EnumControllerCallback(LPCDIDEVICEINSTANCE pdinst, LPVOID pvRef); BOOL CALLBACK EnumControllerObjectsCallback(LPCDIDEVICEOBJECTINSTANCE lpddoi, LPVOID pvRef); void ShutdownController(); void CreateController(LPCDIDEVICEINSTANCE lpddi); void SetupController(); void InitializeControllerFields(JNIEnv *env, jclass clsController); void CacheControllerFields(JNIEnv *env, jclass clsController); void UpdateControllerFields(JNIEnv *env, jclass clsController); void SetControllerCapabilities(JNIEnv *env, jclass clsController); /** * Initializes any field ids */ JNIEXPORT void JNICALL Java_org_lwjgl_input_Controller_initIDs(JNIEnv * env, jclass clazz) { /* Cache fields in Controller */ CacheControllerFields(env, clazz); } /** * Called when the Controller instance is to be created */ JNIEXPORT void JNICALL Java_org_lwjgl_input_Controller_nCreate(JNIEnv *env, jclass clazz) { // Create the DirectInput object. HRESULT hr; hr = DirectInputCreate(dll_handle, DIRECTINPUT_VERSION, &cDI, NULL); if (FAILED(hr)) { ShutdownController(); throwException(env, "DirectInputCreate failed\n"); return; } /* Find all Controllers */ EnumerateControllers(); if (!cCreate_success) { ShutdownController(); throwException(env, "Failed to enumerate."); return; } /* check that we got at least 1 controller */ if (cDIDevice == NULL) { ShutdownController(); throwException(env, "No devices found."); return; } //check for first time initialization - need to detect capabilities if (cFirstTimeInitialization) { cFirstTimeInitialization = false; /* Enumerate capabilities of Controller */ EnumerateControllerCapabilities(); if (!cCreate_success) { ShutdownController(); throwException(env, "Falied to enumerate capabilities."); return; } /* Do setup of Controller */ SetupController(); /* Initialize any fields on the Controller */ InitializeControllerFields(env, clazz); /* Set capabilities */ SetControllerCapabilities(env, clazz); } else { if(cCreate_success) { /* Do setup of Controller */ SetupController(); /* Initialize any fields on the Controller */ InitializeControllerFields(env, clazz); } } /* Aquire the Controller */ hr = IDirectInputDevice_Acquire(cDIDevice); if(FAILED(hr)) { ShutdownController(); throwException(env, "Acquire failed"); return; } } /* * Class: org_lwjgl_input_Controller * Method: nDestroy * Signature: ()V */ JNIEXPORT void JNICALL Java_org_lwjgl_input_Controller_nDestroy(JNIEnv *env, jclass clazz) { ShutdownController(); } /* * Class: org_lwjgl_input_Controller * Method: nPoll * Signature: ()V */ JNIEXPORT void JNICALL Java_org_lwjgl_input_Controller_nPoll(JNIEnv * env, jclass clazz) { HRESULT hRes; // poll the Controller to read the current state hRes = IDirectInputDevice2_Poll(cDIDevice); if (FAILED(hRes)) { printfDebug("Poll fail\n"); //check if we need to reaquire if(hRes == DIERR_INPUTLOST || hRes == DIERR_NOTACQUIRED) { IDirectInputDevice_Acquire(cDIDevice); printfDebug("DIERR_INPUTLOST, reaquiring input : cCreate_success=%d\n", cCreate_success); } return; } UpdateControllerFields(env, clazz); } /** * Shutdown DI */ static void ShutdownController() { // release device if (cDIDevice != NULL) { IDirectInputDevice_Unacquire(cDIDevice); IDirectInputDevice_Release(cDIDevice); cDIDevice = NULL; } } /** * Enumerates the capabilities of the Controller attached to the system */ static void EnumerateControllerCapabilities() { HRESULT hr; hr = IDirectInputDevice_EnumObjects(cDIDevice, EnumControllerObjectsCallback, NULL, DIDFT_ALL); if FAILED(hr) { printfDebug("EnumObjects failed\n"); cCreate_success = false; return; } cCreate_success = true; } /** * Enumerates the Controllers attached to the system */ static void EnumerateControllers() { HRESULT hr; hr = IDirectInput_EnumDevices(cDI, DIDEVTYPE_JOYSTICK, EnumControllerCallback, 0, DIEDFL_ATTACHEDONLY); if FAILED(hr) { printfDebug("EnumDevices failed\n"); cCreate_success = false; return; } cCreate_success = true; } /** * Callback from EnumDevices. Called for each Controller attached to the system */ BOOL CALLBACK EnumControllerCallback(LPCDIDEVICEINSTANCE pdinst, LPVOID pvRef) { /* Add the Controller */ CreateController(pdinst); /* just stop after 1st Controller */ return DIENUM_STOP; } /** * Callback from EnumObjects. Called for each "object" on the Controller. */ BOOL CALLBACK EnumControllerObjectsCallback(LPCDIDEVICEOBJECTINSTANCE lpddoi, LPVOID pvRef) { printfDebug("found %s\n", lpddoi->tszName); if(IsEqualGUID(&lpddoi->guidType, &GUID_Button)) { cButtoncount++; } else if(IsEqualGUID(&lpddoi->guidType, &GUID_XAxis)) { cHasx = true; } else if(IsEqualGUID(&lpddoi->guidType, &GUID_YAxis)) { cHasy = true; } else if(IsEqualGUID(&lpddoi->guidType, &GUID_ZAxis)) { cHasz = true; } else if (IsEqualGUID(&lpddoi->guidType, &GUID_POV)) { cHaspov = true; } else if (IsEqualGUID(&lpddoi->guidType, &GUID_Slider)) { cHasslider = true; } else if (IsEqualGUID(&lpddoi->guidType, &GUID_RxAxis)) { cHasrx = true; } else if (IsEqualGUID(&lpddoi->guidType, &GUID_RyAxis)) { cHasry = true; } else if (IsEqualGUID(&lpddoi->guidType, &GUID_RzAxis)) { cHasrz = true; } else { printfDebug("Unhandled object found: %s\n", lpddoi->tszName); } return DIENUM_CONTINUE; } /** * Creates the specified device as a Controller */ static void CreateController(LPCDIDEVICEINSTANCE lpddi) { HRESULT hr; hr = IDirectInput_CreateDevice(cDI, &lpddi->guidInstance, (LPDIRECTINPUTDEVICE*) &cDIDevice, NULL); if FAILED(hr) { printfDebug("CreateDevice failed\n"); cCreate_success = false; return; } cCreate_success = true; } /** * Sets up the Controller properties */ static void SetupController() { DIPROPRANGE diprg; // set Controller data format if(IDirectInputDevice_SetDataFormat(cDIDevice, &c_dfDIJoystick2) != DI_OK) { printfDebug("SetDataFormat failed\n"); cCreate_success = false; return; } // set the cooperative level if(IDirectInputDevice_SetCooperativeLevel(cDIDevice, getCurrentHWND(), DISCL_EXCLUSIVE | DISCL_FOREGROUND) != DI_OK) { printfDebug("SetCooperativeLevel failed\n"); cCreate_success = false; return; } // set range to (-1000 ... +1000) // This lets us test against 0 to see which way the stick is pointed. diprg.diph.dwSize = sizeof(diprg); diprg.diph.dwHeaderSize = sizeof(diprg.diph); diprg.diph.dwHow = DIPH_BYOFFSET; diprg.lMin = CONTROLLER_AXISMIN; diprg.lMax = CONTROLLER_AXISMAX; // set X-axis if(cHasx) { diprg.diph.dwObj = DIJOFS_X; if(IDirectInputDevice_SetProperty(cDIDevice, DIPROP_RANGE, &diprg.diph) != DI_OK) { printfDebug("SetProperty(DIJOFS_X) failed\n"); cCreate_success = false; return; } } // set RX-axis if(cHasrx) { diprg.diph.dwObj = DIJOFS_RX; if(IDirectInputDevice_SetProperty(cDIDevice, DIPROP_RANGE, &diprg.diph) != DI_OK) { printfDebug("SetProperty(DIJOFS_RX) failed\n"); cCreate_success = false; return; } } // set Y-axis if(cHasy) { diprg.diph.dwObj = DIJOFS_Y; if(IDirectInputDevice_SetProperty(cDIDevice, DIPROP_RANGE, &diprg.diph) != DI_OK) { printfDebug("SetProperty(DIJOFS_Y) failed\n"); cCreate_success = false; return; } } // set RY-axis if(cHasry) { diprg.diph.dwObj = DIJOFS_RY; if(IDirectInputDevice_SetProperty(cDIDevice, DIPROP_RANGE, &diprg.diph) != DI_OK) { printfDebug("SetProperty(DIJOFS_RY) failed\n"); cCreate_success = false; return; } } // set Z-axis if(cHasz) { diprg.diph.dwObj = DIJOFS_Z; if(IDirectInputDevice_SetProperty(cDIDevice, DIPROP_RANGE, &diprg.diph) != DI_OK) { printfDebug("SetProperty(DIJOFS_Z) failed\n"); cCreate_success = false; return; } } // set RZ-axis if(cHasrz) { diprg.diph.dwObj = DIJOFS_RZ; if(IDirectInputDevice_SetProperty(cDIDevice, DIPROP_RANGE, &diprg.diph) != DI_OK) { printfDebug("SetProperty(DIJOFS_RZ) failed\n"); cCreate_success = false; return; } } // // Lastly slider // using z axis since we're running dx 5 // if(cHasslider) { diprg.diph.dwObj = DIJOFS_Z; if(IDirectInputDevice_SetProperty(cDIDevice, DIPROP_RANGE, &diprg.diph) != DI_OK) { printfDebug("SetProperty(DIJOFS_Z(SLIDER)) failed\n"); cCreate_success = false; return; } } cCreate_success = true; } /** * Sets the fields on the Controller */ static void InitializeControllerFields(JNIEnv *env, jclass clsController) { //create buttons array jbooleanArray cButtonsArray = (*env)->NewBooleanArray(env, cButtoncount); //set buttons array (*env)->SetStaticObjectField(env, clsController, fidCButtons, cButtonsArray); } /** * Updates the fields on the Controller */ static void UpdateControllerFields(JNIEnv *env, jclass clsController) { int i; jbyteArray buttonsArray; HRESULT hRes; // get data from the Controller hRes = IDirectInputDevice_GetDeviceState(cDIDevice, sizeof(DIJOYSTATE2), &cJS); if (hRes != DI_OK) { // did the read fail because we lost input for some reason? // if so, then attempt to reacquire. if(hRes == DIERR_INPUTLOST || hRes == DIERR_NOTACQUIRED) { IDirectInputDevice_Acquire(cDIDevice); printfDebug("DIERR_INPUTLOST, reaquiring input : cCreate_success=%d\n", cCreate_success); } printfDebug("Error getting controller state: %d\n", hRes); return; } //axis's if(cHasx) { (*env)->SetStaticIntField(env, clsController, fidCX, cJS.lX); } if(cHasy) { (*env)->SetStaticIntField(env, clsController, fidCY, cJS.lY); } if(cHasz) { (*env)->SetStaticIntField(env, clsController, fidCZ, cJS.lZ); } //rotational axis if(cHasrx) { (*env)->SetStaticIntField(env, clsController, fidCRX, cJS.lRx); } if(cHasry) { (*env)->SetStaticIntField(env, clsController, fidCRY, cJS.lRy); } if(cHasrz) { (*env)->SetStaticIntField(env, clsController, fidCRZ, cJS.lRz); } //buttons for (i = 0; i < cButtoncount; i++) { if (cJS.rgbButtons[i] != 0) { cJS.rgbButtons[i] = 1; } else { cJS.rgbButtons[i] = 0; } } buttonsArray = (jbyteArray) (*env)->GetStaticObjectField(env, clsController, fidCButtons); (*env)->SetByteArrayRegion(env, buttonsArray, 0, cButtoncount, (jbyte *)cJS.rgbButtons); //pov if(cHaspov) { (*env)->SetStaticIntField(env, clsController, fidCPOV, cJS.rgdwPOV[0]); } //slider if(cHasslider) { (*env)->SetStaticIntField(env, clsController, fidCSlider, cJS.lZ); } } /** * Sets the capabilities of the Controller */ static void SetControllerCapabilities(JNIEnv *env, jclass clsController) { //set buttoncount (*env)->SetStaticIntField(env, clsController, fidCButtonCount, cButtoncount); //set axis (*env)->SetStaticBooleanField(env, clsController, fidCHasXAxis, cHasx); (*env)->SetStaticBooleanField(env, clsController, fidCHasYAxis, cHasy); (*env)->SetStaticBooleanField(env, clsController, fidCHasZAxis, cHasz); //set rotational axis (*env)->SetStaticBooleanField(env, clsController, fidCHasRXAxis, cHasrx); (*env)->SetStaticBooleanField(env, clsController, fidCHasRYAxis, cHasry); (*env)->SetStaticBooleanField(env, clsController, fidCHasRZAxis, cHasrz); //set pov (*env)->SetStaticBooleanField(env, clsController, fidCHasPOV, cHaspov); //set slider (*env)->SetStaticBooleanField(env, clsController, fidCHasSlider, cHasslider); } /** * Caches the field ids for quicker access */ static void CacheControllerFields(JNIEnv *env, jclass clsController) { fidCButtonCount = (*env)->GetStaticFieldID(env, clsController, "buttonCount", "I"); fidCHasXAxis = (*env)->GetStaticFieldID(env, clsController, "hasXAxis", "Z"); fidCHasRXAxis = (*env)->GetStaticFieldID(env, clsController, "hasRXAxis", "Z"); fidCHasYAxis = (*env)->GetStaticFieldID(env, clsController, "hasYAxis", "Z"); fidCHasRYAxis = (*env)->GetStaticFieldID(env, clsController, "hasRYAxis", "Z"); fidCHasZAxis = (*env)->GetStaticFieldID(env, clsController, "hasZAxis", "Z"); fidCHasRZAxis = (*env)->GetStaticFieldID(env, clsController, "hasRZAxis", "Z"); fidCHasPOV = (*env)->GetStaticFieldID(env, clsController, "hasPOV", "Z"); fidCHasSlider = (*env)->GetStaticFieldID(env, clsController, "hasSlider", "Z"); fidCButtons = (*env)->GetStaticFieldID(env, clsController, "buttons", "[Z"); fidCX = (*env)->GetStaticFieldID(env, clsController, "x", "I"); fidCRX = (*env)->GetStaticFieldID(env, clsController, "rx", "I"); fidCY = (*env)->GetStaticFieldID(env, clsController, "y", "I"); fidCRY = (*env)->GetStaticFieldID(env, clsController, "ry", "I"); fidCZ = (*env)->GetStaticFieldID(env, clsController, "z", "I"); fidCRZ = (*env)->GetStaticFieldID(env, clsController, "rz", "I"); fidCPOV = (*env)->GetStaticFieldID(env, clsController, "pov", "I"); fidCSlider = (*env)->GetStaticFieldID(env, clsController, "slider", "I"); } --- org_lwjgl_opengl_Pbuffer.cpp DELETED --- --- NEW FILE: extgl_wgl.c --- /* ---------------------------------------------------------------------------- Copyright (c) 2001-2002, Lev Povalahev 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. * The name of the author 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. ------------------------------------------------------------------------------*/ /* Lev Povalahev le...@gm... http://www.uni-karlsruhe.de/~uli2/ */ #include <stdio.h> #include <string.h> #include "extgl.h" #include "extgl_wgl.h" #include "common_tools.h" /* WGL_EXT_etxension_string */ wglGetExtensionsStringEXTPROC wglGetExtensionsStringEXT = NULL; /* WGL_ARB_extension_string */ wglGetExtensionsStringARBPROC wglGetExtensionsStringARB = NULL; /* WGL_ARB_pbuffer */ wglCreatePbufferARBPROC wglCreatePbufferARB = NULL; wglGetPbufferDCARBPROC wglGetPbufferDCARB = NULL; wglReleasePbufferDCARBPROC wglReleasePbufferDCARB = NULL; wglDestroyPbufferARBPROC wglDestroyPbufferARB = NULL; wglQueryPbufferARBPROC wglQueryPbufferARB = NULL; /* WGL_ARB_pixel_format */ wglGetPixelFormatAttribivARBPROC wglGetPixelFormatAttribivARB = NULL; wglGetPixelFormatAttribfvARBPROC wglGetPixelFormatAttribfvARB = NULL; wglChoosePixelFormatARBPROC wglChoosePixelFormatARB = NULL; /* WGL_ARB_render_texture */ wglBindTexImageARBPROC wglBindTexImageARB = NULL; wglReleaseTexImageARBPROC wglReleaseTexImageARB = NULL; wglSetPbufferAttribARBPROC wglSetPbufferAttribARB = NULL; /* WGL_EXT_swap_control */ wglSwapIntervalEXTPROC wglSwapIntervalEXT = NULL; wglGetSwapIntervalEXTPROC wglGetSwapIntervalEXT = NULL; /* WGL_ARB_make_current_read */ wglMakeContextCurrentARBPROC wglMakeContextCurrentARB = NULL; wglGetCurrentReadDCARBPROC wglGetCurrentReadDCARB = NULL; /** returns true if the extention is available */ static bool WGLQueryExtension(JNIEnv *env, const char *name) { const GLubyte *extensions; if (wglGetExtensionsStringARB == NULL) if (wglGetExtensionsStringEXT == NULL) return false; else extensions = (GLubyte*)wglGetExtensionsStringEXT(); else extensions = (GLubyte*)wglGetExtensionsStringARB(wglGetCurrentDC()); return extgl_QueryExtension(env, extensions, name); } static void extgl_InitWGLARBPbuffer(JNIEnv *env) { ExtFunction functions[] = { {"wglCreatePbufferARB", (void **)&wglCreatePbufferARB}, {"wglGetPbufferDCARB", (void **)&wglGetPbufferDCARB}, {"wglReleasePbufferDCARB", (void **)&wglReleasePbufferDCARB}, {"wglDestroyPbufferARB", (void **)&wglDestroyPbufferARB}, {"wglQueryPbufferARB", (void **)&wglQueryPbufferARB}}; if (extgl_Extensions.WGL_ARB_pbuffer) extgl_Extensions.WGL_ARB_pbuffer = extgl_InitializeFunctions(sizeof(functions)/sizeof(ExtFunction), functions); } static void extgl_InitWGLARBPixelFormat(JNIEnv *env) { ExtFunction functions[] = { {"wglGetPixelFormatAttribivARB", (void **)&wglGetPixelFormatAttribivARB}, {"wglGetPixelFormatAttribfvARB", (void **)&wglGetPixelFormatAttribfvARB}, {"wglChoosePixelFormatARB", (void **)&wglChoosePixelFormatARB}}; if (extgl_Extensions.WGL_ARB_pixel_format) extgl_Extensions.WGL_ARB_pixel_format = extgl_InitializeFunctions(sizeof(functions)/sizeof(ExtFunction), functions); } static void extgl_InitWGLARBRenderTexture(JNIEnv *env) { ExtFunction functions[] = { {"wglBindTexImageARB", (void **)&wglBindTexImageARB}, {"wglReleaseTexImageARB", (void **)&wglReleaseTexImageARB}, {"wglSetPbufferAttribARB", (void **)&wglSetPbufferAttribARB}}; if (extgl_Extensions.WGL_ARB_render_texture) extgl_Extensions.WGL_ARB_render_texture = extgl_InitializeFunctions(sizeof(functions)/sizeof(ExtFunction), functions); } static void extgl_InitWGLEXTSwapControl(JNIEnv *env) { ExtFunction functions[] = { {"wglSwapIntervalEXT", (void **)&wglSwapIntervalEXT}, {"wglGetSwapIntervalEXT", (void **)&wglGetSwapIntervalEXT}}; if (extgl_Extensions.WGL_EXT_swap_control) extgl_Extensions.WGL_EXT_swap_control = extgl_InitializeFunctions(sizeof(functions)/sizeof(ExtFunction), functions); } static void extgl_InitWGLARBMakeCurrentRead(JNIEnv *env) { ExtFunction functions[] = { {"wglMakeContextCurrentARB", (void **)&wglMakeContextCurrentARB}, {"wglGetCurrentReadDCARB", (void **)&wglGetCurrentReadDCARB}}; if (extgl_Extensions.WGL_ARB_make_current_read) extgl_Extensions.WGL_ARB_make_current_read = extgl_InitializeFunctions(sizeof(functions)/sizeof(ExtFunction), functions); } static void extgl_InitSupportedWGLExtensions(JNIEnv *env) { extgl_Extensions.WGL_ARB_buffer_region = WGLQueryExtension(env, "WGL_ARB_buffer_region"); extgl_Extensions.WGL_ARB_make_current_read = WGLQueryExtension(env, "WGL_ARB_make_current_read"); extgl_Extensions.WGL_ARB_multisample = WGLQueryExtension(env, "WGL_ARB_multisample"); extgl_Extensions.WGL_ARB_pbuffer = WGLQueryExtension(env, "WGL_ARB_pbuffer"); extgl_Extensions.WGL_ARB_pixel_format = WGLQueryExtension(env, "WGL_ARB_pixel_format"); extgl_Extensions.WGL_ARB_render_texture = WGLQueryExtension(env, "WGL_ARB_render_texture"); extgl_Extensions.WGL_EXT_swap_control = WGLQueryExtension(env, "WGL_EXT_swap_control"); extgl_Extensions.WGL_NV_render_depth_texture = WGLQueryExtension(env, "WGL_NV_render_depth_texture"); extgl_Extensions.WGL_NV_render_texture_rectangle = WGLQueryExtension(env, "WGL_NV_render_texture_rectangle"); } void extgl_InitWGL(JNIEnv *env) { ExtFunction functions[] = { {"wglGetExtensionsStringARB", (void **)&wglGetExtensionsStringARB}, {"wglGetExtensionsStringEXT", (void **)&wglGetExtensionsStringEXT}}; extgl_InitializeFunctions(sizeof(functions)/sizeof(ExtFunction), functions); extgl_Extensions.WGL_ARB_extensions_string = wglGetExtensionsStringARB != NULL; extgl_Extensions.WGL_EXT_extensions_string = wglGetExtensionsStringEXT != NULL; extgl_InitSupportedWGLExtensions(env); extgl_InitWGLARBMakeCurrentRead(env); extgl_InitWGLEXTSwapControl(env); extgl_InitWGLARBRenderTexture(env); extgl_InitWGLARBPixelFormat(env); extgl_InitWGLARBPbuffer(env); //extgl_InitWGLARBBufferRegion(env); } --- NEW FILE: display.c --- /* * 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. */ /** * $Id: display.c,v 1.1 2004/12/09 15:36:13 elias_naur Exp $ * * Win32 specific library for display handling. * * @author cix_foo <ci...@us...> * @version $Revision: 1.1 $ */ #include <windows.h> #include <jni.h> #include "display.h" #include "common_tools.h" #define WINDOWCLASSNAME "LWJGLWINDOW" #define GAMMA_SIZE (3*256) static jobjectArray GetAvailableDisplayModesEx(JNIEnv * env); static jobjectArray GetAvailableDisplayModes(JNIEnv * env); static char * getDriver(); static bool modeSet = false; // Whether we've done a display mode change static WORD originalGamma[GAMMA_SIZE]; // Original gamma settings static WORD currentGamma[GAMMA_SIZE]; // Current gamma settings static DEVMODE devmode; // Now we'll remember this value for the future extern HWND display_hwnd; // Handle to the window extern RECT clientSize; jobjectArray getAvailableDisplayModes(JNIEnv *env) { jobjectArray result = GetAvailableDisplayModesEx(env); if (result == NULL) { printfDebug("Extended display mode selection failed, using fallback\n"); result = GetAvailableDisplayModes(env); } return result; } /** * Choose displaymodes using extended codepath (multiple displaydevices) */ static jobjectArray GetAvailableDisplayModesEx(JNIEnv * env) { typedef BOOL (WINAPI * EnumDisplayDevicesAPROC)(IN LPCSTR lpDevice, IN DWORD iDevNum, OUT PDISPLAY_DEVICEA lpDisplayDevice, IN DWORD dwFlags); typedef BOOL (WINAPI * EnumDisplaySettingsExAPROC)(IN LPCSTR lpszDeviceName, IN DWORD iModeNum, OUT LPDEVMODEA lpDevMode, IN DWORD dwFlags); EnumDisplayDevicesAPROC EnumDisplayDevicesA; EnumDisplaySettingsExAPROC EnumDisplaySettingsExA; HMODULE lib_handle = LoadLibrary("user32.dll"); int i = 0, j = 0, n = 0; int AvailableModes = 0; DISPLAY_DEVICE DisplayDevice; DEVMODE DevMode; jclass displayModeClass; jobjectArray ret; jmethodID displayModeConstructor; if (lib_handle == NULL) { printfDebug("Could not load user32.dll\n"); return NULL; } EnumDisplayDevicesA = (EnumDisplayDevicesAPROC)GetProcAddress(lib_handle, "EnumDisplayDevicesA"); if (EnumDisplayDevicesA == NULL) return NULL; EnumDisplaySettingsExA = (EnumDisplaySettingsExAPROC)GetProcAddress(lib_handle, "EnumDisplaySettingsExA"); if (EnumDisplaySettingsExA == NULL) return NULL; ZeroMemory(&DevMode, sizeof(DEVMODE)); ZeroMemory(&DisplayDevice, sizeof(DISPLAY_DEVICE)); DevMode.dmSize = sizeof(DEVMODE); DisplayDevice.cb = sizeof(DISPLAY_DEVICE); //enumerate all displays, and all of their displaymodes while(EnumDisplayDevicesA(NULL, i++, &DisplayDevice, 0) != 0) { // continue if mirroring device if((DisplayDevice.StateFlags & DISPLAY_DEVICE_MIRRORING_DRIVER) != 0) { continue; } // go ahead printfDebug("Querying %s device\n", DisplayDevice.DeviceString); j = 0; while(EnumDisplaySettingsExA((const char *) DisplayDevice.DeviceName, j++, &DevMode, 0) != 0) { if (DevMode.dmBitsPerPel > 8 && ChangeDisplaySettings(&DevMode, CDS_FULLSCREEN | CDS_TEST) == DISP_CHANGE_SUCCESSFUL) { AvailableModes++; } } } printfDebug("Found %d displaymodes\n", AvailableModes); // now that we have the count create the classes, and add 'em all - we'll remove dups in Java // Allocate an array of DisplayModes big enough displayModeClass = (*env)->FindClass(env, "org/lwjgl/opengl/DisplayMode"); ret = (*env)->NewObjectArray(env, AvailableModes, displayModeClass, NULL); displayModeConstructor = (*env)->GetMethodID(env, displayModeClass, "<init>", "(IIII)V"); i = 0, n = 0; while(EnumDisplayDevicesA(NULL, i++, &DisplayDevice, 0) != 0) { // continue if mirroring device if((DisplayDevice.StateFlags & DISPLAY_DEVICE_MIRRORING_DRIVER) != 0) { continue; } j = 0; while(EnumDisplaySettingsExA((const char *) DisplayDevice.DeviceName, j++, &DevMode, 0) != 0) { // Filter out indexed modes if (DevMode.dmBitsPerPel > 8 && ChangeDisplaySettings(&DevMode, CDS_FULLSCREEN | CDS_TEST) == DISP_CHANGE_SUCCESSFUL) { jobject displayMode; displayMode = (*env)->NewObject(env, displayModeClass, displayModeConstructor, DevMode.dmPelsWidth, DevMode.dmPelsHeight, DevMode.dmBitsPerPel, DevMode.dmDisplayFrequency); (*env)->SetObjectArrayElement(env, ret, n++, displayMode); } } } FreeLibrary(lib_handle); return ret; } /** * Choose displaymodes using standard codepath (single displaydevice) */ static jobjectArray GetAvailableDisplayModes(JNIEnv * env) { int i = 0, j = 0, n = 0; int AvailableModes = 0; DEVMODE DevMode; jclass displayModeClass; jobjectArray ret; jmethodID displayModeConstructor; ZeroMemory(&DevMode, sizeof(DEVMODE)); DevMode.dmSize = sizeof(DEVMODE); //enumerate all displaymodes while(EnumDisplaySettings(NULL, j++, &DevMode) != 0) { if (DevMode.dmBitsPerPel > 8 && ChangeDisplaySettings(&DevMode, CDS_FULLSCREEN | CDS_TEST) == DISP_CHANGE_SUCCESSFUL) { AvailableModes++; } } printfDebug("Found %d displaymodes\n", AvailableModes); // now that we have the count create the classes, and add 'em all - we'll remove dups in Java // Allocate an array of DisplayModes big enough displayModeClass = (*env)->FindClass(env, "org/lwjgl/opengl/DisplayMode"); ret = (*env)->NewObjectArray(env, AvailableModes, displayModeClass, NULL); displayModeConstructor = (*env)->GetMethodID(env, displayModeClass, "<init>", "(IIII)V"); i = 0, j = 0, n = 0; while(EnumDisplaySettings(NULL, j++, &DevMode) != 0) { // Filter out indexed modes if (DevMode.dmBitsPerPel > 8 && ChangeDisplaySettings(&DevMode, CDS_FULLSCREEN | CDS_TEST) == DISP_CHANGE_SUCCESSFUL) { jobject displayMode; displayMode = (*env)->NewObject(env, displayModeClass, displayModeConstructor, DevMode.dmPelsWidth, DevMode.dmPelsHeight, DevMode.dmBitsPerPel, DevMode.dmDisplayFrequency); (*env)->SetObjectArrayElement(env, ret, n++, displayMode); } } return ret; } void switchDisplayMode(JNIEnv * env, jobject mode) { 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"); jfieldID fid_bpp = (*env)->GetFieldID(env, cls_displayMode, "bpp", "I"); jfieldID fid_freq = (*env)->GetFieldID(env, cls_displayMode, "freq", "I"); int width = (*env)->GetIntField(env, mode, fid_width); int height = (*env)->GetIntField(env, mode, fid_height); int bpp = (*env)->GetIntField(env, mode, fid_bpp); int freq = (*env)->GetIntField(env, mode, fid_freq); LONG cdsret; devmode.dmSize = sizeof(DEVMODE); devmode.dmBitsPerPel = bpp; devmode.dmPelsWidth = width; devmode.dmPelsHeight = height; devmode.dmDisplayFlags = 0; devmode.dmDisplayFrequency = freq; devmode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT | DM_DISPLAYFLAGS; if (freq != 0) devmode.dmFields |= DM_DISPLAYFREQUENCY; cdsret = ChangeDisplaySettings(&devmode, CDS_FULLSCREEN); if (cdsret != DISP_CHANGE_SUCCESSFUL) { // Failed: so let's check to see if it's a wierd dual screen display printfDebug("Failed to set display mode... assuming dual monitors\n"); devmode.dmPelsWidth = width * 2; cdsret = ChangeDisplaySettings(&devmode, CDS_FULLSCREEN); if (cdsret != DISP_CHANGE_SUCCESSFUL) { printfDebug("Failed to set display mode using dual monitors\n"); throwException(env, "Failed to set display mode."); return; } } modeSet = true; } int getGammaRampLength(void) { return 256; } void setGammaRamp(JNIEnv * env, jobject gammaRampBuffer) { int i; float scaledRampEntry; WORD rampEntry; HDC screenDC; const float *gammaRamp = (const float *)(*env)->GetDirectBufferAddress(env, gammaRampBuffer); // Turn array of floats into array of RGB WORDs for (i = 0; i < 256; i ++) { scaledRampEntry = gammaRamp[i]*0xffff; rampEntry = (WORD)scaledRampEntry; currentGamma[i] = rampEntry; currentGamma[i + 256] = rampEntry; currentGamma[i + 512] = rampEntry; } screenDC = GetDC(NULL); if (SetDeviceGammaRamp(screenDC, currentGamma) == FALSE) { throwException(env, "Failed to set device gamma."); } ReleaseDC(NULL, screenDC); } jobject initDisplay(JNIEnv * env) { int width; int height; int bpp; int freq; jclass jclass_DisplayMode; jmethodID ctor; jobject newMode; // Determine the current screen resolution // Get the screen HDC screenDC = GetDC(NULL); if (!screenDC) { throwException(env, "Couldn't get screen DC!"); return NULL; } // Get the device caps width = GetDeviceCaps(screenDC, HORZRES); height = GetDeviceCaps(screenDC, VERTRES); bpp = GetDeviceCaps(screenDC, BITSPIXEL); freq = GetDeviceCaps(screenDC, VREFRESH); if (freq <= 1) freq = 0; // Unknown jclass_DisplayMode = (*env)->FindClass(env, "org/lwjgl/opengl/DisplayMode"); ctor = (*env)->GetMethodID(env, jclass_DisplayMode, "<init>", "(IIII)V"); newMode = (*env)->NewObject(env, jclass_DisplayMode, ctor, width, height, bpp, freq); // Get the default gamma ramp if (GetDeviceGammaRamp(screenDC, originalGamma) == FALSE) { printfDebug("Failed to get initial device gamma\n"); } memcpy(currentGamma, originalGamma, sizeof(WORD)*GAMMA_SIZE); ReleaseDC(NULL, screenDC); return newMode; } void resetDisplayMode(JNIEnv * env) { // Return device gamma to normal HDC screenDC = GetDC(NULL); if (!SetDeviceGammaRamp(screenDC, originalGamma)) { printfDebug("Could not reset device gamma\n"); } ReleaseDC(NULL, screenDC); if (modeSet) { modeSet = false; // Under Win32, all we have to do is: ChangeDisplaySettings(NULL, 0); // And we'll call init() again to put the correct mode back in Display if (env != NULL) initDisplay(env); } } /* * Put display settings back to what they were when the window is maximized. */ void restoreDisplayMode(void) { // Restore gamma HDC screenDC = GetDC(NULL); LONG cdsret; if (!SetDeviceGammaRamp(screenDC, currentGamma)) { printfDebug("Could not restore device gamma\n"); } ReleaseDC(NULL, screenDC); if (!modeSet) { printfDebug("Attempting to restore the display mode\n"); modeSet = true; cdsret = ChangeDisplaySettings(&devmode, CDS_FULLSCREEN); if (cdsret != DISP_CHANGE_SUCCESSFUL) { printfDebug("Failed to restore display mode\n"); } } } static char * getDriver() { #define MY_BUFSIZE 256 HKEY hKey; static TCHAR szAdapterKey[MY_BUFSIZE], szDriverValue[MY_BUFSIZE]; DWORD dwBufLen = MY_BUFSIZE; LONG lRet; if(RegOpenKeyEx(HKEY_LOCAL_MACHINE, TEXT("HARDWARE\\DeviceMap\\Video"), 0, KEY_QUERY_VALUE, &hKey) != ERROR_SUCCESS) return NULL; lRet = RegQueryValueEx(hKey, TEXT("\\Device\\Video0"), NULL, NULL, (LPBYTE)szAdapterKey, &dwBufLen); RegCloseKey(hKey); if(lRet != ERROR_SUCCESS) return NULL; printfDebug("Adapter key: %s\n", szAdapterKey); // szAdapterKey now contains something like \Registry\Machine\System\CurrentControlSet\Control\Video\{B70DBD2A-90C4-41CF-A58E-F3BA69F1A6BC}\0000 // We'll check for the first chunk: if (strnicmp("\\Registry\\Machine", szAdapterKey, 17) == 0) { // Yes, it's right, so let's look for that key now TCHAR szDriverKey[MY_BUFSIZE]; strcpy(szDriverKey, &szAdapterKey[18]); if(RegOpenKeyEx(HKEY_LOCAL_MACHINE, TEXT(szDriverKey), 0, KEY_QUERY_VALUE, &hKey) != ERROR_SUCCESS) return NULL; lRet = RegQueryValueEx(hKey, TEXT("InstalledDisplayDrivers"), NULL, NULL, (LPBYTE)szDriverValue, &dwBufLen); RegCloseKey(hKey); } if(lRet != ERROR_SUCCESS) return NULL; return szDriverValue; } jstring getAdapter(JNIEnv * env) { jstring ret = NULL; char *driver = getDriver(); if (driver == NULL) { return NULL; } ret = NewStringNative(env, driver); return ret; } jstring getVersion(JNIEnv * env) { jstring ret = NULL; TCHAR driverDLL[256] = "\0"; DWORD var = 0; DWORD dwInfoSize; LPVOID lpInfoBuff; BOOL bRetval; char *driver = getDriver(); if (driver == NULL) { return NULL; } strcat(driverDLL, driver); strcat(driverDLL, ".dll"); dwInfoSize = GetFileVersionInfoSize(driverDLL, &var); lpInfoBuff = malloc(dwInfoSize); bRetval = GetFileVersionInfo(driverDLL, 0, dwInfoSize, lpInfoBuff); if (bRetval == 0) { } else { VS_FIXEDFILEINFO * fxdFileInfo; UINT uiLen = 0; bRetval = VerQueryValue(lpInfoBuff, TEXT("\\"), (void **) &fxdFileInfo, &uiLen); if (bRetval != 0) { TCHAR version[256]; TCHAR ms[10], ls[10]; sprintf(ms, "%d.%d\0", fxdFileInfo->dwProductVersionMS >> 16, fxdFileInfo->dwProductVersionMS & 0xFFFF); sprintf(ls, "%d.%d\0", fxdFileInfo->dwProductVersionLS >> 16, fxdFileInfo->dwProductVersionLS & 0xFFFF); sprintf(version, "%s.%s\0", ms, ls); ret = NewStringNative(env, version); } } free(lpInfoBuff); return ret; } --- org_lwjgl_input_Keyboard.cpp DELETED --- --- NEW FILE: org_lwjgl_input_Mouse.c --- /* * 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. */ /** * $Id: org_lwjgl_input_Mouse.c,v 1.1 2004/12/09 15:36:13 elias_naur Exp $ * * Win32 mouse handling. * * @author Brian Matzon <br...@ma...> * @version $Revision: 1.1 $ */ #undef DIRECTINPUT_VERSION #define DIRECTINPUT_VERSION 0x0300 #include "Window.h" #include <dinput.h> #include "common_tools.h" #include "org_lwjgl_opengl_Win32Display.h" #include "org_lwjgl_input_Mouse.h" #define EVENT_SIZE 5 extern HINSTANCE dll_handle; // Handle to the LWJGL dll static LPDIRECTINPUT lpdi = NULL; // DirectInput static LPDIRECTINPUTDEVICE mDIDevice; // DI Device instance static int mButtoncount = 0; // Temporary buttoncount static bool mHaswheel; // Temporary wheel check static bool mCreate_success; // bool used to determine successfull creation static bool mFirstTimeInitialization = true; // boolean to determine first time initialization static bool mouse_grabbed; static int mouseMask = DISCL_NONEXCLUSIVE | DISCL_FOREGROUND; /* These accumulated deltas track the cursor position from Windows messages */ static int accum_dx; static int accum_dy; static int accum_dwheel; static int last_x; static int last_y; static event_queue_t event_queue; static bool buffer_enabled; // Function prototypes (defined in the cpp file, since header file is generic across platforms void EnumerateMouseCapabilities(); BOOL CALLBACK EnumMouseObjectsCallback(LPCDIDEVICEOBJECTINSTANCE lpddoi, LPVOID pvRef); void ShutdownMouse(); void CreateMouse(); void SetupMouse(); void InitializeMouseFields(); void UpdateMouseFields(JNIEnv *env, jobject coord_buffer_obj, jobject button_buffer_obj); static int transformY(int y) { RECT clientRect; GetClientRect(getCurrentHWND(), &clientRect); return (clientRect.bottom - clientRect.top) - 1 - y; } static bool putMouseEventWithCoords(jint button, jint state, jint coord1, jint coord2, jint dz) { jint event[] = {button, state, coord1, coord2, dz}; return putEvent(&event_queue, event); } static bool putMouseEvent(jint button, jint state, jint dz) { if (mouse_grabbed) return putMouseEventWithCoords(button, state, 0, 0, dz); else return putMouseEventWithCoords(button, state, last_x, last_y, dz); } static void resetCursorPos(void) { accum_dx = accum_dy = 0; } JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_Win32Display_hasWheel(JNIEnv *env, jobject self) { return mHaswheel; } JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_Win32Display_getButtonCount(JNIEnv *env, jobject self) { return mButtoncount; } /** * Called when the Mouse instance is to be created */ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Win32Display_createMouse(JNIEnv *env, jobject self) { HRESULT ret; initEventQueue(&event_queue, EVENT_SIZE); last_x = last_y = accum_dx = accum_dy = accum_dwheel = 0; buffer_enabled = false; // Create input ret = DirectInputCreate(dll_handle, DIRECTINPUT_VERSION, &lpdi, NULL); if (ret != DI_OK && ret != DIERR_BETADIRECTINPUTVERSION) { throwException(env, "Failed to create DirectInput"); return; } /* skip enumeration, since we only want system mouse */ CreateMouse(); //check for first time initialization - need to detect capabilities if (mFirstTimeInitialization) { mFirstTimeInitialization = false; /* Enumerate capabilities of Mouse */ EnumerateMouseCapabilities(); if (!mCreate_success) { throwException(env, "Failed to enumerate."); ShutdownMouse(); return; } /* Do setup of Mouse */ SetupMouse(); } else { if(mCreate_success) { /* Do setup of Mouse */ SetupMouse(); } } /* Aquire the Mouse */ ret = IDirectInputDevice_Acquire(mDIDevice); if(FAILED(ret)) { printfDebug("Failed to acquire mouse\n"); } } JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Win32Display_enableMouseBuffer(JNIEnv * env, jobject self) { buffer_enabled = true; } void handleMouseScrolled(int event_dwheel) { if(mCreate_success) { accum_dwheel += event_dwheel; putMouseEvent(-1, 0, event_dwheel); } } void handleMouseMoved(int x, int y) { int dx; int dy; if(mCreate_success) { y = transformY(y); dx = x - last_x; dy = y - last_y; accum_dx += dx; accum_dy += dy; last_x = x; last_y = y; if (mouse_grabbed) { putMouseEventWithCoords(-1, 0, dx, dy, 0); } else { putMouseEventWithCoords(-1, 0, x, y, 0); } } } void handleMouseButton(int button, int state) { if(mCreate_success) { putMouseEvent(button, state, 0); } } static void copyDXEvents(int num_di_events, DIDEVICEOBJECTDATA *di_buffer) { int buffer_index = 0; int dx = 0, dy = 0, dwheel = 0; int button_state; int i; for (i = 0; i < num_di_events; i++) { button_state = (di_buffer[i].dwData & 0x80) != 0 ? 1 : 0; switch (di_buffer[i].dwOfs) { case DIMOFS_BUTTON0: putMouseEventWithCoords(0, button_state, dx, -dy, dwheel); dx = dy = dwheel = 0; break; case DIMOFS_BUTTON1: putMouseEventWithCoords(1, button_state, dx, -dy, dwheel); dx = dy = dwheel = 0; break; case DIMOFS_BUTTON2: putMouseEventWithCoords(2, button_state, dx, -dy, dwheel); dx = dy = dwheel = 0; break; case DIMOFS_BUTTON3: putMouseEventWithCoords(3, button_state, dx, -dy, dwheel); dx = dy = dwheel = 0; break; case DIMOFS_X: dx += di_buffer[i].dwData; break; case DIMOFS_Y: dy += di_buffer[i].dwData; break; case DIMOFS_Z: dwheel += di_buffer[i].dwData; break; } } if (dx != 0 || dy != 0 || dwheel != 0) putMouseEventWithCoords(-1, 0, dx, -dy, dwheel); } static void readDXBuffer() { DIDEVICEOBJECTDATA rgdod[EVENT_BUFFER_SIZE]; DWORD num_di_events = EVENT_BUFFER_SIZE; HRESULT ret; ret = IDirectInputDevice_Acquire(mDIDevice); if (ret != DI_OK && ret != S_FALSE) return; ret = IDirectInputDevice_GetDeviceData(mDIDevice, sizeof(DIDEVICEOBJECTDATA), rgdod, &num_di_events, 0); if (ret == DI_OK) { copyDXEvents(num_di_events, rgdod); } else if (ret == DI_BUFFEROVERFLOW) { printfDebug("Buffer overflowed\n"); } else if (ret == DIERR_INPUTLOST) { printfDebug("Input lost\n"); } else if (ret == DIERR_NOTACQUIRED) { printfDebug("not acquired\n"); } else if (ret == DIERR_INVALIDPARAM) { printfDebug("invalid parameter\n"); } else if (ret == DIERR_NOTBUFFERED) { printfDebug("not buffered\n"); } else if (ret == DIERR_NOTINITIALIZED) { printfDebug("not inited\n"); } else { printfDebug("unknown keyboard error\n"); } } JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_Win32Display_readMouse (JNIEnv * env, jobject self, jobject buffer_obj, jint buffer_position) { jint* buffer_ptr = (jint *)(*env)->GetDirectBufferAddress(env, buffer_obj) + buffer_position; int buffer_size = ((*env)->GetDirectBufferCapacity(env, buffer_obj))/sizeof(jint) - buffer_position; if (mouse_grabbed) { readDXBuffer(); } else { handleMessages(); } return copyEvents(&event_queue, buffer_ptr, buffer_size); } JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_Win32Display_getNativeCursorCaps (JNIEnv *env, jobject self) { return org_lwjgl_input_Mouse_CURSOR_ONE_BIT_TRANSPARENCY; } JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Win32Display_setNativeCursor (JNIEnv *env, jobject self, jobject handle_buffer) { HCURSOR *cursor_handle; HCURSOR cursor; if (mDIDevice == NULL) throwException(env, "null device!"); if (handle_buffer != NULL) { cursor_handle = (HCURSOR *)(*env)->GetDirectBufferAddress(env, handle_buffer); cursor = *cursor_handle; SetClassLong(getCurrentHWND(), GCL_HCURSOR, (LONG)cursor); SetCursor(cursor); } else { SetClassLong(getCurrentHWND(), GCL_HCURSOR, (LONG)NULL); SetCursor(LoadCursor(NULL, IDC_ARROW)); } } JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_Win32Display_getMaxCursorSize (JNIEnv *env, jobject self) { return GetSystemMetrics(SM_CXCURSOR); } JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_Win32Display_getMinCursorSize (JNIEnv *env, jobject self) { return GetSystemMetrics(SM_CXCURSOR); } JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Win32Display_destroyMouse(JNIEnv *env, jobject self) { ShutdownMouse(); } JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Win32Display_pollMouse(JNIEnv * env, jobject self, jobject coord_buffer_obj, jobject button_buffer_obj) { IDirectInputDevice_Acquire(mDIDevice); UpdateMouseFields(env, coord_buffer_obj, button_buffer_obj); } JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Win32Display_grabMouse (JNIEnv * env, jobject self, jboolean grab) { IDirectInputDevice_Unacquire(mDIDevice); if(grab) { if (!mouse_grabbed) { mouse_grabbed = true; ShowCursor(false); mouseMask = DISCL_EXCLUSIVE | DISCL_FOREGROUND; } } else { if (mouse_grabbed) { mouse_grabbed = false; ShowCursor(true); mouseMask = DISCL_NONEXCLUSIVE | DISCL_FOREGROUND; } } IDirectInputDevice_Unacquire(mDIDevice); if (IDirectInputDevice_SetCooperativeLevel(mDIDevice, getCurrentHWND(), mouseMask) != DI_OK) { throwException(env, "Could not set the CooperativeLevel."); return; } IDirectInputDevice_Acquire(mDIDevice); initEventQueue(&event_queue, EVENT_SIZE); } /** * Shutdown DI */ static void ShutdownMouse() { // release device if (mDIDevice != NULL) { IDirectInputDevice_Unacquire(mDIDevice); IDirectInputDevice_Release(mDIDevice); mDIDevice = NULL; } // Release DirectInput if (lpdi != NULL) { printfDebug("Destroying directinput\n"); IDirectInput_Release(lpdi); lpdi = NULL; } mCreate_success = false; } /** * Enumerates the capabilities of the Mouse attached to the system */ static void EnumerateMouseCapabilities() { HRESULT hr; hr = IDirectInputDevice_EnumObjects(mDIDevice, EnumMouseObjectsCallback, NULL, DIDFT_ALL); if FAILED(hr) { printfDebug("EnumObjects failed\n"); mCreate_success = false; return; } //check for > 4 buttons - need to clamp since we're using dx 5 if(mButtoncount > 4) { mButtoncount = 4; printfDebug("WARNING: Clamping to 4 mouse buttons\n"); } mCreate_success = true; } /** * Callback from EnumObjects. Called for each "object" on the Mouse. */ static BOOL CALLBACK EnumMouseObjectsCallback(LPCDIDEVICEOBJECTINSTANCE lpddoi, LPVOID pvRef) { printfDebug("found %s\n", lpddoi->tszName); if(IsEqualGUID(&lpddoi->guidType, &GUID_Button)) { mButtoncount++; } else if(IsEqualGUID(&lpddoi->guidType, &GUID_XAxis)) { } else if(IsEqualGUID(&lpddoi->guidType, &GUID_YAxis)) { } else if(IsEqualGUID(&lpddoi->guidType, &GUID_ZAxis)) { mHaswheel = true; } else { printfDebug("Unhandled object found: %s\n", lpddoi->tszName); } return DIENUM_CONTINUE; } /** * Creates the specified device as a Mouse */ static void CreateMouse() { HRESULT hr; hr = IDirectInput_CreateDevice(lpdi, &GUID_SysMouse, &mDIDevice, NULL); if FAILED(hr) { printfDebug("CreateDevice failed\n"); mCreate_success = false; return; } mCreate_success = true; } /** * Sets up the Mouse properties */ static void SetupMouse() { DIPROPDWORD dipropdw; // set Mouse data format if(IDirectInputDevice_SetDataFormat(mDIDevice, &c_dfDIMouse) != DI_OK) { printfDebug("SetDataFormat failed\n"); mCreate_success = false; return; } dipropdw.diph.dwSize = sizeof(DIPROPDWORD); dipropdw.diph.dwHeaderSize = sizeof(DIPROPHEADER); dipropdw.diph.dwObj = 0; dipropdw.diph.dwHow = DIPH_DEVICE; dipropdw.dwData = EVENT_BUFFER_SIZE; IDirectInputDevice_SetProperty(mDIDevice, DIPROP_BUFFERSIZE, &dipropdw.diph); // set the cooperative level if (IDirectInputDevice_SetCooperativeLevel(mDIDevice, getCurrentHWND(), mouseMask) != DI_OK) { printfDebug("SetCooperativeLevel failed\n"); mCreate_success = false; return; } mCreate_success = true; resetCursorPos(); } static int cap(int val, int min, int max) { if (val < min) return min; else if (val > max) return max; else return val; } /** * Updates the fields on the Mouse */ static void UpdateMouseFields(JNIEnv *env, jobject coord_buffer_obj, jobject button_buffer_obj) { HRESULT hRes; DIMOUSESTATE diMouseState; // State of Mouse int i, j; int *coords = (int *)(*env)->GetDirectBufferAddress(env, coord_buffer_obj); int coords_length = (int)(*env)->GetDirectBufferCapacity(env, coord_buffer_obj); unsigned char *buttons_buffer = (unsigned char *)(*env)->GetDirectBufferAddress(env, button_buffer_obj); int num_buttons; int buttons_length = (int)(*env)->GetDirectBufferCapacity(env, button_buffer_obj); if (coords_length < 3) { printfDebug("ERROR: Not enough space in coords array: %d < 3\n", coords_length); return; } handleMessages(); // get data from the Mouse hRes = IDirectInputDevice_GetDeviceState(mDIDevice, sizeof(DIMOUSESTATE), &diMouseState); if (hRes != DI_OK) { // Don't allow the mouse to drift when failed diMouseState.lX = 0; diMouseState.lY = 0; diMouseState.lZ = 0; // did the read fail because we lost input for some reason? // if so, then attempt to reacquire. if(hRes == DIERR_INPUTLOST || hRes == DIERR_NOTACQUIRED) { hRes = IDirectInputDevice_Acquire(mDIDevice); if (hRes != DI_OK) return; } else { printfDebug("Error getting mouse state: %d\n", hRes); return; } } if (mouse_grabbed) { coords[0] = diMouseState.lX; coords[1] = -diMouseState.lY; coords[2] = diMouseState.lZ; } else { coords[0] = last_x; coords[1] = last_y; coords[2] = accum_dwheel; accum_dx = accum_dy = accum_dwheel = 0; } for (i = 0; i < mButtoncount; i++) { if (diMouseState.rgbButtons[i] != 0) { diMouseState.rgbButtons[i] = JNI_TRUE; } else { diMouseState.rgbButtons[i] = JNI_FALSE; } } num_buttons = mButtoncount; if (num_buttons > buttons_length) num_buttons = buttons_length; for (j = 0; j < num_buttons; j++) buttons_buffer[j] = (unsigned char)diMouseState.rgbButtons[j]; } --- display.cpp DELETED --- --- NEW FILE: org_lwjgl_Sys.c --- /* * 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. */ /** * $Id: org_lwjgl_Sys.c,v 1.1 2004/12/09 15:36:13 elias_naur Exp $ * * Win32 system library. * * @author cix_foo <ci...@us...> * @version $Revision: 1.1 $ */ #include "Window.h" #include "org_lwjgl_Sys.h" #include "org_lwjgl_opengl_Win32Display.h" #include "common_tools.h" #include <malloc.h> unsigned __int64 hires_timer_freq = 0; // Hires timer frequency unsigned __int64 hires_timer = 0; // Hires timer current time /* * Class: org_lwjgl_Sys * Method: getTimerResolution * Signature: ()J */ JNIEXPORT jlong JNICALL Java_org_lwjgl_Sys_getTimerResolution (JNIEnv * env, jclass clazz) { QueryPerformanc... [truncated message content] |
|
From: Elias N. <eli...@us...> - 2004-12-08 21:03:15
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/test/openal In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20519/src/java/org/lwjgl/test/openal Modified Files: SourceLimitTest.java Log Message: Fix small bugs in SourceLimitTest.java Index: SourceLimitTest.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/test/openal/SourceLimitTest.java,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- SourceLimitTest.java 22 Jul 2004 14:27:07 -0000 1.13 +++ SourceLimitTest.java 8 Dec 2004 21:02:50 -0000 1.14 @@ -75,6 +75,7 @@ try { CreateAllSources(); } catch(OpenALException oale) { + oale.printStackTrace(); } @@ -82,6 +83,7 @@ try { CreateSourcesStep(); } catch(Exception e) { + e.printStackTrace(); } //shutdown alExit(); @@ -122,7 +124,7 @@ IntBuffer[] sources = new IntBuffer[sourcesToCreate]; //create the sources - for (int i = 0; i <= sourcesToCreate; i++) { + for (int i = 0; i < sourcesToCreate; i++) { sources[i] = BufferUtils.createIntBuffer(1); sources[i].position(0).limit(1); AL10.alGenSources(sources[i]); @@ -160,4 +162,4 @@ SourceLimitTest sourceLimitTest = new SourceLimitTest(); sourceLimitTest.execute(args); } -} \ No newline at end of file +} |
|
From: Mark B. <cap...@us...> - 2004-12-08 19:27:22
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/common/devil In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30280/src/native/common/devil Modified Files: org_lwjgl_devil_IL.c Log Message: Fixed native exception. Index: org_lwjgl_devil_IL.c =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/common/devil/org_lwjgl_devil_IL.c,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- org_lwjgl_devil_IL.c 8 Dec 2004 19:15:49 -0000 1.10 +++ org_lwjgl_devil_IL.c 8 Dec 2004 19:27:12 -0000 1.11 @@ -794,7 +794,7 @@ {"ilSaveData", "(Ljava/lang/String;)Z", (void*)&Java_org_lwjgl_devil_IL_ilSaveData, "ilSaveData", (void*)&ilSaveData} }; int num_functions = NUMFUNCTIONS(functions); - extil_InitializeClass(env, clazz, num_functions, functions); + extil_InitializeFunctions(env, clazz, num_functions, functions); printf("\r\ninitNativeStubs"); } |
|
From: Mark B. <cap...@us...> - 2004-12-08 19:16:41
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/devil In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27627/src/java/org/lwjgl/devil Modified Files: IL.java Log Message: Add all functions that can be called platform independently. Index: IL.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/devil/IL.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- IL.java 21 Nov 2004 10:06:52 -0000 1.4 +++ IL.java 8 Dec 2004 19:16:28 -0000 1.5 @@ -451,9 +451,12 @@ */ public static void create() throws LWJGLException { if (!created) { + nCreate(); IL.initNativeStubs(); IL.ilInit(); created = true; } } + + public static native void nCreate(); } |
|
From: Mark B. <cap...@us...> - 2004-12-08 19:16:03
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/common/devil In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27474/src/native/common/devil Modified Files: org_lwjgl_devil_IL.c Added Files: extil.h extil.c Log Message: Add dynamic loading for DevIL routines. Add all functions that can be called platform independently. Index: org_lwjgl_devil_IL.c =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/common/devil/org_lwjgl_devil_IL.c,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- org_lwjgl_devil_IL.c 21 Nov 2004 10:10:05 -0000 1.9 +++ org_lwjgl_devil_IL.c 8 Dec 2004 19:15:49 -0000 1.10 @@ -1,18 +1,12 @@ -#include <IL\il.h> -#include "extgl.h" -#include "org_lwjgl_devil_IL.h" -#include "common_tools.h" +#include "extil.h" -#ifdef __cplusplus -extern "C" { -#endif /* * Class: org_lwjgl_devil_IL * Method: ilActiveImage * Signature: (I)Z */ JNIEXPORT jboolean JNICALL Java_org_lwjgl_devil_IL_ilActiveImage(JNIEnv *env, jclass clazz, jint number) { - return ilActiveImage((ILuint)number); + return ilActiveImage((ILuint)number); } /* @@ -21,7 +15,7 @@ * Signature: (I)Z */ JNIEXPORT jboolean JNICALL Java_org_lwjgl_devil_IL_ilActiveLayer(JNIEnv *env, jclass clazz, jint number) { - return ilActiveLayer((ILuint)number); + return ilActiveLayer((ILuint)number); } /* @@ -30,7 +24,7 @@ * Signature: (I)Z */ JNIEXPORT jboolean JNICALL Java_org_lwjgl_devil_IL_ilActiveMipmap(JNIEnv *env, jclass clazz, jint number) { - return ilActiveMipmap((ILuint)number); + return ilActiveMipmap((ILuint)number); } /* @@ -39,11 +33,11 @@ * Signature: (Ljava/lang/String;)Z */ JNIEXPORT jboolean JNICALL Java_org_lwjgl_devil_IL_ilApplyPal(JNIEnv *env, jclass clazz, jstring fileName) { - char *strFileName = GetStringNativeChars(env, fileName); - jboolean result = ilApplyPal((const ILstring)strFileName); - free(strFileName); + char *strFileName = GetStringNativeChars(env, fileName); + jboolean result = ilApplyPal((const ILstring)strFileName); + free(strFileName); - return result; + return result; } /* @@ -52,13 +46,13 @@ * Signature: (Ljava/lang/String;Ljava/lang/String;)Z */ JNIEXPORT jboolean JNICALL Java_org_lwjgl_devil_IL_ilApplyProfile(JNIEnv *env, jclass clazz, jstring inProfile, jstring outProfile) { - char *strInProfile = GetStringNativeChars(env, inProfile); - char *strOutProfile = GetStringNativeChars(env, outProfile); - jboolean result = ilApplyProfile((const ILstring)strInProfile, (const ILstring)strOutProfile); - free(strInProfile); - free(strOutProfile); + char *strInProfile = GetStringNativeChars(env, inProfile); + char *strOutProfile = GetStringNativeChars(env, outProfile); + jboolean result = ilApplyProfile((const ILstring)strInProfile, (const ILstring)strOutProfile); + free(strInProfile); + free(strOutProfile); - return result; + return result; } /* @@ -67,7 +61,7 @@ * Signature: (I)V */ JNIEXPORT void JNICALL Java_org_lwjgl_devil_IL_ilBindImage(JNIEnv *env, jclass clazz, jint image) { - ilBindImage(image); + ilBindImage(image); } @@ -77,7 +71,7 @@ * Signature: (IIIIIIIIII)Z */ JNIEXPORT jboolean JNICALL Java_org_lwjgl_devil_IL_ilBlit(JNIEnv *env, jclass clazz, jint source, jint destX, jint destY, jint destZ, jint srcX, jint srcY, jint srcZ, jint width, jint height, jint depth) { - return ilBlit((ILuint)source, (ILint)destX, (ILint)destY, (ILint)destZ, (ILuint)srcX, (ILuint)srcY, (ILuint)srcZ, (ILuint)width, (ILuint)height, (ILuint)depth); + return ilBlit((ILuint)source, (ILint)destX, (ILint)destY, (ILint)destZ, (ILuint)srcX, (ILuint)srcY, (ILuint)srcZ, (ILuint)width, (ILuint)height, (ILuint)depth); } /* @@ -86,7 +80,7 @@ * Signature: (FFFF)V */ JNIEXPORT void JNICALL Java_org_lwjgl_devil_IL_ilClearColour(JNIEnv *env, jclass clazz, jfloat red, jfloat green, jfloat blue, jfloat alpha) { - ilClearColour((ILclampf)red, (ILclampf)green, (ILclampf)blue, (ILclampf)alpha); + ilClearColour((ILclampf)red, (ILclampf)green, (ILclampf)blue, (ILclampf)alpha); } /* @@ -95,7 +89,7 @@ * Signature: ()Z */ JNIEXPORT jboolean JNICALL Java_org_lwjgl_devil_IL_ilClearImage(JNIEnv *env, jclass clazz) { - return ilClearImage(); + return ilClearImage(); } /* @@ -104,7 +98,7 @@ * Signature: ()I */ JNIEXPORT jint JNICALL Java_org_lwjgl_devil_IL_ilCloneCurImage(JNIEnv *env, jclass clazz) { - return ilCloneCurImage(); + return ilCloneCurImage(); } /* @@ -113,7 +107,7 @@ * Signature: (I)Z */ JNIEXPORT jboolean JNICALL Java_org_lwjgl_devil_IL_ilCompressFunc(JNIEnv *env, jclass clazz, jint mode) { - return ilCompressFunc((ILenum)mode); + return ilCompressFunc((ILenum)mode); } /* @@ -122,7 +116,7 @@ * Signature: (II)Z */ JNIEXPORT jboolean JNICALL Java_org_lwjgl_devil_IL_ilConvertImage(JNIEnv *env, jclass clazz, jint destFormat, jint destType) { - return ilConvertImage((ILenum)destFormat, (ILenum)destType); + return ilConvertImage((ILenum)destFormat, (ILenum)destType); } /* @@ -131,7 +125,7 @@ * Signature: (I)Z */ JNIEXPORT jboolean JNICALL Java_org_lwjgl_devil_IL_ilConvertPal(JNIEnv *env, jclass clazz, jint destFormat) { - return ilConvertPal((ILenum)destFormat); + return ilConvertPal((ILenum)destFormat); } /* @@ -140,7 +134,7 @@ * Signature: (I)Z */ JNIEXPORT jboolean JNICALL Java_org_lwjgl_devil_IL_ilCopyImage(JNIEnv *env, jclass clazz, jint src) { - return ilCopyImage((ILuint)src); + return ilCopyImage((ILuint)src); } /* @@ -149,9 +143,9 @@ * Signature: (IIIIIIIILjava/nio/ByteBuffer;I)I */ JNIEXPORT jint JNICALL Java_org_lwjgl_devil_IL_nilCopyPixels(JNIEnv *env, jclass clazz, jint xOff, jint yOff, jint zOff, jint width, jint height, jint depth, jint format, jint type, jobject data_buffer, jint data_offset) { - ILbyte *data = (ILbyte *)(*env)->GetDirectBufferAddress(env, data_buffer); + ILbyte *data = (ILbyte *)(*env)->GetDirectBufferAddress(env, data_buffer); - return ilCopyPixels((ILuint)xOff, (ILuint)yOff, (ILuint)zOff, (ILuint)width, (ILuint)height, (ILuint)depth, (ILenum)format, (ILenum)type, (ILvoid *)(data + data_offset)); + return ilCopyPixels((ILuint)xOff, (ILuint)yOff, (ILuint)zOff, (ILuint)width, (ILuint)height, (ILuint)depth, (ILenum)format, (ILenum)type, (ILvoid *)(data + data_offset)); } /* @@ -160,7 +154,7 @@ * Signature: (II)I */ JNIEXPORT jint JNICALL Java_org_lwjgl_devil_IL_ilCreateSubImage(JNIEnv *env, jclass clazz, jint type, jint num) { - return ilCreateSubImage((ILenum)type, (ILuint)num); + return ilCreateSubImage((ILenum)type, (ILuint)num); } /* @@ -169,17 +163,17 @@ * Signature: ()Z */ JNIEXPORT jboolean JNICALL Java_org_lwjgl_devil_IL_ilDefaultImage(JNIEnv *env, jclass clazz) { - return ilDefaultImage(); + return ilDefaultImage(); } /* * Class: org_lwjgl_devil_IL - * Method: ilDeleteImages - * Signature: (I[I)V + * Method: nilDeleteImages + * Signature: (ILjava/nio/IntBuffer;I)V */ JNIEXPORT void JNICALL Java_org_lwjgl_devil_IL_nilDeleteImages(JNIEnv * env, jclass clazz, jint num, jobject lists_buffer, jint lists_offset) { - ILbyte *lists = (ILbyte *) safeGetBufferAddress(env, lists_buffer, lists_offset); - ilDeleteImages((ILsizei)num, (ILuint *)lists); + ILbyte *lists = (ILbyte *) safeGetBufferAddress(env, lists_buffer, lists_offset); + ilDeleteImages((ILsizei)num, (ILuint *)lists); } @@ -189,7 +183,7 @@ * Signature: (I)Z */ JNIEXPORT jboolean JNICALL Java_org_lwjgl_devil_IL_ilDisable(JNIEnv *env, jclass clazz, jint mode) { - return ilDisable((ILenum)mode); + return ilDisable((ILenum)mode); } /* @@ -198,7 +192,7 @@ * Signature: (I)Z */ JNIEXPORT jboolean JNICALL Java_org_lwjgl_devil_IL_ilEnable(JNIEnv *env, jclass clazz, jint mode) { - return ilEnable((ILenum)mode); + return ilEnable((ILenum)mode); } /* @@ -207,17 +201,17 @@ * Signature: (I)Z */ JNIEXPORT jboolean JNICALL Java_org_lwjgl_devil_IL_ilFormatFunc(JNIEnv *env, jclass clazz, jint mode) { - return ilFormatFunc((ILenum)mode); + return ilFormatFunc((ILenum)mode); } /* * Class: org_lwjgl_devil_IL - * Method: ilGenImages - * Signature: (I[I)V + * Method: nilGenImages + * Signature: (ILjava/nio/IntBuffer;I)V */ JNIEXPORT void JNICALL Java_org_lwjgl_devil_IL_nilGenImages(JNIEnv *env , jclass clazz, jint num, jobject lists_buffer, jint lists_offset) { - ILbyte *lists = (ILbyte *) safeGetBufferAddress(env, lists_buffer, lists_offset); - ilGenImages((ILsizei)num, (ILuint *)lists); + ILbyte *lists = (ILbyte *) safeGetBufferAddress(env, lists_buffer, lists_offset); + ilGenImages((ILsizei)num, (ILuint *)lists); } @@ -227,12 +221,12 @@ * Signature: (I)[B */ JNIEXPORT jobject JNICALL Java_org_lwjgl_devil_IL_ilGetAlpha(JNIEnv *env, jclass clazz, jint type) { - ILubyte *alpha = ilGetAlpha((ILenum)type); + ILubyte *alpha = ilGetAlpha((ILenum)type); - int size = sizeof(alpha); - jobject result = safeNewBuffer(env, alpha, size); + int size = sizeof(alpha); + jobject result = safeNewBuffer(env, alpha, size); - return result; + return result; } /* @@ -241,7 +235,7 @@ * Signature: (I)V */ JNIEXPORT void JNICALL Java_org_lwjgl_devil_IL_ilModAlpha(JNIEnv *env, jclass clazz, jint alphaValue) { - ilModAlpha((ILint)alphaValue); + ilModAlpha((ILint)alphaValue); } /* @@ -250,7 +244,7 @@ * Signature: (I)V */ JNIEXPORT void JNICALL Java_org_lwjgl_devil_IL_ilSetAlpha(JNIEnv *env, jclass clazz, jint alphaValue) { - ilSetAlpha((ILuint)alphaValue); + ilSetAlpha((ILuint)alphaValue); } /* @@ -259,7 +253,7 @@ * Signature: (I)Z */ JNIEXPORT jboolean JNICALL Java_org_lwjgl_devil_IL_ilGetBoolean(JNIEnv *env, jclass clazz, jint mode) { - return ilGetBoolean((ILenum)mode); + return ilGetBoolean((ILenum)mode); } /* @@ -268,12 +262,12 @@ * Signature: ()[B */ JNIEXPORT jobject JNICALL Java_org_lwjgl_devil_IL_ilGetData(JNIEnv * env, jclass clazz) { - ILubyte *data = ilGetData(); + ILubyte *data = ilGetData(); - int size = ilGetInteger(IL_IMAGE_WIDTH) * ilGetInteger(IL_IMAGE_HEIGHT) * ilGetInteger(IL_IMAGE_BYTES_PER_PIXEL); - jobject result = safeNewBuffer(env, data, size); + int size = ilGetInteger(IL_IMAGE_WIDTH) * ilGetInteger(IL_IMAGE_HEIGHT) * ilGetInteger(IL_IMAGE_BYTES_PER_PIXEL); + jobject result = safeNewBuffer(env, data, size); - return result; + return result; } /* @@ -282,7 +276,7 @@ * Signature: ()I */ JNIEXPORT jint JNICALL Java_org_lwjgl_devil_IL_ilGetError(JNIEnv *env, jclass clazz) { - return ilGetError(); + return ilGetError(); } /* @@ -291,7 +285,7 @@ * Signature: (I)I */ JNIEXPORT jint JNICALL Java_org_lwjgl_devil_IL_ilGetInteger(JNIEnv *env, jclass clazz, jint mode) { - return ilGetInteger((ILenum)mode); + return ilGetInteger((ILenum)mode); } @@ -301,7 +295,7 @@ * Signature: ()I */ JNIEXPORT jint JNICALL Java_org_lwjgl_devil_IL_ilGetLumpPos(JNIEnv *env, jclass clazz) { - return ilGetLumpPos(); + return ilGetLumpPos(); } /* @@ -310,12 +304,12 @@ * Signature: ()[B */ JNIEXPORT jobject JNICALL Java_org_lwjgl_devil_IL_ilGetPalette(JNIEnv *env, jclass clazz) { - ILubyte *pal = ilGetPalette(); + ILubyte *pal = ilGetPalette(); - int size = sizeof(pal); - jobject result = safeNewBuffer(env, pal, size); + int size = sizeof(pal); + jobject result = safeNewBuffer(env, pal, size); - return result; + return result; } /* @@ -324,7 +318,7 @@ * Signature: (I)Ljava/lang/String; */ JNIEXPORT jstring JNICALL Java_org_lwjgl_devil_IL_ilGetString(JNIEnv *env, jclass clazz, jint stringName) { - return NewStringNative(env, ilGetString((ILenum)stringName)); + return NewStringNative(env, ilGetString((ILenum)stringName)); } /* @@ -333,7 +327,7 @@ * Signature: (II)V */ JNIEXPORT void JNICALL Java_org_lwjgl_devil_IL_ilHint(JNIEnv *env, jclass clazz, jint target, jint mode) { - ilHint((ILenum)target, (ILenum)mode); + ilHint((ILenum)target, (ILenum)mode); } /* @@ -342,7 +336,7 @@ * Signature: ()V */ JNIEXPORT void JNICALL Java_org_lwjgl_devil_IL_ilInit(JNIEnv * env, jclass clazz) { - ilInit(); + ilInit(); } /* @@ -351,7 +345,7 @@ * Signature: (I)Z */ JNIEXPORT jboolean JNICALL Java_org_lwjgl_devil_IL_ilIsDisabled(JNIEnv *env, jclass clazz, jint mode) { - return ilIsDisabled((ILenum)mode); + return ilIsDisabled((ILenum)mode); } /* @@ -360,7 +354,7 @@ * Signature: (I)Z */ JNIEXPORT jboolean JNICALL Java_org_lwjgl_devil_IL_ilIsEnabled(JNIEnv *env, jclass clazz, jint mode) { - return ilIsEnabled((ILenum)mode); + return ilIsEnabled((ILenum)mode); } /* @@ -369,7 +363,7 @@ * Signature: (I)Z */ JNIEXPORT jboolean JNICALL Java_org_lwjgl_devil_IL_ilIsImage(JNIEnv *env, jclass clazz, jint image) { - return ilIsImage((ILuint)image); + return ilIsImage((ILuint)image); } /* @@ -378,11 +372,11 @@ * Signature: (ILjava/lang/String;)Z */ JNIEXPORT jboolean JNICALL Java_org_lwjgl_devil_IL_ilIsValid(JNIEnv *env, jclass clazz, jint type, jstring fileName) { - char *strFileName = GetStringNativeChars(env, fileName); - jboolean result = ilIsValid((ILuint)type, (const ILstring)strFileName); - free(strFileName); + char *strFileName = GetStringNativeChars(env, fileName); + jboolean result = ilIsValid((ILuint)type, (const ILstring)strFileName); + free(strFileName); - return result; + return result; } /* @@ -391,9 +385,9 @@ * Signature: (ILjava/nio/ByteBuffer;II)Z */ JNIEXPORT jboolean JNICALL Java_org_lwjgl_devil_IL_nilIsValidL(JNIEnv *env, jclass clazz, jint type, jobject lump_buffer, jint lump_offset, jint size) { - ILbyte *lump = (ILbyte *)(*env)->GetDirectBufferAddress(env, lump_buffer); + ILbyte *lump = (ILbyte *)(*env)->GetDirectBufferAddress(env, lump_buffer); - return ilIsValidL((ILenum)type, (ILvoid *)(lump + lump_offset), (ILuint)size); + return ilIsValidL((ILenum)type, (ILvoid *)(lump + lump_offset), (ILuint)size); } /* @@ -402,7 +396,7 @@ * Signature: (FFFF)V */ JNIEXPORT void JNICALL Java_org_lwjgl_devil_IL_ilKeyColour(JNIEnv *env, jclass clazz, jfloat red, jfloat green, jfloat blue, jfloat alpha) { - ilKeyColour((ILclampf)red, (ILclampf)green, (ILclampf)blue, (ILclampf)alpha); + ilKeyColour((ILclampf)red, (ILclampf)green, (ILclampf)blue, (ILclampf)alpha); } /* @@ -411,11 +405,11 @@ * Signature: (ILjava/lang/String;)Z */ JNIEXPORT jboolean JNICALL Java_org_lwjgl_devil_IL_ilLoad(JNIEnv *env, jclass clazz, jint type, jstring fileName) { - char *strFileName = GetStringNativeChars(env, fileName); - jboolean result = ilLoad((ILenum)type, (const ILstring)strFileName); - free(strFileName); + char *strFileName = GetStringNativeChars(env, fileName); + jboolean result = ilLoad((ILenum)type, (const ILstring)strFileName); + free(strFileName); - return result; + return result; } /* @@ -424,11 +418,11 @@ * Signature: (Ljava/lang/String;)Z */ JNIEXPORT jboolean JNICALL Java_org_lwjgl_devil_IL_ilLoadImage(JNIEnv *env, jclass clazz, jstring fileName) { - char *strFileName = GetStringNativeChars(env, fileName); - jboolean result = ilLoadImage((const ILstring)strFileName); - free(strFileName); + char *strFileName = GetStringNativeChars(env, fileName); + jboolean result = ilLoadImage((const ILstring)strFileName); + free(strFileName); - return result; + return result; } @@ -438,9 +432,9 @@ * Signature: (ILjava/nio/ByteBuffer;II)Z */ JNIEXPORT jboolean JNICALL Java_org_lwjgl_devil_IL_nilLoadL(JNIEnv *env, jclass clazz, jint type, jobject lump_buffer, jint lump_offset, jint size) { - ILbyte *lump = (ILbyte *)safeGetBufferAddress(env, lump_buffer, lump_offset); + ILbyte *lump = (ILbyte *)safeGetBufferAddress(env, lump_buffer, lump_offset); - return ilLoadL((ILenum)type, (ILvoid *)(lump), (ILuint)size); + return ilLoadL((ILenum)type, (ILvoid *)(lump), (ILuint)size); } /* @@ -449,11 +443,11 @@ * Signature: (Ljava/lang/String;)Z */ JNIEXPORT jboolean JNICALL Java_org_lwjgl_devil_IL_ilLoadPal(JNIEnv *env, jclass clazz, jstring fileName) { - char *strFileName = GetStringNativeChars(env, fileName); - jboolean result = ilLoadPal((const ILstring)strFileName); - free(strFileName); + char *strFileName = GetStringNativeChars(env, fileName); + jboolean result = ilLoadPal((const ILstring)strFileName); + free(strFileName); - return result; + return result; } /* @@ -462,7 +456,7 @@ * Signature: (I)Z */ JNIEXPORT jboolean JNICALL Java_org_lwjgl_devil_IL_ilOriginFunc(JNIEnv *env, jclass clazz, jint mode) { - return ilOriginFunc((ILenum)mode); + return ilOriginFunc((ILenum)mode); } /* @@ -471,7 +465,7 @@ * Signature: (IIII)Z */ JNIEXPORT jboolean JNICALL Java_org_lwjgl_devil_IL_ilOverlayImage(JNIEnv *env, jclass clazz, jint source, jint xCoord, jint yCoord, jint zCoord) { - return ilOverlayImage((ILuint)source, (ILint)xCoord, (ILint)yCoord, (ILint)zCoord); + return ilOverlayImage((ILuint)source, (ILint)xCoord, (ILint)yCoord, (ILint)zCoord); } /* @@ -480,7 +474,7 @@ * Signature: ()V */ JNIEXPORT void JNICALL Java_org_lwjgl_devil_IL_ilPopAttrib(JNIEnv *env, jclass clazz) { - ilPopAttrib(); + ilPopAttrib(); } /* @@ -489,7 +483,7 @@ * Signature: (I)V */ JNIEXPORT void JNICALL Java_org_lwjgl_devil_IL_ilPushAttrib(JNIEnv *env, jclass clazz, jint bits) { - ilPushAttrib((ILuint)bits); + ilPushAttrib((ILuint)bits); } /* @@ -498,11 +492,11 @@ * Signature: (Ljava/lang/String;)Z */ JNIEXPORT jboolean JNICALL Java_org_lwjgl_devil_IL_ilRemoveLoad(JNIEnv *env, jclass clazz, jstring ext) { - char *strExt = GetStringNativeChars(env, ext); - jboolean result = ilRemoveLoad((const ILstring)strExt); - free(strExt); + char *strExt = GetStringNativeChars(env, ext); + jboolean result = ilRemoveLoad((const ILstring)strExt); + free(strExt); - return result; + return result; } /* @@ -511,11 +505,11 @@ * Signature: (Ljava/lang/String;)Z */ JNIEXPORT jboolean JNICALL Java_org_lwjgl_devil_IL_ilRemoveSave(JNIEnv *env, jclass clazz, jstring ext) { - char *strExt = GetStringNativeChars(env, ext); - jboolean result = ilRemoveSave((const ILstring)strExt); - free(strExt); + char *strExt = GetStringNativeChars(env, ext); + jboolean result = ilRemoveSave((const ILstring)strExt); + free(strExt); - return result; + return result; } /* @@ -524,7 +518,7 @@ * Signature: ()V */ JNIEXPORT void JNICALL Java_org_lwjgl_devil_IL_ilResetMemory(JNIEnv *env, jclass clazz) { - ilResetMemory(); + ilResetMemory(); } /* @@ -533,7 +527,7 @@ * Signature: ()V */ JNIEXPORT void JNICALL Java_org_lwjgl_devil_IL_ilResetRead(JNIEnv *env, jclass clazz) { - ilResetRead(); + ilResetRead(); } /* @@ -542,7 +536,7 @@ * Signature: ()V */ JNIEXPORT void JNICALL Java_org_lwjgl_devil_IL_ilResetWrite(JNIEnv *env, jclass clazz) { - ilResetWrite(); + ilResetWrite(); } /* @@ -551,11 +545,11 @@ * Signature: (ILjava/lang/String;)Z */ JNIEXPORT jboolean JNICALL Java_org_lwjgl_devil_IL_ilSave(JNIEnv *env, jclass clazz, jint type, jstring fileName) { - char *strFileName = GetStringNativeChars(env, fileName); - jboolean result = ilSave((ILenum)type, (const ILstring)strFileName); - free(strFileName); + char *strFileName = GetStringNativeChars(env, fileName); + jboolean result = ilSave((ILenum)type, (const ILstring)strFileName); + free(strFileName); - return result; + return result; } /* @@ -564,11 +558,11 @@ * Signature: (Ljava/lang/String;)Z */ JNIEXPORT jboolean JNICALL Java_org_lwjgl_devil_IL_ilSaveImage(JNIEnv *env, jclass clazz, jstring fileName) { - char *strFileName = GetStringNativeChars(env, fileName); - jboolean result = ilSaveImage((const ILstring)strFileName); - free(strFileName); + char *strFileName = GetStringNativeChars(env, fileName); + jboolean result = ilSaveImage((const ILstring)strFileName); + free(strFileName); - return result; + return result; } /* @@ -577,9 +571,9 @@ * Signature: (ILjava/nio/ByteBuffer;II)I */ JNIEXPORT jint JNICALL Java_org_lwjgl_devil_IL_nilSaveL(JNIEnv *env, jclass clazz, jint type, jobject lump_buffer, jint lump_offset, jint size) { - ILbyte *lump = (ILbyte *)(*env)->GetDirectBufferAddress(env, lump_buffer); + ILbyte *lump = (ILbyte *)(*env)->GetDirectBufferAddress(env, lump_buffer); - return ilSaveL((ILenum)type, (ILvoid *)(lump + lump_offset), (ILuint)size); + return ilSaveL((ILenum)type, (ILvoid *)(lump + lump_offset), (ILuint)size); } /* @@ -588,11 +582,11 @@ * Signature: (Ljava/lang/String;)Z */ JNIEXPORT jboolean JNICALL Java_org_lwjgl_devil_IL_ilSavePal(JNIEnv *env, jclass clazz, jstring fileName) { - char *strFileName = GetStringNativeChars(env, fileName); - jboolean result = ilSavePal((const ILstring)strFileName); - free(strFileName); + char *strFileName = GetStringNativeChars(env, fileName); + jboolean result = ilSavePal((const ILstring)strFileName); + free(strFileName); - return result; + return result; } /* @@ -601,9 +595,9 @@ * Signature: (Ljava/nio/ByteBuffer;I)Z */ JNIEXPORT jboolean JNICALL Java_org_lwjgl_devil_IL_nilSetData(JNIEnv *env, jclass clazz, jobject data_buffer, jint data_offset) { - ILbyte *data = (ILbyte *)(*env)->GetDirectBufferAddress(env, data_buffer); + ILbyte *data = (ILbyte *)(*env)->GetDirectBufferAddress(env, data_buffer); - return ilSetData((ILvoid *)(data + data_offset)); + return ilSetData((ILvoid *)(data + data_offset)); } /* @@ -612,7 +606,7 @@ * Signature: (I)Z */ JNIEXPORT jboolean JNICALL Java_org_lwjgl_devil_IL_ilSetDuration(JNIEnv *env, jclass clazz, jint duration) { - return ilSetDuration((ILuint)duration); + return ilSetDuration((ILuint)duration); } /* @@ -621,7 +615,7 @@ * Signature: (II)V */ JNIEXPORT void JNICALL Java_org_lwjgl_devil_IL_ilSetInteger(JNIEnv *env, jclass clazz, jint mode, jint param) { - ilSetInteger((ILenum)mode, (ILint)param); + ilSetInteger((ILenum)mode, (ILint)param); } /* @@ -630,9 +624,9 @@ * Signature: (IIIIIIIILjava/nio/ByteBuffer;I)V */ JNIEXPORT void JNICALL Java_org_lwjgl_devil_IL_nilSetPixels(JNIEnv *env, jclass clazz, jint xOff, jint yOff, jint zOff, jint width, jint height, jint depth, jint format, jint type, jobject data_buffer, jint data_offset) { - ILbyte *data = (ILbyte *)(*env)->GetDirectBufferAddress(env, data_buffer); + ILbyte *data = (ILbyte *)(*env)->GetDirectBufferAddress(env, data_buffer); - ilSetPixels((ILint)xOff, (ILint)yOff, (ILint)zOff, (ILuint)width, (ILuint)height, (ILuint)depth, (ILenum)format, (ILenum)type, (ILvoid *)(data + data_offset)); + ilSetPixels((ILint)xOff, (ILint)yOff, (ILint)zOff, (ILuint)width, (ILuint)height, (ILuint)depth, (ILenum)format, (ILenum)type, (ILvoid *)(data + data_offset)); } /* @@ -641,10 +635,10 @@ * Signature: (ILjava/lang/String;)V */ JNIEXPORT void JNICALL Java_org_lwjgl_devil_IL_ilSetString(JNIEnv *env, jclass clazz, jint mode, jstring string) { - char *strString = GetStringNativeChars(env, string); + char *strString = GetStringNativeChars(env, string); - ilSetString(mode, (const ILstring)strString); - free(strString); + ilSetString(mode, (const ILstring)strString); + free(strString); } /* @@ -653,7 +647,7 @@ * Signature: ()V */ JNIEXPORT void JNICALL Java_org_lwjgl_devil_IL_ilShutDown(JNIEnv *env, jclass clazz) { - ilShutDown(); + ilShutDown(); } /* @@ -662,9 +656,9 @@ * Signature: (IIIBIILjava/nio/ByteBuffer;I)Z */ JNIEXPORT jboolean JNICALL Java_org_lwjgl_devil_IL_nilTexImage(JNIEnv *env, jclass clazz, jint width, jint height, jint depth , jbyte bpp, jint format, jint type, jobject data_buffer, jint data_offset) { - ILbyte *data = (ILbyte *)(*env)->GetDirectBufferAddress(env, data_buffer); + ILbyte *data = (ILbyte *)(*env)->GetDirectBufferAddress(env, data_buffer); - return ilTexImage((ILuint)width, (ILuint)height, (ILuint)depth , (ILubyte)bpp, (ILenum)format, (ILenum)type, (ILvoid *)(data + data_offset)); + return ilTexImage((ILuint)width, (ILuint)height, (ILuint)depth , (ILubyte)bpp, (ILenum)format, (ILenum)type, (ILvoid *)(data + data_offset)); } /* @@ -673,7 +667,7 @@ * Signature: (I)Z */ JNIEXPORT jboolean JNICALL Java_org_lwjgl_devil_IL_ilTypeFunc(JNIEnv *env, jclass clazz, jint mode) { - return ilTypeFunc((ILenum)mode); + return ilTypeFunc((ILenum)mode); } /* @@ -682,11 +676,11 @@ * Signature: (Ljava/lang/String;IIIB)Z */ JNIEXPORT jboolean JNICALL Java_org_lwjgl_devil_IL_ilLoadData(JNIEnv *env, jclass clazz, jstring fileName, jint width, jint height, jint depth, jbyte bpp) { - char *strFileName = GetStringNativeChars(env, fileName); - jboolean result = ilLoadData((const ILstring)strFileName, (ILuint)width, (ILuint)height, (ILuint)depth, (ILubyte)bpp); - free(strFileName); + char *strFileName = GetStringNativeChars(env, fileName); + jboolean result = ilLoadData((const ILstring)strFileName, (ILuint)width, (ILuint)height, (ILuint)depth, (ILubyte)bpp); + free(strFileName); - return result; + return result; } /* @@ -695,9 +689,9 @@ * Signature: (Ljava/nio/ByteBuffer;IIIIIB)Z */ JNIEXPORT jboolean JNICALL Java_org_lwjgl_devil_IL_nilLoadDataL(JNIEnv *env, jclass clazz, jobject lump_buffer, jint lump_offset, jint size, jint width, jint height, jint depth, jbyte bpp) { - ILbyte *lump = (ILbyte *)(*env)->GetDirectBufferAddress(env, lump_buffer); + ILbyte *lump = (ILbyte *)(*env)->GetDirectBufferAddress(env, lump_buffer); - return ilLoadDataL((ILvoid *)(lump + lump_offset), (ILuint)size, (ILuint)width, (ILuint)height, (ILuint)depth, (ILubyte)bpp); + return ilLoadDataL((ILvoid *)(lump + lump_offset), (ILuint)size, (ILuint)width, (ILuint)height, (ILuint)depth, (ILubyte)bpp); } /* @@ -706,14 +700,102 @@ * Signature: (Ljava/lang/String;)Z */ JNIEXPORT jboolean JNICALL Java_org_lwjgl_devil_IL_ilSaveData(JNIEnv *env, jclass clazz, jstring fileName) { - char *strFileName = GetStringNativeChars(env, fileName); - jboolean result = ilSaveData((const ILstring)strFileName); - free(strFileName); + char *strFileName = GetStringNativeChars(env, fileName); + jboolean result = ilSaveData((const ILstring)strFileName); + free(strFileName); - return result; + return result; } +/* + * Class: org_lwjgl_devil_IL + * Method: nCreate + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_org_lwjgl_devil_IL_nCreate(JNIEnv *env, jclass clazz) { + if (!extil_Open(env)) { + throwException(env, "Failed to load DevIL library"); + return; + } +} + +#ifdef __cplusplus +extern "C" { +#endif JNIEXPORT void JNICALL Java_org_lwjgl_devil_IL_initNativeStubs(JNIEnv *env, jclass clazz) { + JavaMethodAndExtFunction functions[] = { + {"ilActiveImage", "(I)Z", (void*)&Java_org_lwjgl_devil_IL_ilActiveImage, "ilActiveImage", (void*)&ilActiveImage}, + {"ilActiveLayer", "(I)Z", (void*)&Java_org_lwjgl_devil_IL_ilActiveLayer, "ilActiveLayer", (void*)&ilActiveLayer}, + {"ilActiveMipmap", "(I)Z", (void*)&Java_org_lwjgl_devil_IL_ilActiveMipmap, "ilActiveMipmap", (void*)&ilActiveMipmap}, + {"ilApplyPal", "(Ljava/lang/String;)Z", (void*)&Java_org_lwjgl_devil_IL_ilApplyPal, "ilApplyPal", (void*)&ilApplyPal}, + {"ilApplyProfile", "(Ljava/lang/String;Ljava/lang/String;)Z", (void*)&Java_org_lwjgl_devil_IL_ilApplyProfile, "ilApplyProfile", (void*)&ilApplyProfile}, + {"ilBindImage", "(I)V", (void*)&Java_org_lwjgl_devil_IL_ilBindImage, "ilBindImage", (void*)&ilBindImage}, + {"ilBlit", "(IIIIIIIIII)Z", (void*)&Java_org_lwjgl_devil_IL_ilBlit, "ilBlit", (void*)&ilBlit}, + {"ilClearColour", "(FFFF)V", (void*)&Java_org_lwjgl_devil_IL_ilClearColour, "ilClearColour", (void*)&ilClearColour}, + {"ilClearImage", "()Z", (void*)&Java_org_lwjgl_devil_IL_ilClearImage, "ilClearImage", (void*)&ilClearImage}, + {"ilCloneCurImage", "()I", (void*)&Java_org_lwjgl_devil_IL_ilCloneCurImage, "ilCloneCurImage", (void*)&ilCloneCurImage}, + {"ilCompressFunc", "(I)Z", (void*)&Java_org_lwjgl_devil_IL_ilCompressFunc, "ilCompressFunc", (void*)&ilCompressFunc}, + {"ilConvertImage", "(II)Z", (void*)&Java_org_lwjgl_devil_IL_ilConvertImage, "ilConvertImage", (void*)&ilConvertImage}, + {"ilConvertPal", "(I)Z", (void*)&Java_org_lwjgl_devil_IL_ilConvertPal, "ilConvertPal", (void*)&ilConvertPal}, + {"ilCopyImage", "(I)Z", (void*)&Java_org_lwjgl_devil_IL_ilCopyImage, "ilCopyImage", (void*)&ilCopyImage}, + {"nilCopyPixels", "(IIIIIIIILjava/nio/ByteBuffer;I)I", (void*)&Java_org_lwjgl_devil_IL_nilCopyPixels, "ilCopyPixels", (void*)&ilCopyPixels}, + {"ilCreateSubImage", "(II)I", (void*)&Java_org_lwjgl_devil_IL_ilCreateSubImage, "ilCreateSubImage", (void*)&ilCreateSubImage}, + {"ilDefaultImage", "()Z", (void*)&Java_org_lwjgl_devil_IL_ilDefaultImage, "ilDefaultImage", (void*)&ilDefaultImage}, + {"nilDeleteImages", "(ILjava/nio/IntBuffer;I)V", (void*)&Java_org_lwjgl_devil_IL_nilDeleteImages, "ilDeleteImages", (void*)&ilDeleteImages}, + {"ilDisable", "(I)Z", (void*)&Java_org_lwjgl_devil_IL_ilDisable, "ilDisable", (void*)&ilDisable}, + {"ilEnable", "(I)Z", (void*)&Java_org_lwjgl_devil_IL_ilEnable, "ilEnable", (void*)&ilEnable}, + {"ilFormatFunc", "(I)Z", (void*)&Java_org_lwjgl_devil_IL_ilFormatFunc, "ilFormatFunc", (void*)&ilFormatFunc}, + {"nilGenImages", "(ILjava/nio/IntBuffer;I)V", (void*)&Java_org_lwjgl_devil_IL_nilGenImages, "ilGenImages", (void*)&ilGenImages}, + {"ilGetAlpha", "(I)[B", (void*)&Java_org_lwjgl_devil_IL_ilGetAlpha, "ilGetAlpha", (void*)&ilGetAlpha}, + {"ilModAlpha", "(I)V", (void*)&Java_org_lwjgl_devil_IL_ilModAlpha, "ilModAlpha", (void*)&ilModAlpha}, + {"ilSetAlpha", "(I)V", (void*)&Java_org_lwjgl_devil_IL_ilSetAlpha, "ilSetAlpha", (void*)&ilSetAlpha}, + {"ilGetBoolean", "(I)Z", (void*)&Java_org_lwjgl_devil_IL_ilGetBoolean, "ilGetBoolean", (void*)&ilGetBoolean}, + {"ilGetData", "()[B", (void*)&Java_org_lwjgl_devil_IL_ilGetData, "ilGetData", (void*)&ilGetData}, + {"ilGetError", "()I", (void*)&Java_org_lwjgl_devil_IL_ilGetError, "ilGetError", (void*)&ilGetError}, + {"ilGetInteger", "(I)I", (void*)&Java_org_lwjgl_devil_IL_ilGetInteger, "ilGetInteger", (void*)&ilGetInteger}, + {"ilGetLumpPos", "()I", (void*)&Java_org_lwjgl_devil_IL_ilGetLumpPos, "ilGetLumpPos", (void*)&ilGetLumpPos}, + {"ilGetPalette", "()[B", (void*)&Java_org_lwjgl_devil_IL_ilGetPalette, "ilGetPalette", (void*)&ilGetPalette}, + {"ilGetString", "(I)Ljava/lang/String;", (void*)&Java_org_lwjgl_devil_IL_ilGetString, "ilGetString", (void*)&ilGetString}, + {"ilHint", "(II)V", (void*)&Java_org_lwjgl_devil_IL_ilHint, "ilHint", (void*)&ilHint}, + {"ilInit", "()V", (void*)&Java_org_lwjgl_devil_IL_ilInit, "ilInit", (void*)&ilInit}, + {"ilIsDisabled", "(I)Z", (void*)&Java_org_lwjgl_devil_IL_ilIsDisabled, "ilIsDisabled", (void*)&ilIsDisabled}, + {"ilIsEnabled", "(I)Z", (void*)&Java_org_lwjgl_devil_IL_ilIsEnabled, "ilIsEnabled", (void*)&ilIsEnabled}, + {"ilIsImage", "(I)Z", (void*)&Java_org_lwjgl_devil_IL_ilIsImage, "ilIsImage", (void*)&ilIsImage}, + {"ilIsValid", "(ILjava/lang/String;)Z", (void*)&Java_org_lwjgl_devil_IL_ilIsValid, "ilIsValid", (void*)&ilIsValid}, + {"nilIsValidL", "(ILjava/nio/ByteBuffer;II)Z", (void*)&Java_org_lwjgl_devil_IL_nilIsValidL, "ilIsValidL", (void*)&ilIsValidL}, + {"ilKeyColour", "(FFFF)V", (void*)&Java_org_lwjgl_devil_IL_ilKeyColour, "ilKeyColour", (void*)&ilKeyColour}, + {"ilLoad", "(ILjava/lang/String;)Z", (void*)&Java_org_lwjgl_devil_IL_ilLoad, "ilLoad", (void*)&ilLoad}, + {"ilLoadImage", "(Ljava/lang/String;)Z", (void*)&Java_org_lwjgl_devil_IL_ilLoadImage, "ilLoadImage", (void*)&ilLoadImage}, + {"nilLoadL", "(ILjava/nio/ByteBuffer;II)Z", (void*)&Java_org_lwjgl_devil_IL_nilLoadL, "ilLoadL", (void*)&ilLoadL}, + {"ilLoadPal", "(Ljava/lang/String;)Z", (void*)&Java_org_lwjgl_devil_IL_ilLoadPal, "ilLoadPal", (void*)&ilLoadPal}, + {"ilOriginFunc", "(I)Z", (void*)&Java_org_lwjgl_devil_IL_ilOriginFunc, "ilOriginFunc", (void*)&ilOriginFunc}, + {"ilOverlayImage", "(IIII)Z", (void*)&Java_org_lwjgl_devil_IL_ilOverlayImage, "ilOverlayImage", (void*)&ilOverlayImage}, + {"ilPopAttrib", "()V", (void*)&Java_org_lwjgl_devil_IL_ilPopAttrib, "ilPopAttrib", (void*)&ilPopAttrib}, + {"ilPushAttrib", "(I)V", (void*)&Java_org_lwjgl_devil_IL_ilPushAttrib, "ilPushAttrib", (void*)&ilPushAttrib}, + {"ilRemoveLoad", "(Ljava/lang/String;)Z", (void*)&Java_org_lwjgl_devil_IL_ilRemoveLoad, "ilRemoveLoad", (void*)&ilRemoveLoad}, + {"ilRemoveSave", "(Ljava/lang/String;)Z", (void*)&Java_org_lwjgl_devil_IL_ilRemoveSave, "ilRemoveSave", (void*)&ilRemoveSave}, + {"ilResetMemory", "()V", (void*)&Java_org_lwjgl_devil_IL_ilResetMemory, "ilResetMemory", (void*)&ilResetMemory}, + {"ilResetRead", "()V", (void*)&Java_org_lwjgl_devil_IL_ilResetRead, "ilResetRead", (void*)&ilResetRead}, + {"ilResetWrite", "()V", (void*)&Java_org_lwjgl_devil_IL_ilResetWrite, "ilResetWrite", (void*)&ilResetWrite}, + {"ilSave", "(ILjava/lang/String;)Z", (void*)&Java_org_lwjgl_devil_IL_ilSave, "ilSave", (void*)&ilSave}, + {"ilSaveImage", "(Ljava/lang/String;)Z", (void*)&Java_org_lwjgl_devil_IL_ilSaveImage, "ilSaveImage", (void*)&ilSaveImage}, + {"nilSaveL", "(ILjava/nio/ByteBuffer;II)I", (void*)&Java_org_lwjgl_devil_IL_nilSaveL, "ilSaveL", (void*)&ilSaveL}, + {"ilSavePal", "(I)Z", (void*)&Java_org_lwjgl_devil_IL_ilSavePal, "ilSavePal", (void*)&ilSavePal}, + {"nilSetData", "(Ljava/nio/ByteBuffer;I)Z", (void*)&Java_org_lwjgl_devil_IL_nilSetData, "ilSetData", (void*)&ilSetData}, + {"ilSetDuration", "(I)Z", (void*)&Java_org_lwjgl_devil_IL_ilSetDuration, "ilSetDuration", (void*)&ilSetDuration}, + {"ilSetInteger", "(II)V", (void*)&Java_org_lwjgl_devil_IL_ilSetInteger, "ilSetInteger", (void*)&ilSetInteger}, + {"nilSetPixels", "(IIIIIIIILjava/nio/ByteBuffer;I)V", (void*)&Java_org_lwjgl_devil_IL_nilSetPixels, "ilSetPixels", (void*)&ilSetPixels}, + {"ilSetString", "(ILjava/lang/String;)V", (void*)&Java_org_lwjgl_devil_IL_ilSetString, "ilSetString", (void*)&ilSetString}, + {"ilShutDown", "()V", (void*)&Java_org_lwjgl_devil_IL_ilShutDown, "ilShutDown", (void*)&ilShutDown}, + {"nilTexImage", "(IIIBIILjava/nio/ByteBuffer;I)Z", (void*)&Java_org_lwjgl_devil_IL_nilTexImage, "ilTexImage", (void*)&ilTexImage}, + {"ilTypeFunc", "(I)Z", (void*)&Java_org_lwjgl_devil_IL_ilTypeFunc, "ilTypeFunc", (void*)&ilTypeFunc}, + {"ilLoadData", "(Ljava/lang/String;IIIB)Z", (void*)&Java_org_lwjgl_devil_IL_ilLoadData, "ilLoadData", (void*)&ilLoadData}, + {"ilLoadDataL", "(Ljava/nio/ByteBuffer;IIIIIB)Z", (void*)&Java_org_lwjgl_devil_IL_nilLoadDataL, "ilLoadDataL", (void*)&ilLoadDataL}, + {"ilSaveData", "(Ljava/lang/String;)Z", (void*)&Java_org_lwjgl_devil_IL_ilSaveData, "ilSaveData", (void*)&ilSaveData} + }; + int num_functions = NUMFUNCTIONS(functions); + extil_InitializeClass(env, clazz, num_functions, functions); + printf("\r\ninitNativeStubs"); } #ifdef __cplusplus --- NEW FILE: extil.c --- #include "extil.h" /* turn off the warning for the borland compiler*/ #ifdef __BORLANDC__ #pragma warn -8064 #pragma warn -8065 #endif /* __BORLANDC__ */ #ifdef _WIN32 HMODULE devILhandle = NULL; #endif /* getProcAddress */ void *extil_GetProcAddress(const char *name) { #ifdef _WIN32 void *t = GetProcAddress(devILhandle, name); if (t == NULL) { printfDebug("Could not locate symbol %s\n", name); } printf("\r\nget proc address %s %d", name, t); return t; #endif } void extil_InitializeClass(JNIEnv *env, jclass clazz, int num_functions, JavaMethodAndExtFunction *functions) { ext_InitializeClass(env, clazz, &extil_GetProcAddress, num_functions, functions); } bool extil_InitializeFunctions(int num_functions, ExtFunction *functions) { return ext_InitializeFunctions(&extil_GetProcAddress, num_functions, functions); } #ifdef _WIN32 bool extil_Open(JNIEnv *env) { bool result = true; if (devILhandle == NULL) { // load the dynamic libraries for DevIL printf("\r\nattempting to load F:\\Apps\\DevIL\\lib\\DevIL.dll"); devILhandle = LoadLibrary("F:\\Apps\\DevIL\\lib\\DevIL.dll"); if (devILhandle == NULL) { printf("\r\nfailed to load DevIL"); result = false; } } return result; } #endif /* WIN32 */ void extgl_Close(void) { #ifdef _WIN32 FreeLibrary(devILhandle); devILhandle = NULL; #endif } /* turn on the warning for the borland compiler*/ #ifdef __BORLANDC__ #pragma warn .8064 #pragma warn .8065 #endif /* __BORLANDC__ */ --- NEW FILE: extil.h --- #ifndef __EXTIL_H__ #define __EXTIL_H__ #include <jni.h> #include <stdio.h> #include <string.h> #include <IL\il.h> #include "org_lwjgl_devil_IL.h" #include "common_tools.h" /*-----------------------------------------*/ /*-----------------------------------------*/ #if defined(_WIN32) && !defined(APIENTRY) #define WIN32_LEAN_AND_MEAN 1 #include <windows.h> #endif #define __ilext_h_ #define __ILEXT_H_ #define __il_h_ #define __IL_H__ #include <string.h> #ifndef APIENTRY #define APIENTRY #endif #include "common_tools.h" #ifdef __cplusplus extern "C" { #endif /* initializes everything, call this right after the rc is created. the function returns 0 if successful */ extern bool extil_Open(JNIEnv *env); extern void extil_Close(void); extern void extil_InitializeClass(JNIEnv *env, jclass clazz, int num_functions, JavaMethodAndExtFunction *functions); extern bool extil_InitializeFunctions(int num_functions, ExtFunction *functions); #ifdef __cplusplus } #endif #endif /* __EXTIL_H__ */ |
|
From: Brian M. <ma...@us...> - 2004-12-07 23:07:27
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/win32 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3664 Modified Files: display.cpp Log Message: case insensitive key lookup, reported by zhuzheng Index: display.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/win32/display.cpp,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- display.cpp 14 Nov 2004 10:42:19 -0000 1.8 +++ display.cpp 7 Dec 2004 23:07:03 -0000 1.9 @@ -359,7 +359,7 @@ // szAdapterKey now contains something like \Registry\Machine\System\CurrentControlSet\Control\Video\{B70DBD2A-90C4-41CF-A58E-F3BA69F1A6BC}\0000 // We'll check for the first chunk: - if (strncmp("\\Registry\\Machine", szAdapterKey, 17) == 0) { + if (strnicmp("\\Registry\\Machine", szAdapterKey, 17) == 0) { // Yes, it's right, so let's look for that key now TCHAR szDriverKey[MY_BUFSIZE]; |
|
From: Brian M. <ma...@us...> - 2004-12-07 22:01:39
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/test/openal In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20502/src/java/org/lwjgl/test/openal Modified Files: PositionTest.java Log Message: using grabbed mode Index: PositionTest.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/test/openal/PositionTest.java,v retrieving revision 1.23 retrieving revision 1.24 diff -u -d -r1.23 -r1.24 --- PositionTest.java 22 Jul 2004 14:27:07 -0000 1.23 +++ PositionTest.java 7 Dec 2004 22:01:15 -0000 1.24 @@ -226,6 +226,8 @@ Sys.log("Soundfiles loaded successfully"); // ----------------------------------------------------- + + Mouse.setGrabbed(true); } /** @@ -406,6 +408,8 @@ AL10.alListener(AL10.AL_POSITION, listenerPosition); + // empty mouse buffer + while(Mouse.next()); } /** |
|
From: Brian M. <ma...@us...> - 2004-12-07 21:56:22
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/test/input In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19041/src/java/org/lwjgl/test/input Modified Files: MouseTest.java Log Message: using grabbed mode Index: MouseTest.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/test/input/MouseTest.java,v retrieving revision 1.41 retrieving revision 1.42 diff -u -d -r1.41 -r1.42 --- MouseTest.java 22 Sep 2004 18:03:10 -0000 1.41 +++ MouseTest.java 7 Dec 2004 21:56:07 -0000 1.42 @@ -116,6 +116,7 @@ Display.setFullscreen(FULLSCREEN); Display.setVSyncEnabled(true); Display.create(); + Mouse.setGrabbed(true); } catch (Exception e) { e.printStackTrace(); System.exit(-1); @@ -187,8 +188,6 @@ handleKeyboard(); handleMouse(); - System.out.println(Mouse.getX() + ", " + Mouse.getY()); - // pause and continue if minimized if(!Display.isVisible()) { if(Display.isDirty()) { |
|
From: Brian M. <ma...@us...> - 2004-12-07 21:54:52
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/test/input In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18668/src/java/org/lwjgl/test/input Modified Files: MouseCreationTest.java Log Message: fixed displaymode using grabbed mouse mode empty mouse buffer Index: MouseCreationTest.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/test/input/MouseCreationTest.java,v retrieving revision 1.33 retrieving revision 1.34 diff -u -d -r1.33 -r1.34 --- MouseCreationTest.java 22 Jul 2004 14:56:40 -0000 1.33 +++ MouseCreationTest.java 7 Dec 2004 21:54:43 -0000 1.34 @@ -50,9 +50,6 @@ /** position of quad to draw */ private Vector2f position = new Vector2f(320.0f, 240.0f); - /** Display mode selected */ - private DisplayMode displayMode; - /** Creates a new instance of MouseTest */ public MouseCreationTest() { } @@ -62,6 +59,7 @@ setDisplayMode(); Display.setFullscreen(fullscreen); Display.create(); + Mouse.setGrabbed(true); } catch (Exception e) { e.printStackTrace(); System.exit(-1); @@ -118,7 +116,6 @@ try { Display.destroy(); initialize(true); - Display.setDisplayMode(displayMode); } catch (Exception e) { e.printStackTrace(); } @@ -144,10 +141,13 @@ long statustime = Sys.getTime(); long endtime = Sys.getTime() + Sys.getTimerResolution() * 5; - + while (Sys.getTime() < endtime) { Display.update(); + // empty mouse buffer + while(Mouse.next()); + position.x += Mouse.getDX(); position.y += Mouse.getDY(); |
|
From: Brian M. <ma...@us...> - 2004-12-07 21:50:43
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/input In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17676/src/java/org/lwjgl/input Modified Files: Mouse.java Log Message: simple optimization Index: Mouse.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/input/Mouse.java,v retrieving revision 1.70 retrieving revision 1.71 diff -u -d -r1.70 -r1.71 --- Mouse.java 25 Nov 2004 22:16:46 -0000 1.70 +++ Mouse.java 7 Dec 2004 21:50:30 -0000 1.71 @@ -136,6 +136,9 @@ private static final int EVENT_SIZE = 5; private static boolean isGrabbed; + + /** Whether we're running windows - which need to manually update cursor animation */ + private static final boolean isWindows = System.getProperty("os.name").startsWith("Win"); /** * Mouse cannot be constructed. @@ -585,7 +588,7 @@ * shouldn't be called otherwise */ public static void updateCursor() { - if (System.getProperty("os.name").startsWith("Win") && currentCursor != null && currentCursor.hasTimedOut()) { + if (isWindows && currentCursor != null && currentCursor.hasTimedOut()) { currentCursor.nextCursor(); try { setNativeCursor(currentCursor); |
|
From: Brian M. <ma...@us...> - 2004-12-07 21:45:07
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/test/input In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16546/src/java/org/lwjgl/test/input Modified Files: HWCursorTest.java Log Message: cleanup and fixes Index: HWCursorTest.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/test/input/HWCursorTest.java,v retrieving revision 1.37 retrieving revision 1.38 diff -u -d -r1.37 -r1.38 --- HWCursorTest.java 22 Sep 2004 18:03:10 -0000 1.37 +++ HWCursorTest.java 7 Dec 2004 21:44:57 -0000 1.38 @@ -52,357 +52,345 @@ * @version $Revision$ */ public class HWCursorTest { - - /** The native cursor */ - private static Cursor[] cursor = null; - - /** The mouse cursor position */ - private static int mouse_x; - private static int mouse_y; - private static int mouse_btn = 0; - - /** - * Executes the test - */ - public void execute() { - initialize(); - - mainLoop(); - - cleanup(); - } - - /** - * Sets the display mode for fullscreen mode - */ - protected boolean setDisplayMode() { - // get modes - DisplayMode[] dm = org.lwjgl.util.Display.getAvailableDisplayModes(640, 480, -1, -1, -1, -1, 60, 60); - - try { - org.lwjgl.util.Display.setDisplayMode(dm, new String[] { - "width=" + 640, - "height=" + 480, - "freq=" + 60, - "bpp=" + org.lwjgl.opengl.Display.getDisplayMode().getBitsPerPixel() - }); - return true; - } catch (Exception e) { - e.printStackTrace(); - } - - return false; - } - - /** - * Initializes the test - */ - private void initialize() { - try { - // start of in windowed mode - setDisplayMode(); - Display.create(); - - glInit(); - - initNativeCursors(); - - } catch (Exception e) { - e.printStackTrace(); - } - } - - private static void initNativeCursors() throws Exception { - if ((Mouse.getNativeCursorCaps() & Mouse.CURSOR_ONE_BIT_TRANSPARENCY) == 0) { - System.out.println("No HW cursor support!"); - System.exit(0); - } - - cursor = new Cursor[3]; - - int cursorImageCount = 1; - int cursorWidth = Mouse.getMaxCursorSize(); - int cursorHeight = cursorWidth; - IntBuffer cursorImages; - IntBuffer cursorDelays; - - - // Create a single cursor - // ================================== - cursorImages = ByteBuffer.allocateDirect(cursorWidth*cursorHeight*cursorImageCount*4).order(ByteOrder.nativeOrder()).asIntBuffer(); - cursorDelays = null; - for(int j=0; j<cursorWidth; j++) { - for(int l=0; l<cursorHeight; l++) { - cursorImages.put(0xffffffff); - } - } - cursorImages.flip(); - cursor[0] = new Cursor(Mouse.getMaxCursorSize(), Mouse.getMaxCursorSize(), Mouse.getMaxCursorSize()/2, Mouse.getMaxCursorSize()/2, cursorImageCount, cursorImages, cursorDelays); - // ---------------------------------- - - // Create 3 piece animation - // ================================== - cursorImageCount = 3; - cursorImages = ByteBuffer.allocateDirect(cursorWidth*cursorHeight*cursorImageCount*4).order(ByteOrder.nativeOrder()).asIntBuffer(); - cursorDelays = ByteBuffer.allocateDirect(cursorImageCount*4).order(ByteOrder.nativeOrder()).asIntBuffer(); - for(int i=0; i<cursorImageCount; i++) { - - // make a colored square with a chocolate center - int offColor = 0x00000000; - int onColor = 0xffff0000; - - // change color according to cursor - if(i == 1) { - onColor = 0xff00ff00; - } else if (i == 2) { - onColor = 0xff0000ff; - } - - // calculate size of center - int centerSize = (cursorWidth / 5) * (i + 1); - int centerLeft = cursorWidth / 2 - centerSize / 2; - int centerRight = cursorWidth / 2 + centerSize / 2; - - // go! - for(int j=0; j<cursorWidth; j++) { - for(int l=0; l<cursorHeight; l++) { - if(j >= centerLeft && j < centerRight && l >= centerLeft && l < centerRight) { - cursorImages.put(offColor); - } else { - cursorImages.put(onColor); - } - } - } - } - cursorDelays.put(2000).put(2000).put(2000); - cursorDelays.flip(); - cursorImages.flip(); - - cursor[1] = new Cursor(Mouse.getMaxCursorSize(), Mouse.getMaxCursorSize(), Mouse.getMaxCursorSize()/2, Mouse.getMaxCursorSize()/2, cursorImageCount, cursorImages, cursorDelays); - // ---------------------------------- - - - // Create a 20 piece animation - // ================================== - cursorImageCount = 20; - cursorImages = ByteBuffer.allocateDirect(cursorWidth*cursorHeight*cursorImageCount*4).order(ByteOrder.nativeOrder()).asIntBuffer(); - cursorDelays = ByteBuffer.allocateDirect(cursorImageCount*4).order(ByteOrder.nativeOrder()).asIntBuffer(); - cursorDelays.put( - new int[] { - 100, 100, 100, 100, 100, - 100, 100, 100, 100, 100, - 100, 100, 100, 100, 100, - 100, 100, 100, 100, 100 - }); - - float step = 0xffffffff / 20.0f; - for(int i=0; i<cursorImageCount; i++) { - for(int j=0; j<cursorWidth; j++) { - for(int l=0; l<cursorHeight; l++) { - cursorImages.put((int)step); - } - } - step += step; - } - cursorImages.flip(); - cursorDelays.flip(); - cursor[2] = new Cursor(Mouse.getMaxCursorSize(), Mouse.getMaxCursorSize(), Mouse.getMaxCursorSize()/2, Mouse.getMaxCursorSize()/2, cursorImageCount, cursorImages, cursorDelays); - // ---------------------------------- - - Mouse.setNativeCursor(cursor[0]); - } - - /** - * Runs the main loop of the "test" - */ - private void mainLoop() { - while (!Keyboard.isKeyDown(Keyboard.KEY_ESCAPE) - && !Display.isCloseRequested()) { - // allow subsystem to get a chance to run too - Display.update(); - - if (Display.isVisible()) { - // check keyboard input - processKeyboard(); - processMouse(); - - render(); - } else { - - // no need to render/paint if nothing has changed (ie. window dragged over) - if (Display.isDirty()) { - render(); - } - - // don't waste cpu time, sleep more - try { - Thread.sleep(100); - } catch (InterruptedException inte) { - } - } - } - } - - /** - * Performs the logic - */ - private void render() { - //clear background - GL11.glClear(GL11.GL_COLOR_BUFFER_BIT); - - // draw white quad - GL11.glPushMatrix(); - { - GL11.glTranslatef(mouse_x, mouse_y, 0); - GL11.glColor3f(1.0f, 1.0f, 1.0f); - GL11.glBegin(GL11.GL_QUADS); - { - GL11.glColor3f(1.0f, 0.0f, 0.0f); GL11.glVertex2i(-50, -50); - GL11.glColor3f(0.0f, 1.0f, 0.0f); GL11.glVertex2i(50, -50); - GL11.glColor3f(0.0f, 0.0f, 1.0f); GL11.glVertex2i(50, 50); - GL11.glColor3f(1.0f, 0.0f, 1.0f); GL11.glVertex2i(-50, 50); - } - GL11.glEnd(); - } - GL11.glPopMatrix(); - } - - private void processMouse() { - int dx = Mouse.getDX(); - int dy = Mouse.getDY(); - - if (dx != 0 || dy != 0) { - //mouse_x += dx; - //mouse_y += dy; - } - mouse_x = Mouse.getX(); - mouse_y = Mouse.getY(); - - while(Mouse.next()) { - int button = Mouse.getEventButton(); - if(button >= 0 && button < 3 && Mouse.getEventButtonState()) { - mouse_btn = Mouse.getEventButton(); - } - } - } - - /** - * Processes keyboard input - */ - private void processKeyboard() { - //check for fullscreen key - if (Keyboard.isKeyDown(Keyboard.KEY_F)) { - - try { - try { - Mouse.setNativeCursor(null); - } catch (Exception e) { - e.printStackTrace(); - System.exit(1); - } - for(int i=0; i<cursor.length; i++) { - cursor[i].destroy(); - } - Display.setFullscreen(true); - - glInit(); - - initNativeCursors(); - } catch (Exception e) { - e.printStackTrace(); - } - } - - //check for window key - if (Keyboard.isKeyDown(Keyboard.KEY_W)) { - try { - try { - Mouse.setNativeCursor(null); - } catch (Exception e) { - e.printStackTrace(); - System.exit(1); - } - for(int i=0; i<cursor.length; i++) { - cursor[i].destroy(); - } - Display.setFullscreen(false); - glInit(); - - initNativeCursors(); - } catch (Exception e) { - e.printStackTrace(); - } - } - - if (Keyboard.isKeyDown(Keyboard.KEY_M)) { - try { - Mouse.setNativeCursor(null); - } catch (Exception e) { - e.printStackTrace(); - } - } - - if (Keyboard.isKeyDown(Keyboard.KEY_N)) { - try { - Mouse.setNativeCursor(cursor[mouse_btn]); - } catch (Exception e) { - e.printStackTrace(); - } - } - - while(Keyboard.next()) { - if(Keyboard.getEventKey() == Keyboard.KEY_SPACE && Keyboard.getEventKeyState()) { - Mouse.setGrabbed(!Mouse.isGrabbed()); - //mouse_x = Mouse.getX(); - //mouse_y = Mouse.getY(); - } - } - } - - /** - * Cleans up the test - */ - private void cleanup() { - try { - Mouse.setNativeCursor(null); - } catch (Exception e) { - e.printStackTrace(); - System.exit(1); - } - for(int i=0; i<cursor.length; i++) { - cursor[i].destroy(); - } - Display.destroy(); - } - - /** - * Initializes OGL - */ - private void glInit() { - // Go into orthographic projection mode. - GL11.glMatrixMode(GL11.GL_PROJECTION); - GL11.glLoadIdentity(); - GLU.gluOrtho2D(0, Display.getDisplayMode().getWidth(), 0, Display.getDisplayMode().getHeight()); - GL11.glMatrixMode(GL11.GL_MODELVIEW); - GL11.glLoadIdentity(); - GL11.glViewport(0, 0, Display.getDisplayMode().getWidth(), Display.getDisplayMode().getHeight()); - - //set clear color to black - GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); - - //sync frame (only works on windows) - Display.setVSyncEnabled(true); - } - - /** - * Test entry point - */ - public static void main(String[] args) { - System.out.println( - "Change between fullscreen and windowed mode, by pressing F and W respectively. Enable hw cursor with N and disable it with M."); - System.out.println( - "Move quad using arrowkeys, and change rotation using +/-"); - HWCursorTest cursorTest = new HWCursorTest(); - cursorTest.execute(); - } + + /** The native cursor */ + private static Cursor[] cursor = null; + + /** The mouse cursor position */ + private static int mouse_x; + private static int mouse_y; + private static int mouse_btn = 0; + + /** + * Executes the test + */ + public void execute() { + initialize(); + + mainLoop(); + + cleanup(); + } + + /** + * Sets the display mode for fullscreen mode + */ + protected boolean setDisplayMode() { + // get modes + DisplayMode[] dm = org.lwjgl.util.Display.getAvailableDisplayModes(640, 480, -1, -1, -1, -1, 60, 60); + + try { + org.lwjgl.util.Display.setDisplayMode(dm, new String[] { + "width=" + 640, + "height=" + 480, + "freq=" + 60, + "bpp=" + org.lwjgl.opengl.Display.getDisplayMode().getBitsPerPixel() + }); + return true; + } catch (Exception e) { + e.printStackTrace(); + } + + return false; + } + + /** + * Initializes the test + */ + private void initialize() { + try { + // start of in windowed mode + setDisplayMode(); + Display.create(); + + glInit(); + + initNativeCursors(); + + } catch (Exception e) { + e.printStackTrace(); + } + } + + private static void initNativeCursors() throws Exception { + if ((Mouse.getNativeCursorCaps() & Mouse.CURSOR_ONE_BIT_TRANSPARENCY) == 0) { + System.out.println("No HW cursor support!"); + System.exit(0); + } + + cursor = new Cursor[3]; + + int cursorImageCount = 1; + int cursorWidth = Mouse.getMaxCursorSize(); + int cursorHeight = cursorWidth; + IntBuffer cursorImages; + IntBuffer cursorDelays; + + + // Create a single cursor + // ================================== + cursorImages = ByteBuffer.allocateDirect(cursorWidth*cursorHeight*cursorImageCount*4).order(ByteOrder.nativeOrder()).asIntBuffer(); + cursorDelays = null; + for(int j=0; j<cursorWidth; j++) { + for(int l=0; l<cursorHeight; l++) { + cursorImages.put(0xffffffff); + } + } + cursorImages.flip(); + cursor[0] = new Cursor(Mouse.getMaxCursorSize(), Mouse.getMaxCursorSize(), Mouse.getMaxCursorSize()/2, Mouse.getMaxCursorSize()/2, cursorImageCount, cursorImages, cursorDelays); + // ---------------------------------- + + // Create 3 piece animation + // ================================== + cursorImageCount = 3; + cursorImages = ByteBuffer.allocateDirect(cursorWidth*cursorHeight*cursorImageCount*4).order(ByteOrder.nativeOrder()).asIntBuffer(); + cursorDelays = ByteBuffer.allocateDirect(cursorImageCount*4).order(ByteOrder.nativeOrder()).asIntBuffer(); + for(int i=0; i<cursorImageCount; i++) { + + // make a colored square with a chocolate center + int offColor = 0x00000000; + int onColor = 0xffff0000; + + // change color according to cursor + if(i == 1) { + onColor = 0xff00ff00; + } else if (i == 2) { + onColor = 0xff0000ff; + } + + // calculate size of center + int centerSize = (cursorWidth / 5) * (i + 1); + int centerLeft = cursorWidth / 2 - centerSize / 2; + int centerRight = cursorWidth / 2 + centerSize / 2; + + // go! + for(int j=0; j<cursorWidth; j++) { + for(int l=0; l<cursorHeight; l++) { + if(j >= centerLeft && j < centerRight && l >= centerLeft && l < centerRight) { + cursorImages.put(offColor); + } else { + cursorImages.put(onColor); + } + } + } + } + cursorDelays.put(2000).put(2000).put(2000); + cursorDelays.flip(); + cursorImages.flip(); + + cursor[1] = new Cursor(Mouse.getMaxCursorSize(), Mouse.getMaxCursorSize(), Mouse.getMaxCursorSize()/2, Mouse.getMaxCursorSize()/2, cursorImageCount, cursorImages, cursorDelays); + // ---------------------------------- + + + // Create a 20 piece animation + // ================================== + cursorImageCount = 20; + cursorImages = ByteBuffer.allocateDirect(cursorWidth*cursorHeight*cursorImageCount*4).order(ByteOrder.nativeOrder()).asIntBuffer(); + cursorDelays = ByteBuffer.allocateDirect(cursorImageCount*4).order(ByteOrder.nativeOrder()).asIntBuffer(); + cursorDelays.put( + new int[] { + 100, 100, 100, 100, 100, + 100, 100, 100, 100, 100, + 100, 100, 100, 100, 100, + 100, 100, 100, 100, 100 + }); + + float step = 0xffffffff / 20.0f; + for(int i=0; i<cursorImageCount; i++) { + for(int j=0; j<cursorWidth; j++) { + for(int l=0; l<cursorHeight; l++) { + cursorImages.put((int)step); + } + } + step += step; + } + cursorImages.flip(); + cursorDelays.flip(); + cursor[2] = new Cursor(Mouse.getMaxCursorSize(), Mouse.getMaxCursorSize(), Mouse.getMaxCursorSize()/2, Mouse.getMaxCursorSize()/2, cursorImageCount, cursorImages, cursorDelays); + // ---------------------------------- + + Mouse.setNativeCursor(cursor[0]); + } + + /** + * Runs the main loop of the "test" + */ + private void mainLoop() { + while (!Keyboard.isKeyDown(Keyboard.KEY_ESCAPE) + && !Display.isCloseRequested()) { + // allow subsystem to get a chance to run too + Display.update(); + + if (Display.isVisible()) { + // check keyboard input + processKeyboard(); + processMouse(); + + render(); + } else { + + // no need to render/paint if nothing has changed (ie. window dragged over) + if (Display.isDirty()) { + render(); + } + + // don't waste cpu time, sleep more + try { + Thread.sleep(100); + } catch (InterruptedException inte) { + } + } + } + } + + /** + * Performs the logic + */ + private void render() { + //clear background + GL11.glClear(GL11.GL_COLOR_BUFFER_BIT); + + // draw white quad + GL11.glPushMatrix(); + { + GL11.glTranslatef(mouse_x, mouse_y, 0); + GL11.glColor3f(1.0f, 1.0f, 1.0f); + GL11.glBegin(GL11.GL_QUADS); + { + GL11.glColor3f(1.0f, 0.0f, 0.0f); GL11.glVertex2i(-50, -50); + GL11.glColor3f(0.0f, 1.0f, 0.0f); GL11.glVertex2i(50, -50); + GL11.glColor3f(0.0f, 0.0f, 1.0f); GL11.glVertex2i(50, 50); + GL11.glColor3f(1.0f, 0.0f, 1.0f); GL11.glVertex2i(-50, 50); + } + GL11.glEnd(); + } + GL11.glPopMatrix(); + } + + private void processMouse() { + mouse_x = Mouse.getX(); + mouse_y = Mouse.getY(); + + while(Mouse.next()) { + int button = Mouse.getEventButton(); + if(button >= 0 && button < 3 && Mouse.getEventButtonState()) { + mouse_btn = Mouse.getEventButton(); + } + } + } + + /** + * Processes keyboard input + */ + private void processKeyboard() { + //check for fullscreen key + if (Keyboard.isKeyDown(Keyboard.KEY_F)) { + + try { + try { + Mouse.setNativeCursor(null); + } catch (Exception e) { + e.printStackTrace(); + System.exit(1); + } + for(int i=0; i<cursor.length; i++) { + cursor[i].destroy(); + } + Display.setFullscreen(true); + + glInit(); + + initNativeCursors(); + } catch (Exception e) { + e.printStackTrace(); + } + } + + //check for window key + if (Keyboard.isKeyDown(Keyboard.KEY_W)) { + try { + try { + Mouse.setNativeCursor(null); + } catch (Exception e) { + e.printStackTrace(); + System.exit(1); + } + for(int i=0; i<cursor.length; i++) { + cursor[i].destroy(); + } + Display.setFullscreen(false); + glInit(); + + initNativeCursors(); + } catch (Exception e) { + e.printStackTrace(); + } + } + + if (Keyboard.isKeyDown(Keyboard.KEY_M)) { + try { + Mouse.setNativeCursor(null); + } catch (Exception e) { + e.printStackTrace(); + } + } + + if (Keyboard.isKeyDown(Keyboard.KEY_N)) { + try { + Mouse.setNativeCursor(cursor[mouse_btn]); + } catch (Exception e) { + e.printStackTrace(); + } + } + + while(Keyboard.next()) { + if(Keyboard.getEventKey() == Keyboard.KEY_SPACE && Keyboard.getEventKeyState()) { + Mouse.setGrabbed(!Mouse.isGrabbed()); + } + } + } + + /** + * Cleans up the test + */ + private void cleanup() { + try { + Mouse.setNativeCursor(null); + } catch (Exception e) { + e.printStackTrace(); + System.exit(1); + } + for(int i=0; i<cursor.length; i++) { + cursor[i].destroy(); + } + Display.destroy(); + } + + /** + * Initializes OGL + */ + private void glInit() { + // Go into orthographic projection mode. + GL11.glMatrixMode(GL11.GL_PROJECTION); + GL11.glLoadIdentity(); + GLU.gluOrtho2D(0, Display.getDisplayMode().getWidth(), 0, Display.getDisplayMode().getHeight()); + GL11.glMatrixMode(GL11.GL_MODELVIEW); + GL11.glLoadIdentity(); + GL11.glViewport(0, 0, Display.getDisplayMode().getWidth(), Display.getDisplayMode().getHeight()); + + //set clear color to black + GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); + + //sync frame (only works on windows) + Display.setVSyncEnabled(true); + } + + /** + * Test entry point + */ + public static void main(String[] args) { + System.out.println("Change between fullscreen and windowed mode, by pressing F and W respectively. Enable hw cursor with N and disable it with M."); + HWCursorTest cursorTest = new HWCursorTest(); + cursorTest.execute(); + } } |
|
From: Brian M. <ma...@us...> - 2004-12-07 21:34:11
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/test/input In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14401/src/java/org/lwjgl/test/input Modified Files: ControllerCreationTest.java Log Message: fixed display mode bug Index: ControllerCreationTest.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/test/input/ControllerCreationTest.java,v retrieving revision 1.30 retrieving revision 1.31 diff -u -d -r1.30 -r1.31 --- ControllerCreationTest.java 7 Dec 2004 21:29:17 -0000 1.30 +++ ControllerCreationTest.java 7 Dec 2004 21:34:02 -0000 1.31 @@ -50,9 +50,6 @@ /** position of quad to draw */ private Vector2f position = new Vector2f(320.0f, 240.0f); - /** Display mode selected */ - private DisplayMode displayMode; - /** Creates a new instance of MouseTest */ public ControllerCreationTest() { } @@ -122,7 +119,6 @@ try { Display.destroy(); initialize(true); - Display.setDisplayMode(displayMode); } catch (Exception e) { e.printStackTrace(); } |
|
From: Brian M. <ma...@us...> - 2004-12-07 21:29:28
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/test/input In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13373/src/java/org/lwjgl/test/input Modified Files: ControllerCreationTest.java Log Message: check that controller is actually created! Index: ControllerCreationTest.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/test/input/ControllerCreationTest.java,v retrieving revision 1.29 retrieving revision 1.30 diff -u -d -r1.29 -r1.30 --- ControllerCreationTest.java 22 Jul 2004 14:56:40 -0000 1.29 +++ ControllerCreationTest.java 7 Dec 2004 21:29:17 -0000 1.30 @@ -62,7 +62,10 @@ setDisplayMode(); Display.setFullscreen(fullscreen); Display.create(); - + + if(!Controller.isCreated()) { + throw new Exception("Controller could not be created"); + } } catch (Exception e) { e.printStackTrace(); System.exit(-1); |
|
From: Brian M. <ma...@us...> - 2004-12-07 06:38:51
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/test/fmod3 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14088/src/java/org/lwjgl/test/fmod3 Modified Files: StreamPlayerMemory.java Log Message: comment fixing Index: StreamPlayerMemory.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/test/fmod3/StreamPlayerMemory.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- StreamPlayerMemory.java 3 Oct 2004 09:35:38 -0000 1.3 +++ StreamPlayerMemory.java 7 Dec 2004 06:38:37 -0000 1.4 @@ -102,8 +102,7 @@ /** * Reads the file into a ByteBuffer * - * @param filename - * Name of file to load + * @param filename Name of file to load * @return ByteBuffer containing file data */ static protected ByteBuffer getData(String filename) { @@ -126,8 +125,8 @@ //done reading, close bis.close(); - - // if ogg vorbis data, we need to pass it unmodified to alBufferData + + // place it in a buffer buffer = ByteBuffer.allocateDirect(baos.size()); buffer.order(ByteOrder.nativeOrder()); buffer.put(baos.toByteArray()); |
|
From: Caspian Rychlik-P. <ci...@us...> - 2004-12-07 00:24:45
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/util In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3376/src/java/org/lwjgl/util Modified Files: Timer.java Log Message: Index: Timer.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/util/Timer.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- Timer.java 7 Dec 2004 00:23:20 -0000 1.7 +++ Timer.java 7 Dec 2004 00:24:29 -0000 1.8 @@ -82,14 +82,7 @@ */ public float getTime() { if (!paused) { - if (currentTime > startTime) { - lastTime = currentTime - startTime; - } else { - // The timer seems to have wrapped round. We don't know - // when it wrapped round, so the only thing we can reasonably - // do is reset the starttime and have a "glitch" - startTime = currentTime; - } + lastTime = currentTime - startTime; } return (float) ((double) lastTime / (double) resolution); |
|
From: Caspian Rychlik-P. <ci...@us...> - 2004-12-07 00:23:30
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/util In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3059/src/java/org/lwjgl/util Modified Files: Timer.java Log Message: Shoved resolution down into ints for better wrap handling Index: Timer.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/util/Timer.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- Timer.java 3 Dec 2004 00:56:14 -0000 1.6 +++ Timer.java 7 Dec 2004 00:23:20 -0000 1.7 @@ -54,13 +54,13 @@ private static int queryCount = 0; // Globally keeps track of time for all instances of Timer - private static long currentTime; + private static int currentTime; // When the timer was started - private long startTime; + private int startTime; // The last time recorded by getTime() - private long lastTime; + private int lastTime; // Whether the timer is paused private boolean paused; @@ -133,7 +133,7 @@ * @param newTime the new time, in seconds */ public void set(float newTime) { - long newTimeInTicks = (long) ((double) newTime * (double) resolution); + int newTimeInTicks = (int) ((double) newTime * (double) resolution); startTime = currentTime - newTimeInTicks; lastTime = newTimeInTicks; } @@ -144,7 +144,7 @@ * from it. */ public static void tick() { - currentTime = Sys.getTime(); + currentTime = (int) Sys.getTime(); // Periodically refresh the timer resolution: queryCount ++; |
|
From: Mark B. <cap...@us...> - 2004-12-05 02:33:29
|
Update of /cvsroot/java-game-lib/LWJGL In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17423 Modified Files: build.xml Log Message: Made native win32 compile only run if changes are made to source. Index: build.xml =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/build.xml,v retrieving revision 1.41 retrieving revision 1.42 diff -u -d -r1.41 -r1.42 --- build.xml 11 Nov 2004 16:03:10 -0000 1.41 +++ build.xml 5 Dec 2004 02:33:19 -0000 1.42 @@ -155,6 +155,23 @@ <!-- target is going to fail anyway. However we cannot call the 'distribution' before --> <!-- the javadoc target, since the 'distribution' target will try to create the javadoc --> <!-- archive. --> + <antcall target="-initialize"/> + <antcall target="compile"/> + <antcall target="compile_native"/> + <antcall target="jars"/> + <antcall target="-distribution_application"/> + </target> + + <!-- Performs all the tasks needed for a distribution of LWJGL --> + <target name="non-javadoc-rebuild" description="Compile. Make jars. Javadoc and distribute"> + + <!-- Though we perform all targets, we do it in somewhat mixed. --> + <!-- This is because we want the 'distribution_application' target to be --> + <!-- executed as soon as possible, since this target is most likely to fail. --> + <!-- That way we don't spend time doing javadocs, if the 'distribution_application' --> + <!-- target is going to fail anyway. However we cannot call the 'distribution' before --> + <!-- the javadoc target, since the 'distribution' target will try to create the javadoc --> + <!-- archive. --> <antcall target="clean"/> <antcall target="-initialize"/> <antcall target="compile"/> @@ -167,6 +184,7 @@ <target name="clean" description="Cleans the diectories controlled by this ant script"> <delete dir="${lwjgl.temp}" quiet="true" failonerror="false" taskname="cleaning temp folder" /> <delete dir="${lwjgl.dist}" quiet="true" failonerror="false" taskname="cleaning dist folder" /> + <delete dir="${lwjgl.lib}" quiet="true" failonerror="false" taskname="cleaning libs folder" /> <delete dir="${lwjgl.docs}/javadoc" quiet="true" failonerror="false" taskname="cleaning javadoc folder" /> <delete dir="${lwjgl.bin}/org" quiet="true" failonerror="false" taskname="cleaning bin folder" /> <delete taskname="cleaning bin folder" failonerror="false"> @@ -206,35 +224,66 @@ <antcall target="-compile_native_mac" /> </target> + <uptodate property="lwjgl.main.built" targetfile="${lwjgl.lib}/lwjgl.dll" > + <srcfiles dir= "${lwjgl.src.native}/common" includes="*.c*"/> + <srcfiles dir= "${lwjgl.src.native}/common/arb" includes="*.c"/> + <srcfiles dir= "${lwjgl.src.native}/common/nv" includes="*.c"/> + <srcfiles dir= "${lwjgl.src.native}/common/ext" includes="*.c"/> + <srcfiles dir= "${lwjgl.src.native}/common/ati" includes="*.c"/> + <srcfiles dir= "${lwjgl.src.native}/win32" includes="*.cpp"/> + </uptodate> + + <uptodate property="lwjgl.fmod.built" targetfile="${lwjgl.lib}/lwjgl-fmod3.dll" > + <srcfiles dir= "${lwjgl.src.native}/common" includes="*.c"/> + <srcfiles dir= "${lwjgl.src.native}/common/fmod3" includes="*.c"/> + </uptodate> + + <uptodate property="lwjgl.devil.built" targetfile="${lwjgl.lib}/lwjgl-devil.dll" > + <srcfiles dir= "${lwjgl.src.native}/common" includes="*.c"/> + <srcfiles dir= "${lwjgl.src.native}/common/devil" includes="*.c"/> + </uptodate> + <!-- Compiles LWJGL on Win32 platforms --> <target name="-compile_native_win32" if="lwjgl.platform.windows"> <echo>Compiling Win32 LWJGL version</echo> + <antcall target="-compile_native_win32_main" /> + + <antcall target="-compile_native_win32_fmod" /> + + <antcall target="-compile_native_win32_devil" /> + + <!-- optimize using upx --> + <!-- <exec dir="${lwjgl.lib}" executable="upx"> + <arg line="-9 -f win32/*.dll"/> + </exec> --> + + <!-- copy to libs --> + </target> + + <target name="-compile_native_win32_main" unless="lwjgl.main.built"> <!-- build main --> <exec dir="platform_build/win32_ms_cmdline" executable="cmd.exe" failonerror="true"> <arg line="/c build.bat" /> </exec> + <move file="platform_build/win32_ms_cmdline/lwjgl.dll" tofile="${lwjgl.lib}/lwjgl.dll"/> + </target> + <target name="-compile_native_win32_fmod" unless="lwjgl.fmod.built"> <!-- build fmod --> <exec dir="platform_build/win32_ms_cmdline" executable="cmd.exe" failonerror="true"> <arg line="/c build-fmod.bat" /> </exec> - + <move file="platform_build/win32_ms_cmdline/lwjgl-fmod3.dll" tofile="${lwjgl.lib}/lwjgl-fmod3.dll"/> + </target> + + <target name="-compile_native_win32_devil" unless="lwjgl.devil.built"> <!-- build devil --> <exec dir="platform_build/win32_ms_cmdline" executable="cmd.exe" failonerror="true"> <arg line="/c build-devil.bat"/> </exec> - - <!-- optimize using upx --> - <!-- <exec dir="${lwjgl.lib}" executable="upx"> - <arg line="-9 -f win32/*.dll"/> - </exec> --> - - <!-- copy to libs --> - <move file="platform_build/win32_ms_cmdline/lwjgl.dll" tofile="${lwjgl.lib}/lwjgl.dll"/> - <move file="platform_build/win32_ms_cmdline/lwjgl-fmod3.dll" tofile="${lwjgl.lib}/lwjgl-fmod3.dll"/> <move file="platform_build/win32_ms_cmdline/lwjgl-devil.dll" tofile="${lwjgl.lib}/lwjgl-devil.dll"/> - </target> - + </target> + <!-- Compiles LWJGL on Linux platforms --> <target name="-compile_native_linux" if="lwjgl.platform.linux"> <echo>Compiling Linux LWJGL version</echo> |