You can subscribe to this list here.
2004 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(52) |
Aug
(34) |
Sep
(99) |
Oct
(110) |
Nov
(21) |
Dec
(69) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2005 |
Jan
(117) |
Feb
(90) |
Mar
(1) |
Apr
(22) |
May
(96) |
Jun
(25) |
Jul
(22) |
Aug
|
Sep
|
Oct
(18) |
Nov
(43) |
Dec
(71) |
2006 |
Jan
(20) |
Feb
(10) |
Mar
|
Apr
(4) |
May
(2) |
Jun
|
Jul
|
Aug
(3) |
Sep
|
Oct
(60) |
Nov
(63) |
Dec
(35) |
2007 |
Jan
(18) |
Feb
(40) |
Mar
(14) |
Apr
(18) |
May
(33) |
Jun
(2) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(1) |
Dec
|
2008 |
Jan
|
Feb
(1) |
Mar
(25) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2009 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(5) |
2011 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(15) |
Aug
|
Sep
|
Oct
|
Nov
(3) |
Dec
|
2012 |
Jan
|
Feb
|
Mar
|
Apr
(3) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Carsten W. <ca...@us...> - 2004-12-14 00:56:01
|
Update of /cvsroot/jake2/jake2/lib/lwjgl/linux In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15590/lib/lwjgl/linux Added Files: libopenal.so liblwjgl.so Log Message: initial checkin of the lwjgl 0.93 libs --- NEW FILE: liblwjgl.so --- (This appears to be a binary file; contents omitted.) --- NEW FILE: libopenal.so --- (This appears to be a binary file; contents omitted.) |
From: Carsten W. <ca...@us...> - 2004-12-14 00:54:00
|
Update of /cvsroot/jake2/jake2/lib/lwjgl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15260/lib/lwjgl Added Files: lwjgl.jar lwjgl_util.jar Log Message: initial checkin of the lwjgl 0.93 libs --- NEW FILE: lwjgl.jar --- (This appears to be a binary file; contents omitted.) --- NEW FILE: lwjgl_util.jar --- (This appears to be a binary file; contents omitted.) |
From: Carsten W. <ca...@us...> - 2004-12-14 00:53:59
|
Update of /cvsroot/jake2/jake2/lib/lwjgl/windows In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15260/lib/lwjgl/windows Added Files: lwjgl.dll lwjglaudio.dll Log Message: initial checkin of the lwjgl 0.93 libs --- NEW FILE: lwjgl.dll --- (This appears to be a binary file; contents omitted.) --- NEW FILE: lwjglaudio.dll --- (This appears to be a binary file; contents omitted.) |
From: Carsten W. <ca...@us...> - 2004-12-14 00:51:08
|
Update of /cvsroot/jake2/jake2/lib/lwjgl/linux In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14710/lib/lwjgl/linux Log Message: Directory /cvsroot/jake2/jake2/lib/lwjgl/linux added to the repository |
From: Carsten W. <ca...@us...> - 2004-12-14 00:51:08
|
Update of /cvsroot/jake2/jake2/lib/lwjgl/windows In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14710/lib/lwjgl/windows Log Message: Directory /cvsroot/jake2/jake2/lib/lwjgl/windows added to the repository |
From: Carsten W. <ca...@us...> - 2004-12-14 00:51:07
|
Update of /cvsroot/jake2/jake2/lib/lwjgl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14710/lib/lwjgl Log Message: Directory /cvsroot/jake2/jake2/lib/lwjgl added to the repository |
From: Holger Z. <hz...@us...> - 2004-12-14 00:11:45
|
Update of /cvsroot/jake2/jake2/src/jake2/sys In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5406/src/jake2/sys Modified Files: InputListener.java KBD.java Sys.java IN.java Added Files: LWJGLKBD.java JOGLKBD.java Log Message: merge LWJGL input system changes Index: InputListener.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/sys/InputListener.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** InputListener.java 3 Nov 2004 08:53:27 -0000 1.3 --- InputListener.java 14 Dec 2004 00:11:01 -0000 1.4 *************** *** 100,104 **** public void componentShown(ComponentEvent e) { ! IN.c = e.getComponent(); addEvent(new Jake2InputEvent(Jake2InputEvent.CreateNotify, e)); } --- 100,104 ---- public void componentShown(ComponentEvent e) { ! JOGLKBD.c = e.getComponent(); addEvent(new Jake2InputEvent(Jake2InputEvent.CreateNotify, e)); } --- NEW FILE: LWJGLKBD.java --- package jake2.sys; import jake2.Defines; import jake2.client.Key; import jake2.qcommon.Cbuf; import org.lwjgl.input.Keyboard; import org.lwjgl.input.Mouse; import org.lwjgl.opengl.Display; /** * @author dsanders */ public class LWJGLKBD extends KBD { static private int win_w2; static private int win_h2; public void Init() { try { if (!Keyboard.isCreated()) Keyboard.create(); if (!Mouse.isCreated()) Mouse.create(); if (!Keyboard.isBuffered()) Keyboard.enableBuffer(); if (!Mouse.isBuffered()) Mouse.enableBuffer(); win_w2=Display.getDisplayMode().getWidth()/2; win_h2=Display.getDisplayMode().getHeight()/2; } catch (Exception e) {;} } public void Update() { // get events HandleEvents(); } public void Close() { Keyboard.destroy(); Mouse.destroy(); } private void HandleEvents() { if (Display.isCloseRequested()) { Cbuf.ExecuteText(Defines.EXEC_APPEND, "quit"); } for (int i=0; i<Keyboard.getNumKeyboardEvents(); i++) { Keyboard.next(); int key=Keyboard.getEventKey(); char ch=Keyboard.getEventCharacter(); Do_Key_Event(XLateKey(key,ch),Keyboard.getEventKeyState()); } if (IN.mouse_active) { mx=(Mouse.getX()-win_w2)*2; my=(Mouse.getY()-win_h2)*2; } else { mx=0; my=0; } while (Mouse.next()) { int button=Mouse.getEventButton(); if (button>=0) { Do_Key_Event(Key.K_MOUSE1 + button, Mouse.getEventButtonState()); } } } private static int XLateKey(int code, int ch) { int key = 0; switch(code) { // 00626 case XK_KP_Page_Up: key = K_KP_PGUP; break; case Keyboard.KEY_PRIOR: key = Key.K_PGUP; break; // 00629 case XK_KP_Page_Down: key = K_KP_PGDN; break; case Keyboard.KEY_NEXT: key = Key.K_PGDN; break; // 00632 case XK_KP_Home: key = K_KP_HOME; break; case Keyboard.KEY_HOME: key = Key.K_HOME; break; // 00635 case XK_KP_End: key = K_KP_END; break; case Keyboard.KEY_END: key = Key.K_END; break; // case Keyboard.KEY_LEFT: key = Key.K_KP_LEFTARROW; break; case Keyboard.KEY_LEFT: key = Key.K_LEFTARROW; break; // case Keyboard.KEY_RIGHT: key = Key.K_KP_RIGHTARROW; break; case Keyboard.KEY_RIGHT: key = Key.K_RIGHTARROW; break; // case Keyboard.KEY_DOWN: key = Key.K_KP_DOWNARROW; break; case Keyboard.KEY_DOWN: key = Key.K_DOWNARROW; break; // case Keyboard.KEY_UP: key = Key.K_KP_UPARROW; break; case Keyboard.KEY_UP: key = Key.K_UPARROW; break; case Keyboard.KEY_ESCAPE: key = Key.K_ESCAPE; break; case Keyboard.KEY_RETURN: key = Key.K_ENTER; break; // 00652 case XK_KP_Enter: key = K_KP_ENTER; break; case Keyboard.KEY_TAB: key = Key.K_TAB; break; case Keyboard.KEY_F1: key = Key.K_F1; break; case Keyboard.KEY_F2: key = Key.K_F2; break; case Keyboard.KEY_F3: key = Key.K_F3; break; case Keyboard.KEY_F4: key = Key.K_F4; break; case Keyboard.KEY_F5: key = Key.K_F5; break; case Keyboard.KEY_F6: key = Key.K_F6; break; case Keyboard.KEY_F7: key = Key.K_F7; break; case Keyboard.KEY_F8: key = Key.K_F8; break; case Keyboard.KEY_F9: key = Key.K_F9; break; case Keyboard.KEY_F10: key = Key.K_F10; break; case Keyboard.KEY_F11: key = Key.K_F11; break; case Keyboard.KEY_F12: key = Key.K_F12; break; case Keyboard.KEY_BACK: key = Key.K_BACKSPACE; break; case Keyboard.KEY_DELETE: key = Key.K_DEL; break; // 00683 case XK_KP_Delete: key = K_KP_DEL; break; case Keyboard.KEY_PAUSE: key = Key.K_PAUSE; break; case Keyboard.KEY_RSHIFT: case Keyboard.KEY_LSHIFT: key = Key.K_SHIFT; break; case Keyboard.KEY_RCONTROL: case Keyboard.KEY_LCONTROL: key = Key.K_CTRL; break; case Keyboard.KEY_LMENU: case Keyboard.KEY_RMENU: key = Key.K_ALT; break; // 00700 case XK_KP_Begin: key = K_KP_5; break; // 00701 case Keyboard.KEY_INSERT: key = Key.K_INS; break; // toggle console for DE and US keyboards case Keyboard.KEY_CIRCUMFLEX: key = '`'; break; default: key = ch; if (key >= 'A' && key <= 'Z') key = key - 'A' + 'a'; break; } if (key > 255) key = 0; return key; } public void Do_Key_Event(int key, boolean down) { Key.Event(key, down, Sys.Milliseconds()); } public void centerMouse() { Mouse.setPosition(win_x + win_w2,win_y + win_h2); //Mouse.setGrabbed(true); //Mouse.setTrackingEnabled(true); } public void installGrabs() { Mouse.setGrabbed(true); } public void uninstallGrabs() { Mouse.setGrabbed(false); } } Index: KBD.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/sys/KBD.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** KBD.java 3 Nov 2004 10:16:42 -0000 1.5 --- KBD.java 14 Dec 2004 00:11:01 -0000 1.6 *************** *** 26,43 **** package jake2.sys; - import jake2.client.Key; - - import java.awt.*; - import java.awt.event.*; /** * KBD */ ! public final class KBD { static int win_x = 0; static int win_y = 0; - static int win_w2 = 0; - static int win_h2 = 0; // motion values --- 26,37 ---- package jake2.sys; /** * KBD */ ! abstract public class KBD { static int win_x = 0; static int win_y = 0; // motion values *************** *** 45,238 **** public static int my = 0; ! static Robot robot; ! public static InputListener listener = new InputListener(); ! ! static { ! try { ! robot = new Robot(); ! } catch (AWTException e) { ! System.exit(1); ! } ! } ! ! public static void Init() { ! } ! ! public static void Update() { ! // get events ! HandleEvents(); ! } ! ! public static void Close() { ! } ! ! static void HandleEvents() { ! int b; ! ! Jake2InputEvent event; ! while ( (event=InputListener.nextEvent()) != null ) { ! switch(event.type) { ! case Jake2InputEvent.KeyPress: ! case Jake2InputEvent.KeyRelease: ! Do_Key_Event(XLateKey((KeyEvent)event.ev), event.type == Jake2InputEvent.KeyPress); ! break; ! ! case Jake2InputEvent.MotionNotify: ! // if (IN.ignorefirst) { ! // IN.ignorefirst = false; ! // break; ! // } ! if (IN.mouse_active) { ! mx = (((MouseEvent)event.ev).getX() - win_w2) * 2; ! my = (((MouseEvent)event.ev).getY() - win_h2) * 2; ! } else { ! mx = 0; ! my = 0; ! } ! break; ! ! case Jake2InputEvent.ButtonPress: ! b=((MouseEvent)event.ev).getButton()-1; ! Do_Key_Event(Key.K_MOUSE1 + b, true); ! break; ! ! case Jake2InputEvent.ButtonRelease: ! b=((MouseEvent)event.ev).getButton()-1; ! Do_Key_Event(Key.K_MOUSE1 + b, false); ! break; ! ! case Jake2InputEvent.WheelMoved: ! int dir = ((MouseWheelEvent)event.ev).getWheelRotation(); ! if (dir > 0) { ! Do_Key_Event(Key.K_MWHEELDOWN, true); ! Do_Key_Event(Key.K_MWHEELDOWN, false); ! } else { ! Do_Key_Event(Key.K_MWHEELUP, true); ! Do_Key_Event(Key.K_MWHEELUP, false); ! } ! break; ! ! case Jake2InputEvent.CreateNotify : ! case Jake2InputEvent.ConfigureNotify : ! Component c = ((ComponentEvent)event.ev).getComponent(); ! win_x = 0; ! win_y = 0; ! win_w2 = c.getWidth() / 2; ! win_h2 = c.getHeight() / 2; ! while (c != null) { ! if (c instanceof Container) { ! Insets insets = ((Container)c).getInsets(); ! win_x += insets.left; ! win_y += insets.top; ! } ! win_x += c.getX(); ! win_y += c.getY(); ! c = c.getParent(); ! } ! break; ! } ! } ! ! if (mx != 0 || my != 0) { ! // move the mouse to the window center again ! robot.mouseMove(win_x + win_w2, win_y + win_h2); ! } ! } ! ! private static int XLateKey(KeyEvent ev) { ! ! int key = 0; ! int code = ev.getKeyCode(); ! ! switch(code) { ! // 00626 case XK_KP_Page_Up: key = K_KP_PGUP; break; ! case KeyEvent.VK_PAGE_UP: key = Key.K_PGUP; break; ! ! // 00629 case XK_KP_Page_Down: key = K_KP_PGDN; break; ! case KeyEvent.VK_PAGE_DOWN: key = Key.K_PGDN; break; ! ! // 00632 case XK_KP_Home: key = K_KP_HOME; break; ! case KeyEvent.VK_HOME: key = Key.K_HOME; break; ! ! // 00635 case XK_KP_End: key = K_KP_END; break; ! case KeyEvent.VK_END: key = Key.K_END; break; ! ! case KeyEvent.VK_KP_LEFT: key = Key.K_KP_LEFTARROW; break; ! case KeyEvent.VK_LEFT: key = Key.K_LEFTARROW; break; ! ! case KeyEvent.VK_KP_RIGHT: key = Key.K_KP_RIGHTARROW; break; ! case KeyEvent.VK_RIGHT: key = Key.K_RIGHTARROW; break; ! ! case KeyEvent.VK_KP_DOWN: key = Key.K_KP_DOWNARROW; break; ! case KeyEvent.VK_DOWN: key = Key.K_DOWNARROW; break; ! ! case KeyEvent.VK_KP_UP: key = Key.K_KP_UPARROW; break; ! case KeyEvent.VK_UP: key = Key.K_UPARROW; break; ! ! case KeyEvent.VK_ESCAPE: key = Key.K_ESCAPE; break; ! ! ! case KeyEvent.VK_ENTER: key = Key.K_ENTER; break; ! // 00652 case XK_KP_Enter: key = K_KP_ENTER; break; ! ! case KeyEvent.VK_TAB: key = Key.K_TAB; break; ! ! case KeyEvent.VK_F1: key = Key.K_F1; break; ! case KeyEvent.VK_F2: key = Key.K_F2; break; ! case KeyEvent.VK_F3: key = Key.K_F3; break; ! case KeyEvent.VK_F4: key = Key.K_F4; break; ! case KeyEvent.VK_F5: key = Key.K_F5; break; ! case KeyEvent.VK_F6: key = Key.K_F6; break; ! case KeyEvent.VK_F7: key = Key.K_F7; break; ! case KeyEvent.VK_F8: key = Key.K_F8; break; ! case KeyEvent.VK_F9: key = Key.K_F9; break; ! case KeyEvent.VK_F10: key = Key.K_F10; break; ! case KeyEvent.VK_F11: key = Key.K_F11; break; ! case KeyEvent.VK_F12: key = Key.K_F12; break; ! ! case KeyEvent.VK_BACK_SPACE: key = Key.K_BACKSPACE; break; ! case KeyEvent.VK_DELETE: key = Key.K_DEL; break; ! // 00683 case XK_KP_Delete: key = K_KP_DEL; break; ! case KeyEvent.VK_PAUSE: key = Key.K_PAUSE; break; ! ! case KeyEvent.VK_SHIFT: key = Key.K_SHIFT; break; ! case KeyEvent.VK_CONTROL: key = Key.K_CTRL; break; ! ! case KeyEvent.VK_ALT: ! case KeyEvent.VK_ALT_GRAPH: key = Key.K_ALT; break; ! ! // 00700 case XK_KP_Begin: key = K_KP_5; break; ! // 00701 ! case KeyEvent.VK_INSERT: key = Key.K_INS; break; ! // toggle console for DE and US keyboards ! case KeyEvent.VK_DEAD_ACUTE: ! case KeyEvent.VK_CIRCUMFLEX: ! case KeyEvent.VK_DEAD_CIRCUMFLEX: key = '`'; break; ! ! default: ! if ((ev.getModifiers() & (InputEvent.ALT_MASK | InputEvent.CTRL_MASK)) != 0) { ! key = ev.getKeyCode(); ! } else { ! key = ev.getKeyChar(); ! } ! if (key >= 'A' && key <= 'Z') ! key = key - 'A' + 'a'; ! break; ! } ! if (key > 255) key = 0; ! return key; ! } ! ! static void Do_Key_Event(int key, boolean down) { ! Key.Event(key, down, Sys.Milliseconds()); ! } ! ! static void centerMouse() { ! robot.mouseMove(win_x + win_w2, win_y + win_h2); ! } ! } --- 39,52 ---- public static int my = 0; ! abstract public void Init(); ! abstract public void Update(); ! abstract public void Close(); ! abstract public void Do_Key_Event(int key, boolean down); ! abstract public void installGrabs(); ! abstract public void uninstallGrabs(); ! abstract public void centerMouse(); } --- NEW FILE: JOGLKBD.java --- package jake2.sys; import jake2.client.Key; import java.awt.AWTException; import java.awt.Component; import java.awt.Container; import java.awt.Cursor; import java.awt.Insets; import java.awt.Point; import java.awt.Robot; import java.awt.event.ComponentEvent; import java.awt.event.InputEvent; import java.awt.event.KeyEvent; import java.awt.event.MouseEvent; import javax.swing.ImageIcon; final public class JOGLKBD extends KBD { static Robot robot; public static InputListener listener = new InputListener(); static Cursor emptyCursor = null; static Component c = null; static int win_w2 = 0; static int win_h2 = 0; static { try { robot = new Robot(); } catch (AWTException e) { System.exit(1); } } public void Init() { } public void Update() { // get events HandleEvents(); } public void Close() { } private void HandleEvents() { int b; Jake2InputEvent event; while ( (event=InputListener.nextEvent()) != null ) { switch(event.type) { case Jake2InputEvent.KeyPress: case Jake2InputEvent.KeyRelease: Do_Key_Event(XLateKey((KeyEvent)event.ev), event.type == Jake2InputEvent.KeyPress); break; case Jake2InputEvent.MotionNotify: // if (IN.ignorefirst) { // IN.ignorefirst = false; // break; // } if (IN.mouse_active) { mx = (((MouseEvent)event.ev).getX() - win_w2) * 2; my = (((MouseEvent)event.ev).getY() - win_h2) * 2; } else { mx = 0; my = 0; } break; case Jake2InputEvent.ButtonPress: b=((MouseEvent)event.ev).getButton()-1; Do_Key_Event(Key.K_MOUSE1 + b, true); break; case Jake2InputEvent.ButtonRelease: b=((MouseEvent)event.ev).getButton()-1; Do_Key_Event(Key.K_MOUSE1 + b, false); break; case Jake2InputEvent.CreateNotify : case Jake2InputEvent.ConfigureNotify : Component c = ((ComponentEvent)event.ev).getComponent(); win_x = 0; win_y = 0; win_w2 = c.getWidth() / 2; win_h2 = c.getHeight() / 2; while (c != null) { if (c instanceof Container) { Insets insets = ((Container)c).getInsets(); win_x += insets.left; win_y += insets.top; } win_x += c.getX(); win_y += c.getY(); c = c.getParent(); } break; } } if (mx != 0 || my != 0) { // move the mouse to the window center again robot.mouseMove(win_x + win_w2, win_y + win_h2); } } private static int XLateKey(KeyEvent ev) { int key = 0; int code = ev.getKeyCode(); switch(code) { // 00626 case XK_KP_Page_Up: key = K_KP_PGUP; break; case KeyEvent.VK_PAGE_UP: key = Key.K_PGUP; break; // 00629 case XK_KP_Page_Down: key = K_KP_PGDN; break; case KeyEvent.VK_PAGE_DOWN: key = Key.K_PGDN; break; // 00632 case XK_KP_Home: key = K_KP_HOME; break; case KeyEvent.VK_HOME: key = Key.K_HOME; break; // 00635 case XK_KP_End: key = K_KP_END; break; case KeyEvent.VK_END: key = Key.K_END; break; case KeyEvent.VK_KP_LEFT: key = Key.K_KP_LEFTARROW; break; case KeyEvent.VK_LEFT: key = Key.K_LEFTARROW; break; case KeyEvent.VK_KP_RIGHT: key = Key.K_KP_RIGHTARROW; break; case KeyEvent.VK_RIGHT: key = Key.K_RIGHTARROW; break; case KeyEvent.VK_KP_DOWN: key = Key.K_KP_DOWNARROW; break; case KeyEvent.VK_DOWN: key = Key.K_DOWNARROW; break; case KeyEvent.VK_KP_UP: key = Key.K_KP_UPARROW; break; case KeyEvent.VK_UP: key = Key.K_UPARROW; break; case KeyEvent.VK_ESCAPE: key = Key.K_ESCAPE; break; case KeyEvent.VK_ENTER: key = Key.K_ENTER; break; // 00652 case XK_KP_Enter: key = K_KP_ENTER; break; case KeyEvent.VK_TAB: key = Key.K_TAB; break; case KeyEvent.VK_F1: key = Key.K_F1; break; case KeyEvent.VK_F2: key = Key.K_F2; break; case KeyEvent.VK_F3: key = Key.K_F3; break; case KeyEvent.VK_F4: key = Key.K_F4; break; case KeyEvent.VK_F5: key = Key.K_F5; break; case KeyEvent.VK_F6: key = Key.K_F6; break; case KeyEvent.VK_F7: key = Key.K_F7; break; case KeyEvent.VK_F8: key = Key.K_F8; break; case KeyEvent.VK_F9: key = Key.K_F9; break; case KeyEvent.VK_F10: key = Key.K_F10; break; case KeyEvent.VK_F11: key = Key.K_F11; break; case KeyEvent.VK_F12: key = Key.K_F12; break; case KeyEvent.VK_BACK_SPACE: key = Key.K_BACKSPACE; break; case KeyEvent.VK_DELETE: key = Key.K_DEL; break; // 00683 case XK_KP_Delete: key = K_KP_DEL; break; case KeyEvent.VK_PAUSE: key = Key.K_PAUSE; break; case KeyEvent.VK_SHIFT: key = Key.K_SHIFT; break; case KeyEvent.VK_CONTROL: key = Key.K_CTRL; break; case KeyEvent.VK_ALT: case KeyEvent.VK_ALT_GRAPH: key = Key.K_ALT; break; // 00700 case XK_KP_Begin: key = K_KP_5; break; // 00701 case KeyEvent.VK_INSERT: key = Key.K_INS; break; // toggle console for DE and US keyboards case KeyEvent.VK_DEAD_ACUTE: case KeyEvent.VK_CIRCUMFLEX: case KeyEvent.VK_DEAD_CIRCUMFLEX: key = '`'; break; default: if ((ev.getModifiers() & (InputEvent.ALT_MASK | InputEvent.CTRL_MASK)) != 0) { key = ev.getKeyCode(); } else { key = ev.getKeyChar(); } if (key >= 'A' && key <= 'Z') key = key - 'A' + 'a'; break; } if (key > 255) key = 0; return key; } public void Do_Key_Event(int key, boolean down) { Key.Event(key, down, Sys.Milliseconds()); } public void centerMouse() { robot.mouseMove(win_x + win_w2, win_y + win_h2); } public void installGrabs() { if (emptyCursor == null) { ImageIcon emptyIcon = new ImageIcon(new byte[0]); emptyCursor = c.getToolkit().createCustomCursor(emptyIcon.getImage(), new Point(0, 0), "emptyCursor"); } c.setCursor(emptyCursor); } public void uninstallGrabs() { c.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); } } Index: IN.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/sys/IN.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** IN.java 22 Sep 2004 19:22:14 -0000 1.5 --- IN.java 14 Dec 2004 00:11:01 -0000 1.6 *************** *** 46,53 **** public final class IN extends Globals { - static Component c = null; - - static Cursor emptyCursor = null; - static boolean mouse_avail = true; --- 46,49 ---- *************** *** 67,71 **** public static void ActivateMouse() { ! if (!mouse_avail || c == null) return; if (!mouse_active) { --- 63,67 ---- public static void ActivateMouse() { ! if (!mouse_avail) return; if (!mouse_active) { *************** *** 85,101 **** private static void install_grabs() { - if (emptyCursor == null) { - ImageIcon emptyIcon = new ImageIcon(new byte[0]); - emptyCursor = c.getToolkit().createCustomCursor( - emptyIcon.getImage(), new Point(0, 0), "emptyCursor"); - } - c.setCursor(emptyCursor); - KBD.centerMouse(); ! ignorefirst = true; } private static void uninstall_grabs() { ! c.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); } --- 81,93 ---- private static void install_grabs() { ! Globals.re.getKeyboardHandler().installGrabs(); ! Globals.re.getKeyboardHandler().centerMouse(); ! ! ignorefirst = true; } private static void uninstall_grabs() { ! Globals.re.getKeyboardHandler().uninstallGrabs(); } *************** *** 158,176 **** public static void Commands() { ! int i; ! ! if (!IN.mouse_avail) ! return; ! ! for (i = 0; i < 3; i++) { ! if ((IN.mouse_buttonstate & (1 << i)) != 0 ! && (IN.mouse_oldbuttonstate & (1 << i)) == 0) ! KBD.Do_Key_Event(Key.K_MOUSE1 + i, true); ! ! if ((IN.mouse_buttonstate & (1 << i)) == 0 ! && (IN.mouse_oldbuttonstate & (1 << i)) != 0) ! KBD.Do_Key_Event(Key.K_MOUSE1 + i, false); ! } ! IN.mouse_oldbuttonstate = IN.mouse_buttonstate; } --- 150,167 ---- public static void Commands() { ! int i; ! ! if (!IN.mouse_avail) ! return; ! ! KBD kbd=Globals.re.getKeyboardHandler(); ! for (i=0 ; i<3 ; i++) { ! if ( (IN.mouse_buttonstate & (1<<i)) != 0 && (IN.mouse_oldbuttonstate & (1<<i)) == 0 ) ! kbd.Do_Key_Event(Key.K_MOUSE1 + i, true); ! ! if ( (IN.mouse_buttonstate & (1<<i)) == 0 && (IN.mouse_oldbuttonstate & (1<<i)) != 0 ) ! kbd.Do_Key_Event(Key.K_MOUSE1 + i, false); ! } ! IN.mouse_oldbuttonstate = IN.mouse_buttonstate; } Index: Sys.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/sys/Sys.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** Sys.java 22 Sep 2004 19:22:14 -0000 1.9 --- Sys.java 14 Dec 2004 00:11:01 -0000 1.10 *************** *** 228,232 **** public static void SendKeyEvents() { ! KBD.Update(); // grab frame time --- 228,232 ---- public static void SendKeyEvents() { ! Globals.re.getKeyboardHandler().Update(); // grab frame time |
From: Holger Z. <hz...@us...> - 2004-12-14 00:11:19
|
Update of /cvsroot/jake2/jake2/src/jake2/render In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5406/src/jake2/render Modified Files: JoglRenderer.java JoglBase.java FastJoglRenderer.java Log Message: merge LWJGL input system changes Index: JoglRenderer.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/render/JoglRenderer.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** JoglRenderer.java 16 Jul 2004 10:11:34 -0000 1.5 --- JoglRenderer.java 14 Dec 2004 00:11:03 -0000 1.6 *************** *** 27,33 **** import jake2.Defines; ! import jake2.client.*; import jake2.qcommon.xcommand_t; import jake2.render.jogl.Misc; import java.awt.Dimension; --- 27,36 ---- import jake2.Defines; ! import jake2.client.refdef_t; ! import jake2.client.refexport_t; import jake2.qcommon.xcommand_t; import jake2.render.jogl.Misc; + import jake2.sys.JOGLKBD; + import jake2.sys.KBD; import java.awt.Dimension; *************** *** 40,43 **** --- 43,48 ---- final class JoglRenderer extends Misc implements refexport_t, Ref { + private JOGLKBD kbd=new JOGLKBD(); + public static final String DRIVER_NAME = "jogl"; *************** *** 302,304 **** --- 307,314 ---- return this; } + + public KBD getKeyboardHandler() + { + return kbd; + } } \ No newline at end of file Index: FastJoglRenderer.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/render/FastJoglRenderer.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** FastJoglRenderer.java 16 Jul 2004 10:11:34 -0000 1.3 --- FastJoglRenderer.java 14 Dec 2004 00:11:09 -0000 1.4 *************** *** 30,33 **** --- 30,35 ---- import jake2.qcommon.xcommand_t; import jake2.render.fastjogl.Misc; + import jake2.sys.JOGLKBD; + import jake2.sys.KBD; import java.awt.Dimension; *************** *** 40,43 **** --- 42,47 ---- final class FastJoglRenderer extends Misc implements refexport_t, Ref { + private JOGLKBD kbd=new JOGLKBD(); + public static final String DRIVER_NAME = "fastjogl"; *************** *** 305,307 **** --- 309,315 ---- } + public KBD getKeyboardHandler() + { + return kbd; + } } \ No newline at end of file Index: JoglBase.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/render/JoglBase.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** JoglBase.java 3 Nov 2004 08:53:27 -0000 1.12 --- JoglBase.java 14 Dec 2004 00:11:09 -0000 1.13 *************** *** 32,35 **** --- 32,36 ---- import jake2.qcommon.Cbuf; import jake2.qcommon.xcommand_t; + import jake2.sys.JOGLKBD; import jake2.sys.KBD; *************** *** 228,236 **** // D I F F E R E N T J A K E 2 E V E N T P R O C E S S I N G ! window.addComponentListener(KBD.listener); ! canvas.addKeyListener(KBD.listener); ! canvas.addMouseListener(KBD.listener); ! canvas.addMouseMotionListener(KBD.listener); ! canvas.addMouseWheelListener(KBD.listener); if (fullscreen) { --- 229,237 ---- // D I F F E R E N T J A K E 2 E V E N T P R O C E S S I N G ! window.addComponentListener(JOGLKBD.listener); ! canvas.addKeyListener(JOGLKBD.listener); ! canvas.addMouseListener(JOGLKBD.listener); ! canvas.addMouseMotionListener(JOGLKBD.listener); ! canvas.addMouseWheelListener(JOGLKBD.listener); if (fullscreen) { |
From: Holger Z. <hz...@us...> - 2004-12-14 00:11:19
|
Update of /cvsroot/jake2/jake2/src/jake2/client In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5406/src/jake2/client Modified Files: refexport_t.java VID.java Log Message: merge LWJGL input system changes Index: VID.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/client/VID.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** VID.java 23 Aug 2004 20:49:12 -0000 1.9 --- VID.java 14 Dec 2004 00:11:10 -0000 1.10 *************** *** 34,38 **** import jake2.sound.S; import jake2.sys.IN; - import jake2.sys.KBD; import jake2.util.Vargs; --- 34,37 ---- *************** *** 156,160 **** { if (Globals.re != null) { ! KBD.Close(); IN.Shutdown(); } --- 155,159 ---- { if (Globals.re != null) { ! Globals.re.getKeyboardHandler().Close(); IN.Shutdown(); } *************** *** 174,178 **** if ( reflib_active ) { ! KBD.Close(); IN.Shutdown(); --- 173,177 ---- if ( reflib_active ) { ! Globals.re.getKeyboardHandler().Close(); IN.Shutdown(); *************** *** 222,226 **** /* Init KBD */ ! KBD.Init(); Com.Printf( "------------------------------------\n"); --- 221,225 ---- /* Init KBD */ ! Globals.re.getKeyboardHandler().Init(); Com.Printf( "------------------------------------\n"); *************** *** 330,334 **** if ( reflib_active ) { ! KBD.Close(); IN.Shutdown(); --- 329,333 ---- if ( reflib_active ) { ! Globals.re.getKeyboardHandler().Close(); IN.Shutdown(); *************** *** 346,349 **** --- 345,349 ---- static final int REF_OPENGL_JOGL = 0; static final int REF_OPENGL_FASTJOGL =1; + static final int REF_OPENGL_LWJGL =2; static cvar_t gl_mode; *************** *** 532,535 **** --- 532,541 ---- vid_ref.modified = true; break; + case REF_OPENGL_LWJGL : + Cvar.Set( "vid_ref", "lwjgl" ); + Cvar.Set( "gl_driver", "lwjgl" ); + if (gl_driver.modified) + vid_ref.modified = true; + break; } *************** *** 566,569 **** --- 572,576 ---- "[OpenGL jogl ]", "[OpenGL fastjogl]", + "[OpenGL lwjgl]", null }; *************** *** 659,662 **** --- 666,674 ---- s_ref_list[0].curvalue = s_ref_list[1].curvalue = REF_OPENGL_FASTJOGL; } + else if ( vid_ref.string.equalsIgnoreCase("lwjgl")) + { + s_current_menu_index = OPENGL_MENU; + s_ref_list[0].curvalue = s_ref_list[1].curvalue = REF_OPENGL_LWJGL; + } // else if (strcmp( vid_ref->string, "softx" ) == 0 ) // { Index: refexport_t.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/client/refexport_t.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** refexport_t.java 15 Jul 2004 14:37:35 -0000 1.2 --- refexport_t.java 14 Dec 2004 00:11:10 -0000 1.3 *************** *** 30,33 **** --- 30,34 ---- import jake2.render.image_t; import jake2.render.model_t; + import jake2.sys.KBD; import java.awt.Dimension; *************** *** 108,110 **** --- 109,113 ---- DisplayMode[] getModeList(); + + KBD getKeyboardHandler(); } |
Update of /cvsroot/jake2/jake2/src/jake2/sys In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1434/src/jake2/sys Modified Files: Tag: LWJGL_IMPORT Sys.java IN.java InputListener.java KBD.java Added Files: Tag: LWJGL_IMPORT LWJGLKBD.java JOGLKBD.java Log Message: import of LWJGL code Index: InputListener.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/sys/InputListener.java,v retrieving revision 1.1.1.1.2.1 retrieving revision 1.1.1.1.2.1.2.1 diff -C2 -d -r1.1.1.1.2.1 -r1.1.1.1.2.1.2.1 *** InputListener.java 6 Sep 2004 19:39:20 -0000 1.1.1.1.2.1 --- InputListener.java 13 Dec 2004 21:40:43 -0000 1.1.1.1.2.1.2.1 *************** *** 99,103 **** public void componentShown(ComponentEvent e) { ! IN.c = e.getComponent(); addEvent(new Jake2InputEvent(Jake2InputEvent.CreateNotify, e)); } --- 99,103 ---- public void componentShown(ComponentEvent e) { ! JOGLKBD.c = e.getComponent(); addEvent(new Jake2InputEvent(Jake2InputEvent.CreateNotify, e)); } --- NEW FILE: LWJGLKBD.java --- package jake2.sys; import jake2.Defines; import jake2.client.Key; import jake2.qcommon.Cbuf; import org.lwjgl.input.Keyboard; import org.lwjgl.input.Mouse; import org.lwjgl.opengl.Display; /** * @author dsanders */ public class LWJGLKBD extends KBD { static private int win_w2; static private int win_h2; public void Init() { try { if (!Keyboard.isCreated()) Keyboard.create(); if (!Mouse.isCreated()) Mouse.create(); if (!Keyboard.isBuffered()) Keyboard.enableBuffer(); if (!Mouse.isBuffered()) Mouse.enableBuffer(); win_w2=Display.getDisplayMode().getWidth()/2; win_h2=Display.getDisplayMode().getHeight()/2; } catch (Exception e) {;} } public void Update() { // get events HandleEvents(); } public void Close() { Keyboard.destroy(); Mouse.destroy(); } private void HandleEvents() { if (Display.isCloseRequested()) { Cbuf.ExecuteText(Defines.EXEC_APPEND, "quit"); } for (int i=0; i<Keyboard.getNumKeyboardEvents(); i++) { Keyboard.next(); int key=Keyboard.getEventKey(); char ch=Keyboard.getEventCharacter(); Do_Key_Event(XLateKey(key,ch),Keyboard.getEventKeyState()); } if (IN.mouse_active) { mx=(Mouse.getX()-win_w2)*2; my=(Mouse.getY()-win_h2)*2; } else { mx=0; my=0; } while (Mouse.next()) { int button=Mouse.getEventButton(); if (button>=0) { Do_Key_Event(Key.K_MOUSE1 + button, Mouse.getEventButtonState()); } } } private static int XLateKey(int code, int ch) { int key = 0; switch(code) { // 00626 case XK_KP_Page_Up: key = K_KP_PGUP; break; case Keyboard.KEY_PRIOR: key = Key.K_PGUP; break; // 00629 case XK_KP_Page_Down: key = K_KP_PGDN; break; case Keyboard.KEY_NEXT: key = Key.K_PGDN; break; // 00632 case XK_KP_Home: key = K_KP_HOME; break; case Keyboard.KEY_HOME: key = Key.K_HOME; break; // 00635 case XK_KP_End: key = K_KP_END; break; case Keyboard.KEY_END: key = Key.K_END; break; // case Keyboard.KEY_LEFT: key = Key.K_KP_LEFTARROW; break; case Keyboard.KEY_LEFT: key = Key.K_LEFTARROW; break; // case Keyboard.KEY_RIGHT: key = Key.K_KP_RIGHTARROW; break; case Keyboard.KEY_RIGHT: key = Key.K_RIGHTARROW; break; // case Keyboard.KEY_DOWN: key = Key.K_KP_DOWNARROW; break; case Keyboard.KEY_DOWN: key = Key.K_DOWNARROW; break; // case Keyboard.KEY_UP: key = Key.K_KP_UPARROW; break; case Keyboard.KEY_UP: key = Key.K_UPARROW; break; case Keyboard.KEY_ESCAPE: key = Key.K_ESCAPE; break; case Keyboard.KEY_RETURN: key = Key.K_ENTER; break; // 00652 case XK_KP_Enter: key = K_KP_ENTER; break; case Keyboard.KEY_TAB: key = Key.K_TAB; break; case Keyboard.KEY_F1: key = Key.K_F1; break; case Keyboard.KEY_F2: key = Key.K_F2; break; case Keyboard.KEY_F3: key = Key.K_F3; break; case Keyboard.KEY_F4: key = Key.K_F4; break; case Keyboard.KEY_F5: key = Key.K_F5; break; case Keyboard.KEY_F6: key = Key.K_F6; break; case Keyboard.KEY_F7: key = Key.K_F7; break; case Keyboard.KEY_F8: key = Key.K_F8; break; case Keyboard.KEY_F9: key = Key.K_F9; break; case Keyboard.KEY_F10: key = Key.K_F10; break; case Keyboard.KEY_F11: key = Key.K_F11; break; case Keyboard.KEY_F12: key = Key.K_F12; break; case Keyboard.KEY_BACK: key = Key.K_BACKSPACE; break; case Keyboard.KEY_DELETE: key = Key.K_DEL; break; // 00683 case XK_KP_Delete: key = K_KP_DEL; break; case Keyboard.KEY_PAUSE: key = Key.K_PAUSE; break; case Keyboard.KEY_RSHIFT: case Keyboard.KEY_LSHIFT: key = Key.K_SHIFT; break; case Keyboard.KEY_RCONTROL: case Keyboard.KEY_LCONTROL: key = Key.K_CTRL; break; case Keyboard.KEY_LMENU: case Keyboard.KEY_RMENU: key = Key.K_ALT; break; // 00700 case XK_KP_Begin: key = K_KP_5; break; // 00701 case Keyboard.KEY_INSERT: key = Key.K_INS; break; default: key = ch; if (key >= 'A' && key <= 'Z') key = key - 'A' + 'a'; break; } if (key > 255) key = 0; return key; } public void Do_Key_Event(int key, boolean down) { Key.Event(key, down, Sys.Milliseconds()); } public void centerMouse() { Mouse.setPosition(win_x + win_w2,win_y + win_h2); //Mouse.setGrabbed(true); //Mouse.setTrackingEnabled(true); } public void installGrabs() { Mouse.setGrabbed(true); } public void uninstallGrabs() { Mouse.setGrabbed(false); } } Index: KBD.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/sys/KBD.java,v retrieving revision 1.1.1.1 retrieving revision 1.1.1.1.8.1 diff -C2 -d -r1.1.1.1 -r1.1.1.1.8.1 *** KBD.java 7 Jul 2004 19:59:51 -0000 1.1.1.1 --- KBD.java 13 Dec 2004 21:40:43 -0000 1.1.1.1.8.1 *************** *** 26,43 **** package jake2.sys; - import jake2.client.Key; - - import java.awt.*; - import java.awt.event.*; /** * KBD */ ! public final class KBD { static int win_x = 0; static int win_y = 0; - static int win_w2 = 0; - static int win_h2 = 0; // motion values --- 26,37 ---- package jake2.sys; /** * KBD */ ! abstract public class KBD { static int win_x = 0; static int win_y = 0; // motion values *************** *** 45,219 **** public static int my = 0; ! static Robot robot; ! public static InputListener listener = new InputListener(); ! ! static { ! try { ! robot = new Robot(); ! } catch (AWTException e) { ! System.exit(1); ! } ! } ! ! public static void Init() { ! } ! ! public static void Update() { ! // get events ! HandleEvents(); ! } ! ! public static void Close() { ! } ! ! static void HandleEvents() { ! int b; ! ! Jake2InputEvent event; ! while ( (event=InputListener.nextEvent()) != null ) { ! switch(event.type) { ! case Jake2InputEvent.KeyPress: ! case Jake2InputEvent.KeyRelease: ! Do_Key_Event(XLateKey((KeyEvent)event.ev), event.type == Jake2InputEvent.KeyPress); ! break; ! ! case Jake2InputEvent.MotionNotify: ! // if (IN.ignorefirst) { ! // IN.ignorefirst = false; ! // break; ! // } ! if (IN.mouse_active) { ! mx = (((MouseEvent)event.ev).getX() - win_w2) * 2; ! my = (((MouseEvent)event.ev).getY() - win_h2) * 2; ! } else { ! mx = 0; ! my = 0; ! } ! break; ! ! case Jake2InputEvent.ButtonPress: ! b=((MouseEvent)event.ev).getButton()-1; ! Do_Key_Event(Key.K_MOUSE1 + b, true); ! break; ! ! case Jake2InputEvent.ButtonRelease: ! b=((MouseEvent)event.ev).getButton()-1; ! Do_Key_Event(Key.K_MOUSE1 + b, false); ! break; ! ! case Jake2InputEvent.CreateNotify : ! case Jake2InputEvent.ConfigureNotify : ! Component c = ((ComponentEvent)event.ev).getComponent(); ! win_x = 0; ! win_y = 0; ! win_w2 = c.getWidth() / 2; ! win_h2 = c.getHeight() / 2; ! while (c != null) { ! if (c instanceof Container) { ! Insets insets = ((Container)c).getInsets(); ! win_x += insets.left; ! win_y += insets.top; ! } ! win_x += c.getX(); ! win_y += c.getY(); ! c = c.getParent(); ! } ! break; ! } ! } ! ! if (mx != 0 || my != 0) { ! // move the mouse to the window center again ! robot.mouseMove(win_x + win_w2, win_y + win_h2); ! } ! } ! ! private static int XLateKey(KeyEvent ev) { ! ! int key = 0; ! int code = ev.getKeyCode(); ! ! switch(code) { ! // 00626 case XK_KP_Page_Up: key = K_KP_PGUP; break; ! case KeyEvent.VK_PAGE_UP: key = Key.K_PGUP; break; ! ! // 00629 case XK_KP_Page_Down: key = K_KP_PGDN; break; ! case KeyEvent.VK_PAGE_DOWN: key = Key.K_PGDN; break; ! ! // 00632 case XK_KP_Home: key = K_KP_HOME; break; ! case KeyEvent.VK_HOME: key = Key.K_HOME; break; ! ! // 00635 case XK_KP_End: key = K_KP_END; break; ! case KeyEvent.VK_END: key = Key.K_END; break; ! ! case KeyEvent.VK_KP_LEFT: key = Key.K_KP_LEFTARROW; break; ! case KeyEvent.VK_LEFT: key = Key.K_LEFTARROW; break; ! ! case KeyEvent.VK_KP_RIGHT: key = Key.K_KP_RIGHTARROW; break; ! case KeyEvent.VK_RIGHT: key = Key.K_RIGHTARROW; break; ! ! case KeyEvent.VK_KP_DOWN: key = Key.K_KP_DOWNARROW; break; ! case KeyEvent.VK_DOWN: key = Key.K_DOWNARROW; break; ! ! case KeyEvent.VK_KP_UP: key = Key.K_KP_UPARROW; break; ! case KeyEvent.VK_UP: key = Key.K_UPARROW; break; ! ! case KeyEvent.VK_ESCAPE: key = Key.K_ESCAPE; break; ! ! ! case KeyEvent.VK_ENTER: key = Key.K_ENTER; break; ! // 00652 case XK_KP_Enter: key = K_KP_ENTER; break; ! ! case KeyEvent.VK_TAB: key = Key.K_TAB; break; ! ! case KeyEvent.VK_F1: key = Key.K_F1; break; ! case KeyEvent.VK_F2: key = Key.K_F2; break; ! case KeyEvent.VK_F3: key = Key.K_F3; break; ! case KeyEvent.VK_F4: key = Key.K_F4; break; ! case KeyEvent.VK_F5: key = Key.K_F5; break; ! case KeyEvent.VK_F6: key = Key.K_F6; break; ! case KeyEvent.VK_F7: key = Key.K_F7; break; ! case KeyEvent.VK_F8: key = Key.K_F8; break; ! case KeyEvent.VK_F9: key = Key.K_F9; break; ! case KeyEvent.VK_F10: key = Key.K_F10; break; ! case KeyEvent.VK_F11: key = Key.K_F11; break; ! case KeyEvent.VK_F12: key = Key.K_F12; break; ! ! case KeyEvent.VK_BACK_SPACE: key = Key.K_BACKSPACE; break; ! case KeyEvent.VK_DELETE: key = Key.K_DEL; break; ! // 00683 case XK_KP_Delete: key = K_KP_DEL; break; ! case KeyEvent.VK_PAUSE: key = Key.K_PAUSE; break; ! ! case KeyEvent.VK_SHIFT: key = Key.K_SHIFT; break; ! case KeyEvent.VK_CONTROL: key = Key.K_CTRL; break; ! ! case KeyEvent.VK_ALT: ! case KeyEvent.VK_ALT_GRAPH: key = Key.K_ALT; break; ! ! // 00700 case XK_KP_Begin: key = K_KP_5; break; ! // 00701 ! case KeyEvent.VK_INSERT: key = Key.K_INS; break; ! ! default: ! key = ev.getKeyChar(); ! if (key >= 'A' && key <= 'Z') ! key = key - 'A' + 'a'; ! break; ! } ! if (key > 255) key = 0; ! return key; ! } ! ! static void Do_Key_Event(int key, boolean down) { ! Key.Event(key, down, Sys.Milliseconds()); ! } ! ! static void centerMouse() { ! robot.mouseMove(win_x + win_w2, win_y + win_h2); ! } ! } --- 39,52 ---- public static int my = 0; ! abstract public void Init(); ! abstract public void Update(); ! abstract public void Close(); ! abstract public void Do_Key_Event(int key, boolean down); ! abstract public void installGrabs(); ! abstract public void uninstallGrabs(); ! abstract public void centerMouse(); } --- NEW FILE: JOGLKBD.java --- package jake2.sys; import jake2.client.Key; import java.awt.AWTException; import java.awt.Component; import java.awt.Container; import java.awt.Cursor; import java.awt.Insets; import java.awt.Point; import java.awt.Robot; import java.awt.event.ComponentEvent; import java.awt.event.KeyEvent; import java.awt.event.MouseEvent; import javax.swing.ImageIcon; final public class JOGLKBD extends KBD { static Robot robot; public static InputListener listener = new InputListener(); static Cursor emptyCursor = null; static Component c = null; static int win_w2 = 0; static int win_h2 = 0; static { try { robot = new Robot(); } catch (AWTException e) { System.exit(1); } } public void Init() { } public void Update() { // get events HandleEvents(); } public void Close() { } private void HandleEvents() { int b; Jake2InputEvent event; while ( (event=InputListener.nextEvent()) != null ) { switch(event.type) { case Jake2InputEvent.KeyPress: case Jake2InputEvent.KeyRelease: Do_Key_Event(XLateKey((KeyEvent)event.ev), event.type == Jake2InputEvent.KeyPress); break; case Jake2InputEvent.MotionNotify: // if (IN.ignorefirst) { // IN.ignorefirst = false; // break; // } if (IN.mouse_active) { mx = (((MouseEvent)event.ev).getX() - win_w2) * 2; my = (((MouseEvent)event.ev).getY() - win_h2) * 2; } else { mx = 0; my = 0; } break; case Jake2InputEvent.ButtonPress: b=((MouseEvent)event.ev).getButton()-1; Do_Key_Event(Key.K_MOUSE1 + b, true); break; case Jake2InputEvent.ButtonRelease: b=((MouseEvent)event.ev).getButton()-1; Do_Key_Event(Key.K_MOUSE1 + b, false); break; case Jake2InputEvent.CreateNotify : case Jake2InputEvent.ConfigureNotify : Component c = ((ComponentEvent)event.ev).getComponent(); win_x = 0; win_y = 0; win_w2 = c.getWidth() / 2; win_h2 = c.getHeight() / 2; while (c != null) { if (c instanceof Container) { Insets insets = ((Container)c).getInsets(); win_x += insets.left; win_y += insets.top; } win_x += c.getX(); win_y += c.getY(); c = c.getParent(); } break; } } if (mx != 0 || my != 0) { // move the mouse to the window center again robot.mouseMove(win_x + win_w2, win_y + win_h2); } } private static int XLateKey(KeyEvent ev) { int key = 0; int code = ev.getKeyCode(); switch(code) { // 00626 case XK_KP_Page_Up: key = K_KP_PGUP; break; case KeyEvent.VK_PAGE_UP: key = Key.K_PGUP; break; // 00629 case XK_KP_Page_Down: key = K_KP_PGDN; break; case KeyEvent.VK_PAGE_DOWN: key = Key.K_PGDN; break; // 00632 case XK_KP_Home: key = K_KP_HOME; break; case KeyEvent.VK_HOME: key = Key.K_HOME; break; // 00635 case XK_KP_End: key = K_KP_END; break; case KeyEvent.VK_END: key = Key.K_END; break; case KeyEvent.VK_KP_LEFT: key = Key.K_KP_LEFTARROW; break; case KeyEvent.VK_LEFT: key = Key.K_LEFTARROW; break; case KeyEvent.VK_KP_RIGHT: key = Key.K_KP_RIGHTARROW; break; case KeyEvent.VK_RIGHT: key = Key.K_RIGHTARROW; break; case KeyEvent.VK_KP_DOWN: key = Key.K_KP_DOWNARROW; break; case KeyEvent.VK_DOWN: key = Key.K_DOWNARROW; break; case KeyEvent.VK_KP_UP: key = Key.K_KP_UPARROW; break; case KeyEvent.VK_UP: key = Key.K_UPARROW; break; case KeyEvent.VK_ESCAPE: key = Key.K_ESCAPE; break; case KeyEvent.VK_ENTER: key = Key.K_ENTER; break; // 00652 case XK_KP_Enter: key = K_KP_ENTER; break; case KeyEvent.VK_TAB: key = Key.K_TAB; break; case KeyEvent.VK_F1: key = Key.K_F1; break; case KeyEvent.VK_F2: key = Key.K_F2; break; case KeyEvent.VK_F3: key = Key.K_F3; break; case KeyEvent.VK_F4: key = Key.K_F4; break; case KeyEvent.VK_F5: key = Key.K_F5; break; case KeyEvent.VK_F6: key = Key.K_F6; break; case KeyEvent.VK_F7: key = Key.K_F7; break; case KeyEvent.VK_F8: key = Key.K_F8; break; case KeyEvent.VK_F9: key = Key.K_F9; break; case KeyEvent.VK_F10: key = Key.K_F10; break; case KeyEvent.VK_F11: key = Key.K_F11; break; case KeyEvent.VK_F12: key = Key.K_F12; break; case KeyEvent.VK_BACK_SPACE: key = Key.K_BACKSPACE; break; case KeyEvent.VK_DELETE: key = Key.K_DEL; break; // 00683 case XK_KP_Delete: key = K_KP_DEL; break; case KeyEvent.VK_PAUSE: key = Key.K_PAUSE; break; case KeyEvent.VK_SHIFT: key = Key.K_SHIFT; break; case KeyEvent.VK_CONTROL: key = Key.K_CTRL; break; case KeyEvent.VK_ALT: case KeyEvent.VK_ALT_GRAPH: key = Key.K_ALT; break; // 00700 case XK_KP_Begin: key = K_KP_5; break; // 00701 case KeyEvent.VK_INSERT: key = Key.K_INS; break; default: key = ev.getKeyChar(); if (key >= 'A' && key <= 'Z') key = key - 'A' + 'a'; break; } if (key > 255) key = 0; return key; } public void Do_Key_Event(int key, boolean down) { Key.Event(key, down, Sys.Milliseconds()); } public void centerMouse() { robot.mouseMove(win_x + win_w2, win_y + win_h2); } public void installGrabs() { if (emptyCursor == null) { ImageIcon emptyIcon = new ImageIcon(new byte[0]); emptyCursor = c.getToolkit().createCustomCursor(emptyIcon.getImage(), new Point(0, 0), "emptyCursor"); } c.setCursor(emptyCursor); } public void uninstallGrabs() { c.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); } } Index: IN.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/sys/IN.java,v retrieving revision 1.2.2.2 retrieving revision 1.2.2.2.2.1 diff -C2 -d -r1.2.2.2 -r1.2.2.2.2.1 *** IN.java 8 Sep 2004 09:45:47 -0000 1.2.2.2 --- IN.java 13 Dec 2004 21:40:43 -0000 1.2.2.2.2.1 *************** *** 34,41 **** import jake2.qcommon.xcommand_t; - import java.awt.*; - - import javax.swing.ImageIcon; - /** * IN --- 34,37 ---- *************** *** 43,48 **** public final class IN extends Globals { ! static Component c = null; ! static Cursor emptyCursor = null; static boolean mouse_avail = true; --- 39,43 ---- public final class IN extends Globals { ! //static Component c = null; static boolean mouse_avail = true; *************** *** 59,63 **** public static void ActivateMouse() { ! if (!mouse_avail || c == null) return; if (!mouse_active) { KBD.mx = KBD.my = 0; // don't spazz --- 54,58 ---- public static void ActivateMouse() { ! if (!mouse_avail) return; // || c == null) return; if (!mouse_active) { KBD.mx = KBD.my = 0; // don't spazz *************** *** 76,85 **** private static void install_grabs() { ! if (emptyCursor == null) { ! ImageIcon emptyIcon = new ImageIcon(new byte[0]); ! emptyCursor = c.getToolkit().createCustomCursor(emptyIcon.getImage(), new Point(0, 0), "emptyCursor"); ! } ! c.setCursor(emptyCursor); ! KBD.centerMouse(); ignorefirst = true; --- 71,77 ---- private static void install_grabs() { ! ! Globals.re.getKeyboardHandler().installGrabs(); ! Globals.re.getKeyboardHandler().centerMouse(); ignorefirst = true; *************** *** 87,91 **** private static void uninstall_grabs() { ! c.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); } --- 79,83 ---- private static void uninstall_grabs() { ! Globals.re.getKeyboardHandler().uninstallGrabs(); } *************** *** 141,150 **** return; for (i=0 ; i<3 ; i++) { if ( (IN.mouse_buttonstate & (1<<i)) != 0 && (IN.mouse_oldbuttonstate & (1<<i)) == 0 ) ! KBD.Do_Key_Event(Key.K_MOUSE1 + i, true); if ( (IN.mouse_buttonstate & (1<<i)) == 0 && (IN.mouse_oldbuttonstate & (1<<i)) != 0 ) ! KBD.Do_Key_Event(Key.K_MOUSE1 + i, false); } IN.mouse_oldbuttonstate = IN.mouse_buttonstate; --- 133,143 ---- return; + KBD kbd=Globals.re.getKeyboardHandler(); for (i=0 ; i<3 ; i++) { if ( (IN.mouse_buttonstate & (1<<i)) != 0 && (IN.mouse_oldbuttonstate & (1<<i)) == 0 ) ! kbd.Do_Key_Event(Key.K_MOUSE1 + i, true); if ( (IN.mouse_buttonstate & (1<<i)) == 0 && (IN.mouse_oldbuttonstate & (1<<i)) != 0 ) ! kbd.Do_Key_Event(Key.K_MOUSE1 + i, false); } IN.mouse_oldbuttonstate = IN.mouse_buttonstate; *************** *** 166,170 **** if (!IN.mouse_avail) return; ! if (Globals.m_filter.value != 0.0f) { KBD.mx = (KBD.mx + IN.old_mouse_x) / 2; --- 159,164 ---- if (!IN.mouse_avail) return; ! ! KBD kbd=Globals.re.getKeyboardHandler(); if (Globals.m_filter.value != 0.0f) { KBD.mx = (KBD.mx + IN.old_mouse_x) / 2; Index: Sys.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/sys/Sys.java,v retrieving revision 1.3.2.2 retrieving revision 1.3.2.2.2.1 diff -C2 -d -r1.3.2.2 -r1.3.2.2.2.1 *** Sys.java 6 Sep 2004 19:39:20 -0000 1.3.2.2 --- Sys.java 13 Dec 2004 21:40:43 -0000 1.3.2.2.2.1 *************** *** 228,232 **** public static void SendKeyEvents() { ! KBD.Update(); // grab frame time --- 228,232 ---- public static void SendKeyEvents() { ! Globals.re.getKeyboardHandler().Update(); // grab frame time |
From: Holger Z. <hz...@us...> - 2004-12-13 21:41:27
|
Update of /cvsroot/jake2/jake2/src/jake2/render In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1434/src/jake2/render Modified Files: Tag: LWJGL_IMPORT Renderer.java JoglBase.java JoglRenderer.java FastJoglRenderer.java Added Files: Tag: LWJGL_IMPORT LWJGLRenderer.java LWJGLBase.java Log Message: import of LWJGL code Index: JoglRenderer.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/render/JoglRenderer.java,v retrieving revision 1.2.2.2 retrieving revision 1.2.2.2.2.1 diff -C2 -d -r1.2.2.2 -r1.2.2.2.2.1 *** JoglRenderer.java 6 Sep 2004 19:39:14 -0000 1.2.2.2 --- JoglRenderer.java 13 Dec 2004 21:40:43 -0000 1.2.2.2.2.1 *************** *** 27,33 **** import jake2.Defines; ! import jake2.client.*; import jake2.qcommon.xcommand_t; import jake2.render.jogl.Misc; import java.awt.Dimension; --- 27,36 ---- import jake2.Defines; ! import jake2.client.refdef_t; ! import jake2.client.refexport_t; import jake2.qcommon.xcommand_t; import jake2.render.jogl.Misc; + import jake2.sys.JOGLKBD; + import jake2.sys.KBD; import java.awt.Dimension; *************** *** 40,43 **** --- 43,48 ---- final class JoglRenderer extends Misc implements refexport_t, Ref { + private JOGLKBD kbd=new JOGLKBD(); + public static final String DRIVER_NAME = "jogl"; *************** *** 302,304 **** --- 307,314 ---- return this; } + + public KBD getKeyboardHandler() + { + return kbd; + } } \ No newline at end of file --- NEW FILE: LWJGLBase.java --- /* * LWJGLCommon.java * Copyright (C) 2004 * * $Id: LWJGLBase.java,v 1.1.2.1 2004/12/13 21:40:43 hzi Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ package jake2.render; import jake2.Defines; import jake2.client.VID; import jake2.client.viddef_t; import jake2.game.cvar_t; import jake2.qcommon.xcommand_t; import java.awt.Dimension; import java.util.LinkedList; import org.lwjgl.LWJGLException; import org.lwjgl.opengl.Display; import org.lwjgl.opengl.DisplayMode; import org.lwjgl.opengl.GL11; import org.lwjgl.util.GLImpl; public abstract class LWJGLBase { // IMPORTED FUNCTIONS protected DisplayMode oldDisplayMode; protected GLImpl gl=new GLImpl(); // window position on the screen int window_xpos, window_ypos; protected viddef_t vid = new viddef_t(); // handles the post initialization with JoglRenderer protected boolean post_init = false; protected boolean contextInUse = false; protected abstract boolean R_Init2(); protected final xcommand_t INIT_CALLBACK = new xcommand_t() { public void execute() { // only used for the first run (initialization) // clear the screen gl.glClearColor(0, 0, 0, 0); gl.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); // // check the post init process // if (!post_init) { VID.Printf(Defines.PRINT_ALL, "Missing multi-texturing for FastJOGL renderer\n"); } GLimp_EndFrame(); } }; protected xcommand_t callback = INIT_CALLBACK; protected cvar_t vid_fullscreen; // enum rserr_t protected static final int rserr_ok = 0; protected static final int rserr_invalid_fullscreen = 1; protected static final int rserr_invalid_mode = 2; protected static final int rserr_unknown = 3; private java.awt.DisplayMode toAwtDisplayMode(DisplayMode m) { return new java.awt.DisplayMode(m.getWidth(),m.getHeight(),m.getBitsPerPixel(),m.getFrequency()); } public java.awt.DisplayMode[] getModeList() { DisplayMode[] modes = Display.getAvailableDisplayModes(); LinkedList l = new LinkedList(); l.add(toAwtDisplayMode(oldDisplayMode)); for (int i = 0; i < modes.length; i++) { DisplayMode m = modes[i]; if (m.getBitsPerPixel() != oldDisplayMode.getBitsPerPixel()) continue; if (m.getFrequency() > oldDisplayMode.getFrequency()) continue; if (m.getHeight() < 240 || m.getWidth() < 320) continue; int j = 0; java.awt.DisplayMode ml = null; for (j = 0; j < l.size(); j++) { ml = (java.awt.DisplayMode)l.get(j); if (ml.getWidth() > m.getWidth()) break; if (ml.getWidth() == m.getWidth() && ml.getHeight() >= m.getHeight()) break; } if (j == l.size()) { l.addLast(toAwtDisplayMode(m)); } else if (ml.getWidth() > m.getWidth() || ml.getHeight() > m.getHeight()) { l.add(j, toAwtDisplayMode(m)); } else if (m.getFrequency() > ml.getRefreshRate()){ l.remove(j); l.add(j, toAwtDisplayMode(m)); } } java.awt.DisplayMode[] ma = new java.awt.DisplayMode[l.size()]; l.toArray(ma); return ma; } public DisplayMode[] getLWJGLModeList() { DisplayMode[] modes = Display.getAvailableDisplayModes(); LinkedList l = new LinkedList(); l.add(oldDisplayMode); for (int i = 0; i < modes.length; i++) { DisplayMode m = modes[i]; if (m.getBitsPerPixel() != oldDisplayMode.getBitsPerPixel()) continue; if (m.getFrequency() > oldDisplayMode.getFrequency()) continue; if (m.getHeight() < 240 || m.getWidth() < 320) continue; int j = 0; DisplayMode ml = null; for (j = 0; j < l.size(); j++) { ml = (DisplayMode)l.get(j); if (ml.getWidth() > m.getWidth()) break; if (ml.getWidth() == m.getWidth() && ml.getHeight() >= m.getHeight()) break; } if (j == l.size()) { l.addLast(m); } else if (ml.getWidth() > m.getWidth() || ml.getHeight() > m.getHeight()) { l.add(j, m); } else if (m.getFrequency() > ml.getFrequency()){ l.remove(j); l.add(j, m); } } DisplayMode[] ma = new DisplayMode[l.size()]; l.toArray(ma); return ma; } private DisplayMode findDisplayMode(Dimension dim) { DisplayMode mode = null; DisplayMode m = null; DisplayMode[] modes = getLWJGLModeList(); int w = dim.width; int h = dim.height; for (int i = 0; i < modes.length; i++) { m = modes[i]; if (m.getWidth() == w && m.getHeight() == h) { mode = m; break; } } if (mode == null) mode = oldDisplayMode; return mode; } String getModeString(DisplayMode m) { StringBuffer sb = new StringBuffer(); sb.append(m.getWidth()); sb.append('x'); sb.append(m.getHeight()); sb.append('x'); sb.append(m.getBitsPerPixel()); sb.append('@'); sb.append(m.getFrequency()); sb.append("Hz"); return sb.toString(); } /** * @param dim * @param mode * @param fullscreen * @return enum rserr_t */ protected int GLimp_SetMode(Dimension dim, int mode, boolean fullscreen) { Dimension newDim = new Dimension(); VID.Printf(Defines.PRINT_ALL, "Initializing OpenGL display\n"); VID.Printf(Defines.PRINT_ALL, "...setting mode " + mode + ":"); /* * fullscreen handling */ if (oldDisplayMode == null) { oldDisplayMode = Display.getDisplayMode(); } if (!VID.GetModeInfo(newDim, mode)) { VID.Printf(Defines.PRINT_ALL, " invalid mode\n"); return rserr_invalid_mode; } VID.Printf(Defines.PRINT_ALL, " " + newDim.width + " " + newDim.height + '\n'); // destroy the existing window GLimp_Shutdown(); Display.setTitle("Jake2"); DisplayMode displayMode = findDisplayMode(newDim); newDim.width = displayMode.getWidth(); newDim.height = displayMode.getHeight(); if (fullscreen) { try { Display.setDisplayMode(displayMode); } catch (LWJGLException e) { return rserr_invalid_mode; } Display.setLocation(0,0); try { Display.setFullscreen(fullscreen); } catch (LWJGLException e) { return rserr_invalid_fullscreen; } VID.Printf(Defines.PRINT_ALL, "...setting fullscreen " + getModeString(displayMode) + '\n'); } else { try { Display.setDisplayMode(displayMode); } catch (LWJGLException e) { return rserr_invalid_mode; } try { Display.setFullscreen(false); } catch (LWJGLException e) { return rserr_invalid_fullscreen; } Display.setLocation(window_xpos, window_ypos); } vid.width = newDim.width; vid.height = newDim.height; try { Display.create(); } catch (LWJGLException e) { return rserr_unknown; } // let the sound and input subsystems know about the new window VID.NewWindow(vid.width, vid.height); post_init = R_Init2(); updateScreen(); return rserr_ok; } protected void GLimp_Shutdown() { if (oldDisplayMode != null && Display.isFullscreen()) { try { Display.setFullscreen(false); Display.setDisplayMode(oldDisplayMode); } catch (Exception e) { e.printStackTrace(); } } if (Display.isCreated()) Display.destroy(); post_init = false; callback = INIT_CALLBACK; } /** * @return true */ protected boolean GLimp_Init(int xpos, int ypos) { // do nothing window_xpos = xpos; window_ypos = ypos; return true; } protected void GLimp_EndFrame() { gl.glFlush(); // swap buffer // TODO this and a new JOGL-release solves the flickering bug (Loading) // canvas.swapBuffers(); } protected void GLimp_BeginFrame(float camera_separation) { // do nothing } protected void GLimp_AppActivate(boolean activate) { // do nothing } protected void GLimp_EnableLogging(boolean enable) { // doesn't need jogl logging // do nothing } protected void GLimp_LogNewFrame() { // doesn't need jogl logging // do nothing } /* * @see jake2.client.refexport_t#updateScreen() */ public void updateScreen() { this.callback = INIT_CALLBACK; contextInUse = true; callback.execute(); contextInUse = false; Display.update(); } public void updateScreen(xcommand_t callback) { this.callback = callback; contextInUse = true; callback.execute(); contextInUse = false; Display.update(); } } Index: FastJoglRenderer.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/render/FastJoglRenderer.java,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.2.2.1 diff -C2 -d -r1.1.2.2 -r1.1.2.2.2.1 *** FastJoglRenderer.java 6 Sep 2004 19:39:14 -0000 1.1.2.2 --- FastJoglRenderer.java 13 Dec 2004 21:40:43 -0000 1.1.2.2.2.1 *************** *** 27,33 **** import jake2.Defines; ! import jake2.client.*; import jake2.qcommon.xcommand_t; import jake2.render.fastjogl.Misc; import java.awt.Dimension; --- 27,36 ---- import jake2.Defines; ! import jake2.client.refdef_t; ! import jake2.client.refexport_t; import jake2.qcommon.xcommand_t; import jake2.render.fastjogl.Misc; + import jake2.sys.JOGLKBD; + import jake2.sys.KBD; import java.awt.Dimension; *************** *** 39,43 **** */ final class FastJoglRenderer extends Misc implements refexport_t, Ref { ! public static final String DRIVER_NAME = "fastjogl"; --- 42,47 ---- */ final class FastJoglRenderer extends Misc implements refexport_t, Ref { ! private JOGLKBD kbd=new JOGLKBD(); ! public static final String DRIVER_NAME = "fastjogl"; *************** *** 305,307 **** --- 309,315 ---- } + public KBD getKeyboardHandler() + { + return kbd; + } } \ No newline at end of file Index: Renderer.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/render/Renderer.java,v retrieving revision 1.1.1.1.2.3 retrieving revision 1.1.1.1.2.3.2.1 diff -C2 -d -r1.1.1.1.2.3 -r1.1.1.1.2.3.2.1 *** Renderer.java 6 Sep 2004 19:39:14 -0000 1.1.1.1.2.3 --- Renderer.java 13 Dec 2004 21:40:43 -0000 1.1.1.1.2.3.2.1 *************** *** 26,33 **** package jake2.render; - import java.util.Vector; - import jake2.client.refexport_t; /** * Renderer --- 26,33 ---- package jake2.render; import jake2.client.refexport_t; + import java.util.Vector; + /** * Renderer *************** *** 41,48 **** public static final String DEFAULT = JoglRenderer.DRIVER_NAME; ! private static final String DEFAULT_CLASS = "jake2.render.JoglRenderer"; static { try { Class.forName("jake2.render.JoglRenderer"); Class.forName("jake2.render.FastJoglRenderer"); --- 41,50 ---- public static final String DEFAULT = JoglRenderer.DRIVER_NAME; ! // private static final String DEFAULT_CLASS = "jake2.render.JoglRenderer"; ! private static final String DEFAULT_CLASS = "jake2.render.LWJGLRenderer"; static { try { + Class.forName("jake2.render.LWJGLRenderer"); Class.forName("jake2.render.JoglRenderer"); Class.forName("jake2.render.FastJoglRenderer"); *************** *** 78,82 **** return null; } ! public static String[] getDriverNames() { int count = drivers.size(); --- 80,84 ---- return null; } ! public static String[] getDriverNames() { int count = drivers.size(); --- NEW FILE: LWJGLRenderer.java --- /* * LWJGLRenderer.java * Copyright (C) 2004 * * $Id: LWJGLRenderer.java,v 1.1.2.1 2004/12/13 21:40:43 hzi Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ package jake2.render; import jake2.Defines; import jake2.client.refdef_t; import jake2.client.refexport_t; import jake2.qcommon.xcommand_t; import jake2.render.lwjgl.Misc; import jake2.sys.KBD; import jake2.sys.LWJGLKBD; import java.awt.Dimension; /** * LWJGLRenderer * * @author dsanders/cwei */ final class LWJGLRenderer extends Misc implements refexport_t, Ref { private LWJGLKBD kbd=new LWJGLKBD(); public static final String DRIVER_NAME = "lwjgl"; static { Renderer.register(new LWJGLRenderer()); }; private LWJGLRenderer() { } // ============================================================================ // public interface for Renderer implementations // // refexport_t (ref.h) // ============================================================================ /** * @see jake2.client.refexport_t#Init() */ public boolean Init(int vid_xpos, int vid_ypos) { // pre init if (!R_Init(vid_xpos, vid_ypos)) return false; // calls the R_Init2() internally updateScreen(); // the result from R_Init2() return post_init; } /** * @see jake2.client.refexport_t#Shutdown() */ public void Shutdown() { R_Shutdown(); } /** * @see jake2.client.refexport_t#BeginRegistration(java.lang.String) */ public void BeginRegistration(String map) { if (contextInUse) { R_BeginRegistration(map); return; } this.name = map; updateScreen(new xcommand_t() { public void execute() { R_BeginRegistration(LWJGLRenderer.this.name); } }); } private model_t model = null; private String name = null; /** * @see jake2.client.refexport_t#RegisterModel(java.lang.String) */ public model_t RegisterModel(String name) { if (contextInUse) return R_RegisterModel(name); model = null; this.name = name; updateScreen(new xcommand_t() { public void execute() { LWJGLRenderer.this.model = R_RegisterModel(LWJGLRenderer.this.name); } }); return model; } /** * @see jake2.client.refexport_t#RegisterSkin(java.lang.String) */ public image_t RegisterSkin(String name) { if (contextInUse) return R_RegisterSkin(name); this.image = null; this.name = name; updateScreen(new xcommand_t() { public void execute() { LWJGLRenderer.this.image = R_RegisterSkin(LWJGLRenderer.this.name); } }); return image; } private image_t image = null; /** * @see jake2.client.refexport_t#RegisterPic(java.lang.String) */ public image_t RegisterPic(String name) { if (contextInUse) return Draw_FindPic(name); this.image = null; this.name = name; updateScreen(new xcommand_t() { public void execute() { LWJGLRenderer.this.image = Draw_FindPic(LWJGLRenderer.this.name); } }); return image; } private float[] axis; private float rotate; /** * @see jake2.client.refexport_t#SetSky(java.lang.String, float, float[]) */ public void SetSky(String name, float rotate, float[] axis) { if (contextInUse) { R_SetSky(name, rotate, axis); return; } this.name = name; this.rotate = rotate; this.axis = axis; updateScreen(new xcommand_t() { public void execute() { R_SetSky(LWJGLRenderer.this.name, LWJGLRenderer.this.rotate, LWJGLRenderer.this.axis); } }); } /** * @see jake2.client.refexport_t#EndRegistration() */ public void EndRegistration() { if (contextInUse) { R_EndRegistration(); return; } updateScreen(new xcommand_t() { public void execute() { R_EndRegistration(); } }); } /** * @see jake2.client.refexport_t#RenderFrame(jake2.client.refdef_t) */ public void RenderFrame(refdef_t fd) { R_RenderFrame(fd); } /** * @see jake2.client.refexport_t#DrawGetPicSize(java.awt.Dimension, java.lang.String) */ public void DrawGetPicSize(Dimension dim, String name) { Draw_GetPicSize(dim, name); } /** * @see jake2.client.refexport_t#DrawPic(int, int, java.lang.String) */ public void DrawPic(int x, int y, String name) { Draw_Pic(x, y, name); } /** * @see jake2.client.refexport_t#DrawStretchPic(int, int, int, int, java.lang.String) */ public void DrawStretchPic(int x, int y, int w, int h, String name) { Draw_StretchPic(x, y, w, h, name); } /** * @see jake2.client.refexport_t#DrawChar(int, int, int) */ public void DrawChar(int x, int y, int num) { Draw_Char(x, y, num); } /** * @see jake2.client.refexport_t#DrawTileClear(int, int, int, int, java.lang.String) */ public void DrawTileClear(int x, int y, int w, int h, String name) { Draw_TileClear(x, y, w, h, name); } /** * @see jake2.client.refexport_t#DrawFill(int, int, int, int, int) */ public void DrawFill(int x, int y, int w, int h, int c) { Draw_Fill(x, y, w, h, c); } /** * @see jake2.client.refexport_t#DrawFadeScreen() */ public void DrawFadeScreen() { Draw_FadeScreen(); } /** * @see jake2.client.refexport_t#DrawStretchRaw(int, int, int, int, int, int, byte[]) */ public void DrawStretchRaw(int x, int y, int w, int h, int cols, int rows, byte[] data) { Draw_StretchRaw(x, y, w, h, cols, rows, data); } /** * @see jake2.client.refexport_t#CinematicSetPalette(byte[]) */ public void CinematicSetPalette(byte[] palette) { R_SetPalette(palette); } /** * @see jake2.client.refexport_t#BeginFrame(float) */ public void BeginFrame(float camera_separation) { R_BeginFrame(camera_separation); } /** * @see jake2.client.refexport_t#EndFrame() */ public void EndFrame() { GLimp_EndFrame(); } /** * @see jake2.client.refexport_t#AppActivate(boolean) */ public void AppActivate(boolean activate) { GLimp_AppActivate(activate); } public int apiVersion() { return Defines.API_VERSION; } // ============================================================================ // Ref interface // ============================================================================ public String getName() { return DRIVER_NAME; } public String toString() { return DRIVER_NAME; } public refexport_t GetRefAPI() { return this; } public KBD getKeyboardHandler() { return kbd; } } Index: JoglBase.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/render/JoglBase.java,v retrieving revision 1.7.2.1 retrieving revision 1.7.2.1.2.1 diff -C2 -d -r1.7.2.1 -r1.7.2.1.2.1 *** JoglBase.java 6 Sep 2004 19:39:14 -0000 1.7.2.1 --- JoglBase.java 13 Dec 2004 21:40:43 -0000 1.7.2.1.2.1 *************** *** 28,38 **** import jake2.Defines; ! import jake2.client.*; import jake2.game.cvar_t; import jake2.qcommon.Cbuf; import jake2.qcommon.xcommand_t; ! import jake2.sys.KBD; ! import java.awt.*; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; --- 28,42 ---- import jake2.Defines; ! import jake2.client.VID; ! import jake2.client.viddef_t; import jake2.game.cvar_t; import jake2.qcommon.Cbuf; import jake2.qcommon.xcommand_t; ! import jake2.sys.JOGLKBD; ! import java.awt.Dimension; ! import java.awt.DisplayMode; ! import java.awt.GraphicsDevice; ! import java.awt.GraphicsEnvironment; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; *************** *** 41,45 **** import javax.swing.JFrame; ! import net.java.games.jogl.*; import net.java.games.jogl.util.GLUT; --- 45,55 ---- import javax.swing.JFrame; ! import net.java.games.jogl.GL; ! import net.java.games.jogl.GLCanvas; ! import net.java.games.jogl.GLCapabilities; ! import net.java.games.jogl.GLDrawable; ! import net.java.games.jogl.GLDrawableFactory; ! import net.java.games.jogl.GLEventListener; ! import net.java.games.jogl.GLU; import net.java.games.jogl.util.GLUT; *************** *** 218,226 **** }); ! // D I F F E R E N T J A K E 2 E V E N T P R O C E S S I N G ! window.addComponentListener(KBD.listener); ! canvas.addKeyListener(KBD.listener); ! canvas.addMouseListener(KBD.listener); ! canvas.addMouseMotionListener(KBD.listener); if (fullscreen) { --- 228,236 ---- }); ! // D I F F E R E N T J A K E 2 E V E N T P R O C E S S I N G ! window.addComponentListener(JOGLKBD.listener); ! canvas.addKeyListener(JOGLKBD.listener); ! canvas.addMouseListener(JOGLKBD.listener); ! canvas.addMouseMotionListener(JOGLKBD.listener); if (fullscreen) { |
From: Holger Z. <hz...@us...> - 2004-12-13 21:41:26
|
Update of /cvsroot/jake2/jake2/src/jake2/render/jogl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1434/src/jake2/render/jogl Modified Files: Tag: LWJGL_IMPORT Main.java Log Message: import of LWJGL code Index: Main.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/render/jogl/Main.java,v retrieving revision 1.2.2.2 retrieving revision 1.2.2.2.2.1 diff -C2 -d -r1.2.2.2 -r1.2.2.2.2.1 *** Main.java 6 Sep 2004 19:39:16 -0000 1.2.2.2 --- Main.java 13 Dec 2004 21:40:44 -0000 1.2.2.2.2.1 *************** *** 486,490 **** FloatBuffer sourceVertices = particle_t.vertexArray; ! IntBuffer sourceColors = particle_t.colorArray; for (int j = 0, i = 0; i < num_particles; i++) { origin_x = sourceVertices.get(j++); --- 486,490 ---- FloatBuffer sourceVertices = particle_t.vertexArray; ! IntBuffer sourceColors = particle_t.colorArray.asIntBuffer(); for (int j = 0, i = 0; i < num_particles; i++) { origin_x = sourceVertices.get(j++); |
From: Holger Z. <hz...@us...> - 2004-12-13 21:41:00
|
Update of /cvsroot/jake2/jake2/src/jake2/sound In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1434/src/jake2/sound Modified Files: Tag: LWJGL_IMPORT S.java Log Message: import of LWJGL code Index: S.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/sound/S.java,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.1.2.1 diff -C2 -d -r1.1.2.1 -r1.1.2.1.2.1 *** S.java 9 Jul 2004 08:38:26 -0000 1.1.2.1 --- S.java 13 Dec 2004 21:40:46 -0000 1.1.2.1.2.1 *************** *** 46,49 **** --- 46,50 ---- try { Class.forName("jake2.sound.DummyDriver"); + Class.forName("jake2.sound.joal.LWJGLSoundImpl"); Class.forName("jake2.sound.joal.JOALSoundImpl"); Class.forName("jake2.sound.jsound.JSoundImpl"); *************** *** 87,91 **** } ! s_impl = Cvar.Get("s_impl", "joal", Defines.CVAR_ARCHIVE); useDriver(s_impl.string); --- 88,92 ---- } ! s_impl = Cvar.Get("s_impl", "lwjgl_joal", Defines.CVAR_ARCHIVE); useDriver(s_impl.string); |
From: Holger Z. <hz...@us...> - 2004-12-13 21:40:59
|
Update of /cvsroot/jake2/jake2/src/jake2/render/lwjgl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1434/src/jake2/render/lwjgl Added Files: Tag: LWJGL_IMPORT Light.java Image.java Warp.java Main.java Draw.java Model.java Surf.java Mesh.java Anorms.java Misc.java Base.java Log Message: import of LWJGL code --- NEW FILE: Image.java --- /* * Image.java * Copyright (C) 2003 * * $Id: Image.java,v 1.1.2.1 2004/12/13 21:40:44 hzi Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. [...1657 lines suppressed...] */ void GL_ShutdownImages() { image_t image; for (int i=0; i < numgltextures ; i++) { image = gltextures[i]; if (image.registration_sequence == 0) continue; // free image_t slot // free it // TODO jogl bug texnumBuffer.clear(); texnumBuffer.put(0,image.texnum); gl.glDeleteTextures(texnumBuffer); image.clear(); } } } --- NEW FILE: Surf.java --- /* * Surf.java * Copyright (C) 2003 * * $Id: Surf.java,v 1.1.2.1 2004/12/13 21:40:45 hzi Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. [...1442 lines suppressed...] // IntBuffer pix = ByteBuffer.wrap(buf).order(ByteOrder.LITTLE_ENDIAN).asIntBuffer(); // // int[] pixel = new int[w * h]; // // pix.get(pixel); // // BufferedImage image = new BufferedImage(w, h, BufferedImage.TYPE_4BYTE_ABGR); // image.setRGB(0, 0, w, h, pixel, 0, w); // AffineTransformOp op = new AffineTransformOp(AffineTransform.getScaleInstance(scale, scale), AffineTransformOp.TYPE_NEAREST_NEIGHBOR); // BufferedImage tmp = op.filter(image, null); // // if (frame == null) { // frame = new ImageFrame(null); // frame.show(); // } // frame.showImage(tmp); // // } } --- NEW FILE: Light.java --- /* * Light.java * Copyright (C) 2003 * * $Id: Light.java,v 1.1.2.1 2004/12/13 21:40:44 hzi Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ package jake2.render.lwjgl; import jake2.Defines; import jake2.Globals; import jake2.client.dlight_t; import jake2.game.GameBase; import jake2.game.cplane_t; import jake2.qcommon.Com; import jake2.qcommon.longjmpException; import jake2.render.mnode_t; import jake2.render.msurface_t; import jake2.render.mtexinfo_t; import jake2.util.Math3D; import java.nio.ByteBuffer; import java.nio.IntBuffer; import java.util.Arrays; import org.lwjgl.opengl.GL11; /** * Light * * @author cwei */ public abstract class Light extends Warp { // r_light.c int r_dlightframecount; static final int DLIGHT_CUTOFF = 64; /* ============================================================================= DYNAMIC LIGHTS BLEND RENDERING ============================================================================= */ void R_RenderDlight (dlight_t light) { int i, j; float a; float[] v = {0, 0, 0}; float rad; rad = light.intensity * 0.35f; Math3D.VectorSubtract (light.origin, r_origin, v); gl.glBegin (GL11.GL_TRIANGLE_FAN); gl.glColor3f (light.color[0]*0.2f, light.color[1]*0.2f, light.color[2]*0.2f); for (i=0 ; i<3 ; i++) v[i] = light.origin[i] - vpn[i]*rad; gl.glVertex3f(v[0], v[1], v[2]); gl.glColor3f (0,0,0); for (i=16 ; i>=0 ; i--) { a = (float)(i/16.0f * Math.PI*2); for (j=0 ; j<3 ; j++) v[j] = (float)(light.origin[j] + vright[j]*Math.cos(a)*rad + vup[j]*Math.sin(a)*rad); gl.glVertex3f(v[0], v[1], v[2]); } gl.glEnd (); } /* ============= R_RenderDlights ============= */ void R_RenderDlights() { if (gl_flashblend.value == 0) return; r_dlightframecount = r_framecount + 1; // because the count hasn't // advanced yet for this frame gl.glDepthMask(false); gl.glDisable(GL11.GL_TEXTURE_2D); gl.glShadeModel (GL11.GL_SMOOTH); gl.glEnable (GL11.GL_BLEND); gl.glBlendFunc (GL11.GL_ONE, GL11.GL_ONE); for (int i=0 ; i<r_newrefdef.num_dlights ; i++) { R_RenderDlight(r_newrefdef.dlights[i]); } gl.glColor3f (1,1,1); gl.glDisable(GL11.GL_BLEND); gl.glEnable(GL11.GL_TEXTURE_2D); gl.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); gl.glDepthMask(true); } /* ============================================================================= DYNAMIC LIGHTS ============================================================================= */ /* ============= R_MarkLights ============= */ void R_MarkLights (dlight_t light, int bit, mnode_t node) { cplane_t splitplane; float dist; msurface_t surf; int i; int sidebit; if (node.contents != -1) return; splitplane = node.plane; dist = Math3D.DotProduct (light.origin, splitplane.normal) - splitplane.dist; if (dist > light.intensity - DLIGHT_CUTOFF) { R_MarkLights (light, bit, node.children[0]); return; } if (dist < -light.intensity + DLIGHT_CUTOFF) { R_MarkLights (light, bit, node.children[1]); return; } // mark the polygons for (i=0 ; i<node.numsurfaces ; i++) { surf = r_worldmodel.surfaces[node.firstsurface + i]; /* * cwei * bugfix for dlight behind the walls */ dist = Math3D.DotProduct (light.origin, surf.plane.normal) - surf.plane.dist; sidebit = (dist >= 0) ? 0 : Defines.SURF_PLANEBACK; if ( (surf.flags & Defines.SURF_PLANEBACK) != sidebit ) continue; /* * cwei * bugfix end */ if (surf.dlightframe != r_dlightframecount) { surf.dlightbits = 0; surf.dlightframe = r_dlightframecount; } surf.dlightbits |= bit; } R_MarkLights (light, bit, node.children[0]); R_MarkLights (light, bit, node.children[1]); } /* ============= R_PushDlights ============= */ void R_PushDlights() { int i; dlight_t l; if (gl_flashblend.value != 0) return; r_dlightframecount = r_framecount + 1; // because the count hasn't // advanced yet for this frame for (i=0 ; i<r_newrefdef.num_dlights ; i++) { l = r_newrefdef.dlights[i]; R_MarkLights( l, 1<<i, r_worldmodel.nodes[0] ); } } /* ============================================================================= LIGHT SAMPLING ============================================================================= */ float[] pointcolor = {0, 0, 0}; // vec3_t cplane_t lightplane; // used as shadow plane float[] lightspot = {0, 0, 0}; // vec3_t int RecursiveLightPoint (mnode_t node, float[] start, float[] end) { if (node.contents != -1) return -1; // didn't hit anything msurface_t surf; int s, t, ds, dt; int i; mtexinfo_t tex; ByteBuffer lightmap; int maps; float[] mid = {0, 0, 0}; // calculate mid point // FIXME: optimize for axial cplane_t plane = node.plane; float front = Math3D.DotProduct (start, plane.normal) - plane.dist; float back = Math3D.DotProduct (end, plane.normal) - plane.dist; boolean side = (front < 0); int sideIndex = (side) ? 1 : 0; if ( (back < 0) == side) return RecursiveLightPoint (node.children[sideIndex], start, end); float frac = front / (front-back); mid[0] = start[0] + (end[0] - start[0])*frac; mid[1] = start[1] + (end[1] - start[1])*frac; mid[2] = start[2] + (end[2] - start[2])*frac; // go down front side int r = RecursiveLightPoint (node.children[sideIndex], start, mid); if (r >= 0) return r; // hit something if ( (back < 0) == side ) return -1; // didn't hit anuthing // check for impact on this node Math3D.VectorCopy (mid, lightspot); lightplane = plane; int surfIndex = node.firstsurface; float[] scale = {0, 0, 0}; for (i=0 ; i<node.numsurfaces ; i++, surfIndex++) { surf = r_worldmodel.surfaces[surfIndex]; if ((surf.flags & (Defines.SURF_DRAWTURB | Defines.SURF_DRAWSKY)) != 0) continue; // no lightmaps tex = surf.texinfo; s = (int)(Math3D.DotProduct (mid, tex.vecs[0]) + tex.vecs[0][3]); t = (int)(Math3D.DotProduct (mid, tex.vecs[1]) + tex.vecs[1][3]); if (s < surf.texturemins[0] || t < surf.texturemins[1]) continue; ds = s - surf.texturemins[0]; dt = t - surf.texturemins[1]; if ( ds > surf.extents[0] || dt > surf.extents[1] ) continue; if (surf.samples == null) return 0; ds >>= 4; dt >>= 4; lightmap = surf.samples; int lightmapIndex = 0; Math3D.VectorCopy (Globals.vec3_origin, pointcolor); if (lightmap != null) { //float[] scale = {0, 0, 0}; float[] rgb; lightmapIndex += 3 * (dt * ((surf.extents[0] >> 4) + 1) + ds); for (maps = 0 ; maps < Defines.MAXLIGHTMAPS && surf.styles[maps] != (byte)255; maps++) { rgb = r_newrefdef.lightstyles[surf.styles[maps] & 0xFF].rgb; scale[0] = gl_modulate.value * rgb[0]; scale[1] = gl_modulate.value * rgb[1]; scale[2] = gl_modulate.value * rgb[2]; pointcolor[0] += (lightmap.get(lightmapIndex + 0) & 0xFF) * scale[0] * (1.0f/255); pointcolor[1] += (lightmap.get(lightmapIndex + 1) & 0xFF) * scale[1] * (1.0f/255); pointcolor[2] += (lightmap.get(lightmapIndex + 2) & 0xFF) * scale[2] * (1.0f/255); lightmapIndex += 3 * ((surf.extents[0] >> 4) + 1) * ((surf.extents[1] >> 4) + 1); } } return 1; } // go down back side return RecursiveLightPoint (node.children[1 - sideIndex], mid, end); } /* =============== R_LightPoint =============== */ void R_LightPoint (float[] p, float[] color) { assert (p.length == 3) : "vec3_t bug"; assert (color.length == 3) : "rgb bug"; float[] end = {0, 0, 0}; dlight_t dl; float add; if (r_worldmodel.lightdata == null) { color[0] = color[1] = color[2] = 1.0f; return; } end[0] = p[0]; end[1] = p[1]; end[2] = p[2] - 2048; float r = RecursiveLightPoint(r_worldmodel.nodes[0], p, end); if (r == -1) { Math3D.VectorCopy (GameBase.vec3_origin, color); } else { Math3D.VectorCopy (pointcolor, color); } // // add dynamic lights // for (int lnum=0 ; lnum<r_newrefdef.num_dlights ; lnum++) { dl = r_newrefdef.dlights[lnum]; Math3D.VectorSubtract (currententity.origin, dl.origin, end); add = dl.intensity - Math3D.VectorLength(end); add *= (1.0f/256); if (add > 0) { Math3D.VectorMA (color, add, dl.color, color); } } Math3D.VectorScale (color, gl_modulate.value, color); } // =================================================================== float[] s_blocklights = new float[34 * 34 * 3]; /* =============== R_AddDynamicLights =============== */ // TODO sync with jogl renderer. hoz void R_AddDynamicLights(msurface_t surf) { int sd, td; float fdist, frad, fminlight; float[] impact = {0, 0, 0}; float[] local = {0, 0, 0}; int s, t; dlight_t dl; float[] pfBL; float fsacc, ftacc; int smax = (surf.extents[0]>>4)+1; int tmax = (surf.extents[1]>>4)+1; mtexinfo_t tex = surf.texinfo; for (int lnum=0 ; lnum<r_newrefdef.num_dlights ; lnum++) { if ( (surf.dlightbits & (1<<lnum)) == 0 ) continue; // not lit by this light dl = r_newrefdef.dlights[lnum]; frad = dl.intensity; fdist = Math3D.DotProduct (dl.origin, surf.plane.normal) - surf.plane.dist; frad -= Math.abs(fdist); // rad is now the highest intensity on the plane fminlight = DLIGHT_CUTOFF; // FIXME: make configurable? if (frad < fminlight) continue; fminlight = frad - fminlight; for (int i=0 ; i<3 ; i++) { impact[i] = dl.origin[i] - surf.plane.normal[i]*fdist; } local[0] = Math3D.DotProduct (impact, tex.vecs[0]) + tex.vecs[0][3] - surf.texturemins[0]; local[1] = Math3D.DotProduct (impact, tex.vecs[1]) + tex.vecs[1][3] - surf.texturemins[1]; pfBL = s_blocklights; int pfBLindex = 0; for (t = 0, ftacc = 0 ; t<tmax ; t++, ftacc += 16) { td = (int)(local[1] - ftacc); if ( td < 0 ) td = -td; for (s=0, fsacc = 0 ; s<smax ; s++, fsacc += 16, pfBLindex += 3) { sd = (int)( local[0] - fsacc ); if ( sd < 0 ) sd = -sd; if (sd > td) fdist = sd + (td>>1); else fdist = td + (sd>>1); if ( fdist < fminlight ) { pfBL[pfBLindex + 0] += ( frad - fdist ) * dl.color[0]; pfBL[pfBLindex + 1] += ( frad - fdist ) * dl.color[1]; pfBL[pfBLindex + 2] += ( frad - fdist ) * dl.color[2]; } } } } } /* ** R_SetCacheState */ void R_SetCacheState( msurface_t surf ) { for (int maps = 0 ; maps < Defines.MAXLIGHTMAPS && surf.styles[maps] != (byte)255 ; maps++) { surf.cached_light[maps] = r_newrefdef.lightstyles[surf.styles[maps] & 0xFF].white; } } /* =============== R_BuildLightMap Combine and scale multiple lightmaps into the floating format in blocklights =============== */ // TODO sync with jogl renderer. hoz void R_BuildLightMap(msurface_t surf, IntBuffer dest, int stride) { int r, g, b, a, max; int i, j; ByteBuffer lightmap; float[] scale = {0, 0, 0}; int nummaps; float[] bl; //lightstyle_t style; if ( (surf.texinfo.flags & (Defines.SURF_SKY | Defines.SURF_TRANS33 | Defines.SURF_TRANS66 | Defines.SURF_WARP)) != 0 ) Com.Error(Defines.ERR_DROP, "R_BuildLightMap called for non-lit surface"); int smax = (surf.extents[0] >> 4) + 1; int tmax = (surf.extents[1] >> 4) + 1; int size = smax * tmax; if (size > ((s_blocklights.length * Defines.SIZE_OF_FLOAT) >> 4) ) Com.Error(Defines.ERR_DROP, "Bad s_blocklights size"); try { // set to full bright if no light data if (surf.samples == null) { int maps; for (i=0 ; i<size*3 ; i++) s_blocklights[i] = 255; // TODO useless? hoz // for (maps = 0 ; maps < Defines.MAXLIGHTMAPS && surf.styles[maps] != (byte)255; maps++) // { // style = r_newrefdef.lightstyles[surf.styles[maps] & 0xFF]; // } // goto store; throw new longjmpException(); } // count the # of maps for ( nummaps = 0 ; nummaps < Defines.MAXLIGHTMAPS && surf.styles[nummaps] != (byte)255 ; nummaps++) ; lightmap = surf.samples; int lightmapIndex = 0; // add all the lightmaps if ( nummaps == 1 ) { int maps; for (maps = 0 ; maps < Defines.MAXLIGHTMAPS && surf.styles[maps] != (byte)255 ; maps++) { bl = s_blocklights; int blp = 0; for (i=0 ; i<3 ; i++) scale[i] = gl_modulate.value * r_newrefdef.lightstyles[surf.styles[maps] & 0xFF].rgb[i]; if ( scale[0] == 1.0F && scale[1] == 1.0F && scale[2] == 1.0F ) { for (i=0 ; i<size ; i++) { bl[blp++] = lightmap.get(lightmapIndex++) & 0xFF; bl[blp++] = lightmap.get(lightmapIndex++) & 0xFF; bl[blp++] = lightmap.get(lightmapIndex++) & 0xFF; } } else { for (i=0 ; i<size ; i++) { bl[blp++] = (lightmap.get(lightmapIndex++) & 0xFF) * scale[0]; bl[blp++] = (lightmap.get(lightmapIndex++) & 0xFF) * scale[1]; bl[blp++] = (lightmap.get(lightmapIndex++) & 0xFF) * scale[2]; } } //lightmap += size*3; // skip to next lightmap } } else { int maps; // memset( s_blocklights, 0, sizeof( s_blocklights[0] ) * size * 3 ); Arrays.fill(s_blocklights, 0, size * 3, 0.0f); for (maps = 0 ; maps < Defines.MAXLIGHTMAPS && surf.styles[maps] != (byte)255 ; maps++) { bl = s_blocklights; int blp = 0; for (i=0 ; i<3 ; i++) scale[i] = gl_modulate.value*r_newrefdef.lightstyles[surf.styles[maps] & 0xFF].rgb[i]; if ( scale[0] == 1.0F && scale[1] == 1.0F && scale[2] == 1.0F ) { for (i=0 ; i<size ; i++) { bl[blp++] += lightmap.get(lightmapIndex++) & 0xFF; bl[blp++] += lightmap.get(lightmapIndex++) & 0xFF; bl[blp++] += lightmap.get(lightmapIndex++) & 0xFF; } } else { for (i=0 ; i<size ; i++) { bl[blp++] += (lightmap.get(lightmapIndex++) & 0xFF) * scale[0]; bl[blp++] += (lightmap.get(lightmapIndex++) & 0xFF) * scale[1]; bl[blp++] += (lightmap.get(lightmapIndex++) & 0xFF) * scale[2]; } } //lightmap += size*3; // skip to next lightmap } } // add all the dynamic lights if (surf.dlightframe == r_framecount) R_AddDynamicLights(surf); // label store: } catch (longjmpException store) {} // put into texture format stride -= smax; bl = s_blocklights; int blp = 0; int monolightmap = gl_monolightmap.string.charAt(0); int destp = 0; if ( monolightmap == '0' ) { for (i=0 ; i<tmax ; i++, destp += stride) { //dest.position(destp); for (j=0 ; j<smax ; j++) { r = (int)bl[blp++]; g = (int)bl[blp++]; b = (int)bl[blp++]; // catch negative lights if (r < 0) r = 0; if (g < 0) g = 0; if (b < 0) b = 0; /* ** determine the brightest of the three color components */ if (r > g) max = r; else max = g; if (b > max) max = b; /* ** alpha is ONLY used for the mono lightmap case. For this reason ** we set it to the brightest of the color components so that ** things don't get too dim. */ a = max; /* ** rescale all the color components if the intensity of the greatest ** channel exceeds 1.0 */ if (max > 255) { float t = 255.0F / max; r = (int)(r*t); g = (int)(g*t); b = (int)(b*t); a = (int)(a*t); } //r &= 0xFF; g &= 0xFF; b &= 0xFF; a &= 0xFF; dest.put(destp++, (a << 24) | (b << 16) | (g << 8) | (r << 0)); } } } else { for (i=0 ; i<tmax ; i++, destp += stride) { //dest.position(destp); for (j=0 ; j<smax ; j++) { r = (int) bl[blp++]; g = (int) bl[blp++]; b = (int) bl[blp++]; // catch negative lights if (r < 0) r = 0; if (g < 0) g = 0; if (b < 0) b = 0; /* ** determine the brightest of the three color components */ if (r > g) max = r; else max = g; if (b > max) max = b; /* ** alpha is ONLY used for the mono lightmap case. For this reason ** we set it to the brightest of the color components so that ** things don't get too dim. */ a = max; /* ** rescale all the color components if the intensity of the greatest ** channel exceeds 1.0 */ if (max > 255) { float t = 255.0F / max; r = (int)(r*t); g = (int)(g*t); b = (int)(b*t); a = (int)(a*t); } /* ** So if we are doing alpha lightmaps we need to set the R, G, and B ** components to 0 and we need to set alpha to 1-alpha. */ switch ( monolightmap ) { case 'L': case 'I': r = a; g = b = 0; break; case 'C': // try faking colored lighting a = 255 - ((r+g+b)/3); r *= a/255.0f; g *= a/255.0f; b *= a/255.0f; break; case 'A': default: r = g = b = 0; a = 255 - a; break; } //r &= 0xFF; g &= 0xFF; b &= 0xFF; a &= 0xFF; dest.put(destp++, (a << 24) | (b << 16) | (g << 8) | (r << 0)); } } } } } --- NEW FILE: Base.java --- /* * Base.java * Copyright (C) 2003 * * $Id: Base.java,v 1.1.2.1 2004/12/13 21:40:45 hzi Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ package jake2.render.lwjgl; import jake2.render.LWJGLBase; import org.lwjgl.opengl.GL11; /** * Base * * @author dsanders/cwei */ public abstract class Base extends LWJGLBase { static final int GL_COLOR_INDEX8_EXT = GL11.GL_COLOR_INDEX; static final String REF_VERSION = "GL 0.01"; // up / down static final int PITCH = 0; // left / right static final int YAW = 1; // fall over static final int ROLL = 2; /* skins will be outline flood filled and mip mapped pics and sprites with alpha will be outline flood filled pic won't be mip mapped model skin sprite frame wall texture pic */ // enum imagetype_t static final int it_skin = 0; static final int it_sprite = 1; static final int it_wall = 2; static final int it_pic = 3; static final int it_sky = 4; // enum modtype_t static final int mod_bad = 0; static final int mod_brush = 1; static final int mod_sprite = 2; static final int mod_alias = 3; static final int TEXNUM_LIGHTMAPS = 1024; static final int TEXNUM_SCRAPS = 1152; static final int TEXNUM_IMAGES = 1153; static final int MAX_GLTEXTURES = 1024; // =================================================================== // // #include "gl_model.h" // // void GL_BeginRendering (int *x, int *y, int *width, int *height); // void GL_EndRendering (void); // // void GL_SetDefaultState( void ); // void GL_UpdateSwapInterval( void ); static class glvert_t { float x, y, z; float s, t; float r, g, b; } static final int MAX_LBM_HEIGHT = 480; static final float BACKFACE_EPSILON = 0.01f; // ==================================================== // // void R_TranslatePlayerSkin (int playernum); // void GL_Bind (int texnum); // void GL_MBind( GLenum target, int texnum ); // void GL_TexEnv( GLenum value ); // void GL_EnableMultitexture( qboolean enable ); // void GL_SelectTexture( GLenum ); // // void R_LightPoint (vec3_t p, vec3_t color); // void R_PushDlights (void); // // ==================================================================== // // extern int registration_sequence; // // // void V_AddBlend (float r, float g, float b, float a, float *v_blend); // // int R_Init( void *hinstance, void *hWnd ); // void R_Shutdown( void ); // // void R_RenderView (refdef_t *fd); // void GL_ScreenShot_f (void); // void R_DrawAliasModel (entity_t *e); // void R_DrawBrushModel (entity_t *e); // void R_DrawSpriteModel (entity_t *e); // void R_DrawBeam( entity_t *e ); // void R_DrawWorld (void); // void R_RenderDlights (void); // void R_DrawAlphaSurfaces (void); // void R_RenderBrushPoly (msurface_t *fa); // void R_InitParticleTexture (void); // void Draw_InitLocal (void); // void GL_SubdivideSurface (msurface_t *fa); // qboolean R_CullBox (vec3_t mins, vec3_t maxs); // void R_RotateForEntity (entity_t *e); // void R_MarkLeaves (void); // // glpoly_t *WaterWarpPolyVerts (glpoly_t *p); // void EmitWaterPolys (msurface_t *fa); // void R_AddSkySurface (msurface_t *fa); // void R_ClearSkyBox (void); // void R_DrawSkyBox (void); // void R_MarkLights (dlight_t *light, int bit, mnode_t *node); // // // void COM_StripExtension (char *in, char *out); // // void Draw_GetPicSize (int *w, int *h, char *name); // void Draw_Pic (int x, int y, char *name); // void Draw_StretchPic (int x, int y, int w, int h, char *name); // void Draw_Char (int x, int y, int c); // void Draw_TileClear (int x, int y, int w, int h, char *name); // void Draw_Fill (int x, int y, int w, int h, int c); // void Draw_FadeScreen (void); // void Draw_StretchRaw (int x, int y, int w, int h, int cols, int rows, byte *data); // // void R_BeginFrame( float camera_separation ); // void R_SwapBuffers( int ); // void R_SetPalette ( const unsigned char *palette); // // int Draw_GetPalette (void); // // void GL_ResampleTexture (unsigned *in, int inwidth, int inheight, unsigned *out, int outwidth, int outheight); // // struct image_s *R_RegisterSkin (char *name); // // void LoadPCX (char *filename, byte **pic, byte **palette, int *width, int *height); // image_t *GL_LoadPic (char *name, byte *pic, int width, int height, imagetype_t type, int bits); // image_t *GL_FindImage (char *name, imagetype_t type); // void GL_TextureMode( char *string ); // void GL_ImageList_f (void); // // void GL_SetTexturePalette( unsigned palette[256] ); // // void GL_InitImages (void); // void GL_ShutdownImages (void); // // void GL_FreeUnusedImages (void); // // void GL_TextureAlphaMode( char *string ); // void GL_TextureSolidMode( char *string ); // // /* // ** GL extension emulation functions // */ // void GL_DrawParticles( int n, const particle_t particles[], const unsigned colortable[768] ); // /* ** GL config stuff */ static final int GL_RENDERER_VOODOO = 0x00000001; static final int GL_RENDERER_VOODOO2 = 0x00000002; static final int GL_RENDERER_VOODOO_RUSH = 0x00000004; static final int GL_RENDERER_BANSHEE = 0x00000008; static final int GL_RENDERER_3DFX = 0x0000000F; static final int GL_RENDERER_PCX1 = 0x00000010; static final int GL_RENDERER_PCX2 = 0x00000020; static final int GL_RENDERER_PMX = 0x00000040; static final int GL_RENDERER_POWERVR = 0x00000070; static final int GL_RENDERER_PERMEDIA2 = 0x00000100; static final int GL_RENDERER_GLINT_MX = 0x00000200; static final int GL_RENDERER_GLINT_TX = 0x00000400; static final int GL_RENDERER_3DLABS_MISC = 0x00000800; static final int GL_RENDERER_3DLABS = 0x00000F00; static final int GL_RENDERER_REALIZM = 0x00001000; static final int GL_RENDERER_REALIZM2 = 0x00002000; static final int GL_RENDERER_INTERGRAPH = 0x00003000; static final int GL_RENDERER_3DPRO = 0x00004000; static final int GL_RENDERER_REAL3D = 0x00008000; static final int GL_RENDERER_RIVA128 = 0x00010000; static final int GL_RENDERER_DYPIC = 0x00020000; static final int GL_RENDERER_V1000 = 0x00040000; static final int GL_RENDERER_V2100 = 0x00080000; static final int GL_RENDERER_V2200 = 0x00100000; static final int GL_RENDERER_RENDITION = 0x001C0000; static final int GL_RENDERER_O2 = 0x00100000; static final int GL_RENDERER_IMPACT = 0x00200000; static final int GL_RENDERER_RE = 0x00400000; static final int GL_RENDERER_IR = 0x00800000; static final int GL_RENDERER_SGI = 0x00F00000; static final int GL_RENDERER_MCD = 0x01000000; static final int GL_RENDERER_OTHER = 0x80000000; // typedef struct // { // int renderer; // const char *renderer_string; // const char *vendor_string; // const char *version_string; // const char *extensions_string; // // qboolean allow_cds; // } glconfig_t; // // typedef struct // { // float inverse_intensity; // qboolean fullscreen; // // int prev_mode; // // unsigned char *d_16to8table; // // int lightmap_textures; // // int currenttextures[2]; // int currenttmu; // // float camera_separation; // qboolean stereo_enabled; // // unsigned char originalRedGammaTable[256]; // unsigned char originalGreenGammaTable[256]; // unsigned char originalBlueGammaTable[256]; // } glstate_t; // // /* // ==================================================================== // // IMPORTED FUNCTIONS // // ==================================================================== // */ // // extern refimport_t ri; // // // /* // ==================================================================== // // IMPLEMENTATION SPECIFIC FUNCTIONS // // ==================================================================== // */ // // void GLimp_BeginFrame( float camera_separation ); // void GLimp_EndFrame( void ); // int GLimp_Init( void *hinstance, void *hWnd ); // void GLimp_Shutdown( void ); // int GLimp_SetMode( int *pwidth, int *pheight, int mode, qboolean fullscreen ); // void GLimp_AppActivate( qboolean active ); // void GLimp_EnableLogging( qboolean enable ); // void GLimp_LogNewFrame( void ); // } --- NEW FILE: Draw.java --- /* * Draw.java * Copyright (C) 2003 * * $Id: Draw.java,v 1.1.2.1 2004/12/13 21:40:45 hzi Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ package jake2.render.lwjgl; import jake2.Defines; import jake2.client.VID; import jake2.qcommon.Com; import jake2.render.image_t; import java.awt.Dimension; import java.nio.ByteBuffer; import java.nio.IntBuffer; import org.lwjgl.BufferUtils; import org.lwjgl.opengl.GL11; /** * Draw * (gl_draw.c) * * @author cwei */ public abstract class Draw extends Image { /* =============== Draw_InitLocal =============== */ void Draw_InitLocal() { // load console characters (don't bilerp characters) draw_chars = GL_FindImage("pics/conchars.pcx", it_pic); GL_Bind(draw_chars.texnum); gl.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST); gl.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST); } /* ================ Draw_Char Draws one 8*8 graphics character with 0 being transparent. It can be clipped to the top of the screen to allow the console to be smoothly scrolled off. ================ */ protected void Draw_Char(int x, int y, int num) { num &= 255; if ( (num&127) == 32 ) return; // space if (y <= -8) return; // totally off screen int row = num>>4; int col = num&15; float frow = row*0.0625f; float fcol = col*0.0625f; float size = 0.0625f; GL_Bind(draw_chars.texnum); gl.glBegin (GL11.GL_QUADS); gl.glTexCoord2f (fcol, frow); gl.glVertex2f (x, y); gl.glTexCoord2f (fcol + size, frow); gl.glVertex2f (x+8, y); gl.glTexCoord2f (fcol + size, frow + size); gl.glVertex2f (x+8, y+8); gl.glTexCoord2f (fcol, frow + size); gl.glVertex2f (x, y+8); gl.glEnd (); } /* ============= Draw_FindPic ============= */ protected image_t Draw_FindPic(String name) { image_t image = null; String fullname; if (!name.startsWith("/") && !name.startsWith("\\")) { fullname = "pics/" + name + ".pcx"; image = GL_FindImage(fullname, it_pic); } else { image = GL_FindImage(name.substring(1), it_pic); } return image; } /* ============= Draw_GetPicSize ============= */ protected void Draw_GetPicSize(Dimension dim, String pic) { image_t image = Draw_FindPic(pic); dim.width = (image != null) ? image.width : -1; dim.height = (image != null) ? image.height : -1; } /* ============= Draw_StretchPic ============= */ protected void Draw_StretchPic (int x, int y, int w, int h, String pic) { image_t image; image = Draw_FindPic(pic); if (image == null) { VID.Printf (Defines.PRINT_ALL, "Can't find pic: " + pic +'\n'); return; } if (scrap_dirty) Scrap_Upload(); if ( ( ( gl_config.renderer == GL_RENDERER_MCD ) || ( (gl_config.renderer & GL_RENDERER_RENDITION) != 0) ) && !image.has_alpha) gl.glDisable(GL11.GL_ALPHA_TEST); GL_Bind(image.texnum); gl.glBegin (GL11.GL_QUADS); gl.glTexCoord2f (image.sl, image.tl); gl.glVertex2f (x, y); gl.glTexCoord2f (image.sh, image.tl); gl.glVertex2f (x+w, y); gl.glTexCoord2f (image.sh, image.th); gl.glVertex2f (x+w, y+h); gl.glTexCoord2f (image.sl, image.th); gl.glVertex2f (x, y+h); gl.glEnd (); if ( ( ( gl_config.renderer == GL_RENDERER_MCD ) || ( (gl_config.renderer & GL_RENDERER_RENDITION) !=0 ) ) && !image.has_alpha) gl.glEnable(GL11.GL_ALPHA_TEST); } /* ============= Draw_Pic ============= */ protected void Draw_Pic(int x, int y, String pic) { image_t image; image = Draw_FindPic(pic); if (image == null) { VID.Printf(Defines.PRINT_ALL, "Can't find pic: " +pic + '\n'); return; } if (scrap_dirty) Scrap_Upload(); if ( ( ( gl_config.renderer == GL_RENDERER_MCD ) || ( (gl_config.renderer & GL_RENDERER_RENDITION) != 0 ) ) && !image.has_alpha) gl.glDisable (GL11.GL_ALPHA_TEST); GL_Bind(image.texnum); gl.glBegin (GL11.GL_QUADS); gl.glTexCoord2f (image.sl, image.tl); gl.glVertex2f (x, y); gl.glTexCoord2f (image.sh, image.tl); gl.glVertex2f (x+image.width, y); gl.glTexCoord2f (image.sh, image.th); gl.glVertex2f (x+image.width, y+image.height); gl.glTexCoord2f (image.sl, image.th); gl.glVertex2f (x, y+image.height); gl.glEnd (); if ( ( ( gl_config.renderer == GL_RENDERER_MCD ) || ( (gl_config.renderer & GL_RENDERER_RENDITION) != 0 ) ) && !image.has_alpha) gl.glEnable (GL11.GL_ALPHA_TEST); } /* ============= Draw_TileClear This repeats a 64*64 tile graphic to fill the screen around a sized down refresh window. ============= */ protected void Draw_TileClear(int x, int y, int w, int h, String pic) { image_t image; image = Draw_FindPic(pic); if (image == null) { VID.Printf(Defines.PRINT_ALL, "Can't find pic: " + pic + '\n'); return; } if ( ( ( gl_config.renderer == GL_RENDERER_MCD ) || ( (gl_config.renderer & GL_RENDERER_RENDITION) != 0 ) ) && !image.has_alpha) gl.glDisable(GL11.GL_ALPHA_TEST); GL_Bind(image.texnum); gl.glBegin (GL11.GL_QUADS); gl.glTexCoord2f(x/64.0f, y/64.0f); gl.glVertex2f (x, y); gl.glTexCoord2f( (x+w)/64.0f, y/64.0f); gl.glVertex2f(x+w, y); gl.glTexCoord2f( (x+w)/64.0f, (y+h)/64.0f); gl.glVertex2f(x+w, y+h); gl.glTexCoord2f( x/64.0f, (y+h)/64.0f ); gl.glVertex2f (x, y+h); gl.glEnd (); if ( ( ( gl_config.renderer == GL_RENDERER_MCD ) || ( (gl_config.renderer & GL_RENDERER_RENDITION) != 0 ) ) && !image.has_alpha) gl.glEnable(GL11.GL_ALPHA_TEST); } /* ============= Draw_Fill Fills a box of pixels with a single color ============= */ protected void Draw_Fill(int x, int y, int w, int h, int colorIndex) { if ( colorIndex > 255) Com.Error(Defines.ERR_FATAL, "Draw_Fill: bad color"); gl.glDisable(GL11.GL_TEXTURE_2D); int color = d_8to24table[colorIndex]; gl.glColor3ub( (byte)((color >> 0) & 0xff), // r (byte)((color >> 8) & 0xff), // g (byte)((color >> 16) & 0xff) // b ); gl.glBegin (GL11.GL_QUADS); gl.glVertex2f(x,y); gl.glVertex2f(x+w, y); gl.glVertex2f(x+w, y+h); gl.glVertex2f(x, y+h); gl.glEnd(); gl.glColor3f(1,1,1); gl.glEnable(GL11.GL_TEXTURE_2D); } //============================================================================= /* ================ Draw_FadeScreen ================ */ protected void Draw_FadeScreen() { gl.glEnable(GL11.GL_BLEND); gl.glDisable(GL11.GL_TEXTURE_2D); gl.glColor4f(0, 0, 0, 0.8f); gl.glBegin(GL11.GL_QUADS); gl.glVertex2f(0,0); gl.glVertex2f(vid.width, 0); gl.glVertex2f(vid.width, vid.height); gl.glVertex2f(0, vid.height); gl.glEnd(); gl.glColor4f(1,1,1,1); gl.glEnable(GL11.GL_TEXTURE_2D); gl.glDisable(GL11.GL_BLEND); } // ==================================================================== IntBuffer image32=BufferUtils.createIntBuffer(256*256); ByteBuffer image8=BufferUtils.createByteBuffer(256*256); /* ============= Draw_StretchRaw ============= */ protected void Draw_StretchRaw (int x, int y, int w, int h, int cols, int rows, byte[] data) { int i, j, trows; int sourceIndex; int frac, fracstep; float hscale; int row; float t; GL_Bind(0); if (rows<=256) { hscale = 1; trows = rows; } else { hscale = rows/256.0f; trows = 256; } t = rows*hscale / 256; if ( !qglColorTableEXT ) { //int[] image32 = new int[256*256]; image32.clear(); int destIndex = 0; for (i=0 ; i<trows ; i++) { row = (int)(i*hscale); if (row > rows) break; sourceIndex = cols*row; destIndex = i*256; fracstep = cols*0x10000/256; frac = fracstep >> 1; for (j=0 ; j<256 ; j++) { image32.put(destIndex + j, r_rawpalette[data[sourceIndex + (frac>>16)] & 0xff]); frac += fracstep; } } gl.glTexImage2D (GL11.GL_TEXTURE_2D, 0, gl_tex_solid_format, 256, 256, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, image32); } else { //byte[] image8 = new byte[256*256]; image8.clear(); int destIndex = 0;; for (i=0 ; i<trows ; i++) { row = (int)(i*hscale); if (row > rows) break; sourceIndex = cols*row; destIndex = i*256; fracstep = cols*0x10000/256; frac = fracstep >> 1; for (j=0 ; j<256 ; j++) { image8.put(destIndex + j, data[sourceIndex + (frac>>16)]); frac += fracstep; } } gl.glTexImage2D( GL11.GL_TEXTURE_2D, 0, GL_COLOR_INDEX8_EXT, 256, 256, 0, GL11.GL_COLOR_INDEX, GL11.GL_UNSIGNED_BYTE, image8 ); } gl.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR); gl.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR); if ( ( gl_config.renderer == GL_RENDERER_MCD ) || ( (gl_config.renderer & GL_RENDERER_RENDITION) != 0 ) ) gl.glDisable (GL11.GL_ALPHA_TEST); gl.glBegin (GL11.GL_QUADS); gl.glTexCoord2f (0, 0); gl.glVertex2f (x, y); gl.glTexCoord2f (1, 0); gl.glVertex2f (x+w, y); gl.glTexCoord2f (1, t); gl.glVertex2f (x+w, y+h); gl.glTexCoord2f (0, t); gl.glVertex2f (x, y+h); gl.glEnd (); if ( ( gl_config.renderer == GL_RENDERER_MCD ) || ( (gl_config.renderer & GL_RENDERER_RENDITION) != 0 ) ) gl.glEnable (GL11.GL_ALPHA_TEST); } } --- NEW FILE: Model.java --- /* * Model.java * Copyright (C) 2003 * * $Id: Model.java,v 1.1.2.1 2004/12/13 21:40:45 hzi Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. [...1327 lines suppressed...] for (int i = 0; i < model.counts.length; i++) { count = ((Integer)tmp.get(i)).intValue(); model.counts[i] = count; count = (count < 0) ? -count : count; model.vertexIndexBuf.position(pos); model.indexElements[i] = model.vertexIndexBuf.slice(); pos += count; } } static void resetModelArrays() { globalModelTextureCoordBuf.rewind(); globalModelVertexIndexBuf.rewind(); } static void modelMemoryUsage() { System.out.println("AliasModels: globalVertexBuffer size " + globalModelVertexIndexBuf.position()); } } --- NEW FILE: Main.java --- /* * Main.java * Copyright (C) 2003 * * $Id: Main.java,v 1.1.2.1 2004/12/13 21:40:45 hzi Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. [...1530 lines suppressed...] float[] v; for (i = 0; i < NUM_BEAM_SEGS; i++) { v = start_points[i]; gl.glVertex3f(v[0], v[1], v[2]); v = end_points[i]; gl.glVertex3f(v[0], v[1], v[2]); v = start_points[(i + 1) % NUM_BEAM_SEGS]; gl.glVertex3f(v[0], v[1], v[2]); v = end_points[(i + 1) % NUM_BEAM_SEGS]; gl.glVertex3f(v[0], v[1], v[2]); } gl.glEnd(); gl.glEnable(GL11.GL_TEXTURE_2D); gl.glDisable(GL11.GL_BLEND); gl.glDepthMask(true); } } --- NEW FILE: Warp.java --- /* * Warp.java * Copyright (C) 2003 * * $Id: Warp.java,v 1.1.2.1 2004/12/13 21:40:44 hzi Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ package jake2.render.lwjgl; import jake2.Defines; import jake2.Globals; import jake2.qcommon.Com; import jake2.render.glpoly_t; import jake2.render.image_t; import jake2.render.msurface_t; import jake2.util.Math3D; import java.nio.FloatBuffer; import org.lwjgl.opengl.GL11; /** * Warp * * @author cwei */ public abstract class Warp extends Model { // warpsin.h public static final float[] SIN = { 0f, 0.19633f, 0.392541f, 0.588517f, 0.784137f, 0.979285f, 1.17384f, 1.3677f, 1.56072f, 1.75281f, 1.94384f, 2.1337f, 2.32228f, 2.50945f, 2.69512f, 2.87916f, 3.06147f, 3.24193f, 3.42044f, 3.59689f, 3.77117f, 3.94319f, 4.11282f, 4.27998f, 4.44456f, 4.60647f, 4.76559f, 4.92185f, 5.07515f, 5.22538f, 5.37247f, 5.51632f, 5.65685f, 5.79398f, 5.92761f, 6.05767f, 6.18408f, 6.30677f, 6.42566f, 6.54068f, 6.65176f, 6.75883f, 6.86183f, 6.9607f, 7.05537f, 7.14579f, 7.23191f, 7.31368f, 7.39104f, 7.46394f, 7.53235f, 7.59623f, 7.65552f, 7.71021f, 7.76025f, 7.80562f, 7.84628f, 7.88222f, 7.91341f, 7.93984f, 7.96148f, 7.97832f, 7.99036f, 7.99759f, 8f, 7.99759f, 7.99036f, 7.97832f, 7.96148f, 7.93984f, 7.91341f, 7.88222f, 7.84628f, 7.80562f, 7.76025f, 7.71021f, 7.65552f, 7.59623f, 7.53235f, 7.46394f, 7.39104f, 7.31368f, 7.23191f, 7.14579f, 7.05537f, 6.9607f, 6.86183f, 6.75883f, 6.65176f, 6.54068f, 6.42566f, 6.30677f, 6.18408f, 6.05767f, 5.92761f, 5.79398f, 5.65685f, 5.51632f, 5.37247f, 5.22538f, 5.07515f, 4.92185f, 4.76559f, 4.60647f, 4.44456f, 4.27998f, 4.11282f, 3.94319f, 3.77117f, 3.59689f, 3.42044f, 3.24193f, 3.06147f, 2.87916f, 2.69512f, 2.50945f, 2.32228f, 2.1337f, 1.94384f, 1.75281f, 1.56072f, 1.3677f, 1.17384f, 0.979285f, 0.784137f, 0.588517f, 0.392541f, 0.19633f, 9.79717e-16f, -0.19633f, -0.392541f, -0.588517f, -0.784137f, -0.979285f, -1.17384f, -1.3677f, -1.56072f, -1.75281f, -1.94384f, -2.1337f, -2.32228f, -2.50945f, -2.69512f, -2.87916f, -3.06147f, -3.24193f, -3.42044f, -3.59689f, -3.77117f, -3.94319f, -4.11282f, -4.27998f, -4.44456f, -4.60647f, -4.76559f, -4.92185f, -5.07515f, -5.22538f, -5.37247f, -5.51632f, -5.65685f, -5.79398f, -5.92761f, -6.05767f, -6.18408f, -6.30677f, -6.42566f, -6.54068f, -6.65176f, -6.75883f, -6.86183f, -6.9607f, -7.05537f, -7.14579f, -7.23191f, -7.31368f, -7.39104f, -7.46394f, -7.53235f, -7.59623f, -7.65552f, -7.71021f, -7.76025f, -7.80562f, -7.84628f, -7.88222f, -7.91341f, -7.93984f, -7.96148f, -7.97832f, -7.99036f, -7.99759f, -8f, -7.99759f, -7.99036f, -7.97832f, -7.96148f, -7.93984f, -7.91341f, -7.88222f, -7.84628f, -7.80562f, -7.76025f, -7.71021f, -7.65552f, -7.59623f, -7.53235f, -7.46394f, -7.39104f, -7.31368f, -7.23191f, -7.14579f, -7.05537f, -6.9607f, -6.86183f, -6.75883f, -6.65176f, -6.54068f, -6.42566f, -6.30677f, -6.18408f, -6.05767f, -5.92761f, -5.79398f, -5.65685f, -5.51632f, -5.37247f, -5.22538f, -5.07515f, -4.92185f, -4.76559f, -4.60647f, -4.44456f, -4.27998f, -4.11282f, -3.94319f, -3.77117f, -3.59689f, -3.42044f, -3.24193f, -3.06147f, -2.87916f, -2.69512f, -2.50945f, -2.32228f, -2.1337f, -1.94384f, -1.75281f, -1.56072f, -1.3677f, -1.17384f, -0.979285f, -0.784137f, -0.588517f, -0.392541f, -0.19633f }; // gl_warp.c -- sky and water polygons //extern model_t *loadmodel; // Model.java String skyname; float skyrotate; float[] skyaxis = {0, 0, 0}; image_t[] sky_images = new image_t[6]; msurface_t warpface; static final int SUBDIVIDE_SIZE = 64; void BoundPoly(int numverts, float[][] verts, float[] mins, float[] maxs) { int i, j; float[] v; mins[0] = mins[1] = mins[2] = 9999; maxs[0] = maxs[1] = maxs[2] = -9999; for (i=0 ; i<numverts ; i++) { v = verts[i]; for (j=0 ; j<3 ; j++) { if (v[j] < mins[j]) mins[j] = v[j]; if (v[j] > maxs[j]) maxs[j] = v[j]; } } } void SubdividePolygon(int numverts, float[][] verts) { int i, j, k; float[] mins = {0, 0, 0}; float[] maxs = {0, 0, 0}; float m; float[] v = {0, 0, 0}; float[][] front = new float[64][3]; float[][] back = new float[64][3]; int f, b; float[] dist = new float[64]; float frac; float s, t; float[] total = {0, 0, 0}; float total_s, total_t; if (numverts > 60) Com.Error(Defines.ERR_DROP, "numverts = " + numverts); BoundPoly(numverts, verts, mins, maxs); // x,y und z for (i=0 ; i<3 ; i++) { m = (mins[i] + maxs[i]) * 0.5f; m = SUBDIVIDE_SIZE * (float)Math.floor(m / SUBDIVIDE_SIZE + 0.5f); if (maxs[i] - m < 8) continue; if (m - mins[i] < 8) continue; // cut it for (j=0 ; j<numverts ; j++) { dist[j] = verts[j][i] - m; } // wrap cases dist[j] = dist[0]; Math3D.VectorCopy(verts[0], verts[numverts]); f = b = 0; for (j=0 ; j<numverts ; j++) { v = verts[j]; if (dist[j] >= 0) { Math3D.VectorCopy(v, front[f]); f++; } if (dist[j] <= 0) { Math3D.VectorCopy(v, back[b]); b++; } if (dist[j] == 0 || dist[j+1] == 0) continue; if ( (dist[j] > 0) != (dist[j+1] > 0) ) { // clip point frac = dist[j] / (dist[j] - dist[j+1]); for (k=0 ; k<3 ; k++) front[f][k] = back[b][k] = v[k] + frac*(verts[j+1][k] - v[k]); f++; b++; } } SubdividePolygon(f, front); SubdividePolygon(b, back); return; } // add a point in the center to help keep warp valid // wird im Konstruktor erschlagen // poly = Hunk_Alloc (sizeof(glpoly_t) + ((numverts-4)+2) * VERTEXSIZE*sizeof(float)); // init polys glpoly_t poly = new glpoly_t(numverts + 2); poly.next = warpface.polys; warpface.polys = poly; poly.numverts = numverts + 2; Math3D.VectorClear(total); total_s = 0; total_t = 0; for (i=0 ; i<numverts ; i++) { Math3D.VectorCopy(verts[i], poly.verts[i+1]); s = Math3D.DotProduct(verts[i], warpface.texinfo.vecs[0]); t = Math3D.DotProduct(verts[i], warpface.texinfo.vecs[1]); total_s += s; total_t += t; Math3D.VectorAdd(total, verts[i], total); poly.verts[i+1][3] = s; poly.verts[i+1][4] = t; } Math3D.VectorScale(total, (1.0f/numverts), poly.verts[0]); poly.verts[0][3] = total_s/numverts; poly.verts[0][4] = total_t/numverts; // memcpy (poly.verts[i+1], poly.verts[1], sizeof(poly.verts[0])); System.arraycopy(poly.verts[1], 0, poly.verts[i+1], 0, poly.verts[1].length); // :-) precompilePolygon(poly); } /* ================ GL_SubdivideSurface Breaks a polygon up along axial 64 unit boundaries so that turbulent and sky warps can be done reasonably. ================ */ void GL_SubdivideSurface(msurface_t fa) { float[][] verts = new float[64][3]; int numverts; int i; int lindex; float[] vec; warpface = fa; // // convert edges back to a normal polygon // numverts = 0; for (i=0 ; i < fa.numedges ; i++) { lindex = loadmodel.surfedges[fa.firstedge + i]; if (lindex > 0) vec = loadmodel.vertexes[loadmodel.edges[lindex].v[0]].position; else vec = loadmodel.vertexes[loadmodel.edges[-lindex].v[1]].position; Math3D.VectorCopy(vec, verts[numverts]); numverts++; } SubdividePolygon(numverts, verts); } // ========================================================= //// speed up sin calculations - Ed // float r_turbsin[] = // { // #include "warpsin.h" // }; static final float TURBSCALE = (float)(256.0f / (2 * Math.PI)); /* ============= EmitWaterPolys Does a water warp on the pre-fragmented glpoly_t chain ============= */ void EmitWaterPolys(msurface_t fa) { glpoly_t p, bp; float[] v; int i; float s = 0; float t = 0; float os, ot; float scroll; float rdt = r_newrefdef.time; if ((fa.texinfo.flags & Defines.SURF_FLOWING) != 0) scroll = -64 * ( (r_newrefdef.time*0.5f) - (int)(r_newrefdef.time*0.5f) ); else scroll = 0; int index; FloatBuffer texCoord = globalPolygonInterleavedBuf; for (bp=fa.polys ; bp != null ; bp=bp.next) { p = bp; index = p.pos * POLYGON_STRIDE; for (i=0; i<p.numverts ; i++) { v = p.verts[i]; os = v[3]; ot = v[4]; s = os + Warp.SIN[(int)((ot * 0.125f + r_newrefdef.time) * TURBSCALE) & 255]; s += scroll; s *= (1.0f/64); t = ot + Warp.SIN[(int)((os * 0.125f + rdt) * TURBSCALE) & 255]; t *= (1.0f/64); texCoord.put(index, s); texCoord.put(index + 1, t); index += POLYGON_STRIDE; } gl.glDrawArrays(GL11.GL_TRIANGLE_FAN, p.pos, p.numverts); } } // =================================================================== float[][] skyclip = { { 1, 1, 0}, { 1, -1, 0}, { 0, -1, 1}, { 0, 1, 1}, { 1, 0, 1}, {-1, 0, 1} }; int c_sky; // 1 = s, 2 = t, 3 = 2048 int[][] st_to_vec = { {3,-1,2}, {-3,1,2}, {1,3,2}, {-1,-3,2}, {-2,-1,3}, // 0 degrees yaw, look straight up {2,-1,-3} // look straight down }; int[][] vec_to_st = { {-2,3,1}, {2,3,-1}, {1,3,2}, {-1,3,-2}, {-2,-1,3}, {-2,1,-3} }; float[][] skymins = new float[2][6]; float[][] skymaxs = new float[2][6]; float sky_min, sky_max; void DrawSkyPolygon (int nump, float[][] vecs) { int i,j; float[] v = {0, 0, 0}; float[] av = {0, 0, 0}; float s, t, dv; int axis; float[] vp; c_sky++; // decide which face it maps to Math3D.VectorCopy(Globals.vec3_origin, v); for (i=0; i<nump ; i++) { Math3D.VectorAdd(vecs[i], v, v); } av[0] = Math.abs(v[0]); av[1] = Math.abs(v[1]); av[2] = Math.abs(v[2]); if (av[0] > av[1] && av[0] > av[2]) { if (v[0] < 0) axis = 1; else axis = 0; } else if (av[1] > av[2] && av[1] > av[0]) { if (v[1] < 0) axis = 3; else axis = 2; } else { if (v[2] < 0) axis = 5; else axis = 4; } // project new texture coords for (i=0 ; i<nump ; i++) { j = vec_to_st[axis][2]; if (j > 0) dv = vecs[i][j - 1]; else dv = -vecs[i][-j - 1]; if (dv < 0.001f) continue; // don't divide by zero j = vec_to_st[axis][0]; if (j < 0) s = -vecs[i][-j -1] / dv; else s = vecs[i][j-1] / dv; j = vec_to_st[axis][1]; if (j < 0) t = -vecs[i][-j -1] / dv; else t = vecs[i][j-1] / dv; if (s < skymins[0][axis]) skymins[0][axis] = s; if (t < skymins[1][axis]) skymins[1][axis] = t; if (s > skymaxs[0][axis]) skymaxs[0][axis] = s; if (t > skymaxs[1][axis]) skymaxs[1][axis] = t; } } static final float ON_EPSILON = 0.1f; // point on plane side epsilon static final int MAX_CLIP_VERTS = 64; static final int SIDE_BACK = 1; static final int SIDE_FRONT = 0; static final int SIDE_ON = 2; float[] dists = new float[MAX_CLIP_VERTS]; int[] sides = new int[MAX_CLIP_VERTS]; float[][][][] newv = new float[6][2][MAX_CLIP_VERTS][3]; void ClipSkyPolygon(int nump, float[][] vecs, int stage) { float[] norm; float[] v; boolean front, back; float d, e; int[] newc = { 0, 0 }; int i, j; if (nump > MAX_CLIP_VERTS-2) Com.Error(Defines.ERR_DROP, "ClipSkyPolygon: MAX_CLIP_VERTS"); if (stage == 6) { // fully clipped, so draw it DrawSkyPolygon(nump, vecs); return; } front = back = false; norm = skyclip[stage]; for (i=0 ; i<nump ; i++) { d = Math3D.DotProduct(vecs[i], norm); if (d > ON_EPSILON) { front = true; sides[i] = SIDE_FRONT; } else if (d < -ON_EPSILON) { back = true; sides[i] = SIDE_BACK; } else sides[i] = SIDE_ON; dists[i] = d; } if (!front || !back) { // not clipped ClipSkyPolygon (nump, vecs, stage+1); return; } // clip it sides[i] = sides[0]; dists[i] = dists[0]; Math3D.VectorCopy(vecs[0], vecs[i]); newc[0] = newc[1] = 0; for (i=0; i<nump ; i++) { v = vecs[i]; switch (sides[i]) { case SIDE_FRONT: Math3D.VectorCopy(v, newv[stage][0][newc[0]]); newc[0]++; break; case SIDE_BACK: Math3D.VectorCopy(v, newv[stage][1][newc[1]]); newc[1]++; break; case SIDE_ON: Math3D.VectorCopy(v, newv[stage][0][newc[0]]); newc[0]++; Math3D.VectorCopy (v, newv[stage][1][newc[1]]); newc[1]++; break; } if (sides[i] == SIDE_ON || sides[i+1] == SIDE_ON || sides[i+1] == sides[i]) continue; d = dists[i] / (dists[i] - dists[i+1]); for (j=0 ; j<3 ; j++) { e = v[j] + d * (vecs[i + 1][j] - v[j]); newv[stage][0][newc[0]][j] = e; newv[stage][1][newc[1]][j] = e; } newc[0]++; newc[1]++; } // continue ClipSkyPolygon(newc[0], newv[stage][0], stage+1); ClipSkyPolygon(newc[1], newv[stage][1], stage+1); } float[][] verts = new float[MAX_CLIP_VERTS][3]; /* ================= R_AddSkySurface ================= */ void R_AddSkySurface(msurface_t fa) { int i; glpoly_t p; // calculate vertex values for sky box for (p=fa.polys ; p != null ; p=p.next) { for (i=0 ; i < p.numverts ; i++) { Math3D.VectorSubtract(p.verts[i], r_origin, verts[i]); } ClipSkyPolygon (p.numverts, verts, 0); } } /* ============== R_ClearSkyBox ============== */ void R_ClearSkyBox() { int i; for (i=0 ; i<6 ; i++) { skymins[0][i] = skymins[1][i] = 9999; skymaxs[0][i] = skymaxs[1][i] = -9999; } } void MakeSkyVec (float s, float t, int axis) { float[] v = {0, 0, 0}; float[] b = {0, 0, 0}; int j, k; b[0] = s*2300; b[1] = t*2300; b[2] = 2300; for (j=0 ; j<3 ; j++) { k = st_to_vec[axis][j]; if (k < 0) v[j] = -b[-k - 1]; else v[j] = b[k - 1]; } // avoid bilerp seam s = (s + 1) * 0.5f; t = (t + 1) * 0.5f; if (s < sky_min) s = sky_min; else if (s > sky_max) s = sky_max; if (t < sky_min) t = sky_min; else if (t > sky_max) t = sky_max; t = 1.0f - t; gl.glTexCoord2f (s, t); gl.glVertex3f(v[0], v[1], v[2]); } /* ============== R_DrawSkyBox ============== */ int[] skytexorder = {0,2,1,3,4,5}; void R_DrawSkyBox() { int i; if (skyrotate != 0) { // check for no sky at all for (i=0 ; i<6 ; i++) if (skymins[0][i] < skymaxs[0][i] && skymins[1][i] < skymaxs[1][i]) break; if (i == 6) return; // nothing visible } gl.glPushMatrix (); gl.glTranslatef (r_origin[0], r_origin[1], r_origin[2]); gl.glRotatef (r_newrefdef.time * skyrotate, skyaxis[0], skyaxis[1], skyaxis[2]); for (i=0 ; i<6 ; i++) { if (skyrotate != 0) { // hack, forces full sky to draw when rotating skymins[0][i] = -1; skymins[1][i] = -1; skymaxs[0][i] = 1; skymaxs[1][i] = 1; } if (skymins[0][i] >= skymaxs[0][i] || skymins[1][i] >= skymaxs[1][i]) continue; GL_Bind(sky_images[skytexorder[i]].texnum); gl.glBegin(GL11.GL_QUADS); MakeSkyVec(skymins[0][i], skymins[1][i], i); MakeSkyVec(skymins[0][i], skymaxs[1][i], i); MakeSkyVec(skymaxs[0][i], skymaxs[1][i], i); MakeSkyVec(skymaxs[0][i], skymins[1][i], i); gl.glEnd (); } gl.glPopMatrix (); } /* ============ R_SetSky ============ */ // 3dstudio environment map names String[] suf = {"rt", "bk", "lf", "ft", "up", "dn"}; protected void R_SetSky(String name, float rotate, float[] axis) { assert (axis.length == 3) : "vec3_t bug"; int i; String pathname; // strncpy (skyname, name, sizeof(skyname)-1); skyname = name; skyrotate = rotate; Math3D.VectorCopy(axis, skyaxis); for (i=0 ; i<6 ; i++) { // chop down rotating skies for less memory if (gl_skymip.value != 0 || skyrotate != 0) gl_picmip.value++; if ( qglColorTableEXT && gl_ext_palettedtexture.value != 0) { // Com_sprintf (pathname, sizeof(pathname), "env/%s%s.pcx", skyname, suf[i]); pathname = "env/" + skyname + suf[i] + ".pcx"; } else { // Com_sprintf (pathname, sizeof(pathname), "env/%s%s.tga", skyname, suf[i]); pathname = "env/" + skyname + suf[i] + ".tga"; } sky_images[i] = GL_FindImage(pathname, it_sky); if (sky_images[i] == null) sky_images[i] = r_notexture; if (gl_skymip.value != 0 || skyrotate != 0) { // take less memory gl_picmip.value--; sky_min = 1.0f / 256; sky_max = 255.0f / 256; } else { sky_min = 1.0f / 512; sky_max = 511.0f / 512; } } } } --- NEW FILE: Anorms.java --- /* * Anorms.java * Copyright (C) 2003 * * $Id: Anorms.java,v 1.1.2.1 2004/12/13 21:40:45 hzi Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ package jake2.render.lwjgl; /** * Anorms * * @author cwei */ public interface Anorms { final float[][] VERTEXNORMALS = { {-0.525731f, 0.000000f, 0.850651f}, {-0.442863f, 0.238856f, 0.864188f}, {-0.295242f, 0.000000f, 0.955423f}, {-0.309017f, 0.500000f, 0.809017f}, {-0.162460f, 0.262866f, 0.951056f}, {0.000000f, 0.000000f, 1.000000f}, {0.000000f, 0.850651f, 0.525731f}, {-0.147621f, 0.716567f, 0.681718f}, {0.147621f, 0.716567f, 0.681718f}, {0.000000f, 0.525731f, 0.850651f}, {0.309017f, 0.500000f, 0.809017f}, {0.525731f, 0.000000f, 0.850651f}, {0.295242f, 0.000000f, 0.955423f}, {0.442863f, 0.238856f, 0.864188f}, {0.162460f, 0.262866f, 0.951056f}, {-0.681718f, 0.147621f, 0.716567f}, {-0.809017f, 0.309017f, 0.500000f}, {-0.587785f, 0.425325f, 0.688191f}, {-0.850651f, 0.525731f, 0.000000f}, {-0.864188f, 0.442863f, 0.238856f}, {-0.716567f, 0.681718f, 0.147621f}, {-0.688191f, 0.587785f, 0.425325f}, {-0.500000f, 0.809017f, 0.309017f}, {-0.238856f, 0.864188f, 0.442863f}, {-0.425325f, 0.688191f, 0.587785f}, {-0.716567f, 0.681718f, -0.147621f}, {-0.500000f, 0.809017f, ... [truncated message content] |
From: Holger Z. <hz...@us...> - 2004-12-13 21:40:58
|
Update of /cvsroot/jake2/jake2/src/jake2/sound/joal In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1434/src/jake2/sound/joal Added Files: Tag: LWJGL_IMPORT LWJGLSoundImpl.java Log Message: import of LWJGL code --- NEW FILE: LWJGLSoundImpl.java --- /* * LWJGLSoundImpl.java * Copyright (C) 2004 * * $Id: LWJGLSoundImpl.java,v 1.1.2.1 2004/12/13 21:40:46 hzi Exp $ */ package jake2.sound.joal; import jake2.Defines; import jake2.Globals; import jake2.client.CL; import jake2.game.Cmd; import jake2.game.Game; import jake2.game.cvar_t; import jake2.game.entity_state_t; import jake2.qcommon.Com; import jake2.qcommon.Cvar; import jake2.qcommon.FS; import jake2.qcommon.xcommand_t; import jake2.sound.S; import jake2.sound.Sound; import jake2.sound.WaveLoader; import jake2.sound.sfx_t; import jake2.sound.sfxcache_t; import jake2.util.Lib; import jake2.util.Math3D; import jake2.util.Vargs; import java.io.IOException; import java.io.RandomAccessFile; import java.nio.ByteBuffer; import java.nio.FloatBuffer; import java.nio.IntBuffer; import java.util.Hashtable; import java.util.Iterator; import java.util.Map; import org.lwjgl.BufferUtils; import org.lwjgl.LWJGLException; import org.lwjgl.openal.AL; import org.lwjgl.openal.AL10; import org.lwjgl.openal.ALC; import org.lwjgl.openal.OpenALException; import org.lwjgl.openal.eax.EAX20; import org.lwjgl.openal.eax.EAXListenerProperties; /** * LWJGLSoundImpl */ public final class LWJGLSoundImpl implements Sound { static { S.register(new LWJGLSoundImpl()); }; private boolean hasEAX; private cvar_t s_volume; private static final int MAX_SFX = Defines.MAX_SOUNDS * 2; private static final int MAX_CHANNELS = 32; private IntBuffer buffers = BufferUtils.createIntBuffer(MAX_SFX); private IntBuffer sources = BufferUtils.createIntBuffer(MAX_CHANNELS); private Channel[] channels = null; private int num_channels = 0; // singleton private LWJGLSoundImpl() { } /* (non-Javadoc) * @see jake2.sound.SoundImpl#Init() */ public boolean Init() { try { initOpenAL(); checkError(); initOpenALExtensions(); } catch (OpenALException e) { Com.Printf(e.getMessage() + '\n'); return false; } catch (Exception e) { Com.DPrintf(e.getMessage() + '\n'); return false; } AL10.alGenBuffers(buffers); s_volume = Cvar.Get("s_volume", "0.7", Defines.CVAR_ARCHIVE); initChannels(); AL10.alDistanceModel(AL10.AL_INVERSE_DISTANCE_CLAMPED); Cmd.AddCommand("play", new xcommand_t() { public void execute() { Play(); } }); Cmd.AddCommand("stopsound", new xcommand_t() { public void execute() { StopAllSounds(); } }); Cmd.AddCommand("soundlist", new xcommand_t() { public void execute() { SoundList(); } }); Cmd.AddCommand("soundinfo", new xcommand_t() { public void execute() { SoundInfo_f(); } }); num_sfx = 0; Com.Printf("sound sampling rate: 44100Hz\n"); StopAllSounds(); Com.Printf("------------------------------------\n"); return true; } private void initOpenAL() throws OpenALException { try { AL.create(); } catch (LWJGLException e) { throw new OpenALException(e); } String deviceName = null; String os = System.getProperty("os.name"); if (os.startsWith("Windows")) { deviceName = "DirectSound3D"; } String deviceSpecifier = ALC.alcGetString(ALC.ALC_DEVICE_SPECIFIER); String defaultSpecifier = ALC.alcGetString(ALC.ALC_DEFAULT_DEVICE_SPECIFIER); Com.Printf(os + " using " + ((deviceName == null) ? defaultSpecifier : deviceName) + '\n'); // Check for an error. if (ALC.alcGetError() != ALC.ALC_NO_ERROR) { Com.DPrintf("Error with SoundDevice"); } } private void initOpenALExtensions() throws OpenALException { if (AL10.alIsExtensionPresent("EAX2.0")) { Com.Printf("... using EAX2.0\n"); hasEAX=true; } else { Com.Printf("... EAX2.0 not found\n"); hasEAX=false; } } void exitOpenAL() { // Release the context and the device. AL.destroy(); } private void initChannels() { // create channels channels = new Channel[MAX_CHANNELS]; int sourceId; IntBuffer tmp = BufferUtils.createIntBuffer(1); int error; for (int i = 0; i < MAX_CHANNELS; i++) { AL10.alGenSources(tmp); sourceId = tmp.get(0); //if ((error = al.alGetError()) != AL.AL_NO_ERROR) break; if (sourceId <= 0) break; sources.put(i, sourceId); channels[i] = new Channel(sourceId); num_channels++; // set default values for AL sources AL10.alSourcef (sourceId, AL10.AL_GAIN, s_volume.value); AL10.alSourcef (sourceId, AL10.AL_PITCH, 1.0f); AL10.alSourcei (sourceId, AL10.AL_SOURCE_ABSOLUTE, AL10.AL_TRUE); AL10.nalSourcefv(sourceId, AL10.AL_VELOCITY, NULLVECTOR_BUFFER,0); AL10.alSourcei (sourceId, AL10.AL_LOOPING, AL10.AL_FALSE); AL10.alSourcef (sourceId, AL10.AL_REFERENCE_DISTANCE, 300.0f); AL10.alSourcef (sourceId, AL10.AL_MIN_GAIN, 0.0005f); AL10.alSourcef (sourceId, AL10.AL_MAX_GAIN, 1.0f); } Com.Printf("... using " + num_channels + " channels\n"); } /* (non-Javadoc) * @see jake2.sound.SoundImpl#RegisterSound(jake2.sound.sfx_t) */ private void initBuffer(sfx_t sfx) { if (sfx.cache == null ) { //System.out.println(sfx.name + " " + sfx.cache.length+ " " + sfx.cache.loopstart + " " + sfx.cache.speed + " " + sfx.cache.stereo + " " + sfx.cache.width); return; } int format = AL10.AL_FORMAT_MONO16; ByteBuffer data = BufferUtils.createByteBuffer(sfx.cache.data.length); data.put(sfx.cache.data); data.rewind(); int freq = sfx.cache.speed; AL10.alBufferData( buffers.get(sfx.bufferId), format, data, freq); } private void checkError() { Com.DPrintf("AL Error: " + alErrorString() +'\n'); } private String alErrorString(){ int error; String message = ""; if ((error = AL10.alGetError()) != AL10.AL_NO_ERROR) { switch(error) { case AL10.AL_INVALID_OPERATION: message = "invalid operation"; break; case AL10.AL_INVALID_VALUE: message = "invalid value"; break; case AL10.AL_INVALID_ENUM: message = "invalid enum"; break; case AL10.AL_INVALID_NAME: message = "invalid name"; break; default: message = "" + error; } } return message; } /* (non-Javadoc) * @see jake2.sound.SoundImpl#Shutdown() */ public void Shutdown() { StopAllSounds(); AL10.alDeleteSources(sources); AL10.alDeleteBuffers(buffers); exitOpenAL(); Cmd.RemoveCommand("play"); Cmd.RemoveCommand("stopsound"); Cmd.RemoveCommand("soundlist"); Cmd.RemoveCommand("soundinfo"); // free all sounds for (int i = 0; i < num_sfx; i++) { if (known_sfx[i].name == null) continue; known_sfx[i].clear(); } num_sfx = 0; num_channels = 0; } //private final static float[] NULLVECTOR = {0, 0, 0}; private final static FloatBuffer NULLVECTOR_BUFFER=Lib.newFloatBuffer(3); private float[] entityOrigin = {0, 0, 0}; private float[] sourceOrigin = {0, 0, 0}; /* (non-Javadoc) * @see jake2.sound.SoundImpl#StartSound(float[], int, int, jake2.sound.sfx_t, float, float, float) */ public void StartSound(float[] origin, int entnum, int entchannel, sfx_t sfx, float fvol, float attenuation, float timeofs) { if (sfx == null) return; if (sfx.name.charAt(0) == '*') sfx = RegisterSexedSound(Globals.cl_entities[entnum].current, sfx.name); if (LoadSound(sfx) == null) return; // can't load sound if (attenuation != Defines.ATTN_STATIC) attenuation *= 0.5f; Channel ch = pickChannel(entnum, entchannel, buffers.get(sfx.bufferId), attenuation); if (ch == null) return; if (entnum == Globals.cl.playernum + 1) { ch.addListener(); } else if (origin != null) { ch.addFixed(origin); } else { ch.addDynamic(entnum); } } Channel pickChannel(int entnum, int entchannel, int bufferId, float rolloff) { Channel ch = null; int state; int i; for (i = 0; i < num_channels; i++) { ch = channels[i]; if (entchannel != 0 && ch.entnum == entnum && ch.entchannel == entchannel) { // always override sound from same entity break; } // don't let monster sounds override player sounds if ((ch.entnum == Globals.cl.playernum+1) && (entnum != Globals.cl.playernum+1) && ch.bufferId != -1) continue; // looking for a free AL source if (!ch.active) { break; } } if (i == num_channels) return null; ch.entnum = entnum; ch.entchannel = entchannel; if (ch.bufferId != bufferId) { ch.bufferId = bufferId; ch.bufferChanged = true; } ch.rolloff = rolloff * 2; ch.active = true; ch.modified = true; return ch; } private float[] listenerOrigin = {0, 0, 0}; private FloatBuffer listenerOriginBuffer=FloatBuffer.wrap(listenerOrigin); private float[] listenerOrientation = {0, 0, 0, 0, 0, 0}; private FloatBuffer listenerOrientationBuffer=FloatBuffer.wrap(listenerOrientation); private IntBuffer eaxEnv = Lib.newIntBuffer(1); private int currentEnv = -1; private boolean changeEnv = true; // TODO workaround for JOAL-bug // should be EAX.LISTENER private final static int EAX_LISTENER = 0; // should be EAX.SOURCE private final static int EAX_SOURCE = 1; /* (non-Javadoc) * @see jake2.sound.SoundImpl#Update(float[], float[], float[], float[]) */ public void Update(float[] origin, float[] forward, float[] right, float[] up) { convertVector(origin, listenerOrigin); AL10.nalListenerfv(AL10.AL_POSITION, listenerOriginBuffer,0); convertOrientation(forward, up, listenerOrientation); AL10.nalListenerfv(AL10.AL_ORIENTATION, listenerOrientationBuffer,0); if (hasEAX) { // workaround for environment initialisation if (currentEnv == -1) { eaxEnv.put(0, EAX20.EAX_ENVIRONMENT_UNDERWATER); EAX20.eaxSet(EAX_LISTENER, EAXListenerProperties.EAXLISTENER_ENVIRONMENT | EAXListenerProperties.EAXLISTENER_DEFERRED, 0, eaxEnv, 4); changeEnv = true; } if ((Game.gi.pointcontents.pointcontents(origin)& Defines.MASK_WATER)!= 0) { changeEnv = currentEnv != EAX20.EAX_ENVIRONMENT_UNDERWATER; currentEnv = EAX20.EAX_ENVIRONMENT_UNDERWATER; } else { changeEnv = currentEnv != EAX20.EAX_ENVIRONMENT_GENERIC; currentEnv = EAX20.EAX_ENVIRONMENT_GENERIC; } if (changeEnv) { eaxEnv.put(0, currentEnv); EAX20.eaxSet(EAX_LISTENER, EAXListenerProperties.EAXLISTENER_ENVIRONMENT | EAXListenerProperties.EAXLISTENER_DEFERRED, 0, eaxEnv, 4); } } AddLoopSounds(origin); playChannels(listenerOrigin); } Map looptable = new Hashtable(MAX_CHANNELS); /* ================== S_AddLoopSounds Entities with a ->sound field will generated looped sounds that are automatically started, stopped, and merged together as the entities are sent to the client ================== */ void AddLoopSounds(float[] listener) { if (Globals.cl_paused.value != 0.0f) { removeUnusedLoopSounds(); return; } if (Globals.cls.state != Globals.ca_active) { removeUnusedLoopSounds(); return; } if (!Globals.cl.sound_prepped) { removeUnusedLoopSounds(); return; } Channel ch; sfx_t sfx; sfxcache_t sc; int num; entity_state_t ent; Object key; int sound = 0; for (int i=0 ; i<Globals.cl.frame.num_entities ; i++) { num = (Globals.cl.frame.parse_entities + i)&(Defines.MAX_PARSE_ENTITIES-1); ent = Globals.cl_parse_entities[num]; sound = ent.sound; if (sound == 0) continue; key = new Integer(ent.number); ch = (Channel)looptable.get(key); if (ch != null) { // keep on looping ch.autosound = true; ch.origin = ent.origin; continue; } sfx = Globals.cl.sound_precache[sound]; if (sfx == null) continue; // bad sound effect sc = sfx.cache; if (sc == null) continue; // allocate a channel ch = pickChannel(0, 0, buffers.get(sfx.bufferId), 6); if (ch == null) break; ch.addFixed(ent.origin); ch.autosound = true; looptable.put(key, ch); AL10.alSourcei(ch.sourceId, AL10.AL_LOOPING, AL10.AL_TRUE); } removeUnusedLoopSounds(); } void removeUnusedLoopSounds() { Channel ch; // stop unused loopsounds for (Iterator iter = looptable.values().iterator(); iter.hasNext();) { ch = (Channel)iter.next(); if (!ch.autosound) { AL10.alSourceStop(ch.sourceId); AL10.alSourcei(ch.sourceId, AL10.AL_LOOPING, AL10.AL_FALSE); iter.remove(); ch.clear(); } } } void playChannels(float[] listenerOrigin) { float[] sourceOrigin = {0, 0, 0}; FloatBuffer sourceOriginBuffer=FloatBuffer.wrap(sourceOrigin); float[] entityOrigin = {0, 0, 0}; Channel ch; int sourceId; int state; for (int i = 0; i < num_channels; i++) { ch = channels[i]; if (ch.active) { sourceId = ch.sourceId; switch (ch.type) { case Channel.LISTENER: Math3D.VectorCopy(listenerOrigin, sourceOrigin); break; case Channel.DYNAMIC: CL.GetEntitySoundOrigin(ch.entity, entityOrigin); convertVector(entityOrigin, sourceOrigin); break; case Channel.FIXED: convertVector(ch.origin, sourceOrigin); break; } if (ch.modified) { if (ch.bufferChanged) AL10.alSourcei (sourceId, AL10.AL_BUFFER, ch.bufferId); AL10.alSourcef (sourceId, AL10.AL_GAIN, s_volume.value); AL10.alSourcef (sourceId, AL10.AL_ROLLOFF_FACTOR, ch.rolloff); AL10.nalSourcefv(sourceId, AL10.AL_POSITION, sourceOriginBuffer,0); AL10.alSourcePlay(sourceId); ch.modified = false; } else { state = AL10.alGetSourcei(ch.sourceId, AL10.AL_SOURCE_STATE); if (state == AL10.AL_PLAYING) { AL10.nalSourcefv(sourceId, AL10.AL_POSITION, sourceOriginBuffer,0); } else { ch.clear(); } } ch.autosound = false; } } } /* (non-Javadoc) * @see jake2.sound.SoundImpl#StopAllSounds() */ public void StopAllSounds() { for (int i = 0; i < num_channels; i++) { AL10.alSourceStop(sources.get(i)); AL10.alSourcei(sources.get(i), AL10.AL_BUFFER, 0); channels[i].clear(); } } static void convertVector(float[] from, float[] to) { to[0] = from[0]; to[1] = from[2]; to[2] = -from[1]; } static void convertOrientation(float[] forward, float[] up, float[] orientation) { orientation[0] = forward[0]; orientation[1] = forward[2]; orientation[2] = -forward[1]; orientation[3] = up[0]; orientation[4] = up[2]; orientation[5] = -up[1]; } /* (non-Javadoc) * @see jake2.sound.Sound#getName() */ public String getName() { return "lwjgl_joal"; } int s_registration_sequence; boolean s_registering; /* (non-Javadoc) * @see jake2.sound.Sound#BeginRegistration() */ public void BeginRegistration() { s_registration_sequence++; s_registering = true; } /* (non-Javadoc) * @see jake2.sound.Sound#RegisterSound(java.lang.String) */ public sfx_t RegisterSound(String name) { sfx_t sfx = FindName(name, true); sfx.registration_sequence = s_registration_sequence; if (!s_registering) LoadSound(sfx); return sfx; } /* (non-Javadoc) * @see jake2.sound.Sound#EndRegistration() */ public void EndRegistration() { int i; sfx_t sfx; int size; // free any sounds not from this registration sequence for (i = 0; i < num_sfx; i++) { sfx = known_sfx[i]; if (sfx.name == null) continue; if (sfx.registration_sequence != s_registration_sequence) { // don't need this sound sfx.clear(); } } // load everything in for (i = 0; i < num_sfx; i++) { sfx = known_sfx[i]; if (sfx.name == null) continue; LoadSound(sfx); } s_registering = false; } sfx_t RegisterSexedSound(entity_state_t ent, String base) { sfx_t sfx = null; // determine what model the client is using // TODO configstrings for player male and female are wrong String model = "male"; int n = Globals.CS_PLAYERSKINS + ent.number - 1; if (Globals.cl.configstrings[n] != null) { int p = Globals.cl.configstrings[n].indexOf('\\'); if (p >= 0) { p++; model = Globals.cl.configstrings[n].substring(p); //strcpy(model, p); p = model.indexOf('/'); if (p > 0) model = model.substring(0, p); } } // if we can't figure it out, they're male if (model == null || model.length() == 0) model = "male"; // see if we already know of the model specific sound String sexedFilename = "#players/" + model + "/" + base.substring(1); //Com_sprintf (sexedFilename, sizeof(sexedFilename), "#players/%s/%s", model, base+1); sfx = FindName(sexedFilename, false); if (sfx == null) { // no, so see if it exists RandomAccessFile f = null; try { f = FS.FOpenFile(sexedFilename.substring(1)); } catch (IOException e) {} if (f != null) { // yes, close the file and register it try { FS.FCloseFile(f); } catch (IOException e1) {} sfx = RegisterSound(sexedFilename); } else { // no, revert to the male sound in the pak0.pak String maleFilename = "player/male/" + base.substring(1); sfx = AliasName(sexedFilename, maleFilename); } } return sfx; } static sfx_t[] known_sfx = new sfx_t[MAX_SFX]; static { for (int i = 0; i< known_sfx.length; i++) known_sfx[i] = new sfx_t(); } static int num_sfx; sfx_t FindName(String name, boolean create) { int i; sfx_t sfx = null; if (name == null) Com.Error(Defines.ERR_FATAL, "S_FindName: NULL\n"); if (name.length() == 0) Com.Error(Defines.ERR_FATAL, "S_FindName: empty name\n"); if (name.length() >= Defines.MAX_QPATH) Com.Error(Defines.ERR_FATAL, "Sound name too long: " + name); // see if already loaded for (i = 0; i < num_sfx; i++) if (name.equals(known_sfx[i].name)) { return known_sfx[i]; } if (!create) return null; // find a free sfx for (i = 0; i < num_sfx; i++) if (known_sfx[i].name == null) // registration_sequence < s_registration_sequence) break; if (i == num_sfx) { if (num_sfx == MAX_SFX) Com.Error(Defines.ERR_FATAL, "S_FindName: out of sfx_t"); num_sfx++; } sfx = known_sfx[i]; sfx.clear(); sfx.name = name; sfx.registration_sequence = s_registration_sequence; sfx.bufferId = i; return sfx; } /* ================== S_AliasName ================== */ sfx_t AliasName(String aliasname, String truename) { sfx_t sfx = null; String s; int i; s = new String(truename); // find a free sfx for (i=0 ; i < num_sfx ; i++) if (known_sfx[i].name == null) break; if (i == num_sfx) { if (num_sfx == MAX_SFX) Com.Error(Defines.ERR_FATAL, "S_FindName: out of sfx_t"); num_sfx++; } sfx = known_sfx[i]; sfx.clear(); sfx.name = new String(aliasname); sfx.registration_sequence = s_registration_sequence; sfx.truename = s; // set the AL bufferId sfx.bufferId = i; return sfx; } /* ============== S_LoadSound ============== */ public sfxcache_t LoadSound(sfx_t s) { sfxcache_t sc = WaveLoader.LoadSound(s); initBuffer(s); return sc; } /* (non-Javadoc) * @see jake2.sound.Sound#StartLocalSound(java.lang.String) */ public void StartLocalSound(String sound) { sfx_t sfx; sfx = RegisterSound(sound); if (sfx == null) { Com.Printf("S_StartLocalSound: can't cache " + sound + "\n"); return; } StartSound(null, Globals.cl.playernum + 1, 0, sfx, 1, 1, 0); } /* (non-Javadoc) * @see jake2.sound.Sound#RawSamples(int, int, int, int, byte[]) */ public void RawSamples(int samples, int rate, int width, int channels, byte[] data) { // TODO implement RawSamples } /* =============================================================================== console functions =============================================================================== */ void Play() { int i; String name; sfx_t sfx; i = 1; while (i < Cmd.Argc()) { name = new String(Cmd.Argv(i)); if (name.indexOf('.') == -1) name += ".wav"; sfx = RegisterSound(name); StartSound(null, Globals.cl.playernum + 1, 0, sfx, 1.0f, 1.0f, 0.0f); i++; } } void SoundList() { int i; sfx_t sfx; sfxcache_t sc; int size, total; total = 0; for (i = 0; i < num_sfx; i++) { sfx = known_sfx[i]; if (sfx.registration_sequence == 0) continue; sc = sfx.cache; if (sc != null) { size = sc.length * sc.width * (sc.stereo + 1); total += size; if (sc.loopstart >= 0) Com.Printf("L"); else Com.Printf(" "); Com.Printf("(%2db) %6i : %s\n", new Vargs(3).add(sc.width * 8).add(size).add(sfx.name)); } else { if (sfx.name.charAt(0) == '*') Com.Printf(" placeholder : " + sfx.name + "\n"); else Com.Printf(" not loaded : " + sfx.name + "\n"); } } Com.Printf("Total resident: " + total + "\n"); } void SoundInfo_f() { Com.Printf("%5d stereo\n", new Vargs(1).add(1)); Com.Printf("%5d samples\n", new Vargs(1).add(22050)); Com.Printf("%5d samplebits\n", new Vargs(1).add(16)); Com.Printf("%5d speed\n", new Vargs(1).add(44100)); } } |
From: Holger Z. <hz...@us...> - 2004-12-13 21:40:56
|
Update of /cvsroot/jake2/jake2/src/jake2/render/fastjogl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1434/src/jake2/render/fastjogl Modified Files: Tag: LWJGL_IMPORT Main.java Log Message: import of LWJGL code Index: Main.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/render/fastjogl/Main.java,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.2.2.1 diff -C2 -d -r1.1.2.2 -r1.1.2.2.2.1 *** Main.java 6 Sep 2004 19:39:17 -0000 1.1.2.2 --- Main.java 13 Dec 2004 21:40:46 -0000 1.1.2.2.2.1 *************** *** 488,492 **** FloatBuffer sourceVertices = particle_t.vertexArray; ! IntBuffer sourceColors = particle_t.colorArray; for (int j = 0, i = 0; i < num_particles; i++) { origin_x = sourceVertices.get(j++); --- 488,492 ---- FloatBuffer sourceVertices = particle_t.vertexArray; ! IntBuffer sourceColors = particle_t.colorArray.asIntBuffer(); for (int j = 0, i = 0; i < num_particles; i++) { origin_x = sourceVertices.get(j++); |
From: Holger Z. <hz...@us...> - 2004-12-13 21:40:55
|
Update of /cvsroot/jake2/jake2/src/jake2/client In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1434/src/jake2/client Modified Files: Tag: LWJGL_IMPORT VID.java V.java particle_t.java refexport_t.java Log Message: import of LWJGL code Index: particle_t.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/client/particle_t.java,v retrieving revision 1.1.1.1.2.1 retrieving revision 1.1.1.1.2.1.2.1 diff -C2 -d -r1.1.1.1.2.1 -r1.1.1.1.2.1.2.1 *** particle_t.java 9 Jul 2004 08:38:23 -0000 1.1.1.1.2.1 --- particle_t.java 13 Dec 2004 21:40:45 -0000 1.1.1.1.2.1.2.1 *************** *** 32,36 **** public static FloatBuffer vertexArray = Lib.newFloatBuffer(Defines.MAX_PARTICLES * 3); ! public static IntBuffer colorArray = Lib.newIntBuffer(Defines.MAX_PARTICLES, ByteOrder.LITTLE_ENDIAN); public static int[] colorTable = new int[256]; --- 32,37 ---- public static FloatBuffer vertexArray = Lib.newFloatBuffer(Defines.MAX_PARTICLES * 3); ! //public static IntBuffer colorArray = Lib.newIntBuffer(Defines.MAX_PARTICLES, ByteOrder.LITTLE_ENDIAN); ! public static ByteBuffer colorArray = Lib.newByteBuffer(Defines.MAX_PARTICLES*Lib.SIZEOF_INT, ByteOrder.LITTLE_ENDIAN); public static int[] colorTable = new int[256]; Index: VID.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/client/VID.java,v retrieving revision 1.4.2.2 retrieving revision 1.4.2.2.2.1 diff -C2 -d -r1.4.2.2 -r1.4.2.2.2.1 *** VID.java 6 Sep 2004 19:39:13 -0000 1.4.2.2 --- VID.java 13 Dec 2004 21:40:45 -0000 1.4.2.2.2.1 *************** *** 34,38 **** import jake2.sound.S; import jake2.sys.IN; - import jake2.sys.KBD; import jake2.util.Vargs; --- 34,37 ---- *************** *** 156,160 **** { if (Globals.re != null) { ! KBD.Close(); IN.Shutdown(); } --- 155,159 ---- { if (Globals.re != null) { ! Globals.re.getKeyboardHandler().Close(); IN.Shutdown(); } *************** *** 174,178 **** if ( reflib_active ) { ! KBD.Close(); IN.Shutdown(); --- 173,177 ---- if ( reflib_active ) { ! Globals.re.getKeyboardHandler().Close(); IN.Shutdown(); *************** *** 222,226 **** /* Init KBD */ ! KBD.Init(); Com.Printf( "------------------------------------\n"); --- 221,225 ---- /* Init KBD */ ! Globals.re.getKeyboardHandler().Init(); Com.Printf( "------------------------------------\n"); *************** *** 296,300 **** { /* Create the video variables so we know how to start the graphics drivers */ ! vid_ref = Cvar.Get("vid_ref", "fastjogl", CVAR_ARCHIVE); vid_xpos = Cvar.Get("vid_xpos", "3", CVAR_ARCHIVE); vid_ypos = Cvar.Get("vid_ypos", "22", CVAR_ARCHIVE); --- 295,300 ---- { /* Create the video variables so we know how to start the graphics drivers */ ! //vid_ref = Cvar.Get("vid_ref", "fastjogl", CVAR_ARCHIVE); ! vid_ref = Cvar.Get("vid_ref", "lwjgl", CVAR_ARCHIVE); vid_xpos = Cvar.Get("vid_xpos", "3", CVAR_ARCHIVE); vid_ypos = Cvar.Get("vid_ypos", "22", CVAR_ARCHIVE); *************** *** 330,334 **** if ( reflib_active ) { ! KBD.Close(); IN.Shutdown(); --- 330,334 ---- if ( reflib_active ) { ! Globals.re.getKeyboardHandler().Close(); IN.Shutdown(); *************** *** 346,349 **** --- 346,350 ---- static final int REF_OPENGL_JOGL = 0; static final int REF_OPENGL_FASTJOGL =1; + static final int REF_OPENGL_LWJGL =2; static cvar_t gl_mode; *************** *** 532,535 **** --- 533,542 ---- vid_ref.modified = true; break; + case REF_OPENGL_LWJGL : + Cvar.Set( "vid_ref", "lwjgl" ); + Cvar.Set( "gl_driver", "lwjgl" ); + if (gl_driver.modified) + vid_ref.modified = true; + break; } *************** *** 566,569 **** --- 573,577 ---- "[OpenGL jogl ]", "[OpenGL fastjogl]", + "[OpenGL lwjgl]", null }; *************** *** 659,662 **** --- 667,675 ---- s_ref_list[0].curvalue = s_ref_list[1].curvalue = REF_OPENGL_FASTJOGL; } + else if ( vid_ref.string.equalsIgnoreCase("lwjgl")) + { + s_current_menu_index = OPENGL_MENU; + s_ref_list[0].curvalue = s_ref_list[1].curvalue = REF_OPENGL_LWJGL; + } // else if (strcmp( vid_ref->string, "softx" ) == 0 ) // { Index: V.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/client/V.java,v retrieving revision 1.1.1.1.2.1 retrieving revision 1.1.1.1.2.1.2.1 diff -C2 -d -r1.1.1.1.2.1 -r1.1.1.1.2.1.2.1 *** V.java 9 Jul 2004 08:38:24 -0000 1.1.1.1.2.1 --- V.java 13 Dec 2004 21:40:45 -0000 1.1.1.1.2.1.2.1 *************** *** 29,33 **** import jake2.game.Cmd; import jake2.game.cvar_t; ! import jake2.qcommon.*; import jake2.sys.Sys; import jake2.util.Math3D; --- 29,35 ---- import jake2.game.Cmd; import jake2.game.cvar_t; ! import jake2.qcommon.Com; ! import jake2.qcommon.Cvar; ! import jake2.qcommon.xcommand_t; import jake2.sys.Sys; import jake2.util.Math3D; *************** *** 106,110 **** int c = particle_t.colorTable[color]; c |= (int)(alpha * 255) << 24; ! particle_t.colorArray.put(i, c); i *= 3; --- 108,112 ---- int c = particle_t.colorTable[color]; c |= (int)(alpha * 255) << 24; ! particle_t.colorArray.asIntBuffer().put(i, c); i *= 3; Index: refexport_t.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/client/refexport_t.java,v retrieving revision 1.1.1.1.2.1 retrieving revision 1.1.1.1.2.1.2.1 diff -C2 -d -r1.1.1.1.2.1 -r1.1.1.1.2.1.2.1 *** refexport_t.java 6 Sep 2004 19:39:13 -0000 1.1.1.1.2.1 --- refexport_t.java 13 Dec 2004 21:40:45 -0000 1.1.1.1.2.1.2.1 *************** *** 30,33 **** --- 30,34 ---- import jake2.render.image_t; import jake2.render.model_t; + import jake2.sys.KBD; import java.awt.Dimension; *************** *** 108,110 **** --- 109,113 ---- DisplayMode[] getModeList(); + + KBD getKeyboardHandler(); } |
From: Holger Z. <hz...@us...> - 2004-12-13 21:40:19
|
Update of /cvsroot/jake2/jake2/src/jake2/render/lwjgl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1364/src/jake2/render/lwjgl Log Message: Directory /cvsroot/jake2/jake2/src/jake2/render/lwjgl added to the repository --> Using per-directory sticky tag `LWJGL_IMPORT' |
From: Holger Z. <hz...@us...> - 2004-12-08 09:58:44
|
Update of /cvsroot/jake2/jake2/src/jake2/render/jogl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4912/src/jake2/render/jogl Modified Files: Main.java Log Message: print jogl version during initialization Index: Main.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/render/jogl/Main.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Main.java 16 Jul 2004 10:11:35 -0000 1.5 --- Main.java 8 Dec 2004 09:58:34 -0000 1.6 *************** *** 42,45 **** --- 42,46 ---- import net.java.games.jogl.GL; + import net.java.games.jogl.Version; /** *************** *** 1109,1112 **** --- 1110,1114 ---- ** get our various GL strings */ + VID.Printf(Defines.PRINT_ALL, "JOGL_VERSION: " + Version.getVersion() + '\n'); gl_config.vendor_string = gl.glGetString(GL.GL_VENDOR); VID.Printf(Defines.PRINT_ALL, "GL_VENDOR: " + gl_config.vendor_string + '\n'); |
From: Holger Z. <hz...@us...> - 2004-12-08 09:58:43
|
Update of /cvsroot/jake2/jake2/src/jake2/render/fastjogl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4912/src/jake2/render/fastjogl Modified Files: Main.java Log Message: print jogl version during initialization Index: Main.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/render/fastjogl/Main.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Main.java 19 Jul 2004 19:39:57 -0000 1.4 --- Main.java 8 Dec 2004 09:58:34 -0000 1.5 *************** *** 44,47 **** --- 44,48 ---- import net.java.games.jogl.GL; + import net.java.games.jogl.Version; /** *************** *** 1114,1117 **** --- 1115,1119 ---- ** get our various GL strings */ + VID.Printf(Defines.PRINT_ALL, "JOGL_VERSION: " + Version.getVersion() + '\n'); gl_config.vendor_string = gl.glGetString(GL.GL_VENDOR); VID.Printf(Defines.PRINT_ALL, "GL_VENDOR: " + gl_config.vendor_string + '\n'); |
From: Holger Z. <hz...@us...> - 2004-12-06 14:23:16
|
Update of /cvsroot/jake2/jake2/src/jake2/server In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26679/src/jake2/server Modified Files: SV_USER.java Log Message: Index: SV_USER.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/server/SV_USER.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** SV_USER.java 22 Sep 2004 19:22:12 -0000 1.6 --- SV_USER.java 6 Dec 2004 14:23:04 -0000 1.7 *************** *** 524,528 **** for (; i < SV_USER.ucmds.length; i++) { u = SV_USER.ucmds[i]; ! if (0 == Lib.strcmp(Cmd.Argv(0), u.name)) { u.r.run(); break; --- 524,528 ---- for (; i < SV_USER.ucmds.length; i++) { u = SV_USER.ucmds[i]; ! if (Cmd.Argv(0).equals(u.name)) { u.r.run(); break; |
From: Holger Z. <hz...@us...> - 2004-12-06 13:47:24
|
Update of /cvsroot/jake2/jake2/src/jake2/util In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18833/src/jake2/util Modified Files: Lib.java Log Message: bugfix: wrong length calculation Index: Lib.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/util/Lib.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** Lib.java 7 Nov 2004 19:30:12 -0000 1.9 --- Lib.java 6 Dec 2004 13:47:02 -0000 1.10 *************** *** 271,275 **** public static String CtoJava(byte[] old, int offset, int maxLenght) { int i; ! for (i = offset; old[i] != 0 && i < maxLenght; i++); return new String(old, offset, i - offset); } --- 271,275 ---- public static String CtoJava(byte[] old, int offset, int maxLenght) { int i; ! for (i = offset; old[i] != 0 && (i - offset) < maxLenght; i++); return new String(old, offset, i - offset); } |
From: Carsten W. <ca...@us...> - 2004-11-10 20:41:50
|
Update of /cvsroot/jake2/jake2/src/jake2/qcommon In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24485/src/jake2/qcommon Modified Files: FS.java Log Message: pak file is mmapped and buffers will be sliced Index: FS.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/qcommon/FS.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** FS.java 28 Oct 2004 21:09:11 -0000 1.11 --- FS.java 10 Nov 2004 20:41:40 -0000 1.12 *************** *** 72,75 **** --- 72,77 ---- RandomAccessFile handle; + + ByteBuffer backbuffer; int numfiles; *************** *** 450,458 **** } // open a new file on the pakfile ! ! channel = pak.handle.getChannel(); ! buffer = channel.map(FileChannel.MapMode.READ_ONLY, ! entry.filepos, entry.filelen); ! channel.close(); return buffer; } --- 452,465 ---- } // open a new file on the pakfile ! if (pak.backbuffer == null) { ! channel = pak.handle.getChannel(); ! pak.backbuffer = channel.map( ! FileChannel.MapMode.READ_ONLY, 0, ! pak.handle.length()); ! channel.close(); ! } ! pak.backbuffer.position(entry.filepos); ! buffer = pak.backbuffer.slice(); ! buffer.limit(entry.filelen); return buffer; } |
From: Carsten W. <ca...@us...> - 2004-11-10 20:35:47
|
Update of /cvsroot/jake2/jake2/src/jake2/render/fastjogl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23073/src/jake2/render/fastjogl Modified Files: Image.java Log Message: this is the right method to get the readable lenght or size (capacity() doesn't work with sliced buffers) Index: Image.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/render/fastjogl/Image.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Image.java 20 Oct 2004 19:20:14 -0000 1.7 --- Image.java 10 Nov 2004 20:35:36 -0000 1.8 *************** *** 464,468 **** if (palette != null) { palette[0] = new byte[768]; ! raw.position(raw.capacity() - 768); raw.get(palette[0]); } --- 464,468 ---- if (palette != null) { palette[0] = new byte[768]; ! raw.position(raw.limit() - 768); raw.get(palette[0]); } |
From: Carsten W. <ca...@us...> - 2004-11-07 19:38:48
|
Update of /cvsroot/jake2/jake2/src/jake2/client In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5255/src/jake2/client Modified Files: CL.java Log Message: bugfix: models download (C-string to Java-string) Index: CL.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/client/CL.java,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** CL.java 24 Oct 2004 21:02:04 -0000 1.15 --- CL.java 7 Nov 2004 19:38:40 -0000 1.16 *************** *** 1049,1053 **** // mess!\n"); ! String name = new String(CL.precache_model, pheader.ofs_skins + (CL.precache_model_skin - 1) --- 1049,1053 ---- // mess!\n"); ! String name = Lib.CtoJava(CL.precache_model, pheader.ofs_skins + (CL.precache_model_skin - 1) |