| 1 | /* |
|---|
| 2 | ================================================================================= |
|---|
| 3 | This file is part of Cafu, the open-source game engine and graphics engine |
|---|
| 4 | for multiplayer, cross-platform, real-time 3D action. |
|---|
| 5 | Copyright (C) 2002-2012 Carsten Fuchs Software. |
|---|
| 6 | |
|---|
| 7 | Cafu is free software: you can redistribute it and/or modify it under the terms |
|---|
| 8 | of the GNU General Public License as published by the Free Software Foundation, |
|---|
| 9 | either version 3 of the License, or (at your option) any later version. |
|---|
| 10 | |
|---|
| 11 | Cafu is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
|---|
| 12 | without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
|---|
| 13 | PURPOSE. See the GNU General Public License for more details. |
|---|
| 14 | |
|---|
| 15 | You should have received a copy of the GNU General Public License |
|---|
| 16 | along with Cafu. If not, see <http://www.gnu.org/licenses/>. |
|---|
| 17 | |
|---|
| 18 | For support and more information about Cafu, visit us at <http://www.cafu.de>. |
|---|
| 19 | ================================================================================= |
|---|
| 20 | */ |
|---|
| 21 | |
|---|
| 22 | #ifndef CAFU_MAIN_CANVAS_HPP_INCLUDED |
|---|
| 23 | #define CAFU_MAIN_CANVAS_HPP_INCLUDED |
|---|
| 24 | |
|---|
| 25 | #include "Util/Util.hpp" |
|---|
| 26 | #include "wx/wx.h" |
|---|
| 27 | #include "wx/glcanvas.h" |
|---|
| 28 | |
|---|
| 29 | #if __linux__ |
|---|
| 30 | #define HMODULE void* |
|---|
| 31 | #endif |
|---|
| 32 | |
|---|
| 33 | |
|---|
| 34 | class MainFrameT; |
|---|
| 35 | class wxGLContext; |
|---|
| 36 | class ClientT; |
|---|
| 37 | class ServerT; |
|---|
| 38 | class SvGuiCallbT; |
|---|
| 39 | class ModelManagerT; |
|---|
| 40 | namespace cf { namespace GuiSys { class GuiResourcesT; } } |
|---|
| 41 | namespace cf { class ConsoleI; } |
|---|
| 42 | |
|---|
| 43 | |
|---|
| 44 | /// This class represents the Cafu main OpenGL 3D canvas. |
|---|
| 45 | class MainCanvasT : public wxGLCanvas |
|---|
| 46 | { |
|---|
| 47 | public: |
|---|
| 48 | |
|---|
| 49 | /// The constructor. |
|---|
| 50 | MainCanvasT(MainFrameT* Parent); |
|---|
| 51 | |
|---|
| 52 | /// The destructor. |
|---|
| 53 | ~MainCanvasT(); |
|---|
| 54 | |
|---|
| 55 | |
|---|
| 56 | private: |
|---|
| 57 | |
|---|
| 58 | enum InitStateT { INIT_REQUIRED, INIT_FAILED, INIT_SUCCESS }; |
|---|
| 59 | enum LastMousePosT { IN_CLIENT_3D_GUI, IN_OTHER_2D_GUI }; |
|---|
| 60 | |
|---|
| 61 | void Initialize(); |
|---|
| 62 | void TakeScreenshot() const; |
|---|
| 63 | |
|---|
| 64 | void OnPaint(wxPaintEvent& PE); |
|---|
| 65 | void OnSize(wxSizeEvent& SE); |
|---|
| 66 | void OnIdle(wxIdleEvent& IE); ///< The idle event handler runs one frame of the Cafu Engine (client and/or server). |
|---|
| 67 | |
|---|
| 68 | void OnMouseMove (wxMouseEvent& ME); |
|---|
| 69 | void OnMouseWheel(wxMouseEvent& ME); |
|---|
| 70 | void OnLMouseDown(wxMouseEvent& ME); |
|---|
| 71 | void OnLMouseUp (wxMouseEvent& ME); |
|---|
| 72 | void OnRMouseDown(wxMouseEvent& ME); |
|---|
| 73 | void OnRMouseUp (wxMouseEvent& ME); |
|---|
| 74 | |
|---|
| 75 | void OnKeyDown(wxKeyEvent& KE); |
|---|
| 76 | void OnKeyUp (wxKeyEvent& KE); |
|---|
| 77 | void OnKeyChar(wxKeyEvent& KE); |
|---|
| 78 | |
|---|
| 79 | MainFrameT* m_Parent; |
|---|
| 80 | InitStateT m_InitState; ///< Indicates whether initialization is still required, was attempted but failed, or completed successfully. |
|---|
| 81 | wxGLContext* m_GLContext; ///< The OpenGL rendering context that represents our app-global OpenGL state. |
|---|
| 82 | HMODULE m_RendererDLL; |
|---|
| 83 | ModelManagerT* m_ModelManager; |
|---|
| 84 | cf::GuiSys::GuiResourcesT* m_GuiResources; |
|---|
| 85 | HMODULE m_SoundSysDLL; |
|---|
| 86 | HMODULE m_GameDLL; |
|---|
| 87 | ClientT* m_Client; |
|---|
| 88 | ServerT* m_Server; |
|---|
| 89 | SvGuiCallbT* m_SvGuiCallback; |
|---|
| 90 | cf::ConsoleI* m_ConByGuiWin; ///< This points to an instance of cf::GuiSys::ConsoleByWindowT. |
|---|
| 91 | TimerT m_Timer; |
|---|
| 92 | double m_TotalTime; |
|---|
| 93 | LastMousePosT m_LastMousePos; ///< Used to prevent unwanted changes to the players heading and pitch when we're switching back from a 2D GUI to the 3D client view. |
|---|
| 94 | |
|---|
| 95 | DECLARE_EVENT_TABLE() |
|---|
| 96 | }; |
|---|
| 97 | |
|---|
| 98 | #endif |
|---|