diff options
author | Hans Lambermont <hans@lambermont.dyndns.org> | 2002-10-12 15:37:38 +0400 |
---|---|---|
committer | Hans Lambermont <hans@lambermont.dyndns.org> | 2002-10-12 15:37:38 +0400 |
commit | 12315f4d0e0ae993805f141f64cb8c73c5297311 (patch) | |
tree | 59b45827cd8293cfb727758989c7a74b40183974 /source/gameengine/GamePlayer/common/unix |
Initial revisionv2.25
Diffstat (limited to 'source/gameengine/GamePlayer/common/unix')
10 files changed, 950 insertions, 0 deletions
diff --git a/source/gameengine/GamePlayer/common/unix/GPU_Canvas.cpp b/source/gameengine/GamePlayer/common/unix/GPU_Canvas.cpp new file mode 100644 index 00000000000..29f0bffe1c5 --- /dev/null +++ b/source/gameengine/GamePlayer/common/unix/GPU_Canvas.cpp @@ -0,0 +1,72 @@ +/** + * $Id$ + * + * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * + * 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. The Blender + * Foundation also sells licenses for use in proprietary software under + * the Blender License. See http://www.blender.org/BL/ for information + * about this. + * + * 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. + * + * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL/BL DUAL LICENSE BLOCK ***** + */ + +//#include <iostream> + +#include "GPU_Canvas.h" + +GPU_Canvas::GPU_Canvas(KXH_plugin_handle p, int width, int height) + : GPC_Canvas(width, height), m_plugin(p) +{ + /* intentionally empty */ +} + + +GPU_Canvas::~GPU_Canvas(void) +{ + /* intentionally empty */ +} + +void GPU_Canvas::Init(void) +{ + /* intentionally empty */ +} + +void GPU_Canvas::SwapBuffers(void) +{ + if (m_plugin) KXH_swap_buffers(m_plugin); +} + +bool +GPU_Canvas::BeginDraw(void) +{ + if (m_plugin) { + return KXH_begin_draw(m_plugin); + } else { + return false; + } +} + +void GPU_Canvas::EndDraw(void) +{ + if (m_plugin) KXH_end_draw(m_plugin); +} diff --git a/source/gameengine/GamePlayer/common/unix/GPU_Canvas.h b/source/gameengine/GamePlayer/common/unix/GPU_Canvas.h new file mode 100644 index 00000000000..5b3309a83bf --- /dev/null +++ b/source/gameengine/GamePlayer/common/unix/GPU_Canvas.h @@ -0,0 +1,60 @@ +/** + * $Id$ + * + * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * + * 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. The Blender + * Foundation also sells licenses for use in proprietary software under + * the Blender License. See http://www.blender.org/BL/ for information + * about this. + * + * 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. + * + * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL/BL DUAL LICENSE BLOCK ***** + */ + +#ifndef __GPU_CANVAS_H +#define __GPU_CANVAS_H + +#include <iostream> + +#include "KXH_ketsji_hooks.h" +#include "GPC_Canvas.h" + +class GPU_Canvas : public GPC_Canvas +{ +private: + + /** Handle to the drawing resource. */ + KXH_plugin_handle m_plugin; + +public: + GPU_Canvas(KXH_plugin_handle display, int width, int height); + virtual ~GPU_Canvas(); + + virtual void Init(void); + + bool BeginDraw(void); + void EndDraw(void); + virtual void SwapBuffers(void); + +}; + +#endif // __GPU_CANVAS_H diff --git a/source/gameengine/GamePlayer/common/unix/GPU_Engine.cpp b/source/gameengine/GamePlayer/common/unix/GPU_Engine.cpp new file mode 100644 index 00000000000..56b1340eb92 --- /dev/null +++ b/source/gameengine/GamePlayer/common/unix/GPU_Engine.cpp @@ -0,0 +1,307 @@ +/** + * $Id$ + * + * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * + * 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. The Blender + * Foundation also sells licenses for use in proprietary software under + * the Blender License. See http://www.blender.org/BL/ for information + * about this. + * + * 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. + * + * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL/BL DUAL LICENSE BLOCK ***** + */ + +#include <assert.h> +#include <unistd.h> + +#include "GPU_Engine.h" + +#include "GPC_MouseDevice.h" + +#include "GPU_Canvas.h" +#include "GPU_KeyboardDevice.h" +#include "GPU_System.h" + +#include "BLI_blenlib.h" +#include "BLO_readfile.h" + +#include "SND_DeviceManager.h" + +#include "NG_NetworkScene.h" +#include "NG_LoopBackNetworkDeviceInterface.h" +#include "SND_DeviceManager.h" +#include "KX_BlenderSceneConverter.h" +#include "SM_Scene.h" +#include "KX_KetsjiEngine.h" + +#include "GPC_RenderTools.h" +#include "GPC_RawImage.h" + + +void Redraw(GPU_Engine *engine); // -the- redraw function + +// callback functions +/* +void RedrawCallback(Widget, XtPointer closure, XEvent *, Boolean *continue_to_dispatch); + +void KeyDownCallback(Widget w, XtPointer closure, XEvent *event, Boolean *continue_to_dispatch); +void KeyUpCallback(Widget w, XtPointer closure, XEvent *event, Boolean *continue_to_dispatch); + +void ButtonPressReleaseCallback(Widget w, XtPointer closure, XEvent *event, Boolean *continue_to_dispatch); +void PointerMotionCallback(Widget w, XtPointer closure, XEvent *event, Boolean *continue_to_dispatch); + +void TimeOutCallback(XtPointer closure, XtIntervalId *id); +*/ + +GPU_Engine::GPU_Engine(char *customLoadingAnimationURL, + int foregroundColor, int backgroundColor, int frameRate) : + GPC_Engine(customLoadingAnimationURL, foregroundColor, backgroundColor, + frameRate), m_timerTimeOutMsecs(10) +{ +} + + +GPU_Engine::~GPU_Engine() +{ +} + +/* +bool GPU_Engine::Initialize(Display *display, Window window, int width, int height) +{ + SND_DeviceManager::Subscribe(); + m_audiodevice = SND_DeviceManager::Instance(); + + m_keyboarddev = new GPU_KeyboardDevice(); + m_mousedev = new GPC_MouseDevice(); + + // constructor only initializes data + // m_canvas = new GPU_Canvas(display, window, width, height); + //m_canvas->Init(); // create the actual visual and rendering context + //cout << "GPU_Canvas created and initialized, m_canvas " << m_canvas << endl; + //AddEventHandlers(); // done here (in GPU_Engine) since the event handlers need access to 'this', ie the engine + + // put the Blender logo in the topleft corner + if(m_BlenderLogo != 0) + // adding a banner automatically enables them + m_BlenderLogoId = m_canvas->AddBanner(m_BlenderLogo->Width(), m_BlenderLogo->Height(), + m_BlenderLogo->Width(), m_BlenderLogo->Height(), + m_BlenderLogo->Data(), GPC_Canvas::alignTopLeft); + + // put the Blender3D logo in the bottom right corner + if(m_Blender3DLogo != 0) + // adding a banner automatically enables them + m_Blender3DLogoId = m_canvas->AddBanner(m_Blender3DLogo->Width(), m_Blender3DLogo->Height(), + m_Blender3DLogo->Width(), m_Blender3DLogo->Height(), + m_Blender3DLogo->Data(), GPC_Canvas::alignTopLeft); + +#if 0 + // put the NaN logo in the bottom right corner + if(m_NaNLogo != 0) + // adding a banner automatically enables them + m_NaNLogoId = m_canvas->AddBanner(m_NaNLogo->Width(), m_NaNLogo->Height(), + m_NaNLogo->Width(), m_NaNLogo->Height(), + m_NaNLogo->Data(), GPC_Canvas::alignBottomRight); +#endif + // enable the display of all banners + m_canvas->SetBannerDisplayEnabled(true); + + m_rendertools = new GPC_RenderTools(); + + m_networkdev = new NG_LoopBackNetworkDeviceInterface(); + assert(m_networkdev); + + // creation of system needs 'current rendering context', this is taken care + // of by the GPU_Canvas::Init() + m_system = new GPU_System(); + + m_system->SetKeyboardDevice((GPU_KeyboardDevice *)m_keyboarddev); + m_system->SetMouseDevice(m_mousedev); + m_system->SetNetworkDevice(m_networkdev); + + m_initialized = true; + + return m_initialized; +} +*/ + +/* +void GPU_Engine::HandleNewWindow(Window window) +{ + // everything only if it's really a new window + if(window != ((GPU_Canvas *)m_canvas)->GetWindow()) + { + cout << "GPU_Engine::HandleNewWindow(), new window so calling SetNewWindowMakeNewWidgetAndMakeCurrent()" << endl; + // We don't have to remove the event handlers ourselves, they are destroyed by X11 + + // make canvas aware of new window, and make it current + ((GPU_Canvas *)m_canvas)->SetNewWindowMakeNewWidgetAndMakeCurrent(window); + + // and add event handlers to new widget + AddEventHandlers(); + cout << "GPU_Engine::HandleNewWindow(), event handlers added" << endl; + } +} +*/ +/* +void GPU_Engine::AddEventHandlers(void) +{ + Widget widget = ((GPU_Canvas *)m_canvas)->GetWidget(); + + // redraw + // MUST be the *Raw* event handler, the normal one doesn't work! + XtAddRawEventHandler(widget, ExposureMask, FALSE, RedrawCallback, this); +#if 0 + // key down + XtAddRawEventHandler(widget, KeyPressMask, FALSE, KeyDownCallback, this); + // key up + XtAddRawEventHandler(widget, KeyReleaseMask, FALSE, KeyUpCallback, this); + + // mouse button press + XtAddRawEventHandler(widget, ButtonPressMask, FALSE, ButtonPressReleaseCallback, this); + // mouse button release + XtAddRawEventHandler(widget, ButtonReleaseMask, FALSE, ButtonPressReleaseCallback, this); + // mouse motion + XtAddRawEventHandler(widget, PointerMotionMask, FALSE, PointerMotionCallback, this); +#endif +#if 0 + // time out, not a real timer. New time out will be set in callback + m_timerId = XtAppAddTimeOut(XtWidgetToApplicationContext(widget), + m_timerTimeOutMsecs, TimeOutCallback, this); +#endif +} +*/ + +void Redraw(GPU_Engine *engine) +{ +/* if(engine->Running()) + { + if(engine->Loading()) + { + engine->UpdateLoadingAnimation(); + } + + engine->m_system->DoMainLoopCallback(); + }*/ +} + + +/*+++++++++++++++++++++++++++++++++++++++++++++++++ + * Callback functions + +++++++++++++++++++++++++++++++++++++++++++++++++*/ +void RedrawCallback(Widget, XtPointer closure, XEvent *, Boolean *continue_to_dispatch) +{ + GPU_Engine *engine = (GPU_Engine *)closure; + + Redraw(engine); + + *continue_to_dispatch = True; +} + + +void KeyDownCallback(Widget, XtPointer closure, XEvent *event, Boolean *continue_to_dispatch) +{ +/* GPU_Engine *engine = (GPU_Engine *)closure; + XKeyEvent *keyEvent = (XKeyEvent *)event; + + if(engine->Running()) + engine->m_system->AddKey(int(keyEvent->keycode), 1); + + *continue_to_dispatch = True;*/ +} + + +void KeyUpCallback(Widget, XtPointer closure, XEvent *event, Boolean *continue_to_dispatch) +{ +/* GPU_Engine *engine = (GPU_Engine *)closure; + XKeyEvent *keyEvent = (XKeyEvent *)event; + + if(engine->Running()) + engine->m_system->AddKey(int(keyEvent->keycode), 0); + + *continue_to_dispatch = True;*/ +} + + +void ButtonPressReleaseCallback(Widget, XtPointer closure, XEvent *event, Boolean *continue_to_dispatch) +{ + GPU_Engine *engine = (GPU_Engine *)closure; + XButtonEvent *buttonEvent = (XButtonEvent *)event; + bool isDown; + GPC_MouseDevice::TButtonId button; + + if(engine->Running()) + { + // determine type of event, press or release + isDown = false; + if(buttonEvent->type == ButtonPress) + isDown = true; + // determine which button exactly generated this event + switch(buttonEvent->button) + { + case 1: + button = GPC_MouseDevice::buttonLeft; + break; + case 2: + button = GPC_MouseDevice::buttonMiddle; + break; + case 3: + button = GPC_MouseDevice::buttonRight; + break; + } + engine->m_mousedev->ConvertButtonEvent(button, + isDown, buttonEvent->x, buttonEvent->y); + } + + *continue_to_dispatch = True; +} + + +void PointerMotionCallback(Widget w, XtPointer closure, XEvent *event, Boolean *continue_to_dispatch) +{ + GPU_Engine *engine = (GPU_Engine *)closure; + XButtonEvent *buttonEvent = (XButtonEvent *)event; + + if(engine->Running()) + { + engine->m_mousedev->ConvertMoveEvent(buttonEvent->x, buttonEvent->y); + } + + *continue_to_dispatch = True; +} + +/* +void TimeOutCallback(XtPointer closure, XtIntervalId *id) +{ + GPU_Engine *engine = (GPU_Engine *)closure; + + Redraw(engine); + // add a new time out since there is no real timer for X (not a simple one like under windows) + // TODO Have to get faster timer ! + + if(engine->Running()) + engine->m_timerId = XtAppAddTimeOut(XtWidgetToApplicationContext( + ((GPU_Canvas *)engine->m_canvas)->GetWidget()), + engine->m_timerTimeOutMsecs, TimeOutCallback, + closure); +} + +*/ diff --git a/source/gameengine/GamePlayer/common/unix/GPU_Engine.h b/source/gameengine/GamePlayer/common/unix/GPU_Engine.h new file mode 100644 index 00000000000..fe8743f7695 --- /dev/null +++ b/source/gameengine/GamePlayer/common/unix/GPU_Engine.h @@ -0,0 +1,65 @@ +/** + * $Id$ + * + * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * + * 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. The Blender + * Foundation also sells licenses for use in proprietary software under + * the Blender License. See http://www.blender.org/BL/ for information + * about this. + * + * 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. + * + * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL/BL DUAL LICENSE BLOCK ***** + */ + +#ifndef __GPU_ENGINE_H +#define __GPU_ENGINE_H + + +#include <X11/Xlib.h> +#include <X11/Intrinsic.h> +#include <X11/StringDefs.h> + +#define Object DNA_Object // tricky stuff !!! but without it it doesn't compile... + +#include "GPC_Engine.h" + + +class GPU_Engine : public GPC_Engine +{ +public: + XtIntervalId m_timerId; + unsigned long m_timerTimeOutMsecs; + +public: + GPU_Engine(char *customLoadingAnimation, + int foregroundColor, int backgroundColor, int frameRate); + virtual ~GPU_Engine(); + bool Initialize(Display *display, Window window, int width, int height); + + void HandleNewWindow(Window window); + +private: + void AddEventHandlers(); +}; + + +#endif // __GPU_ENGINE_H diff --git a/source/gameengine/GamePlayer/common/unix/GPU_KeyboardDevice.cpp b/source/gameengine/GamePlayer/common/unix/GPU_KeyboardDevice.cpp new file mode 100644 index 00000000000..125adcc4b7b --- /dev/null +++ b/source/gameengine/GamePlayer/common/unix/GPU_KeyboardDevice.cpp @@ -0,0 +1,137 @@ +/** + * $Id$ + * + * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * + * 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. The Blender + * Foundation also sells licenses for use in proprietary software under + * the Blender License. See http://www.blender.org/BL/ for information + * about this. + * + * 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. + * + * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL/BL DUAL LICENSE BLOCK ***** + */ +#include <iostream.h> +#include "GPU_KeyboardDevice.h" + +void GPU_KeyboardDevice::register_X_key_down_event(KeySym k) +{ + ConvertEvent(k, 1); +} + +void GPU_KeyboardDevice::register_X_key_up_event(KeySym k) +{ + ConvertEvent(k, 0); +} + + +#define map_x_key_to_kx_key(x,y) m_reverseKeyTranslateTable[x] = y; + +GPU_KeyboardDevice::GPU_KeyboardDevice(void) +{ + unsigned int i = 0; + + // Needed? + m_reverseKeyTranslateTable.clear(); + + for (i = XK_A; i< XK_Z; i++) { + m_reverseKeyTranslateTable[i] + = (SCA_IInputDevice::KX_EnumInputs) + (((unsigned int)SCA_IInputDevice::KX_AKEY) + i - XK_A); + } + + // Shifted versions: should not occur: KX doesn't distinguish + for (i = XK_a; i< XK_z; i++) { + m_reverseKeyTranslateTable[i] + = (SCA_IInputDevice::KX_EnumInputs) + (((int)SCA_IInputDevice::KX_AKEY) + i - XK_a); + } + + for (i = XK_0; i< XK_9; i++) { + m_reverseKeyTranslateTable[i] + = (SCA_IInputDevice::KX_EnumInputs) + (((int)SCA_IInputDevice::KX_ZEROKEY) + i - XK_0); + } + + for (i = XK_F1; i< XK_F12; i++) { + m_reverseKeyTranslateTable[i] + = (SCA_IInputDevice::KX_EnumInputs) + (((int)SCA_IInputDevice::KX_F1KEY) + i - XK_F1); + } + + // the remainder: + map_x_key_to_kx_key(XK_BackSpace, SCA_IInputDevice::KX_BACKSPACEKEY); + map_x_key_to_kx_key(XK_Tab, SCA_IInputDevice::KX_TABKEY); + map_x_key_to_kx_key(XK_Return, SCA_IInputDevice::KX_RETKEY); + map_x_key_to_kx_key(XK_Escape, SCA_IInputDevice::KX_ESCKEY); + map_x_key_to_kx_key(XK_space, SCA_IInputDevice::KX_SPACEKEY); + + map_x_key_to_kx_key(XK_Shift_L, SCA_IInputDevice::KX_LEFTSHIFTKEY); + map_x_key_to_kx_key(XK_Shift_R, SCA_IInputDevice::KX_RIGHTSHIFTKEY); + map_x_key_to_kx_key(XK_Control_L, SCA_IInputDevice::KX_LEFTCTRLKEY); + map_x_key_to_kx_key(XK_Control_R, SCA_IInputDevice::KX_RIGHTCTRLKEY); + map_x_key_to_kx_key(XK_Alt_L, SCA_IInputDevice::KX_LEFTALTKEY); + map_x_key_to_kx_key(XK_Alt_R, SCA_IInputDevice::KX_RIGHTALTKEY); + + map_x_key_to_kx_key(XK_Insert, SCA_IInputDevice::KX_INSERTKEY); + map_x_key_to_kx_key(XK_Delete, SCA_IInputDevice::KX_DELKEY); + map_x_key_to_kx_key(XK_Home, SCA_IInputDevice::KX_HOMEKEY); + map_x_key_to_kx_key(XK_End, SCA_IInputDevice::KX_ENDKEY); + map_x_key_to_kx_key(XK_Page_Up, SCA_IInputDevice::KX_PAGEUPKEY); + map_x_key_to_kx_key(XK_Page_Down, SCA_IInputDevice::KX_PAGEDOWNKEY); + + map_x_key_to_kx_key(XK_Left, SCA_IInputDevice::KX_LEFTARROWKEY); + map_x_key_to_kx_key(XK_Right, SCA_IInputDevice::KX_RIGHTARROWKEY); + map_x_key_to_kx_key(XK_Up, SCA_IInputDevice::KX_UPARROWKEY); + map_x_key_to_kx_key(XK_Down, SCA_IInputDevice::KX_DOWNARROWKEY); + + map_x_key_to_kx_key(XK_KP_0, SCA_IInputDevice::KX_PAD0); + map_x_key_to_kx_key(XK_KP_1, SCA_IInputDevice::KX_PAD1); + map_x_key_to_kx_key(XK_KP_2, SCA_IInputDevice::KX_PAD2); + map_x_key_to_kx_key(XK_KP_3, SCA_IInputDevice::KX_PAD3); + map_x_key_to_kx_key(XK_KP_4, SCA_IInputDevice::KX_PAD4); + map_x_key_to_kx_key(XK_KP_5, SCA_IInputDevice::KX_PAD5); + map_x_key_to_kx_key(XK_KP_6, SCA_IInputDevice::KX_PAD6); + map_x_key_to_kx_key(XK_KP_7, SCA_IInputDevice::KX_PAD7); + map_x_key_to_kx_key(XK_KP_8, SCA_IInputDevice::KX_PAD8); + map_x_key_to_kx_key(XK_KP_9, SCA_IInputDevice::KX_PAD9); + map_x_key_to_kx_key(XK_KP_Decimal, SCA_IInputDevice::KX_PADPERIOD); + + map_x_key_to_kx_key(XK_KP_Insert, SCA_IInputDevice::KX_INSERTKEY); + map_x_key_to_kx_key(XK_KP_End, SCA_IInputDevice::KX_ENDKEY); + map_x_key_to_kx_key(XK_KP_Down, SCA_IInputDevice::KX_DOWNARROWKEY); + map_x_key_to_kx_key(XK_KP_Page_Down,SCA_IInputDevice::KX_PAGEDOWNKEY); + map_x_key_to_kx_key(XK_KP_Left, SCA_IInputDevice::KX_LEFTARROWKEY); + map_x_key_to_kx_key(XK_KP_Right, SCA_IInputDevice::KX_RIGHTARROWKEY); + map_x_key_to_kx_key(XK_KP_Home, SCA_IInputDevice::KX_HOMEKEY); + map_x_key_to_kx_key(XK_KP_Up, SCA_IInputDevice::KX_UPARROWKEY); + map_x_key_to_kx_key(XK_KP_Page_Up, SCA_IInputDevice::KX_PAGEUPKEY); + map_x_key_to_kx_key(XK_KP_Delete, SCA_IInputDevice::KX_DELKEY); + + map_x_key_to_kx_key(XK_KP_Enter, SCA_IInputDevice::KX_PADENTER); + map_x_key_to_kx_key(XK_KP_Add, SCA_IInputDevice::KX_PADPLUSKEY); + map_x_key_to_kx_key(XK_KP_Subtract, SCA_IInputDevice::KX_PADMINUS); + map_x_key_to_kx_key(XK_KP_Multiply, SCA_IInputDevice::KX_PADASTERKEY); + map_x_key_to_kx_key(XK_KP_Divide, SCA_IInputDevice::KX_PADSLASHKEY); + + map_x_key_to_kx_key(XK_Caps_Lock, SCA_IInputDevice::KX_CAPSLOCKKEY); + +} diff --git a/source/gameengine/GamePlayer/common/unix/GPU_KeyboardDevice.h b/source/gameengine/GamePlayer/common/unix/GPU_KeyboardDevice.h new file mode 100644 index 00000000000..24226bf6bfd --- /dev/null +++ b/source/gameengine/GamePlayer/common/unix/GPU_KeyboardDevice.h @@ -0,0 +1,64 @@ +/** + * $Id$ + * + * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * + * 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. The Blender + * Foundation also sells licenses for use in proprietary software under + * the Blender License. See http://www.blender.org/BL/ for information + * about this. + * + * 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. + * + * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL/BL DUAL LICENSE BLOCK ***** + */ + +#ifndef __GPU_KEYBOARDDEVICE_H +#define __GPU_KEYBOARDDEVICE_H + +#include <X11/keysym.h> +#include <X11/X.h> // Brilliant name, eh? Stupid !@#!$!@#@@% This is + // actually needed so as not to get name clashes between Object from + // blender and Object from X11... The proper include would be + // Intrinsic.h . Yes, we are a bunch of sado-masochists. Let's hurt + // ourselves! + +#include "GPC_KeyboardDevice.h" + +class GPU_KeyboardDevice : public GPC_KeyboardDevice +{ +public: + + void register_X_key_down_event(KeySym k); + void register_X_key_up_event(KeySym k); + + GPU_KeyboardDevice(void); + virtual ~GPU_KeyboardDevice() + { + /* intentionally empty */ + } + + private: + SCA_IInputDevice::KX_EnumInputs + convert_x_keycode_to_kx_keycode(unsigned int key); +}; + + +#endif // _GPU_KEYBOARDDEVICE_H diff --git a/source/gameengine/GamePlayer/common/unix/GPU_PolygonMaterial.h b/source/gameengine/GamePlayer/common/unix/GPU_PolygonMaterial.h new file mode 100644 index 00000000000..a0629c14158 --- /dev/null +++ b/source/gameengine/GamePlayer/common/unix/GPU_PolygonMaterial.h @@ -0,0 +1,57 @@ +/** + * $Id$ + * + * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * + * 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. The Blender + * Foundation also sells licenses for use in proprietary software under + * the Blender License. See http://www.blender.org/BL/ for information + * about this. + * + * 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. + * + * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL/BL DUAL LICENSE BLOCK ***** + */ + +#ifndef __GPU_POLYGONMATERIAL_H +#define __GPU_POLYGONMATERIAL_H + + +#include "BP_PolygonMaterial.h" + + +class GPU_PolygonMaterial : public BP_PolygonMaterial +{ +public: + GPUPolygonMaterial(const STR_String& texname, bool ba,const STR_String& matname, + int tile, int tileXrep, int tileYrep, int mode, int transparant, + int lightlayer,bool bIsTriangle,void* clientobject,void* tpage) : + BP_PolygonMaterial(texname, ba,matname, tile, tileXrep, tileYrep, + mode, transparant, lightlayer, bIsTriangle, clientobject), + m_tface(tpage) + { + } + + virtual ~GPU_PolygonMaterial() + { + } +}; + +#endif // __GPU_POLYGONMATERIAL_H diff --git a/source/gameengine/GamePlayer/common/unix/GPU_System.cpp b/source/gameengine/GamePlayer/common/unix/GPU_System.cpp new file mode 100644 index 00000000000..d7484c97dc2 --- /dev/null +++ b/source/gameengine/GamePlayer/common/unix/GPU_System.cpp @@ -0,0 +1,56 @@ +/** + * $Id$ + * + * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * + * 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. The Blender + * Foundation also sells licenses for use in proprietary software under + * the Blender License. See http://www.blender.org/BL/ for information + * about this. + * + * 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. + * + * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL/BL DUAL LICENSE BLOCK ***** + */ + +#include <sys/time.h> + +#include "GPU_System.h" + + +static struct timeval startTime; +static int startTimeDone = 0; + + +double GPU_System::GetTimeInSeconds() +{ + if(!startTimeDone) + { + gettimeofday(&startTime, NULL); + startTimeDone = 1; + } + + struct timeval now; + gettimeofday(&now, NULL); + // next '1000' are used for precision + long ticks = (now.tv_sec - startTime.tv_sec) * 1000 + (now.tv_usec - startTime.tv_usec) / 1000; + double secs = (double)ticks / 1000.0; + return secs; +} diff --git a/source/gameengine/GamePlayer/common/unix/GPU_System.h b/source/gameengine/GamePlayer/common/unix/GPU_System.h new file mode 100644 index 00000000000..7a578fb75ad --- /dev/null +++ b/source/gameengine/GamePlayer/common/unix/GPU_System.h @@ -0,0 +1,51 @@ +/** + * $Id$ + * + * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * + * 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. The Blender + * Foundation also sells licenses for use in proprietary software under + * the Blender License. See http://www.blender.org/BL/ for information + * about this. + * + * 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. + * + * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL/BL DUAL LICENSE BLOCK ***** + */ + +#ifndef __GPU_SYSTEM_H +#define __GPU_SYSTEM_H + + +#include "GPC_System.h" + + +class GPU_System : public GPC_System +{ +public: + GPU_System() + { + } + + virtual double GetTimeInSeconds(); +}; + + +#endif // __GPU_SYSTEM_H diff --git a/source/gameengine/GamePlayer/common/unix/Makefile b/source/gameengine/GamePlayer/common/unix/Makefile new file mode 100644 index 00000000000..5f6a52ded9a --- /dev/null +++ b/source/gameengine/GamePlayer/common/unix/Makefile @@ -0,0 +1,81 @@ +# +# $Id$ +# +# ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** +# +# 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. The Blender +# Foundation also sells licenses for use in proprietary software under +# the Blender License. See http://www.blender.org/BL/ for information +# about this. +# +# 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. +# +# The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. +# All rights reserved. +# +# The Original Code is: all of this file. +# +# Contributor(s): none yet. +# +# ***** END GPL/BL DUAL LICENSE BLOCK ***** +# +# + +LIBNAME = unix +DIR = $(OCGDIR)/gameengine/GamePlayer/common/$(LIBNAME) + +include nan_compile.mk + +CCFLAGS += $(LEVEL_1_CPP_WARNINGS) + +CPPFLAGS += -I$(OPENGL_HEADERS) +CPPFLAGS += -I$(NAN_STRING)/include + +CPPFLAGS += -I.. +CPPFLAGS += -I../../netscape/src/ketsji +CPPFLAGS += -I$(NAN_PYTHON)/include/python$(NAN_PYTHON_VERSION) + +# Game Engine +CPPFLAGS += -I../../../../gameengine/Converter +CPPFLAGS += -I../../../../gameengine/Expressions +CPPFLAGS += -I../../../../gameengine/GameLogic +CPPFLAGS += -I../../../../gameengine/Ketsji +CPPFLAGS += -I../../../../gameengine/Ketsji/KXNetwork +CPPFLAGS += -I../../../../gameengine/Network +CPPFLAGS += -I../../../../gameengine/Network/LoopBackNetwork +CPPFLAGS += -I../../../../gameengine/Rasterizer +CPPFLAGS += -I../../../../gameengine/Rasterizer/RAS_OpenGLRasterizer +CPPFLAGS += -I../../../../gameengine/SceneGraph +ifeq ($(NAN_SND), OPENAL) + CPPFLAGS += -I../../../../gameengine/SoundSystem + CPPFLAGS += -I../../../../gameengine/SoundSystem/SND_OpenAL +else + CPPFLAGS += -I../../../../gameengine/SoundSystem + CPPFLAGS += -I../../../../gameengine/SoundSystem/SND_Dummy +endif + +CPPFLAGS += -I../../../../sumo/Fuzzics/include +CPPFLAGS += -I../../../../sumo/include +CPPFLAGS += -I$(NAN_MOTO)/include +CPPFLAGS += -I$(NAN_BMFONT)/include + +# Blender stuff +CPPFLAGS += -I../../../../blender/blenkernel +CPPFLAGS += -I../../../../blender/blenlib +CPPFLAGS += -I../../../../blender/blenloader +CPPFLAGS += -I../../../../blender/imbuf +CPPFLAGS += -I../../../../blender/makesdna +CPPFLAGS += -I../../../../kernel/gen_system + +CPPFLAGS += -I../../kernel/gen_system + |