Merge pull request #19 from coderloff/dev

fix: Fix resources conflict and add shell file support
This commit is contained in:
Huseyn Ismayilov 2024-11-22 17:54:37 +04:00 committed by GitHub
commit 1deac4cae6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
13 changed files with 131 additions and 62 deletions

View File

@ -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)

View File

@ -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)

View File

@ -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

View File

@ -3,6 +3,8 @@
#include <imgui_impl_opengl3.h>
#include "GUI.h"
#include <Editor.h>
#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();
}

View File

@ -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

View File

@ -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()

43
scripts/BuildProject.sh Executable file
View File

@ -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

34
scripts/Makefile Normal file
View File

@ -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)