AGX Dynamics 2.38.0.2
Loading...
Searching...
No Matches
SdlApplication.h
Go to the documentation of this file.
1/*
2Copyright 2007-2024. Algoryx Simulation AB.
3
4All AGX source code, intellectual property, documentation, sample code,
5tutorials, scene files and technical white papers, are copyrighted, proprietary
6and confidential material of Algoryx Simulation AB. You may not download, read,
7store, distribute, publish, copy or otherwise disseminate, use or expose this
8material unless having a written signed agreement with Algoryx Simulation AB, or having been
9advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10valid commercial license from Algoryx Simulation AB.
11
12Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13from using this software, unless otherwise stated in written agreements with
14Algoryx 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
28namespace 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:254
#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.
Base class providing referencing counted objects.
Definition Referenced.h:120
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
uint64_t UInt
Definition Integer.h:27
double Real
Definition Real.h:42