diff --git a/Makefile b/Makefile deleted file mode 100644 index fd57751..0000000 --- a/Makefile +++ /dev/null @@ -1,24 +0,0 @@ -BUILD_DIR = build -EDITOR_DIR = editor -NAME = ferx - -RM += -r - -all: debug run - -release: - cmake -S . -B $(BUILD_DIR) -G Ninja -DCMAKE_BUILD_TYPE=Release - cmake --build $(BUILD_DIR) -j8 - -debug: - cmake -S . -B $(BUILD_DIR) -G Ninja -DCMAKE_BUILD_TYPE=Debug - cmake --build $(BUILD_DIR) -j8 - -run: - cd $(BUILD_DIR)/${EDITOR_DIR} && ./${NAME} - -clean: - cmake --build $(BUILD_DIR) --target clean - -clean-all: - $(RM) $(BUILD_DIR) diff --git a/editor/CMakeLists.txt b/editor/CMakeLists.txt index 6a079a0..5f10860 100644 --- a/editor/CMakeLists.txt +++ b/editor/CMakeLists.txt @@ -8,11 +8,17 @@ set(EDITOR_INCLUDE_DIR include) set(EDITOR_RESOURCES_DIR resources) file(GLOB_RECURSE EDITOR_SOURCES ${EDITOR_SOURCE_DIR}/*.cpp) -file(COPY ${EDITOR_RESOURCES_DIR}/ DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) add_executable(${NAME}) +# Add resources folder +if(CMAKE_BUILD_TYPE STREQUAL "Release") + file(COPY ${EDITOR_RESOURCES_DIR} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) + target_compile_definitions(${NAME} PUBLIC EDITOR_RESOURCES_PATH="resources/") +else() + target_compile_definitions(${NAME} PUBLIC EDITOR_RESOURCES_PATH="${CMAKE_CURRENT_SOURCE_DIR}/resources/") +endif() + target_sources(${NAME} PRIVATE ${EDITOR_SOURCES}) target_include_directories(${NAME} PRIVATE ${EDITOR_INCLUDE_DIR}) - target_link_libraries(${NAME} engine) diff --git a/editor/resources/imgui.ini b/editor/resources/imgui.ini index 2bf75d3..7377525 100644 --- a/editor/resources/imgui.ini +++ b/editor/resources/imgui.ini @@ -1,49 +1,49 @@ [Window][DockSpaceViewport_11111111] -Pos=0,19 -Size=900,581 +Pos=0,24 +Size=900,576 Collapsed=0 +[Window][ Properties] +Pos=706,24 +Size=194,576 +Collapsed=0 +DockId=0x00000002,0 + [Window][Debug##Default] Pos=60,60 Size=400,400 Collapsed=0 -[Window][Hierarchy] -Pos=0,19 -Size=189,581 -Collapsed=0 -DockId=0x00000005,0 - -[Window][Scene] -Pos=191,19 -Size=510,420 +[Window][ Entities] +Pos=0,24 +Size=176,576 Collapsed=0 DockId=0x00000003,0 -[Window][Project] -Pos=191,441 -Size=510,159 +[Window][ Files] +Pos=178,442 +Size=526,158 Collapsed=0 -DockId=0x00000004,0 +DockId=0x00000006,0 -[Window][Console] -Pos=191,441 -Size=510,159 +[Window][ Scene] +Pos=178,24 +Size=526,416 Collapsed=0 -DockId=0x00000004,1 +DockId=0x00000005,0 -[Window][Inspector] -Pos=703,19 -Size=197,581 +[Window][ Console] +Pos=178,442 +Size=526,158 Collapsed=0 -DockId=0x00000002,0 +DockId=0x00000006,1 [Docking][Data] -DockSpace ID=0x8B93E3BD Window=0xA787BDB4 Pos=0,19 Size=900,581 Split=X - DockNode ID=0x00000005 Parent=0x8B93E3BD SizeRef=189,581 Selected=0x29EABFBD - DockNode ID=0x00000006 Parent=0x8B93E3BD SizeRef=709,581 Split=X - DockNode ID=0x00000001 Parent=0x00000006 SizeRef=701,581 Split=Y - DockNode ID=0x00000003 Parent=0x00000001 SizeRef=608,420 CentralNode=1 Selected=0xE192E354 - DockNode ID=0x00000004 Parent=0x00000001 SizeRef=608,159 Selected=0xD04A4B96 - DockNode ID=0x00000002 Parent=0x00000006 SizeRef=197,581 Selected=0xE7039252 +DockSpace ID=0x8B93E3BD Window=0xA787BDB4 Pos=0,24 Size=900,576 Split=X + DockNode ID=0x00000003 Parent=0x8B93E3BD SizeRef=176,576 Selected=0xCCD86976 + DockNode ID=0x00000004 Parent=0x8B93E3BD SizeRef=722,576 Split=X + DockNode ID=0x00000001 Parent=0x00000004 SizeRef=526,576 Split=Y Selected=0xEE09B48D + DockNode ID=0x00000005 Parent=0x00000001 SizeRef=517,416 CentralNode=1 Selected=0xEE09B48D + DockNode ID=0x00000006 Parent=0x00000001 SizeRef=517,158 Selected=0x3CB89FC3 + DockNode ID=0x00000002 Parent=0x00000004 SizeRef=194,576 Selected=0x7B89DB48 diff --git a/editor/src/GUI.cpp b/editor/src/GUI.cpp index 4094ea8..c515a37 100644 --- a/editor/src/GUI.cpp +++ b/editor/src/GUI.cpp @@ -3,6 +3,8 @@ #include #include "GUI.h" +#include + #include "FrameBuffer.h" #include "Window.h" @@ -31,17 +33,19 @@ void GUI::LoadConfigs() io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; + io.IniFilename = EDITOR_RESOURCES_PATH"imgui.ini"; + float baseFontSize = 14.0f; float iconFontSize = baseFontSize * 2.0f / 2.4f; // FontAwesome fonts need to have their sizes reduced by 2.0f/3.0f in order to align correctly - io.Fonts->AddFontFromFileTTF("fonts/Ruda-Bold.ttf", baseFontSize); + io.Fonts->AddFontFromFileTTF(ENGINE_RESOURCES_PATH"fonts/Ruda-Bold.ttf", baseFontSize); static const ImWchar iconsRanges[] = { ICON_MIN_FA, ICON_MAX_16_FA, 0 }; ImFontConfig iconsConfig; iconsConfig.MergeMode = true; iconsConfig.PixelSnapH = true; iconsConfig.GlyphMinAdvanceX = iconFontSize; - io.Fonts->AddFontFromFileTTF( "fonts/" FONT_ICON_FILE_NAME_FAS, iconFontSize, &iconsConfig, iconsRanges ); + io.Fonts->AddFontFromFileTTF(ENGINE_RESOURCES_PATH"fonts/" FONT_ICON_FILE_NAME_FAS, iconFontSize, &iconsConfig, iconsRanges ); ImGui::StyleColorsDark(); @@ -146,7 +150,10 @@ void GUI::ShowEntities() { ImGui::Begin(ICON_FA_CUBE" Entities"); - ImGui::CollapsingHeader("Cube"); + for(const auto& cube : Renderer::GetData().m_Scene->GetCubes()) + { + ImGui::CollapsingHeader(cube->name.c_str()); + } ImGui::End(); } diff --git a/engine/CMakeLists.txt b/engine/CMakeLists.txt index 389d57a..79f5b10 100644 --- a/engine/CMakeLists.txt +++ b/engine/CMakeLists.txt @@ -21,14 +21,17 @@ file(GLOB COMPONENTS_SOURCES "${COMPONENTS_INCLUDES}/*.cpp") set(UI_INCLUDES ui) file(GLOB UI_SOURCES "${UI_INCLUDES}/*.cpp") +set(ENGINE_RESOURCES_DIR resources) + # Build engine as library add_library(${PROJECT_NAME}) # Add resources folder if(CMAKE_BUILD_TYPE STREQUAL "Release") - target_compile_definitions(${PROJECT_NAME} PUBLIC RESOURCES_PATH="./resources/") + file(COPY ${ENGINE_RESOURCES_DIR} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) + target_compile_definitions(${PROJECT_NAME} PUBLIC ENGINE_RESOURCES_PATH="${CMAKE_CURRENT_BINARY_DIR}/resources/") else() - target_compile_definitions(${PROJECT_NAME} PUBLIC RESOURCES_PATH="${CMAKE_SOURCE_DIR}/editor/resources/") + target_compile_definitions(${PROJECT_NAME} PUBLIC ENGINE_RESOURCES_PATH="${CMAKE_CURRENT_SOURCE_DIR}/resources/") endif() # Link sources, include directories, and third party libraries diff --git a/engine/rendering/Renderer.cpp b/engine/rendering/Renderer.cpp index c11958a..e418b6b 100644 --- a/engine/rendering/Renderer.cpp +++ b/engine/rendering/Renderer.cpp @@ -47,7 +47,7 @@ RendererData& Renderer::GetData() void Renderer::LoadShaders() { - s_Data.m_Shader = new Shader(RESOURCES_PATH"shaders/vertex.glsl", RESOURCES_PATH"shaders/fragment.glsl"); + s_Data.m_Shader = new Shader(ENGINE_RESOURCES_PATH"shaders/vertex.glsl", ENGINE_RESOURCES_PATH"shaders/fragment.glsl"); } void Renderer::SetupBuffers() diff --git a/editor/resources/fonts/Ruda-Bold.ttf b/engine/resources/fonts/Ruda-Bold.ttf similarity index 100% rename from editor/resources/fonts/Ruda-Bold.ttf rename to engine/resources/fonts/Ruda-Bold.ttf diff --git a/editor/resources/fonts/fa-regular-400.ttf b/engine/resources/fonts/fa-regular-400.ttf similarity index 100% rename from editor/resources/fonts/fa-regular-400.ttf rename to engine/resources/fonts/fa-regular-400.ttf diff --git a/editor/resources/fonts/fa-solid-900.ttf b/engine/resources/fonts/fa-solid-900.ttf similarity index 100% rename from editor/resources/fonts/fa-solid-900.ttf rename to engine/resources/fonts/fa-solid-900.ttf diff --git a/editor/resources/shaders/fragment.glsl b/engine/resources/shaders/fragment.glsl similarity index 100% rename from editor/resources/shaders/fragment.glsl rename to engine/resources/shaders/fragment.glsl diff --git a/editor/resources/shaders/vertex.glsl b/engine/resources/shaders/vertex.glsl similarity index 100% rename from editor/resources/shaders/vertex.glsl rename to engine/resources/shaders/vertex.glsl diff --git a/scripts/BuildProject.sh b/scripts/BuildProject.sh new file mode 100755 index 0000000..4323d49 --- /dev/null +++ b/scripts/BuildProject.sh @@ -0,0 +1,43 @@ +#!/bin/bash + +RELEASE_BUILD_DIR="build-release" +DEBUG_BUILD_DIR="build-debug" +EDITOR_DIR="editor" +NAME="ferx" + +case $1 in + build-release) + cmake -S .. -B ../"$RELEASE_BUILD_DIR" -G Ninja -DCMAKE_BUILD_TYPE=Release + cmake --build ../"$RELEASE_BUILD_DIR" -j8 + ;; + build-debug) + cmake -S .. -B ../"$DEBUG_BUILD_DIR" -G Ninja -DCMAKE_BUILD_TYPE=Debug + cmake --build ../"$DEBUG_BUILD_DIR" -j8 + ;; + run-release) + cd "../$RELEASE_BUILD_DIR/$EDITOR_DIR" && ./"$NAME" + ;; + run-debug) + cd "../$DEBUG_BUILD_DIR/$EDITOR_DIR" && ./"$NAME" + ;; + clean-release) + cmake --build ../"$RELEASE_BUILD_DIR" --target clean + ;; + clean-debug) + cmake --build ../"$DEBUG_BUILD_DIR" --target clean + ;; + clean-release-all) + rm -r ../"$RELEASE_BUILD_DIR" + ;; + clean-debug-all) + rm -r ../"$DEBUG_BUILD_DIR" + ;; + all) + bash $0 build-debug + bash $0 run-debug + ;; + *) + echo "Usage: $0 {all|build-release|build-debug|run-release|run-debug|clean-release|clean-debug|clean-release-all|clean-debug-all}" + exit 1 + ;; +esac diff --git a/scripts/Makefile b/scripts/Makefile new file mode 100644 index 0000000..7975e90 --- /dev/null +++ b/scripts/Makefile @@ -0,0 +1,34 @@ +DEBUG_BUILD_DIR = build-debug +RELEASE_BUILD_DIR = build-release +EDITOR_DIR = editor +NAME = ferx + +RM += -r + +all: build-debug run-debug + +build-release: + cmake -S .. -B ../$(RELEASE_BUILD_DIR) -G Ninja -DCMAKE_BUILD_TYPE=Release + cmake --build ../$(RELEASE_BUILD_DIR) -j8 + +build-debug: + cmake -S .. -B ../$(DEBUG_BUILD_DIR) -G Ninja -DCMAKE_BUILD_TYPE=Debug + cmake --build ../$(DEBUG_BUILD_DIR) -j8 + +run-release: + cd ../$(RELEASE_BUILD_DIR)/${EDITOR_DIR} && ./${NAME} + +run-debug: + cd ../$(DEBUG_BUILD_DIR)/${EDITOR_DIR} && ./${NAME} + +clean-release: + cmake --build ../$(RELEASE_BUILD_DIR) --target clean + +clean-debug: + cmake --build ../$(DEBUG_BUILD_DIR) --target clean + +clean-release-all: + $(RM) ../$(RELEASE_BUILD_DIR) + +clean-debug-all: + $(RM) ../$(DEBUG_BUILD_DIR)