AGX Dynamics  2.35.0.1
SdlApplication.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2022. Algoryx Simulation AB.
3 
4 All AGX source code, intellectual property, documentation, sample code,
5 tutorials, scene files and technical white papers, are copyrighted, proprietary
6 and confidential material of Algoryx Simulation AB. You may not download, read,
7 store, distribute, publish, copy or otherwise disseminate, use or expose this
8 material unless having a written signed agreement with Algoryx Simulation AB, or having been
9 advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10 valid commercial license from Algoryx Simulation AB.
11 
12 Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13 from using this software, unless otherwise stated in written agreements with
14 Algoryx Simulation AB.
15 */
16 #ifndef AGXGL_SDLAPPLICATION_H
17 #define AGXGL_SDLAPPLICATION_H
18 
19 #if AGX_USE_SDL()
20 
21 #include <agx/config/AGX_USE_SDL.h>
22 #include <agx/Referenced.h>
23 #include <agx/Component.h>
24 #include <agx/Timer.h>
25 #include <agxGL/Camera.h>
26 #include <SDL/SDL.h>
27 
28 namespace agxGL
29 {
30  AGX_DECLARE_POINTER_TYPES(SdlApplication);
31  class AGXPHYSICS_EXPORT SdlApplication : public agx::Referenced
32  {
33  public:
34  SdlApplication(agx::System *system, agx::UInt width = 1024, agx::UInt height = 768);
35 
36  void run(bool blocking = true);
37 
38  protected:
39  virtual ~SdlApplication();
40 
41  private:
42  void initSDL(agx::UInt width, agx::UInt height);
43  void handleEvents();
44  void handleContinuousEvents(agx::Real dt);
45  void handleEvent(const SDL_Event& event);
46  void initComponent(agx::Component *component);
47 
48  private:
49  bool m_running;
50  bool m_autoStepping;
51  agx::SystemRef m_system;
52  CameraRef m_camera;
53 
54  bool m_mouseDragged;
55  agx::Vec2i m_mouseDragStartPosition;
56  agx::HashSet<int> m_continuousKeys;
57  agx::Vec2i m_relMouse;
58  agx::Real m_moveSpeed;
59  agx::Real m_zoomSpeed;
60  agx::Real m_mouseSensitivity;
61  agx::Real m_moveSpeedDelta;
62  agx::Timer m_eventTimer;
63  agx::Timer m_stepTimer;
64  agx::Real m_accumulatedTime;
65  };
66 
67 }
68 
69 #endif
70 
71 #endif /* _AGXGL_SDLAPPLICATION_H_ */
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:248
#define AGXPHYSICS_EXPORT
A component is an object containing other objects, enabling hierarchical structuring.
Definition: Component.h:39
Inheritance with partial specialization due to bug with ref_ptr containers.
Definition: agx/HashSet.h:666
Base class providing referencing counted objects.
Definition: Referenced.h:114
The Timer class permits timing execution speed with the same refinement as the built in hardware cloc...
Definition: Timer.h:75
This namespace contains OpenGL specific details for connecting OpenCL/OpenGL.
agx::ref_ptr< Camera > CameraRef
Definition: Camera.h:184
agx::ref_ptr< System > SystemRef
Definition: Output.h:28
uint32_t UInt
Definition: Integer.h:34
double Real
Definition: Real.h:42