diff --git a/src/java/org/lwjgl/test/input/HWCursorTest.java b/src/java/org/lwjgl/test/input/HWCursorTest.java index cc51c4b8..b0b0db23 100644 --- a/src/java/org/lwjgl/test/input/HWCursorTest.java +++ b/src/java/org/lwjgl/test/input/HWCursorTest.java @@ -52,357 +52,345 @@ import org.lwjgl.opengl.glu.GLU; * @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= 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= 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= 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= 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