-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
76 changed files
with
3,990 additions
and
4,104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--- | ||
BasedOnStyle: Google | ||
--- | ||
Language: Cpp | ||
IndentWidth: 4 | ||
ColumnLimit: 150 | ||
BreakBeforeBraces: Allman | ||
PackConstructorInitializers: Never | ||
SpaceBeforeCtorInitializerColon: true | ||
BreakConstructorInitializers: AfterColon | ||
AllowShortFunctionsOnASingleLine: Inline | ||
BreakBeforeBinaryOperators: None | ||
AlignAfterOpenBracket: BlockIndent | ||
AllowShortLambdasOnASingleLine: Empty | ||
BinPackArguments: false | ||
BinPackParameters: false | ||
NamespaceIndentation: All | ||
ReferenceAlignment: Left | ||
AllowAllParametersOfDeclarationOnNextLine: true | ||
--- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,79 +1,79 @@ | ||
#pragma once | ||
|
||
#include "GlfwWindow.hpp" | ||
#include "input/EntityController.hpp" | ||
#include "world/BlockRegistry.hpp" | ||
#include "world/Entity.hpp" | ||
#include "video/DebugUi.hpp" | ||
#include "util/SyncJobExecutor.hpp" | ||
#include "util/ThreadPool.hpp" | ||
#include "world/volume/SinCosVolumeGenerator.hpp" | ||
#include "world/volume/PerlinNoiseGenerator.hpp" | ||
#include "video/DebugUi.hpp" | ||
#include "world/BlockRegistry.hpp" | ||
#include "world/Entity.hpp" | ||
#include "world/surface/BlockySurfaceGenerator.hpp" | ||
#include "GlfwWindow.hpp" | ||
#include "world/volume/PerlinNoiseGenerator.hpp" | ||
#include "world/volume/SinCosVolumeGenerator.hpp" | ||
|
||
namespace explo | ||
{ | ||
class Game | ||
{ | ||
public: | ||
/* Misc utils */ | ||
SyncJobExecutor m_main_thread_executor; | ||
ThreadPool m_thread_pool; | ||
public: | ||
/* Misc utils */ | ||
SyncJobExecutor m_main_thread_executor; | ||
ThreadPool m_thread_pool; | ||
|
||
/* World */ | ||
BlockRegistry m_block_registry; | ||
PerlinNoiseGenerator m_volume_generator; | ||
BlockySurfaceGenerator m_surface_generator; | ||
BlockRegistry m_block_registry; | ||
PerlinNoiseGenerator m_volume_generator; | ||
BlockySurfaceGenerator m_surface_generator; | ||
|
||
/* Video */ | ||
GlfwWindow& m_window; | ||
std::unique_ptr<DebugUi> m_debug_ui; | ||
GlfwWindow &m_window; | ||
std::unique_ptr<DebugUi> m_debug_ui; | ||
|
||
float m_dt = 0.0f; | ||
std::optional<float> m_last_frame_time; | ||
float m_dt = 0.0f; | ||
std::optional<float> m_last_frame_time; | ||
|
||
// FPS | ||
std::optional<float> m_last_fps_time; | ||
int m_fps_counter = 0; | ||
int m_fps = 0; | ||
// FPS | ||
std::optional<float> m_last_fps_time; | ||
int m_fps_counter = 0; | ||
int m_fps = 0; | ||
|
||
/* Late initialize */ | ||
std::shared_ptr<World> m_world; | ||
std::shared_ptr<Entity> m_player; | ||
std::unique_ptr<EntityController> m_player_controller; | ||
/* Late initialize */ | ||
std::shared_ptr<World> m_world; | ||
std::shared_ptr<Entity> m_player; | ||
std::unique_ptr<EntityController> m_player_controller; | ||
|
||
public: | ||
explicit Game(GlfwWindow& window); | ||
public: | ||
explicit Game(GlfwWindow &window); | ||
~Game(); | ||
|
||
GlfwWindow& get_window() { return m_window; }; | ||
float get_dt() const { return m_dt; } | ||
GlfwWindow &get_window() { return m_window; }; | ||
float get_dt() const { return m_dt; } | ||
|
||
/* Job executors */ | ||
/* Job executors */ | ||
|
||
void run_on_main_thread(std::function<void()> const& job); | ||
void run_async(std::function<void()> const& job); | ||
void run_on_main_thread(std::function<void()> const &job); | ||
void run_async(std::function<void()> const &job); | ||
|
||
void on_window_resize(uint32_t width, uint32_t height); | ||
void on_window_resize(uint32_t width, uint32_t height); | ||
void render(); | ||
|
||
private: | ||
void late_initialize(); | ||
private: | ||
void late_initialize(); | ||
|
||
void on_key_change(int key, int action); | ||
void on_key_change(int key, int action); | ||
}; | ||
|
||
// -------------------------------------------------------------------------------------------------------------------------------- | ||
// -------------------------------------------------------------------------------------------------------------------------------- | ||
|
||
void init(GlfwWindow& window); | ||
void shutdown(); | ||
void init(GlfwWindow &window); | ||
void shutdown(); | ||
|
||
void render(); | ||
void render(); | ||
|
||
Game& game(); | ||
Game &game(); | ||
|
||
/* Helpers */ | ||
/* Helpers */ | ||
|
||
void run_on_main_thread(std::function<void()> const& job); | ||
void run_async(std::function<void()> const& job); | ||
} | ||
void run_on_main_thread(std::function<void()> const &job); | ||
void run_async(std::function<void()> const &job); | ||
} // namespace explo |
Oops, something went wrong.