From: <eli...@us...> - 2008-04-10 20:26:02
|
Revision: 3002 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3002&view=rev Author: elias_naur Date: 2008-04-10 13:25:54 -0700 (Thu, 10 Apr 2008) Log Message: ----------- Removed AWTInputAdapter, since Display.setParent() works much betterdiff Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/opengl/AWTCanvasImplementation.java trunk/LWJGL/src/java/org/lwjgl/opengl/AWTGLCanvas.java trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxCanvasImplementation.java trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXCanvasImplementation.java trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsCanvasImplementation.java trunk/LWJGL/src/java/org/lwjgl/test/applet/AppletLoaderTest.java trunk/LWJGL/src/java/org/lwjgl/test/applet/OpenGL.java Removed Paths: ------------- trunk/LWJGL/src/java/org/lwjgl/opengl/AWTCanvasInputImplementation.java trunk/LWJGL/src/java/org/lwjgl/opengl/AWTInputAdapter.java trunk/LWJGL/src/java/org/lwjgl/opengl/AbstractAWTInput.java trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxAWTInput.java trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXAWTInput.java trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsAWTInput.java trunk/LWJGL/src/java/org/lwjgl/test/opengl/awt/AWTInputAdapterTest.java trunk/LWJGL/src/native/linux/org_lwjgl_opengl_LinuxAWTInput.c trunk/LWJGL/src/native/windows/org_lwjgl_opengl_WindowsAWTInput.c Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/AWTCanvasImplementation.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/AWTCanvasImplementation.java 2008-04-10 20:14:15 UTC (rev 3001) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/AWTCanvasImplementation.java 2008-04-10 20:25:54 UTC (rev 3002) @@ -56,12 +56,4 @@ * @throws LWJGLException if no suitable configuration could be found. */ GraphicsConfiguration findConfiguration(GraphicsDevice device, PixelFormat pixel_format) throws LWJGLException; - - /** - * Create an AWTCanvasInputImplementation for a specified AWTGLCanvas. - * - * @return A platform specific AWTCanvasInputImplementation. - * @param canvas An AWTGLCanvas - */ - AWTCanvasInputImplementation createInput(AWTGLCanvas canvas) throws LWJGLException; } Deleted: trunk/LWJGL/src/java/org/lwjgl/opengl/AWTCanvasInputImplementation.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/AWTCanvasInputImplementation.java 2008-04-10 20:14:15 UTC (rev 3001) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/AWTCanvasInputImplementation.java 2008-04-10 20:25:54 UTC (rev 3002) @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2002-2008 LWJGL Project - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of 'LWJGL' nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package org.lwjgl.opengl; - - -/** - * - * @author elias_naur <eli...@us...> - * @version $Revision: 2286 $ - * $Id: AWTCanvasImplementation.java 2286 2006-03-23 19:32:21Z matzon $ - */ -interface AWTCanvasInputImplementation extends InputImplementation { - void processInput(PeerInfo peer_info); - void init(); - void destroy(); -} Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/AWTGLCanvas.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/AWTGLCanvas.java 2008-04-10 20:14:15 UTC (rev 3001) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/AWTGLCanvas.java 2008-04-10 20:25:54 UTC (rev 3002) @@ -81,9 +81,6 @@ /** Tracks whether initGL() needs to be called */ private boolean first_run; - /** Track the input adapter, if any */ - private volatile AWTCanvasInputImplementation awt_input; - static { Sys.initialize(); implementation = createImplementation(); @@ -102,17 +99,6 @@ } } - /** - * Used from AWTInputAdapter - */ - static AWTCanvasImplementation getImplementation() { - return implementation; - } - - void setInput(AWTCanvasInputImplementation awt_input) { - this.awt_input = awt_input; - } - private void setUpdate() { synchronized(SYNC_LOCK) { update_context = true; @@ -297,9 +283,6 @@ context.update(); update_context = false; } - AWTCanvasInputImplementation current_input = awt_input; - if (current_input != null) - current_input.processInput(peer_info); if (first_run) { first_run = false; initGL(); Deleted: trunk/LWJGL/src/java/org/lwjgl/opengl/AWTInputAdapter.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/AWTInputAdapter.java 2008-04-10 20:14:15 UTC (rev 3001) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/AWTInputAdapter.java 2008-04-10 20:25:54 UTC (rev 3002) @@ -1,101 +0,0 @@ -/* - * Copyright (c) 2002-2008 LWJGL Project - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of 'LWJGL' nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package org.lwjgl.opengl; - -import java.lang.reflect.Method; -import java.security.AccessController; -import java.security.PrivilegedActionException; -import java.security.PrivilegedExceptionAction; - -import org.lwjgl.LWJGLException; -import org.lwjgl.input.Keyboard; -import org.lwjgl.input.Mouse; - -/** - * This is the static class for using LWJGL input (Mouse and Keyboard) - * with an AWTGLCanvas. - * - * @author Elias Naur - * @version $Revision: 2286 $ - * $Id: AWTCanvasImplementation.java 2286 2006-03-23 19:32:21Z matzon $ - */ -public final class AWTInputAdapter { - private static AWTCanvasInputImplementation awt_input; - - /** - * Create AWTInputAdapter with the specified AWTGLCanvas. Use - * update() to receive input. - * - * @param canvas The canvas to receive input from. - */ - public static synchronized void create(AWTGLCanvas canvas) throws LWJGLException { - if (isCreated()) - throw new IllegalStateException("You need to destroy() the adapter."); - awt_input = AWTGLCanvas.getImplementation().createInput(canvas); - // Invoke Mouse.create(awt_input) and Keyboard.create(awt_input) - try { - AccessController.doPrivileged(new PrivilegedExceptionAction() { - private void invokeCreate(Class input_class) throws Exception { - Method create_method = input_class.getDeclaredMethod("create", new Class[]{InputImplementation.class}); - create_method.setAccessible(true); - create_method.invoke(null, new Object[]{awt_input}); - } - - public Object run() throws Exception { - invokeCreate(Mouse.class); - invokeCreate(Keyboard.class); - return null; - } - }); - } catch (PrivilegedActionException e) { - Throwable cause = e.getCause(); - if (cause instanceof LWJGLException) - throw (LWJGLException)cause; - else - throw new Error(cause); - } - awt_input.init(); - } - - public static synchronized boolean isCreated() { - return awt_input != null; - } - - public static synchronized void destroy() { - if (isCreated()) { - Mouse.destroy(); - Keyboard.destroy(); - awt_input.destroy(); - awt_input = null; - } - } -} Deleted: trunk/LWJGL/src/java/org/lwjgl/opengl/AbstractAWTInput.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/AbstractAWTInput.java 2008-04-10 20:14:15 UTC (rev 3001) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/AbstractAWTInput.java 2008-04-10 20:25:54 UTC (rev 3002) @@ -1,178 +0,0 @@ -/* - * Copyright (c) 2002-2008 LWJGL Project - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of 'LWJGL' nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package org.lwjgl.opengl; - -import java.awt.Cursor; -import java.awt.Robot; -import java.nio.ByteBuffer; -import java.nio.IntBuffer; - -import org.lwjgl.LWJGLException; - -/** - * - * @author elias_naur <eli...@us...> - * @version $Revision: 2586 $ - * $Id: LinuxAWTGLCanvasPeerInfo.java 2586 2006-10-20 11:51:34Z elias_naur $ - */ -abstract class AbstractAWTInput implements AWTCanvasInputImplementation { - private AWTGLCanvas canvas; - private Robot robot; - - private KeyboardEventQueue keyboard_queue; - private MouseEventQueue mouse_queue; - private volatile boolean grab; - - protected AbstractAWTInput(AWTGLCanvas canvas) { - this.canvas = canvas; - } - - protected MouseEventQueue getMouseEventQueue() { - return mouse_queue; - } - - protected KeyboardEventQueue getKeyboardEventQueue() { - return keyboard_queue; - } - - public synchronized void grabMouse(boolean grab) { - this.grab = grab; - if (mouse_queue != null) - mouse_queue.setGrabbed(grab); - } - - protected boolean isGrabbed() { - return grab; - } - - protected final AWTGLCanvas getCanvas() { - return canvas; - } - - public final void init() { - canvas.setInput(this); - } - - public synchronized void destroy() { - canvas.setInput(null); - canvas = null; - } - - public final int getWidth() { - return canvas.getWidth(); - } - - public final int getHeight() { - return canvas.getHeight(); - } - - public boolean hasWheel() { - return AWTUtil.hasWheel(); - } - - public int getButtonCount() { - return AWTUtil.getButtonCount(); - } - - public void createMouse() throws LWJGLException { - mouse_queue = createMouseQueue(); - mouse_queue.register(); - } - - protected MouseEventQueue createMouseQueue() { - return new MouseEventQueue(getCanvas()); - } - - public synchronized void destroyMouse() { - if (mouse_queue != null) { - mouse_queue.unregister(); - mouse_queue = null; - } - } - - public int getNativeCursorCapabilities() { - return AWTUtil.getNativeCursorCapabilities(); - } - - public void setCursorPosition(int x, int y) { - if (robot == null) - robot = AWTUtil.createRobot(canvas); - AWTUtil.setCursorPosition(canvas, robot, x, y); - } - - public void setNativeCursor(Object handle) throws LWJGLException { - canvas.setCursor((Cursor)handle); - } - - public int getMinCursorSize() { - return AWTUtil.getMinCursorSize(); - } - - public int getMaxCursorSize() { - return AWTUtil.getMaxCursorSize(); - } - - public synchronized void createKeyboard() throws LWJGLException { - keyboard_queue = new KeyboardEventQueue(canvas); - keyboard_queue.register(); - } - - public synchronized void destroyKeyboard() { - if (keyboard_queue != null) { - keyboard_queue.unregister(); - keyboard_queue = null; - } - } - - public Object createCursor(int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, IntBuffer delays) throws LWJGLException { - return AWTUtil.createCursor(width, height, xHotspot, yHotspot, numImages, images, delays); - } - - public void destroyCursor(Object cursor_handle) { - } - - public synchronized void readMouse(ByteBuffer buffer) { - mouse_queue.copyEvents(buffer); - } - - public synchronized void pollMouse(IntBuffer coord_buffer, ByteBuffer buttons) { - mouse_queue.poll(coord_buffer, buttons); - } - - public synchronized void readKeyboard(ByteBuffer buffer) { - keyboard_queue.copyEvents(buffer); - } - - public synchronized void pollKeyboard(ByteBuffer keyDownBuffer) { - keyboard_queue.poll(keyDownBuffer); - } -} Deleted: trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxAWTInput.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxAWTInput.java 2008-04-10 20:14:15 UTC (rev 3001) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxAWTInput.java 2008-04-10 20:25:54 UTC (rev 3002) @@ -1,229 +0,0 @@ -/* - * Copyright (c) 2002-2008 LWJGL Project - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of 'LWJGL' nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package org.lwjgl.opengl; - -import java.nio.IntBuffer; -import java.nio.ByteBuffer; - -import org.lwjgl.LWJGLException; -import org.lwjgl.LWJGLUtil; - -/** - * - * @author elias_naur <eli...@us...> - * @version $Revision: 2586 $ - * $Id: LinuxAWTGLCanvasPeerInfo.java 2586 2006-10-20 11:51:34Z elias_naur $ - */ -final class LinuxAWTInput extends AbstractAWTInput { - private final long display; - private final long input_window; - private final LinuxEvent event = new LinuxEvent(); - - private long cached_window; - private LinuxMouse cached_mouse; -// private LinuxKeyboard cached_keyboard; - private long blank_cursor = LinuxDisplay.None; - private boolean input_grabbed; - private boolean input_released; - - public LinuxAWTInput(AWTGLCanvas canvas) throws LWJGLException { - super(canvas); - LinuxDisplay.lockAWT(); - try { - this.display = LinuxDisplay.openDisplay(); - this.input_window = createInputOnlyWindow(display, LinuxDisplay.nGetDefaultScreen(display)); - } finally { - LinuxDisplay.unlockAWT(); - } - } - private static native long createInputOnlyWindow(long display, int screen); - - public synchronized void destroy() { - super.destroy(); - LinuxDisplay.lockAWT(); - try { - destroyCursor(); - LinuxDisplay.nDestroyWindow(display, input_window); - LinuxDisplay.closeDisplay(display); - } finally { - LinuxDisplay.unlockAWT(); - } - } - - private void ungrabInputLocked() { - LinuxDisplay.lockAWT(); - try { - ungrabInput(); - } finally { - LinuxDisplay.unlockAWT(); - } - } - - private void ungrabInput() { - if (input_grabbed) { -// LinuxDisplay.nUngrabKeyboard(display); - LinuxDisplay.nUngrabPointer(display); - input_grabbed = false; - } - } - - private void grabInput(long window) { - if (!input_grabbed) { -// int res1 = LinuxDisplay.nGrabKeyboard(display, window); - int res2 = LinuxDisplay.nGrabPointer(display, window, blank_cursor); - if (/*res1 == LinuxDisplay.GrabSuccess && */res2 == LinuxDisplay.GrabSuccess) - input_grabbed = true; - } - } - - private final void destroyCursor() { - if (blank_cursor != LinuxDisplay.None) - LinuxDisplay.nDestroyCursor(display, blank_cursor); - } - - public synchronized void processInput(PeerInfo peer_info) { - LinuxDisplay.lockAWT(); - try { - LinuxPeerInfo linux_peer_info = (LinuxPeerInfo)peer_info; - long new_window = linux_peer_info.getDrawable(); - if (cached_mouse == null || new_window != cached_window) { - ungrabInput(); - cached_window = new_window; - try { - cached_mouse = new LinuxMouse(display, new_window, input_window); -// cached_keyboard = new LinuxKeyboard(display, new_window); - } catch (LWJGLException e) { - LWJGLUtil.log("Failed to create input devices: " + e); - } - destroyCursor(); - this.blank_cursor = LinuxDisplay.nCreateBlankCursor(display, new_window); - } - checkFocus(); - if (!input_grabbed && shouldGrab()) - grabInput(new_window); - update(); - } finally { - LinuxDisplay.unlockAWT(); - } - } - - public void destroyMouse() { - ungrabInputLocked(); - super.destroyMouse(); - } - - private void checkFocus() { - if (getCanvas().isFocusOwner()) { - input_released = false; - } else { - input_released = true; - ungrabInput(); - } - } - - private boolean shouldGrab() { - return !input_released && isGrabbed() && getMouseEventQueue() != null; - } - - private void update() { - while (LinuxEvent.getPending(display) > 0) { - event.nextEvent(display); - if (shouldGrab()) { - long event_window = event.getWindow(); - boolean processed = event.filterEvent(event_window) || - cached_mouse.filterEvent(isGrabbed(), shouldGrab(), event);/* || - cached_keyboard.filterEvent(event) */ - } - } - } - - public synchronized void grabMouse(boolean grab) { - if (grab != isGrabbed()) { - if (cached_mouse != null) - cached_mouse.changeGrabbed(grab, shouldGrab()); - ungrabInputLocked(); - super.grabMouse(grab); - } - } - -/* public synchronized void pollKeyboard(ByteBuffer keyDownBuffer) { - if (isGrabbed()) { - LinuxDisplay.lockAWT(); - try { - if (cached_keyboard != null) - cached_keyboard.poll(keyDownBuffer); - } finally { - LinuxDisplay.unlockAWT(); - } - } else - super.pollKeyboard(keyDownBuffer); - } - - public synchronized void readKeyboard(ByteBuffer buffer) { - if (isGrabbed()) { - LinuxDisplay.lockAWT(); - try { - if (cached_keyboard != null) - cached_keyboard.read(buffer); - } finally { - LinuxDisplay.unlockAWT(); - } - } else - super.readKeyboard(buffer); - } -*/ - public synchronized void pollMouse(IntBuffer coord_buffer, ByteBuffer buttons) { - if (isGrabbed()) { - LinuxDisplay.lockAWT(); - try { - if (cached_mouse != null) - cached_mouse.poll(isGrabbed(), coord_buffer, buttons); - } finally { - LinuxDisplay.unlockAWT(); - } - } else - super.pollMouse(coord_buffer, buttons); - } - - public synchronized void readMouse(ByteBuffer buffer) { - if (isGrabbed()) { - LinuxDisplay.lockAWT(); - try { - if (cached_mouse != null) - cached_mouse.read(buffer); - } finally { - LinuxDisplay.unlockAWT(); - } - } else - super.readMouse(buffer); - } -} Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxCanvasImplementation.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxCanvasImplementation.java 2008-04-10 20:14:15 UTC (rev 3001) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxCanvasImplementation.java 2008-04-10 20:25:54 UTC (rev 3002) @@ -120,8 +120,4 @@ } } private static native int nFindVisualIDFromFormat(long display, int screen, PixelFormat pixel_format) throws LWJGLException; - - public AWTCanvasInputImplementation createInput(AWTGLCanvas canvas) throws LWJGLException { - return new LinuxAWTInput(canvas); - } } Deleted: trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXAWTInput.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXAWTInput.java 2008-04-10 20:14:15 UTC (rev 3001) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXAWTInput.java 2008-04-10 20:25:54 UTC (rev 3002) @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2002-2008 LWJGL Project - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of 'LWJGL' nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package org.lwjgl.opengl; - - -/** - * - * @author elias_naur <eli...@us...> - * @version $Revision: 2586 $ - * $Id: LinuxAWTGLCanvasPeerInfo.java 2586 2006-10-20 11:51:34Z elias_naur $ - */ -final class MacOSXAWTInput extends AbstractAWTInput { - private boolean had_focus; - - MacOSXAWTInput(AWTGLCanvas canvas) { - super(canvas); - } - - protected MouseEventQueue createMouseQueue() { - return new MacOSXMouseEventQueue(getCanvas()); - } - - public synchronized void processInput(PeerInfo peer_info) { - boolean has_focus = getCanvas().isFocusOwner(); - if (!had_focus && has_focus) - ((MacOSXMouseEventQueue)getMouseEventQueue()).warpCursor(); - had_focus = has_focus; - } - - public synchronized void destroyMouse() { - if (getMouseEventQueue() != null) - getMouseEventQueue().setGrabbed(false); - super.destroyMouse(); - } -} Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXCanvasImplementation.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXCanvasImplementation.java 2008-04-10 20:14:15 UTC (rev 3001) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXCanvasImplementation.java 2008-04-10 20:25:54 UTC (rev 3002) @@ -63,8 +63,4 @@ */ return null; } - - public AWTCanvasInputImplementation createInput(AWTGLCanvas canvas) throws LWJGLException { - return new MacOSXAWTInput(canvas); - } } Deleted: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsAWTInput.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsAWTInput.java 2008-04-10 20:14:15 UTC (rev 3001) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsAWTInput.java 2008-04-10 20:25:54 UTC (rev 3002) @@ -1,192 +0,0 @@ -/* - * Copyright (c) 2002-2008 LWJGL Project - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of 'LWJGL' nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package org.lwjgl.opengl; - -import java.awt.Cursor; -import java.nio.ByteBuffer; -import java.nio.IntBuffer; - -import org.lwjgl.BufferUtils; -import org.lwjgl.LWJGLException; -import org.lwjgl.LWJGLUtil; - -/** - * - * @author elias_naur <eli...@us...> - * @version $Revision: 2586 $ - * $Id: LinuxAWTGLCanvasPeerInfo.java 2586 2006-10-20 11:51:34Z elias_naur $ - */ -final class WindowsAWTInput extends AbstractAWTInput { - private final static int WS_CHILD = 0x40000000; - private final Cursor blank_cursor; - private Cursor cached_cursor; - - private long cached_hwnd; - private WindowsDirectInputMouse cached_mouse; -// private WindowsKeyboard cached_keyboard; - private boolean has_grabbed; - - public WindowsAWTInput(AWTGLCanvas canvas) throws LWJGLException { - super(canvas); - int w = AWTUtil.getMinCursorSize(); - int h = AWTUtil.getMinCursorSize(); - blank_cursor = AWTUtil.createCursor(w, h, 0, 0, 1, BufferUtils.createIntBuffer(w*h), null); - } - - public synchronized void destroyMouse() { - if (cached_mouse != null) { - grab(false); - cached_mouse.destroy(); - cached_mouse = null; - } - super.destroyMouse(); - } - -/* public synchronized void destroyKeyboard() { - if (cached_keyboard != null) { - cached_keyboard.destroy(); - cached_keyboard = null; - } - super.destroyKeyboard(); - } -*/ - public synchronized void processInput(PeerInfo peer_info) { - WindowsPeerInfo windows_peerinfo = (WindowsPeerInfo)peer_info; - long hwnd = windows_peerinfo.getHwnd(); - try { - hwnd = findTopLevelWindow(hwnd); - if (cached_mouse == null || hwnd != cached_hwnd) { - has_grabbed = false; - cached_hwnd = hwnd; - if (cached_mouse != null) { - cached_mouse.destroy(); - } -/* if (cached_keyboard != null) { - cached_keyboard.destroy(); - }*/ - WindowsDirectInput dinput = WindowsDisplay.createDirectInput(); - cached_mouse = new WindowsDirectInputMouse(dinput, hwnd); -// cached_keyboard = new WindowsKeyboard(dinput, hwnd); - } - if (isGrabbed()) { - /** - * DirectInput won't always stop the cursor from moving on top of the - * task bar and clicking on it. So we'll use ClipCursor to - * contain it while the cursor is grabbed. - */ - WindowsDisplay.setupCursorClipping(hwnd); // Just clip it to a fullscreen window - if (getCanvas().getCursor() != blank_cursor) { - cached_cursor = getCanvas().getCursor(); - /** - * For some reason, DirectInput won't let us blank the cursor - * with the EXCLUSIVE access mode, so we'll work around it with a - * custom blank cursor - */ - getCanvas().setCursor(blank_cursor); - } - } else - WindowsDisplay.resetCursorClipping(); - grab(isGrabbed()); - } catch (LWJGLException e) { - LWJGLUtil.log("Failed to create windows mouse: " + e); - } - } - private static native int getWindowStyles(long hwnd) throws LWJGLException; - private static native long getParentWindow(long hwnd); - - private static long findTopLevelWindow(long hwnd) throws LWJGLException { - int window_styles = getWindowStyles(hwnd); - while ((window_styles & WS_CHILD) != 0) { - hwnd = getParentWindow(hwnd); - window_styles = getWindowStyles(hwnd); - } - return hwnd; - } - - private void grab(boolean grab) { - if (has_grabbed != grab) { - cached_mouse.grab(grab); -// cached_keyboard.grab(grab); - has_grabbed = grab; - cached_mouse.flush(); -// cached_keyboard.flush(); - getMouseEventQueue().clearEvents(); -// getKeyboardEventQueue().clearEvents(); - if (!grab) { - getCanvas().setCursor(cached_cursor); - } - } - } - - public synchronized void grabMouse(boolean grab) { - if (grab != isGrabbed()) { - /* Only ungrab since grabbing can only occur in processInput - * when the hwnd is guaranteed valid - */ - if (cached_mouse != null && !grab) - grab(grab); - super.grabMouse(grab); - } - } - - public synchronized void pollMouse(IntBuffer coord_buffer, ByteBuffer buttons) { - if (isGrabbed()) { - if (cached_mouse != null) - cached_mouse.poll(coord_buffer, buttons); - } else - super.pollMouse(coord_buffer, buttons); - } - - public synchronized void readMouse(ByteBuffer buffer) { - if (isGrabbed()) { - if (cached_mouse != null) - cached_mouse.read(buffer); - } else - super.readMouse(buffer); - } - -/* public synchronized void readKeyboard(ByteBuffer buffer) { - if (isGrabbed()) { - if (cached_keyboard != null) - cached_keyboard.read(buffer); - } else - super.readKeyboard(buffer); - } - - public synchronized void pollKeyboard(ByteBuffer keyDownBuffer) { - if (isGrabbed()) { - if (cached_keyboard != null) - cached_keyboard.poll(keyDownBuffer); - } else - super.pollKeyboard(keyDownBuffer); - }*/ -} Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsCanvasImplementation.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsCanvasImplementation.java 2008-04-10 20:14:15 UTC (rev 3001) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsCanvasImplementation.java 2008-04-10 20:25:54 UTC (rev 3002) @@ -66,10 +66,6 @@ }); } - public AWTCanvasInputImplementation createInput(AWTGLCanvas canvas) throws LWJGLException { - return new WindowsAWTInput(canvas); - } - public PeerInfo createPeerInfo(Canvas component, PixelFormat pixel_format) throws LWJGLException { return new WindowsAWTGLCanvasPeerInfo(component, pixel_format); } Modified: trunk/LWJGL/src/java/org/lwjgl/test/applet/AppletLoaderTest.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/test/applet/AppletLoaderTest.java 2008-04-10 20:14:15 UTC (rev 3001) +++ trunk/LWJGL/src/java/org/lwjgl/test/applet/AppletLoaderTest.java 2008-04-10 20:25:54 UTC (rev 3002) @@ -35,8 +35,6 @@ import java.awt.BorderLayout; import java.awt.Canvas; -import org.lwjgl.opengl.AWTInputAdapter; - public class AppletLoaderTest extends Applet { Test test = null; @@ -44,7 +42,6 @@ public void destroy() { super.destroy(); System.out.println("*** destroy ***"); - AWTInputAdapter.destroy(); } public void start() { Modified: trunk/LWJGL/src/java/org/lwjgl/test/applet/OpenGL.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/test/applet/OpenGL.java 2008-04-10 20:14:15 UTC (rev 3001) +++ trunk/LWJGL/src/java/org/lwjgl/test/applet/OpenGL.java 2008-04-10 20:25:54 UTC (rev 3002) @@ -35,7 +35,6 @@ import org.lwjgl.input.Keyboard; import org.lwjgl.input.Mouse; import org.lwjgl.opengl.AWTGLCanvas; -import org.lwjgl.opengl.AWTInputAdapter; import org.lwjgl.opengl.GL11; public class OpenGL extends AWTGLCanvas implements Test { @@ -55,11 +54,6 @@ y = 240; GL11.glMatrixMode(GL11.GL_MODELVIEW_MATRIX); setVSyncEnabled(true); - try { - AWTInputAdapter.create(this); - } catch (LWJGLException e) { - e.printStackTrace(); - } } public void paintGL() { @@ -93,9 +87,6 @@ String key_name = Keyboard.getKeyName(Keyboard.getEventKey()); if (Keyboard.getEventKeyState()) { switch (Keyboard.getEventKey()) { - case Keyboard.KEY_H: - AWTInputAdapter.destroy(); - break; case Keyboard.KEY_G: Mouse.setGrabbed(!Mouse.isGrabbed()); break; Deleted: trunk/LWJGL/src/java/org/lwjgl/test/opengl/awt/AWTInputAdapterTest.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/test/opengl/awt/AWTInputAdapterTest.java 2008-04-10 20:14:15 UTC (rev 3001) +++ trunk/LWJGL/src/java/org/lwjgl/test/opengl/awt/AWTInputAdapterTest.java 2008-04-10 20:25:54 UTC (rev 3002) @@ -1,384 +0,0 @@ -/* - * Copyright (c) 2002-2008 LWJGL Project - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of 'LWJGL' nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package org.lwjgl.test.opengl.awt; - -import java.awt.Frame; -import java.awt.Color; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; -import java.nio.FloatBuffer; - -import org.lwjgl.BufferUtils; -import org.lwjgl.LWJGLException; -import org.lwjgl.input.Mouse; -import org.lwjgl.input.Keyboard; -import org.lwjgl.opengl.ARBTransposeMatrix; -import org.lwjgl.opengl.AWTGLCanvas; -import org.lwjgl.opengl.AWTInputAdapter; -import org.lwjgl.opengl.GL11; -import org.lwjgl.opengl.GLContext; - -/** - * <p> - * Gears demo using AWTInputAdapter input - * <p> - * @version $Revision$ - * @author Brian Matzon <br...@ma...> - * @author Elias Naur <eli...@us...> - * $Id$ - */ -public class AWTInputAdapterTest extends Frame { - /** AWT GL canvas */ - private AWTGLCanvas canvas0; - - private float view_rotx = 20.0f; - - private float view_roty = 30.0f; - - private float view_rotz = 0.0f; - - private int gear1; - - private int gear2; - - private int gear3; - - private float angle = 0.0f; - - /** - * C'tor - */ - public AWTInputAdapterTest() throws LWJGLException { - setTitle("Gears"); - setSize(300, 300); - setBackground(Color.BLACK); - add(canvas0 = new AWTGLCanvas() { - long startTime = 0; - long fps = 0; - int current_width; - int current_height; - public void paintGL() { - - if(startTime == 0) { - setup(); - startTime = System.currentTimeMillis() + 5000; - } - - try { - angle += 2.0f; - if (getWidth() != current_width || getHeight() != current_height) { - current_width = getWidth(); - current_height = getHeight(); - GL11.glViewport(0, 0, current_width, current_height); - } - GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); - - GL11.glPushMatrix(); - GL11.glRotatef(view_rotx, 1.0f, 0.0f, 0.0f); - GL11.glRotatef(view_roty, 0.0f, 1.0f, 0.0f); - GL11.glRotatef(view_rotz, 0.0f, 0.0f, 1.0f); - - GL11.glPushMatrix(); - GL11.glTranslatef(-3.0f, -2.0f, 0.0f); - GL11.glRotatef(angle, 0.0f, 0.0f, 1.0f); - GL11.glCallList(gear1); - GL11.glPopMatrix(); - - GL11.glPushMatrix(); - GL11.glTranslatef(3.1f, -2.0f, 0.0f); - GL11.glRotatef(-2.0f * angle - 9.0f, 0.0f, 0.0f, 1.0f); - GL11.glCallList(gear2); - GL11.glPopMatrix(); - - GL11.glPushMatrix(); - GL11.glTranslatef(-3.1f, 4.2f, 0.0f); - GL11.glRotatef(-2.0f * angle - 25.0f, 0.0f, 0.0f, 1.0f); - GL11.glCallList(gear3); - GL11.glPopMatrix(); - - GL11.glPopMatrix(); - swapBuffers(); - repaint(); - } catch (LWJGLException e) { - throw new RuntimeException(e); - } - if (startTime > System.currentTimeMillis()) { - fps++; - } else { - long timeUsed = 5000 + (startTime - System.currentTimeMillis()); - startTime = System.currentTimeMillis() + 5000; - System.out.println(fps + " frames in " + (float) (timeUsed / 1000f) + " seconds = " - + (fps / (timeUsed / 1000f))); - fps = 0; - } - if (Mouse.isCreated()) { - Mouse.poll(); - while (Mouse.next()) { - view_roty += Mouse.getEventDX()*.1; - view_rotx -= Mouse.getEventDY()*.1; - } - } - if (Keyboard.isCreated()) { - Keyboard.poll(); - } - while (Keyboard.isCreated() && Keyboard.next()) { - if (Keyboard.getEventKey() != Keyboard.KEY_NONE) { - String key_name = Keyboard.getKeyName(Keyboard.getEventKey()); - if (Keyboard.getEventKeyState()) { - switch (Keyboard.getEventKey()) { - case Keyboard.KEY_ESCAPE: - System.exit(0); - break; - case Keyboard.KEY_H: - AWTInputAdapter.destroy(); - break; - case Keyboard.KEY_G: - Mouse.setGrabbed(!Mouse.isGrabbed()); - break; - default: - break; - } - System.out.println("Pressed: " + key_name); - } else - System.out.println("Released: " + key_name); - } - if (Keyboard.getEventCharacter() != Keyboard.CHAR_NONE) - System.out.println("Typed: " + Keyboard.getEventCharacter()); - } - if (Keyboard.isCreated()) { - if (Keyboard.isKeyDown(Keyboard.KEY_UP)) - view_rotx -= .1; - else if (Keyboard.isKeyDown(Keyboard.KEY_DOWN)) - view_rotx += .1; - if (Keyboard.isKeyDown(Keyboard.KEY_LEFT)) - view_roty -= .1; - else if (Keyboard.isKeyDown(Keyboard.KEY_RIGHT)) - view_roty += .1; - } - } - }); - addWindowListener(new WindowAdapter() { - public void windowClosing(WindowEvent e) { - dispose(); - System.exit(0); - } - }); - AWTInputAdapter.create(canvas0); - canvas0.setFocusable(true); - canvas0.requestFocus(); - setResizable(true); - setVisible(true); - } - - private void setup() { - // setup ogl - FloatBuffer pos = BufferUtils.createFloatBuffer(4).put(new float[] { 5.0f, 5.0f, 10.0f, 0.0f}); - FloatBuffer red = BufferUtils.createFloatBuffer(4).put(new float[] { 0.8f, 0.1f, 0.0f, 1.0f}); - FloatBuffer green = BufferUtils.createFloatBuffer(4).put(new float[] { 0.0f, 0.8f, 0.2f, 1.0f}); - FloatBuffer blue = BufferUtils.createFloatBuffer(4).put(new float[] { 0.2f, 0.2f, 1.0f, 1.0f}); - pos.flip(); - red.flip(); - green.flip(); - blue.flip(); - - GL11.glLight(GL11.GL_LIGHT0, GL11.GL_POSITION, pos); - GL11.glEnable(GL11.GL_CULL_FACE); - GL11.glEnable(GL11.GL_LIGHTING); - GL11.glEnable(GL11.GL_LIGHT0); - GL11.glEnable(GL11.GL_DEPTH_TEST); - - /* make the gears */ - gear1 = GL11.glGenLists(1); - GL11.glNewList(gear1, GL11.GL_COMPILE); - GL11.glMaterial(GL11.GL_FRONT, GL11.GL_AMBIENT_AND_DIFFUSE, red); - gear(1.0f, 4.0f, 1.0f, 20, 0.7f); - GL11.glEndList(); - - gear2 = GL11.glGenLists(1); - GL11.glNewList(gear2, GL11.GL_COMPILE); - GL11.glMaterial(GL11.GL_FRONT, GL11.GL_AMBIENT_AND_DIFFUSE, green); - gear(0.5f, 2.0f, 2.0f, 10, 0.7f); - GL11.glEndList(); - - gear3 = GL11.glGenLists(1); - GL11.glNewList(gear3, GL11.GL_COMPILE); - GL11.glMaterial(GL11.GL_FRONT, GL11.GL_AMBIENT_AND_DIFFUSE, blue); - gear(1.3f, 2.0f, 0.5f, 10, 0.7f); - GL11.glEndList(); - - GL11.glEnable(GL11.GL_NORMALIZE); - - GL11.glMatrixMode(GL11.GL_PROJECTION); - - System.err.println("Use the arrow keys and the mouse to rotate the gears. Press 'G' to toggle mouse grabbing. Press 'H' to destroy the AWTInputAdapter."); - System.err.println("GL_VENDOR: " + GL11.glGetString(GL11.GL_VENDOR)); - System.err.println("GL_RENDERER: " + GL11.glGetString(GL11.GL_RENDERER)); - System.err.println("GL_VERSION: " + GL11.glGetString(GL11.GL_VERSION)); - System.err.println(); - System.err.println("glLoadTransposeMatrixfARB() supported: " + GLContext.getCapabilities().GL_ARB_transpose_matrix); - if (!GLContext.getCapabilities().GL_ARB_transpose_matrix) { - // --- not using extensions - GL11.glLoadIdentity(); - } else { - // --- using extensions - final FloatBuffer identityTranspose = BufferUtils.createFloatBuffer(16).put( - new float[] { 1, 0, 0, 0, 0, 1, 0, 0, - 0, 0, 1, 0, 0, 0, 0, 1}); - identityTranspose.flip(); - ARBTransposeMatrix.glLoadTransposeMatrixARB(identityTranspose); - } - - float h = (float) 300 / (float) 300; - GL11.glFrustum(-1.0f, 1.0f, -h, h, 5.0f, 60.0f); - GL11.glMatrixMode(GL11.GL_MODELVIEW); - GL11.glLoadIdentity(); - GL11.glTranslatef(0.0f, 0.0f, -40.0f); - } - - /** - * Draw a gear wheel. You'll probably want to call this function when - * building a display list since we do a lot of trig here. - * - * @param inner_radius radius of hole at center - * @param outer_radius radius at center of teeth - * @param width width of gear - * @param teeth number of teeth - * @param tooth_depth depth of tooth - */ - private void gear(float inner_radius, float outer_radius, float width, int teeth, float tooth_depth) { - int i; - float r0, r1, r2; - float angle, da; - float u, v, len; - - r0 = inner_radius; - r1 = outer_radius - tooth_depth / 2.0f; - r2 = outer_radius + tooth_depth / 2.0f; - - da = 2.0f * (float) Math.PI / teeth / 4.0f; - - GL11.glShadeModel(GL11.GL_FLAT); - - GL11.glNormal3f(0.0f, 0.0f, 1.0f); - - /* draw front face */ - GL11.glBegin(GL11.GL_QUAD_STRIP); - for (i = 0; i <= teeth; i++) { - angle = i * 2.0f * (float) Math.PI / teeth; - GL11.glVertex3f(r0 * (float) Math.cos(angle), r0 * (float) Math.sin(angle), width * 0.5f); - GL11.glVertex3f(r1 * (float) Math.cos(angle), r1 * (float) Math.sin(angle), width * 0.5f); - if (i < teeth) { - GL11.glVertex3f(r0 * (float) Math.cos(angle), r0 * (float) Math.sin(angle), width * 0.5f); - GL11.glVertex3f(r1 * (float) Math.cos(angle + 3.0f * da), r1 * (float) Math.sin(angle + 3.0f * da), - width * 0.5f); - } - } - GL11.glEnd(); - - /* draw front sides of teeth */ - GL11.glBegin(GL11.GL_QUADS); - for (i = 0; i < teeth; i++) { - angle = i * 2.0f * (float) Math.PI / teeth; - GL11.glVertex3f(r1 * (float) Math.cos(angle), r1 * (float) Math.sin(angle), width * 0.5f); - GL11.glVertex3f(r2 * (float) Math.cos(angle + da), r2 * (float) Math.sin(angle + da), width * 0.5f); - GL11.glVertex3f(r2 * (float) Math.cos(angle + 2.0f * da), r2 * (float) Math.sin(angle + 2.0f * da), width * 0.5f); - GL11.glVertex3f(r1 * (float) Math.cos(angle + 3.0f * da), r1 * (float) Math.sin(angle + 3.0f * da), width * 0.5f); - } - GL11.glEnd(); - - /* draw back face */ - GL11.glBegin(GL11.GL_QUAD_STRIP); - for (i = 0; i <= teeth; i++) { - angle = i * 2.0f * (float) Math.PI / teeth; - GL11.glVertex3f(r1 * (float) Math.cos(angle), r1 * (float) Math.sin(angle), -width * 0.5f); - GL11.glVertex3f(r0 * (float) Math.cos(angle), r0 * (float) Math.sin(angle), -width * 0.5f); - GL11.glVertex3f(r1 * (float) Math.cos(angle + 3 * da), r1 * (float) Math.sin(angle + 3 * da), -width * 0.5f); - GL11.glVertex3f(r0 * (float) Math.cos(angle), r0 * (float) Math.sin(angle), -width * 0.5f); - } - GL11.glEnd(); - - /* draw back sides of teeth */ - GL11.glBegin(GL11.GL_QUADS); - for (i = 0; i < teeth; i++) { - angle = i * 2.0f * (float) Math.PI / teeth; - GL11.glVertex3f(r1 * (float) Math.cos(angle + 3 * da), r1 * (float) Math.sin(angle + 3 * da), -width * 0.5f); - GL11.glVertex3f(r2 * (float) Math.cos(angle + 2 * da), r2 * (float) Math.sin(angle + 2 * da), -width * 0.5f); - GL11.glVertex3f(r2 * (float) Math.cos(angle + da), r2 * (float) Math.sin(angle + da), -width * 0.5f); - GL11.glVertex3f(r1 * (float) Math.cos(angle), r1 * (float) Math.sin(angle), -width * 0.5f); - } - GL11.glEnd(); - - /* draw outward faces of teeth */ - GL11.glBegin(GL11.GL_QUAD_STRIP); - for (i = 0; i < teeth; i++) { - angle = i * 2.0f * (float) Math.PI / teeth; - GL11.glVertex3f(r1 * (float) Math.cos(angle), r1 * (float) Math.sin(angle), width * 0.5f); - GL11.glVertex3f(r1 * (float) Math.cos(angle), r1 * (float) Math.sin(angle), -width * 0.5f); - u = r2 * (float) Math.cos(angle + da) - r1 * (float) Math.cos(angle); - v = r2 * (float) Math.sin(angle + da) - r1 * (float) Math.sin(angle); - len = (float) Math.sqrt(u * u + v * v); - u /= len; - v /= len; - GL11.glNormal3f(v, -u, 0.0f); - GL11.glVertex3f(r2 * (float) Math.cos(angle + da), r2 * (float) Math.sin(angle + da), width * 0.5f); - GL11.glVertex3f(r2 * (float) Math.cos(angle + da), r2 * (float) Math.sin(angle + da), -width * 0.5f); - GL11.glNormal3f((float) Math.cos(angle), (float) Math.sin(angle), 0.0f); - GL11.glVertex3f(r2 * (float) Math.cos(angle + 2 * da), r2 * (float) Math.sin(angle + 2 * da), width * 0.5f); - GL11.glVertex3f(r2 * (float) Math.cos(angle + 2 * da), r2 * (float) Math.sin(angle + 2 * da), -width * 0.5f); - u = r1 * (float) Math.cos(angle + 3 * da) - r2 * (float) Math.cos(angle + 2 * da); - v = r1 * (float) Math.sin(angle + 3 * da) - r2 * (float) Math.sin(angle + 2 * da); - GL11.glNormal3f(v, -u, 0.0f); - GL11.glVertex3f(r1 * (float) Math.cos(angle + 3 * da), r1 * (float) Math.sin(angle + 3 * da), width * 0.5f); - GL11.glVertex3f(r1 * (float) Math.cos(angle + 3 * da), r1 * (float) Math.sin(angle + 3 * da), -width * 0.5f); - GL11.glNormal3f((float) Math.cos(angle), (float) Math.sin(angle), 0.0f); - } - GL11.glVertex3f(r1 * (float) Math.cos(0), r1 * (float) Math.sin(0), width * 0.5f); - GL11.glVertex3f(r1 * (float) Math.cos(0), r1 * (float) Math.sin(0), -width * 0.5f); - GL11.glEnd(); - - GL11.glShadeModel(GL11.GL_SMOOTH); - - /* draw inside radius cylinder */ - GL11.glBegin(GL11.GL_QUAD_STRIP); - for (i = 0; i <= teeth; i++) { - angle = i * 2.0f * (float) Math.PI / teeth; - GL11.glNormal3f(-(float) Math.cos(angle), -(float) Math.sin(angle), 0.0f); - GL11.glVertex3f(r0 * (float) Math.cos(angle), r0 * (float) Math.sin(angle), -width * 0.5f); - GL11.glVertex3f(r0 * (float) Math.cos(angle), r0 * (float) Math.sin(angle), width * 0.5f); - } - GL11.glEnd(); - } - - public static void main(String[] args) throws LWJGLException { - new AWTInputAdapterTest(); - } -} Deleted: trunk/LWJGL/src/native/linux/org_lwjgl_opengl_LinuxAWTInput.c =================================================================== --- trunk/LWJGL/src/native/linux/org_lwjgl_opengl_LinuxAWTInput.c 2008-04-10 20:14:15 UTC (rev 3001) +++ trunk/LWJGL/src/native/linux/org_lwjgl_opengl_LinuxAWTInput.c 2008-04-10 20:25:54 UTC (rev 3002) @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2002-2008 LWJGL Project - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * 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_opengl_LinuxEvent.c 2598 2006-10-24 08:33:09Z elias_naur $ - * - * @author elias_naur <eli...@us...> - * @version $Revision: 2598 $ - */ - -#include <X11/X.h> -#include <X11/Xlib.h> -#include <X11/Xutil.h> -#include <jni.h> -#include "common_tools.h" -#include "org_lwjgl_opengl_LinuxAWTInput.h" - -JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxAWTInput_createInputOnlyWindow(JNIEnv *env, jclass unused, jlong display_ptr, jint screen) { - Display *disp = (Display *)(intptr_t)display_ptr; - Window window = XCreateWindow(disp, RootWindow(disp, screen), 0, 0, 1, 1, 0, CopyFromParent, InputOnly, CopyFromParent, 0, NULL); - return window; -} Deleted: trunk/LWJGL/src/native/windows/org_lwjgl_opengl_WindowsAWTInput.c =================================================================== --- trunk/LWJGL/src/native/windows/org_lwjgl_opengl_WindowsAWTInput.c 2008-04-10 20:14:15 UTC (rev 3001) +++ trunk/LWJGL/src/native/windows/org_lwjgl_opengl_WindowsAWTInput.c 2008-04-10 20:25:54 UTC (rev 3002) @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2002-2008 LWJGL Project - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * 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_opengl_WindowsAWTGLCanvasPeerInfo.c 2575 2006-09-19 14:17:13Z elias_naur $ - * - * @author elias_naur <eli...@us...> - * @version $Revision: 2575 $ - */ - -#include <jni.h> -#include "context.h" -#include "org_lwjgl_opengl_WindowsAWTInput.h" - -JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_WindowsAWTInput_getWindowStyles(JNIEnv *env, jclass unused, jlong hwnd_ptr) { - HWND hwnd = (HWND)(intptr_t)hwnd_ptr; - WINDOWINFO window_info; - if (!GetWindowInfo(hwnd, &window_info)) { - throwFormattedException(env, "Failed to get window info (%d).", GetLastError()); - return 0; - } - return window_info.dwStyle; -} - -JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_WindowsAWTInput_getParentWindow(JNIEnv *env, jclass unused, jlong hwnd_ptr) { - HWND hwnd = (HWND)(intptr_t)hwnd_ptr; - return (intptr_t)GetParent(hwnd); -} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |