Skip to content

Commit

Permalink
remove core/utils subdir
Browse files Browse the repository at this point in the history
  • Loading branch information
nekoffski committed May 1, 2024
1 parent 63eb611 commit f690e1f
Show file tree
Hide file tree
Showing 63 changed files with 145 additions and 70 deletions.
5 changes: 3 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ set(CMAKE_BUILD_TYPE Debug)
# set(CMAKE_BUILD_TYPE RelWithDebInfo)
set(SL_INCLUDE ${CMAKE_CURRENT_SOURCE_DIR}/engine/src)

set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=address")
set (CMAKE_LINKER_FLAGS_DEBUG "${CMAKE_LINKER_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=address")
# set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=address")
# set (CMAKE_LINKER_FLAGS_DEBUG "${CMAKE_LINKER_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=address")

add_definitions(-DDEV_MODE=1)
add_definitions(-DUSE_GLFW=1)
Expand Down Expand Up @@ -40,3 +40,4 @@ endif()
add_subdirectory(3rdparty)
add_subdirectory(engine)
add_subdirectory(editor)
add_subdirectory(sandbox)
14 changes: 7 additions & 7 deletions editor/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@

Application::Application(int argc, char** argv) :
m_isRunning(false), m_update(false), m_context("Starlight Editor"),
m_window(m_context.getWindow()), m_renderer(*m_window, *m_context.getConfig()),
m_window(m_context.getWindow()), m_renderer(m_context),
m_resourceContext(*m_renderer.getResourcePools()), m_activeCamera(nullptr),
m_ui(
m_window->getSize().width,
m_window->getSize().height, // TODO: no comment required
m_window.getSize().width,
m_window.getSize().height, // TODO: no comment required
m_renderer, &m_scene
),
m_logger(m_ui.getLogger()), m_sceneSerializer(m_fileSystem),
m_sceneDeserializer(m_fileSystem) {
const auto& [w, h] = m_window->getSize();
const auto& [w, h] = m_window.getSize();

sl::ModelManager::get().load("falcon");
sl::ModelManager::get().load("tower");
Expand Down Expand Up @@ -130,13 +130,13 @@ void Application::setupEventHandlers() {
if (key == SL_KEY_4) {
m_activeCamera = m_eulerCamera.get();
m_ui.getState()->camera = m_activeCamera;
m_window->showCursor();
m_window.showCursor();
for (auto& view : m_views) view->setCamera(m_activeCamera);
}
if (key == SL_KEY_3) {
m_activeCamera = m_firstPersonCamera.get();
m_ui.getState()->camera = m_activeCamera;
m_window->hideCursor();
m_window.hideCursor();
for (auto& view : m_views) view->setCamera(m_activeCamera);
}
if (key == SL_KEY_U) m_update = !m_update;
Expand Down Expand Up @@ -176,7 +176,7 @@ void Application::setupEventHandlers() {
}

void Application::calculateViewport() {
const auto [w, h] = m_window->getSize();
const auto [w, h] = m_window.getSize();

m_viewport.x = panelWidthFactor * w;
m_viewport.y = 0.25f * h;
Expand Down
4 changes: 2 additions & 2 deletions editor/Application.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include "starlight/core/memory/Memory.hpp"
#include "starlight/core/window/Window.h"
#include "starlight/core/Context.h"
#include "starlight/core/utils/FileSystem.h"
#include "starlight/core/FileSystem.h"

#include "starlight/renderer/camera/EulerCamera.h"
#include "starlight/renderer/camera/FirstPersonCamera.h"
Expand Down Expand Up @@ -37,7 +37,7 @@ class Application {
bool m_update;

sl::Context m_context;
sl::Window* m_window;
sl::Window& m_window;
sl::RendererFrontend m_renderer;
sl::ResourceContext m_resourceContext;

Expand Down
2 changes: 1 addition & 1 deletion editor/ui/Console.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "Console.h"

#include "starlight/core/utils/TimeManager.h"
#include "starlight/core/TimeManager.h"
#include "starlight/ui/UI.h"

Console::Console() : m_logger(m_buffer) {}
Expand Down
2 changes: 1 addition & 1 deletion editor/ui/Console.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#include <fmt/core.h>

#include "starlight/core/utils/Log.h"
#include "starlight/core/Log.h"

class Logger {
enum class Severity { info, debug, warning };
Expand Down
2 changes: 1 addition & 1 deletion editor/ui/UI.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "UI.h"

#include "starlight/core/utils/Log.h"
#include "starlight/core/Log.h"
#include "starlight/core/math/Glm.h"
#include "starlight/core/event/Event.h"

Expand Down
7 changes: 3 additions & 4 deletions engine/src/starlight/core/Context.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "Context.h"

#include "utils/Log.h"
#include "Log.h"

namespace sl {

Expand All @@ -12,8 +12,6 @@ Context::LoggerInitializator::LoggerInitializator(const std::string& application
Context::Context(const std::string& applicationName) :
m_loggerInitializator(applicationName), m_windowManager(&m_window) {}

Window* Context::getWindow() { return &m_window; }

float Context::beginFrame() {
const auto deltaTime = m_timeManager.getDeltaTime();

Expand All @@ -31,6 +29,7 @@ void Context::endFrame() {
m_windowManager.update();
}

Config* Context::getConfig() { return &m_config; }
Config& Context::getConfig() { return m_config; }
Window& Context::getWindow() { return m_window; }

} // namespace sl
8 changes: 5 additions & 3 deletions engine/src/starlight/core/Context.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include "window/Vendor.h"

#include "event/Event.h"
#include "utils/TimeManager.h"
#include "TimeManager.h"
#include "Config.h"
#include "Core.h"

Expand All @@ -17,6 +17,8 @@ class Context {
explicit LoggerInitializator(const std::string& applicationName);
};

NO_COPY(Context);

public:
explicit Context(const std::string& applicationName = "starlight");

Expand All @@ -27,8 +29,8 @@ class Context {
endFrame();
}

Window* getWindow();
Config* getConfig();
Window& getWindow();
Config& getConfig();

private:
float beginFrame();
Expand Down
4 changes: 4 additions & 0 deletions engine/src/starlight/core/Core.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ namespace sl {

DEFINE_ERROR(Error);

#define NO_COPY(Class) \
Class(Class&) = delete; \
Class& operator=(Class&) = delete;

using u64 = uint64_t;
using u32 = uint32_t;
using u16 = uint16_t;
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <cstdint>

#include <starlight/core/Core.h>
#include <starlight/core/utils/Log.h>
#include <starlight/core/Log.h>

namespace sl {

Expand Down
1 change: 0 additions & 1 deletion engine/src/starlight/core/Id.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ class Id {
void invalidate() { m_value = invalidId; }

bool hasValue() const { return m_value != invalidId; }
// operator T() const { return m_value; }

private:
T m_value;
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include "starlight/core/Core.h"
#include "starlight/core/memory/Memory.hpp"
#include "starlight/core/math/Vertex.h"
#include "starlight/core/utils/Log.h"
#include "starlight/core/Log.h"

namespace sl {

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion engine/src/starlight/core/math/Vertex.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "Vertex.h"

#include "starlight/core/utils/Log.h"
#include "starlight/core/Log.h"

namespace sl {

Expand Down
2 changes: 1 addition & 1 deletion engine/src/starlight/core/memory/DynamicAllocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include <vector>

#include "starlight/core/utils/FreeList.h"
#include "starlight/core/FreeList.h"

namespace sl {

Expand Down
2 changes: 1 addition & 1 deletion engine/src/starlight/core/window/glfw/Vulkan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#include <GLFW/glfw3.h>

#include "starlight/core/utils/Log.h"
#include "starlight/core/Log.h"

#define VK_ASSERT(expr) \
{ ASSERT(expr == VK_SUCCESS, "Vulkan Fatal Error: {}", expr); }
Expand Down
2 changes: 1 addition & 1 deletion engine/src/starlight/core/window/glfw/Window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include <GLFW/glfw3.h>

#include "starlight/core/utils/Log.h"
#include "starlight/core/Log.h"
#include "starlight/core/event/Input.h"

namespace sl::glfw {
Expand Down
2 changes: 1 addition & 1 deletion engine/src/starlight/renderer/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
find_package(Vulkan REQUIRED)

set(SL_LIBS spdlog stb assimp dl kc fmt glfw imgui backward backward backward ${Vulkan_LIBRARIES} starlight-core)
set(SL_LIBS spdlog stb assimp dl kc fmt glfw imgui backward ${Vulkan_LIBRARIES} starlight-core)
set(SL_TARGET starlight-renderer)
file(GLOB_RECURSE SL_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp)

Expand Down
2 changes: 1 addition & 1 deletion engine/src/starlight/renderer/PolygonMode.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "PolygonMode.h"

#include "starlight/core/utils/Log.h"
#include "starlight/core/Log.h"

namespace sl {

Expand Down
8 changes: 4 additions & 4 deletions engine/src/starlight/renderer/RendererFrontend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@

namespace sl {

RendererFrontend::RendererFrontend(Window& window, const Config& config) :
m_backend(window, config), m_renderMode(RenderMode::standard),
m_framesSinceResize(0u), m_resizing(false) {
const auto [w, h] = window.getSize();
RendererFrontend::RendererFrontend(Context& context) :
m_backend(context.getWindow(), context.getConfig()),
m_renderMode(RenderMode::standard), m_framesSinceResize(0u), m_resizing(false) {
const auto [w, h] = context.getWindow().getSize();
m_viewportWidth = w;
m_viewportHeight = h;
}
Expand Down
8 changes: 6 additions & 2 deletions engine/src/starlight/renderer/RendererFrontend.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#include <functional>
#include <span>

#include "starlight/core/Context.h"

#include "RenderPacket.h"
#include "RenderMode.h"
#include "FrameStatistics.h"
Expand All @@ -17,8 +19,10 @@
namespace sl {

class RendererFrontend {
NO_COPY(RendererFrontend);

public:
explicit RendererFrontend(Window& window, const Config& config);
explicit RendererFrontend(Context& context);

void init(std::span<RenderView*> renderViews);

Expand All @@ -33,7 +37,7 @@ class RendererFrontend {
void onViewportResize(u32 w, u32 h);

private:
vk::VKRendererBackend m_backend;
RendererBackendVendor m_backend;

std::vector<RenderView*> m_renderViews;

Expand Down
2 changes: 1 addition & 1 deletion engine/src/starlight/renderer/Utils.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "CullMode.h"

#include "starlight/core/utils/Log.h"
#include "starlight/core/Log.h"

namespace sl {

Expand Down
2 changes: 1 addition & 1 deletion engine/src/starlight/renderer/camera/FirstPersonCamera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include <glm/gtc/matrix_transform.hpp>

#include "starlight/core/utils/Log.h"
#include "starlight/core/Log.h"
#include "starlight/core/window/Keys.h"

namespace sl {
Expand Down
2 changes: 1 addition & 1 deletion engine/src/starlight/renderer/gpu/Shader.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include "starlight/core/math/Glm.h"
#include "starlight/core/Id.hpp"
#include "starlight/core/Core.h"
#include "starlight/core/utils/Log.h"
#include "starlight/core/Log.h"
#include "starlight/renderer/CullMode.h"
#include "starlight/renderer/PolygonMode.h"
#include "fwd.h"
Expand Down
2 changes: 1 addition & 1 deletion engine/src/starlight/renderer/gpu/UIRenderer.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "UIRenderer.h"

#include "starlight/core/utils/Log.h"
#include "starlight/core/Log.h"

#include <imgui.h>

Expand Down
2 changes: 1 addition & 1 deletion engine/src/starlight/renderer/gpu/vulkan/VKBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <kc/core/Countable.hpp>

#include "starlight/core/memory/Memory.hpp"
#include "starlight/core/utils/FreeList.h"
#include "starlight/core/FreeList.h"

#include "VKLogicalDevice.h"
#include "VKContext.h"
Expand Down
2 changes: 1 addition & 1 deletion engine/src/starlight/renderer/gpu/vulkan/VKContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#include "starlight/core/fwd.h"
#include "starlight/core/Config.h"
#include "starlight/core/utils/RAIIWrapper.hpp"
#include "starlight/core/RAIIWrapper.hpp"

namespace sl::vk {

Expand Down
2 changes: 1 addition & 1 deletion engine/src/starlight/renderer/gpu/vulkan/VKPipeline.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <span>
#include <vector>

#include "starlight/core/utils/Log.h"
#include "starlight/core/Log.h"
#include "starlight/core/Core.h"

#include "Vulkan.h"
Expand Down
2 changes: 1 addition & 1 deletion engine/src/starlight/renderer/gpu/vulkan/VKResourcePools.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include "starlight/core/utils/ResourcePool.hpp"
#include "starlight/core/ResourcePool.hpp"
#include "starlight/renderer/gpu/ResourcePools.h"

#include "VKTexture.h"
Expand Down
2 changes: 1 addition & 1 deletion engine/src/starlight/renderer/gpu/vulkan/VKUIRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <imgui.h>
#include <ImGuizmo.h>

#include "starlight/core/utils/Log.h"
#include "starlight/core/Log.h"

#include "Vulkan.h"
#include "VKContext.h"
Expand Down
2 changes: 1 addition & 1 deletion engine/src/starlight/resource/configs/ImageData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include <stb.h>

#include "starlight/core/utils/Log.h"
#include "starlight/core/Log.h"

namespace sl {

Expand Down
2 changes: 1 addition & 1 deletion engine/src/starlight/resource/configs/MaterialConfig.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "MaterialConfig.h"

#include "starlight/core/utils/Json.hpp"
#include "starlight/core/Json.hpp"

namespace sl {

Expand Down
2 changes: 1 addition & 1 deletion engine/src/starlight/resource/configs/MaterialConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <string>

#include "starlight/core/math/Glm.h"
#include "starlight/core/utils/FileSystem.h"
#include "starlight/core/FileSystem.h"

#include "starlight/renderer/Material.h"

Expand Down

0 comments on commit f690e1f

Please sign in to comment.