Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ platform setup (Vulkan SDK, GLFW, etc.).

- First time in a fresh clone: `./Init.sh` (Linux) / `Init.bat` (Windows). This pulls
git submodules, builds/installs Catch2 locally, and configures CMake into `build/`.
- Day to day: `./build-debug.sh`, `./build-release.sh`, or `./build-shipping.sh`, then
build with your generator (e.g. `cmake --build build --parallel`).
- Day to day: reconfigure `build/` for the mode you want, e.g.
`cmake -B build -DCMAKE_BUILD_TYPE=Debug`, then build with your generator
(e.g. `cmake --build build --parallel`).
- `-DDEFINE_SHIPPING=ON` strips dev-only code gated behind `#ifdef FLING_SHIPPING`.
- Full detail: [`Skills/building.md`](Skills/building.md).

Expand Down
13 changes: 11 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,18 @@ set_target_properties(spirv-cross-glsl PROPERTIES FOLDER SPIRV-Cross)
set_target_properties(spirv-cross-reflect PROPERTIES FOLDER SPIRV-Cross)
set_target_properties(spirv-cross-util PROPERTIES FOLDER SPIRV-Cross)

# ImGUI
# ImGUI
# Built directly here (rather than via the submodule's own CMakeLists.txt) so that
# the submodule can stay pinned to an unmodified upstream ocornut/imgui tag.
if( WITH_IMGUI_FLAG )
add_subdirectory( external/imgui )
add_library( ImGui STATIC
external/imgui/imgui.cpp
external/imgui/imgui_demo.cpp
external/imgui/imgui_draw.cpp
external/imgui/imgui_tables.cpp
external/imgui/imgui_widgets.cpp )
target_include_directories( ImGui PUBLIC external/imgui )

include_directories( external/imgui )
include_directories( external/imgui_entt_entity_editor )
endif()
Expand Down
7 changes: 3 additions & 4 deletions FlingEngine/Editor/inc/ImFileBrowser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -336,10 +336,10 @@ inline void ImGui::FileBrowser::Display()

// browse files in a child window

float reserveHeight = GetItemsLineHeightWithSpacing();
float reserveHeight = GetFrameHeightWithSpacing();
std::filesystem::path newPwd; bool setNewPwd = false;
if(!(flags_ & ImGuiFileBrowserFlags_SelectDirectory) && (flags_ & ImGuiFileBrowserFlags_EnterNewFilename))
reserveHeight += GetItemsLineHeightWithSpacing();
reserveHeight += GetFrameHeightWithSpacing();
{
BeginChild("ch", ImVec2(0, -reserveHeight), true,
(flags_ & ImGuiFileBrowserFlags_NoModal) ? ImGuiWindowFlags_AlwaysHorizontalScrollbar : 0);
Expand Down Expand Up @@ -421,9 +421,8 @@ inline void ImGui::FileBrowser::Display()

SameLine();

int escIdx = GetIO().KeyMap[ImGuiKey_Escape];
if(Button("cancel") || closeFlag_ ||
((flags_ & ImGuiFileBrowserFlags_CloseOnEsc) && IsWindowFocused(ImGuiFocusedFlags_RootAndChildWindows) && escIdx >= 0 && IsKeyPressed(escIdx)))
((flags_ & ImGuiFileBrowserFlags_CloseOnEsc) && IsWindowFocused(ImGuiFocusedFlags_RootAndChildWindows) && IsKeyPressed(ImGuiKey_Escape)))
CloseCurrentPopup();

if(!statusStr_.empty() && !(flags_ & ImGuiFileBrowserFlags_NoStatusBar))
Expand Down
88 changes: 50 additions & 38 deletions FlingEngine/Platform/inc/ImGuiInputBinding.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,46 @@ namespace Fling
glfwSetClipboardString((GLFWwindow*)user_data, text);
}

// Maps a raw FL_KEYCODE_* key code to the ImGuiKey enum required by the
// enum required by the modern (1.87+) io.AddKeyEvent() input API.
static ImGuiKey ImGui_ImplGlfw_KeyToImGuiKey(int key)
{
switch (key)
{
case FL_KEYCODE_TAB: return ImGuiKey_Tab;
case FL_KEYCODE_LEFT: return ImGuiKey_LeftArrow;
case FL_KEYCODE_RIGHT: return ImGuiKey_RightArrow;
case FL_KEYCODE_UP: return ImGuiKey_UpArrow;
case FL_KEYCODE_DOWN: return ImGuiKey_DownArrow;
case FL_KEYCODE_PAGE_UP: return ImGuiKey_PageUp;
case FL_KEYCODE_PAGE_DOWN: return ImGuiKey_PageDown;
case FL_KEYCODE_HOME: return ImGuiKey_Home;
case FL_KEYCODE_END: return ImGuiKey_End;
case FL_KEYCODE_INSERT: return ImGuiKey_Insert;
case FL_KEYCODE_DELETE: return ImGuiKey_Delete;
case FL_KEYCODE_BACKSPACE: return ImGuiKey_Backspace;
case FL_KEYCODE_SPACE: return ImGuiKey_Space;
case FL_KEYCODE_ENTER: return ImGuiKey_Enter;
case FL_KEYCODE_ESCAPE: return ImGuiKey_Escape;
case FL_KEYCODE_KP_ENTER: return ImGuiKey_KeypadEnter;
case FL_KEYCODE_LEFT_CONTROL: return ImGuiKey_LeftCtrl;
case FL_KEYCODE_RIGHT_CONTROL: return ImGuiKey_RightCtrl;
case FL_KEYCODE_LEFT_SHIFT: return ImGuiKey_LeftShift;
case FL_KEYCODE_RIGHT_SHIFT: return ImGuiKey_RightShift;
case FL_KEYCODE_LEFT_ALT: return ImGuiKey_LeftAlt;
case FL_KEYCODE_RIGHT_ALT: return ImGuiKey_RightAlt;
case FL_KEYCODE_LEFT_SUPER: return ImGuiKey_LeftSuper;
case FL_KEYCODE_RIGHT_SUPER: return ImGuiKey_RightSuper;
case FL_KEYCODE_A: return ImGuiKey_A;
case FL_KEYCODE_C: return ImGuiKey_C;
case FL_KEYCODE_V: return ImGuiKey_V;
case FL_KEYCODE_X: return ImGuiKey_X;
case FL_KEYCODE_Y: return ImGuiKey_Y;
case FL_KEYCODE_Z: return ImGuiKey_Z;
default: return ImGuiKey_None;
}
}

void ImGui_ImplGlfw_MouseButtonCallback(GLFWwindow* window, int button, int action, int mods)
{
if (g_PrevUserCallbackMousebutton != NULL)
Expand Down Expand Up @@ -82,17 +122,17 @@ namespace Fling
if (g_PrevUserCallbackKey != NULL)
g_PrevUserCallbackKey(window, key, scancode, action, mods);

if (action != GLFW_PRESS && action != GLFW_RELEASE)
return;

ImGuiIO& io = ImGui::GetIO();
if (action == GLFW_PRESS)
io.KeysDown[key] = true;
if (action == GLFW_RELEASE)
io.KeysDown[key] = false;

// Modifiers are not reliable across systems
io.KeyCtrl = io.KeysDown[GLFW_KEY_LEFT_CONTROL] || io.KeysDown[GLFW_KEY_RIGHT_CONTROL];
io.KeyShift = io.KeysDown[GLFW_KEY_LEFT_SHIFT] || io.KeysDown[GLFW_KEY_RIGHT_SHIFT];
io.KeyAlt = io.KeysDown[GLFW_KEY_LEFT_ALT] || io.KeysDown[GLFW_KEY_RIGHT_ALT];
io.KeySuper = io.KeysDown[GLFW_KEY_LEFT_SUPER] || io.KeysDown[GLFW_KEY_RIGHT_SUPER];
io.AddKeyEvent(ImGuiMod_Ctrl, (mods & GLFW_MOD_CONTROL) != 0);
io.AddKeyEvent(ImGuiMod_Shift, (mods & GLFW_MOD_SHIFT) != 0);
io.AddKeyEvent(ImGuiMod_Alt, (mods & GLFW_MOD_ALT) != 0);
io.AddKeyEvent(ImGuiMod_Super, (mods & GLFW_MOD_SUPER) != 0);

ImGuiKey ImGuiKeyCode = ImGui_ImplGlfw_KeyToImGuiKey(key);
io.AddKeyEvent(ImGuiKeyCode, action == GLFW_PRESS);
}

void SetImGuiCallbacks()
Expand All @@ -107,29 +147,6 @@ namespace Fling
io.BackendFlags |= ImGuiBackendFlags_HasSetMousePos; // We can honor io.WantSetMousePos requests (optional, rarely used)
io.BackendPlatformName = "imgui_impl_glfw";

io.KeyMap[ImGuiKey_Tab] = FL_KEYCODE_TAB;
io.KeyMap[ImGuiKey_LeftArrow] = FL_KEYCODE_LEFT;
io.KeyMap[ImGuiKey_RightArrow] = FL_KEYCODE_RIGHT;
io.KeyMap[ImGuiKey_UpArrow] = FL_KEYCODE_UP;
io.KeyMap[ImGuiKey_DownArrow] = FL_KEYCODE_DOWN;
io.KeyMap[ImGuiKey_PageUp] = FL_KEYCODE_PAGE_UP;
io.KeyMap[ImGuiKey_PageDown] = FL_KEYCODE_PAGE_DOWN;
io.KeyMap[ImGuiKey_Home] = FL_KEYCODE_HOME;
io.KeyMap[ImGuiKey_End] = FL_KEYCODE_END;
io.KeyMap[ImGuiKey_Insert] = FL_KEYCODE_INSERT;
io.KeyMap[ImGuiKey_Delete] = FL_KEYCODE_DELETE;
io.KeyMap[ImGuiKey_Backspace] = FL_KEYCODE_BACKSPACE;
io.KeyMap[ImGuiKey_Space] = FL_KEYCODE_SPACE;
io.KeyMap[ImGuiKey_Enter] = FL_KEYCODE_ENTER;
io.KeyMap[ImGuiKey_Escape] = FL_KEYCODE_ESCAPE;
io.KeyMap[ImGuiKey_KeyPadEnter] = FL_KEYCODE_KP_ENTER;
io.KeyMap[ImGuiKey_A] = FL_KEYCODE_A;
io.KeyMap[ImGuiKey_C] = FL_KEYCODE_C;
io.KeyMap[ImGuiKey_V] = FL_KEYCODE_V;
io.KeyMap[ImGuiKey_X] = FL_KEYCODE_X;
io.KeyMap[ImGuiKey_Y] = FL_KEYCODE_Y;
io.KeyMap[ImGuiKey_Z] = FL_KEYCODE_Z;

DesktopWindow* DesktopWin = static_cast<DesktopWindow*>(VulkanApp::Get().GetCurrentWindow());

assert(DesktopWin);
Expand All @@ -138,11 +155,6 @@ namespace Fling
io.GetClipboardTextFn = ImGui_ImplGlfw_GetClipboardText;
io.ClipboardUserData = DesktopWin;

#if FLING_WINDOWS
io.ImeWindowHandle = (void*)glfwGetWin32Window(DesktopWin->GetGlfwWindow());
#elif FLING_LINUX
io.ImeWindowHandle = (void*)glfwGetX11Window(DesktopWin->GetGlfwWindow());
#endif
// Chain GLFW callbacks: our callbacks will call the user's previously installed callbacks, if any.
g_PrevUserCallbackMousebutton = nullptr;
g_PrevUserCallbackScroll = nullptr;
Expand Down
18 changes: 0 additions & 18 deletions Init_VS_2017.bat

This file was deleted.

12 changes: 0 additions & 12 deletions Jenkinsfile

This file was deleted.

32 changes: 32 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,38 @@ Running either one of these scripts will simply get all submodules and external
that the engine uses and create a folder called `build`. The `build` folder will have your
platform specific build files (Visual Studio, Makefiles, etc).

### Quick start: clone, build, and run the Sandbox

Once the system dependencies and Vulkan SDK above are installed, here's the full path
from a fresh clone to a running game, on Linux/macOS:

```bash
# 1. Pull submodules, install Catch2 locally, and configure CMake into `build/`
./Init.sh

# 2. Build the Sandbox target
cmake --build build --target Sandbox --parallel

# 3. Run it
./build/Sandbox/bin/Sandbox
```

On Windows, the equivalent is:

```bat
:: 1. Pull submodules and configure CMake into `build/`
Init.bat

:: 2. Build the Sandbox target
cmake --build build --target Sandbox --config Debug

:: 3. Run it (path includes the build config)
build\Sandbox\bin\Debug\Sandbox.exe
```

See [`Skills/building.md`](Skills/building.md) for switching build types (Debug/Release/
shipping) and other day-to-day build details.

#### Packaging a project

For ease of development and iteration the file paths to Assets (shaders, textures, models, etc) are all
Expand Down
15 changes: 10 additions & 5 deletions Skills/building.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ headers, X11/Wayland dev libs) — see the root [README.md](../README.md) for th

## Day-to-day builds

Three convenience scripts reconfigure CMake for a given mode (they do **not**
build — build separately):
Reconfigure `build/` for the mode you want (this does **not** build — build
separately), e.g.:

```bash
./build-debug.sh # -DCMAKE_BUILD_TYPE=Debug
./build-release.sh # -DCMAKE_BUILD_TYPE=Release
./build-shipping.sh # -DCMAKE_BUILD_TYPE=Release -DDEFINE_SHIPPING=ON
cmake -B build -DCMAKE_BUILD_TYPE=Debug # debug
cmake -B build -DCMAKE_BUILD_TYPE=Release # release
cmake -B build -DCMAKE_BUILD_TYPE=Release -DDEFINE_SHIPPING=ON # shipping
```

Then build with your generator, e.g.:
Expand All @@ -37,6 +37,11 @@ Then build with your generator, e.g.:
cmake --build build --parallel
```

There used to be `build-debug.sh`/`build-release.sh`/`build-shipping.sh` wrapper
scripts for the commands above; they were removed since CI and IDE tooling
(VS Code's cmake-tools extension) never used them and they only added an
indirection layer over a couple of CMake flags.

## `DEFINE_SHIPPING`

`-DDEFINE_SHIPPING=ON` sets `FLING_SHIPPING`, used in first-party code to strip
Expand Down
Loading
Loading