Cafu Engine
MainCanvas.hpp
1 /*
2 Cafu Engine, http://www.cafu.de/
3 Copyright (c) Carsten Fuchs and other contributors.
4 This project is licensed under the terms of the MIT license.
5 */
6 
7 #ifndef CAFU_MAIN_CANVAS_HPP_INCLUDED
8 #define CAFU_MAIN_CANVAS_HPP_INCLUDED
9 
10 #include "Util/Util.hpp"
11 #include "wx/wx.h"
12 #include "wx/glcanvas.h"
13 
14 #if __linux__
15 #define HMODULE void*
16 #endif
17 
18 
19 class MainFrameT;
20 class GameInfoT;
21 class wxGLContext;
22 class ClientT;
23 class ServerT;
24 class SvGuiCallbT;
25 class ModelManagerT;
26 namespace cf { namespace GuiSys { class GuiResourcesT; } }
27 namespace cf { class ConsoleI; }
28 
29 
30 /// This class represents the Cafu main OpenGL 3D canvas.
31 class MainCanvasT : public wxGLCanvas
32 {
33  public:
34 
35  /// The constructor.
36  MainCanvasT(MainFrameT* Parent, const GameInfoT& GameInfo);
37 
38  /// The destructor.
39  ~MainCanvasT();
40 
41 
42  private:
43 
44  enum InitStateT { INIT_REQUIRED, INIT_FAILED, INIT_SUCCESS };
45  enum LastMousePosT { IN_CLIENT_3D_GUI, IN_OTHER_2D_GUI };
46 
47  void Initialize();
48  void TakeScreenshot() const;
49 
50  void OnPaint(wxPaintEvent& PE);
51  void OnSize(wxSizeEvent& SE);
52  void OnIdle(wxIdleEvent& IE); ///< The idle event handler runs one frame of the Cafu Engine (client and/or server).
53 
54  void OnMouseMove (wxMouseEvent& ME);
55  void OnMouseWheel(wxMouseEvent& ME);
56  void OnLMouseDown(wxMouseEvent& ME);
57  void OnLMouseUp (wxMouseEvent& ME);
58  void OnRMouseDown(wxMouseEvent& ME);
59  void OnRMouseUp (wxMouseEvent& ME);
60 
61  void OnKeyDown(wxKeyEvent& KE);
62  void OnKeyUp (wxKeyEvent& KE);
63  void OnKeyChar(wxKeyEvent& KE);
64 
65  MainFrameT* m_Parent;
66  const GameInfoT& m_GameInfo;
67  InitStateT m_InitState; ///< Indicates whether initialization is still required, was attempted but failed, or completed successfully.
68  wxGLContext* m_GLContext; ///< The OpenGL rendering context that represents our app-global OpenGL state.
69  HMODULE m_RendererDLL;
70  ModelManagerT* m_ModelManager;
71  cf::GuiSys::GuiResourcesT* m_GuiResources;
72  HMODULE m_SoundSysDLL;
73  ClientT* m_Client;
74  ServerT* m_Server;
75  SvGuiCallbT* m_SvGuiCallback;
76  cf::ConsoleI* m_ConByGuiWin; ///< This points to an instance of cf::GuiSys::ConsoleByWindowT.
77  TimerT m_Timer;
78  double m_TotalTime;
79  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.
80 
81  DECLARE_EVENT_TABLE()
82 };
83 
84 #endif
~MainCanvasT()
The destructor.
Definition: MainCanvas.cpp:121
This class represents the Cafu main OpenGL 3D canvas.
Definition: MainCanvas.hpp:31
The server, like the client, is a state machine.
Definition: Server.hpp:30
This class is an interface to the application console.
Definition: Console.hpp:18
A platform independent timer class that allows to measure the time passed since its construction or t...
Definition: Util.hpp:24
Definition: MainCanvas.cpp:44
This class encapsulates information about a game.
Definition: GameInfo.hpp:14
Definition: Client.hpp:24
This class is used for managing model instances.
Definition: ModelManager.hpp:31
This class represents the Cafu main frame.
Definition: MainFrame.hpp:18
MainCanvasT(MainFrameT *Parent, const GameInfoT &GameInfo)
The constructor.
Definition: MainCanvas.cpp:96
This class manages and provides resources (fonts and models) for GuiImplT instances.
Definition: GuiResources.hpp:26