Source/Gorgon/Main.h

Tue, 06 Jul 2021 10:22:49 +0300

author
cemkalyoncu
date
Tue, 06 Jul 2021 10:22:49 +0300
branch
4.x-dev
changeset 1701
b168349a931d
parent 1387
2e91fa117d0f
child 1728
92bb193f0a6e
permissions
-rwxr-xr-x

* Image/Bitmap rotate

764
7c71952bd75b Gorgon code base has been moved to Source/Gorgon
cengizkandemir
parents:
diff changeset
1 #pragma once
7c71952bd75b Gorgon code base has been moved to Source/Gorgon
cengizkandemir
parents:
diff changeset
2
7c71952bd75b Gorgon code base has been moved to Source/Gorgon
cengizkandemir
parents:
diff changeset
3 #include <string>
7c71952bd75b Gorgon code base has been moved to Source/Gorgon
cengizkandemir
parents:
diff changeset
4
789
4de9ca4d7da0 * HTTP transfer using CURL
cemkalyoncu <cemkalyoncu@gmail.com>
parents: 764
diff changeset
5 #include "Event.h"
4de9ca4d7da0 * HTTP transfer using CURL
cemkalyoncu <cemkalyoncu@gmail.com>
parents: 764
diff changeset
6
831
c8208074b8fa * Design document improvements
cemkalyoncu <cemkalyoncu@gmail.com>
parents: 789
diff changeset
7 ///@page Design
c8208074b8fa * Design document improvements
cemkalyoncu <cemkalyoncu@gmail.com>
parents: 789
diff changeset
8 ///@htmlinclude "Design.html"
c8208074b8fa * Design document improvements
cemkalyoncu <cemkalyoncu@gmail.com>
parents: 789
diff changeset
9
764
7c71952bd75b Gorgon code base has been moved to Source/Gorgon
cengizkandemir
parents:
diff changeset
10 /// Root namespace for Gorgon Game Engine.
7c71952bd75b Gorgon code base has been moved to Source/Gorgon
cengizkandemir
parents:
diff changeset
11 namespace Gorgon {
7c71952bd75b Gorgon code base has been moved to Source/Gorgon
cengizkandemir
parents:
diff changeset
12
7c71952bd75b Gorgon code base has been moved to Source/Gorgon
cengizkandemir
parents:
diff changeset
13 /// @cond INTERNAL
7c71952bd75b Gorgon code base has been moved to Source/Gorgon
cengizkandemir
parents:
diff changeset
14 namespace internal {
7c71952bd75b Gorgon code base has been moved to Source/Gorgon
cengizkandemir
parents:
diff changeset
15 extern std::string systemname;
7c71952bd75b Gorgon code base has been moved to Source/Gorgon
cengizkandemir
parents:
diff changeset
16 }
7c71952bd75b Gorgon code base has been moved to Source/Gorgon
cengizkandemir
parents:
diff changeset
17 /// @endcond
7c71952bd75b Gorgon code base has been moved to Source/Gorgon
cengizkandemir
parents:
diff changeset
18
1077
97d2ec99a868 * Added documentation for Scene system, still needs an example
cemkalyoncu
parents: 1072
diff changeset
19 /// Defines the abstract class of Runner. Runners take the control of the code
1070
d52068ce190d * Scene support is ready, waiting for unit tests
cemkalyoncu
parents: 831
diff changeset
20 /// execution, calling any necessary functions as the events occur.
d52068ce190d * Scene support is ready, waiting for unit tests
cemkalyoncu
parents: 831
diff changeset
21 class Runner {
d52068ce190d * Scene support is ready, waiting for unit tests
cemkalyoncu
parents: 831
diff changeset
22 public:
d52068ce190d * Scene support is ready, waiting for unit tests
cemkalyoncu
parents: 831
diff changeset
23 /// Takes the control of the execution until Quit is called.
d52068ce190d * Scene support is ready, waiting for unit tests
cemkalyoncu
parents: 831
diff changeset
24 virtual void Run() = 0;
d52068ce190d * Scene support is ready, waiting for unit tests
cemkalyoncu
parents: 831
diff changeset
25
1072
5d8b0d820bb8 * Unit tests for scene system
cemkalyoncu
parents: 1070
diff changeset
26 /// Runs a single frame
5d8b0d820bb8 * Unit tests for scene system
cemkalyoncu
parents: 1070
diff changeset
27 virtual void Step() = 0;
5d8b0d820bb8 * Unit tests for scene system
cemkalyoncu
parents: 1070
diff changeset
28
1070
d52068ce190d * Scene support is ready, waiting for unit tests
cemkalyoncu
parents: 831
diff changeset
29 /// Should quit after the current frame is completed for a graceful exit.
d52068ce190d * Scene support is ready, waiting for unit tests
cemkalyoncu
parents: 831
diff changeset
30 virtual void Quit() = 0;
d52068ce190d * Scene support is ready, waiting for unit tests
cemkalyoncu
parents: 831
diff changeset
31 };
d52068ce190d * Scene support is ready, waiting for unit tests
cemkalyoncu
parents: 831
diff changeset
32
1387
2e91fa117d0f * Widget registry
cemkalyoncu
parents: 1288
diff changeset
33 /// Initializes the entire system except for graphics and UI. Graphics should
2e91fa117d0f * Widget registry
cemkalyoncu
parents: 1288
diff changeset
34 /// be initialized after a window is created and UI should be initialized last.
764
7c71952bd75b Gorgon code base has been moved to Source/Gorgon
cengizkandemir
parents:
diff changeset
35 void Initialize(const std::string &systemname);
7c71952bd75b Gorgon code base has been moved to Source/Gorgon
cengizkandemir
parents:
diff changeset
36
7c71952bd75b Gorgon code base has been moved to Source/Gorgon
cengizkandemir
parents:
diff changeset
37 /// Returns the name of the current system
7c71952bd75b Gorgon code base has been moved to Source/Gorgon
cengizkandemir
parents:
diff changeset
38 inline std::string GetSystemName() { return internal::systemname; }
7c71952bd75b Gorgon code base has been moved to Source/Gorgon
cengizkandemir
parents:
diff changeset
39
7c71952bd75b Gorgon code base has been moved to Source/Gorgon
cengizkandemir
parents:
diff changeset
40 /// Performs various operations that are vital to system execution. These include
7c71952bd75b Gorgon code base has been moved to Source/Gorgon
cengizkandemir
parents:
diff changeset
41 /// OS message handling, animation and sound progressions, time progression and
7c71952bd75b Gorgon code base has been moved to Source/Gorgon
cengizkandemir
parents:
diff changeset
42 /// delta time calculation. NextFrame function should be preferred if the frame delay
7c71952bd75b Gorgon code base has been moved to Source/Gorgon
cengizkandemir
parents:
diff changeset
43 /// is tolerable.
7c71952bd75b Gorgon code base has been moved to Source/Gorgon
cengizkandemir
parents:
diff changeset
44 void Tick();
7c71952bd75b Gorgon code base has been moved to Source/Gorgon
cengizkandemir
parents:
diff changeset
45
7c71952bd75b Gorgon code base has been moved to Source/Gorgon
cengizkandemir
parents:
diff changeset
46 /// This function calls the starts the rendering pipeline. Rendering should be last
7c71952bd75b Gorgon code base has been moved to Source/Gorgon
cengizkandemir
parents:
diff changeset
47 /// operation of a frame.
7c71952bd75b Gorgon code base has been moved to Source/Gorgon
cengizkandemir
parents:
diff changeset
48 void Render();
7c71952bd75b Gorgon code base has been moved to Source/Gorgon
cengizkandemir
parents:
diff changeset
49
7c71952bd75b Gorgon code base has been moved to Source/Gorgon
cengizkandemir
parents:
diff changeset
50 /// This function marks the end of current frame and starts the next one. This function calls
7c71952bd75b Gorgon code base has been moved to Source/Gorgon
cengizkandemir
parents:
diff changeset
51 /// the Tick function at start of the next frame. Additionally, this function calls end of
7c71952bd75b Gorgon code base has been moved to Source/Gorgon
cengizkandemir
parents:
diff changeset
52 /// frame tasks such as rendering. Before starting the next frame, a certain delay is performed.
7c71952bd75b Gorgon code base has been moved to Source/Gorgon
cengizkandemir
parents:
diff changeset
53 /// This delay aims to set each frame duration to 16ms, this duration sets the frames per second
7c71952bd75b Gorgon code base has been moved to Source/Gorgon
cengizkandemir
parents:
diff changeset
54 /// to 62.5. This delay greatly reduces the system load of simple games/applications.
7c71952bd75b Gorgon code base has been moved to Source/Gorgon
cengizkandemir
parents:
diff changeset
55 void NextFrame();
7c71952bd75b Gorgon code base has been moved to Source/Gorgon
cengizkandemir
parents:
diff changeset
56
7c71952bd75b Gorgon code base has been moved to Source/Gorgon
cengizkandemir
parents:
diff changeset
57 /// This method works similar to next frame, however, no delay is done. This function allows an
7c71952bd75b Gorgon code base has been moved to Source/Gorgon
cengizkandemir
parents:
diff changeset
58 /// application to update the display and perform OS tasks while still continuing operation.
789
4de9ca4d7da0 * HTTP transfer using CURL
cemkalyoncu <cemkalyoncu@gmail.com>
parents: 764
diff changeset
59 inline void UpdateFrame();
1288
27ad8c8a1fa8 * Press/Release events for buttons
cemkalyoncu
parents: 1077
diff changeset
60
27ad8c8a1fa8 * Press/Release events for buttons
cemkalyoncu
parents: 1077
diff changeset
61 /// Registers a function to be run at the start of the next frame.
27ad8c8a1fa8 * Press/Release events for buttons
cemkalyoncu
parents: 1077
diff changeset
62 void RegisterOnce(std::function<void()> fn);
789
4de9ca4d7da0 * HTTP transfer using CURL
cemkalyoncu <cemkalyoncu@gmail.com>
parents: 764
diff changeset
63
4de9ca4d7da0 * HTTP transfer using CURL
cemkalyoncu <cemkalyoncu@gmail.com>
parents: 764
diff changeset
64 extern Event<> BeforeFrameEvent;
764
7c71952bd75b Gorgon code base has been moved to Source/Gorgon
cengizkandemir
parents:
diff changeset
65 }

mercurial