Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • gamedev/fggl
  • onuralpsezer/fggl
2 results
Show changes
Showing
with 1148 additions and 218 deletions
# headers # headers
file(GLOB_RECURSE HEADER_LIST CONFIGURE_DEPENDS "${CMAKE_SOURCE_DIR}/include/fggl/**.hpp") file(GLOB_RECURSE HEADER_LIST CONFIGURE_DEPENDS "${CMAKE_SOURCE_DIR}/include/fggl/**.hpp")
# the fggl library itself # the fggl library itself
# Should be shared linkage for legal reasons (LGPL)
add_library(fggl ${HEADER_LIST}) add_library(fggl ${HEADER_LIST})
target_link_libraries(fggl PUBLIC entt)
# we need to tell people using the library about our headers # we need to tell people using the library about our headers
target_include_directories(fggl target_include_directories(fggl
PUBLIC PUBLIC
...@@ -31,6 +33,14 @@ if (CLANG_TIDY_FOUND) ...@@ -31,6 +33,14 @@ if (CLANG_TIDY_FOUND)
set(CMAKE_CXX_CLANG_TIDY clang-tidy -checks=*,-llvmlibc-*,-fuchsia-*,-cppcoreguidelines-*,-android-*,-llvm-*,-altera-*,-modernize-use-trailing-return-type) set(CMAKE_CXX_CLANG_TIDY clang-tidy -checks=*,-llvmlibc-*,-fuchsia-*,-cppcoreguidelines-*,-android-*,-llvm-*,-altera-*,-modernize-use-trailing-return-type)
endif () endif ()
# the important stuff everything else uses
add_subdirectory(math)
add_subdirectory(util)
add_subdirectory(grid)
add_subdirectory(assets)
add_subdirectory(phys)
target_sources(${PROJECT_NAME} target_sources(${PROJECT_NAME}
PRIVATE PRIVATE
app.cpp app.cpp
...@@ -38,11 +48,7 @@ target_sources(${PROJECT_NAME} ...@@ -38,11 +48,7 @@ target_sources(${PROJECT_NAME}
data/model.cpp data/model.cpp
data/procedural.cpp data/procedural.cpp
data/heightmap.cpp data/heightmap.cpp
data/module.cpp
ecs/ecs.cpp
ecs3/module/module.cpp
ecs3/fast/Container.cpp
ecs3/prototype/world.cpp
scenes/menu.cpp scenes/menu.cpp
scenes/game.cpp scenes/game.cpp
...@@ -50,35 +56,35 @@ target_sources(${PROJECT_NAME} ...@@ -50,35 +56,35 @@ target_sources(${PROJECT_NAME}
input/input.cpp input/input.cpp
input/mouse.cpp input/mouse.cpp
input/camera_input.cpp input/camera_input.cpp
)
gui/widget.cpp # GUI support
gui/widgets.cpp add_subdirectory(gui)
gui/containers.cpp
gui/fonts.cpp
math/triangulation.cpp
math/shapes.cpp
)
# yaml-cpp for configs and storage # yaml-cpp for configs and storage
find_package(yaml-cpp) find_package(yaml-cpp)
target_link_libraries(fggl PUBLIC yaml-cpp) target_link_libraries(fggl PUBLIC yaml-cpp)
# spdlog for cleaner logging # model loading
find_package(spdlog) add_subdirectory(data/assimp)
target_link_libraries(${PROJECT_NAME} PRIVATE spdlog::spdlog)
find_package(freetype)
target_link_libraries(${PROJECT_NAME} PUBLIC freetype)
# Graphics backend # Graphics backend
add_subdirectory(gfx) add_subdirectory(gfx)
add_subdirectory(audio) add_subdirectory(audio)
# physics integration # physics integration
add_subdirectory(phys/bullet)
# Debug backend # Debug backend
add_subdirectory(debug) add_subdirectory(debug)
# platform integrations
add_subdirectory(platform)
add_subdirectory(entity)
##
# begin windows support
##
if (MSVC)
target_compile_options(${PROJECT_NAME} PUBLIC "/ZI")
target_link_options(${PROJECT_NAME} PUBLIC "/INCREMENTAL")
endif ()
/*
* This file is part of FGGL.
*
* FGGL is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* FGGL is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with FGGL.
* If not, see <https://www.gnu.org/licenses/>.
*/
// the configured options and settings for Tutorial // the configured options and settings for Tutorial
#define FGGL_VERSION_MAJOR @FGGL_VERSION_MAJOR@ #define FGGL_VERSION_MAJOR @FGGL_VERSION_MAJOR@
#define FGGL_VERSION_MINOR @FGGL_VERSION_MINOR@ #define FGGL_VERSION_MINOR @FGGL_VERSION_MINOR@
/*
* This file is part of FGGL.
*
* FGGL is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* FGGL is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with FGGL.
* If not, see <https://www.gnu.org/licenses/>.
*/
#include <cstdlib> #include <cstdlib>
#include <memory>
#include <spdlog/spdlog.h> #include <spdlog/spdlog.h>
#include <fggl/app.hpp> #include <fggl/app.hpp>
#include <fggl/ecs3/types.hpp>
#include <fggl/ecs3/module/module.h>
#include <fggl/util/service.h>
namespace fggl { namespace fggl {
App::App(const Identifer& name) : App::App( name, name ) { App::App(modules::Manager *services, const Identifer &name) : App::App(services, name, name) {
} }
App::App(const Identifer& name, const Identifer& folder ) : App::App(modules::Manager *services, const Identifer & /*name*/, const Identifer & /*folder*/ ) :
m_running(true), m_running(true),
m_types(std::make_unique<ecs3::TypeRegistry>()),
m_modules(std::make_unique<ecs3::ModuleManager>(*m_types)),
m_window(nullptr), m_window(nullptr),
m_states() {} m_states(),
m_subsystems(services) {}
int App::run(int argc, const char** argv) { auto App::run(int /*argc*/, const char **/*argv*/) -> int {
auto *windowing = m_subsystems->get<display::WindowService>();
{ {
// activate the first state // activate the first state
auto& state = m_states.active(); auto &state = m_states.active();
m_expectedScene = m_states.activeID(); m_expectedScene = m_states.activeID();
state.activate(); state.activate();
} }
auto lastTime = glfwGetTime();
while (m_running) {
auto currTime = glfwGetTime();
auto delta = currTime - lastTime;
lastTime = currTime;
while ( m_running ) {
// trigger a state change if expected // trigger a state change if expected
if ( m_expectedScene != m_states.activeID() ) { if (m_expectedScene != m_states.activeID()) {
m_states.change(m_expectedScene); auto result = m_states.change(m_expectedScene);
if (!result) {
m_expectedScene = m_states.activeID();
}
} }
auto& state = m_states.active(); // process window events
m_modules->onUpdate(); if (windowing != nullptr) {
state.update(); windowing->pollEvents();
}
//m_modules->onUpdate();
auto &state = m_states.active();
state.update((float)delta);
// window rendering to frame buffer // window rendering to frame buffer
if ( m_window != nullptr ) { if (m_window != nullptr) {
m_modules->onFrameStart(); // m_modules->onFrameStart();
m_window->frameStart(); m_window->frameStart();
// get draw instructions // get draw instructions
auto& graphics = m_window->graphics(); auto &graphics = m_window->graphics();
state.render(graphics); state.render(graphics);
m_window->frameEnd(); m_window->frameEnd();
m_modules->onFrameEnd(); // m_modules->onFrameEnd();
m_running = m_running && !m_window->wantClose(); m_running = m_running && !m_window->wantClose();
} }
} }
{ {
// shutdown last state // shutdown last state
auto& state = m_states.active(); auto &state = m_states.active();
state.deactivate(); state.deactivate();
} }
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
} //namespace fggl } //namespace fggl
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.