diff --git a/CMakeLists.txt b/CMakeLists.txt index 7c8f4bb..5a7894b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,85 +1,26 @@ cmake_minimum_required(VERSION 3.24) -project(RaylibDmx) # Project Name: RaylibDmx +project(RaylibStuff) # nvim/fleet users (ONLY WORKS WITH MINGW/NINJA BUILDERS) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) -# Dependencies -## - Raylib -## - rlImGui -#### - ImGui - -# Use FetchContent to download and build raylib -# This is a faster alternative to using a git repo, since this just downloads the source -# while the git repo pull takes a lot longer. Not sure why, other repos don't seem to have this issue - -# If you would like to use git instead, use this: -# - - - - - - - - - - - - - - - - - - - - - - - - -#FetchContent_Declare( -# raylib -# GIT_REPOSITORY "https://github.com/raysan5/raylib.git" -# GIT_TAG "master" -# GIT_SHALLOW TRUE -# GIT_PROGRESS TRUE -#) -# - - - - - - - - - - - - - - - - - - - - - - - - - -include(FetchContent) -set(FETCHCONTENT_QUIET FALSE) -set(BUILD_EXAMPLES OFF CACHE BOOL "" FORCE) # don't build the supplied examples -set(BUILD_GAMES OFF CACHE BOOL "" FORCE) # don't build the supplied example games - -FetchContent_Declare( - raylib - URL https://github.com/raysan5/raylib/archive/refs/tags/4.5.0.tar.gz -) -FetchContent_MakeAvailable(raylib) - -# Raylib conf -set(raylib_VERBOSE 1) # Not 100% sure if this does anything... - -# Download and build Dear ImGui -FetchContent_Declare( - imgui - GIT_REPOSITORY https://github.com/ocornut/imgui.git - GIT_SHALLOW TRUE - GIT_TAG v1.89.4 -) -FetchContent_MakeAvailable(imgui) - -# Download and build rlImGui -FetchContent_Declare( - rlImGui - GIT_REPOSITORY https://github.com/raylib-extras/rlImGui.git - GIT_TAG main -) -FetchContent_MakeAvailable(rlImGui) - -# Add rlImGui library -add_library(rlImGui STATIC - ${rlImGui_SOURCE_DIR}/rlImGui.cpp - ${rlImGui_SOURCE_DIR}/imgui_impl_raylib.cpp -) - -# Include directories for rlImGui -target_include_directories(rlImGui PRIVATE - ${imgui_SOURCE_DIR} - ${raylib_SOURCE_DIR}/src - ${rlImGui_SOURCE_DIR} -) - -# Link rlImGui with Raylib -target_link_libraries(rlImGui PRIVATE raylib) +# Deps +add_subdirectory(lib/raylib) +add_subdirectory(lib/imgui) +add_subdirectory(lib/rlImGui) # add source code -file(GLOB_RECURSE PROJECT_SOURCES CONFIGURE_DEPENDS "${CMAKE_CURRENT_LIST_DIR}/src/*.cpp") # Define PROJECT_SOURCES as a list of all source files +file(GLOB_RECURSE PROJECT_SOURCES CONFIGURE_DEPENDS "${CMAKE_CURRENT_LIST_DIR}/src/*.cpp") set(PROJECT_INCLUDE "${CMAKE_CURRENT_LIST_DIR}/src") # exe add_executable(${PROJECT_NAME}) target_sources(${PROJECT_NAME} PRIVATE ${PROJECT_SOURCES}) target_include_directories(${PROJECT_NAME} PRIVATE ${PROJECT_INCLUDE}) -target_link_libraries(${PROJECT_NAME} PRIVATE raylib rlImGui) + +# THIS IS WHEREE THE OTHER LIBRARIES ARE LINKED +# SCREW YOU LINKER +target_link_libraries(${PROJECT_NAME} PRIVATE imgui raylib rlImGui) # Web Configurations if (${PLATFORM} STREQUAL "Web") diff --git a/lib/imgui/CMakeLists.txt b/lib/imgui/CMakeLists.txt new file mode 100644 index 0000000..894229c --- /dev/null +++ b/lib/imgui/CMakeLists.txt @@ -0,0 +1,23 @@ +include(FetchContent) + +FetchContent_Declare( + imgui + GIT_REPOSITORY https://github.com/ocornut/imgui.git + GIT_SHALLOW TRUE + GIT_TAG master +) +FetchContent_MakeAvailable(imgui) + +add_library(imgui STATIC + ${imgui_SOURCE_DIR}/imgui.cpp + ${imgui_SOURCE_DIR}/imgui_draw.cpp + ${imgui_SOURCE_DIR}/imgui_tables.cpp + ${imgui_SOURCE_DIR}/imgui_widgets.cpp + ${imgui_SOURCE_DIR}/imgui_demo.cpp + ${imgui_SOURCE_DIR}/backends/imgui_impl_opengl3.cpp\ +) + +target_include_directories(imgui PUBLIC + ${imgui_SOURCE_DIR} + ${imgui_SOURCE_DIR}/backends +) \ No newline at end of file diff --git a/lib/raylib/CMakeLists.txt b/lib/raylib/CMakeLists.txt new file mode 100644 index 0000000..635fc24 --- /dev/null +++ b/lib/raylib/CMakeLists.txt @@ -0,0 +1,29 @@ +# Use FetchContent to download and build raylib +# This is a faster alternative to using a git repo, since this just downloads the source +# while the git repo pull takes a lot longer. Not sure why, other repos don't seem to have this issue + +# If you would like to use git instead, use this: +# - - - - - - - - - - - - - - - - - - - - - - - - +#FetchContent_Declare( +# raylib +# GIT_REPOSITORY "https://github.com/raysan5/raylib.git" +# GIT_TAG "master" +# GIT_SHALLOW TRUE +# GIT_PROGRESS TRUE +#) +# - - - - - - - - - - - - - - - - - - - - - - - - + +include(FetchContent) + +set(FETCHCONTENT_QUIET FALSE) +set(BUILD_EXAMPLES OFF CACHE BOOL "" FORCE) # don't build the supplied examples +set(BUILD_GAMES OFF CACHE BOOL "" FORCE) # don't build the supplied example games + +FetchContent_Declare( + raylib + URL https://github.com/raysan5/raylib/archive/refs/tags/4.5.0.tar.gz +) +FetchContent_MakeAvailable(raylib) + +# Raylib conf +set(raylib_VERBOSE 1) # not 100 % sure if this does anything... \ No newline at end of file diff --git a/lib/rlImGui/CMakeLists.txt b/lib/rlImGui/CMakeLists.txt new file mode 100644 index 0000000..29f768b --- /dev/null +++ b/lib/rlImGui/CMakeLists.txt @@ -0,0 +1,49 @@ +cmake_minimum_required(VERSION 3.24) +project(rlImGui) + +include(FetchContent) + +FetchContent_Declare( + rlImGui + GIT_REPOSITORY https://github.com/raylib-extras/rlImGui.git + GIT_SHALLOW TRUE + GIT_TAG main +) + +FetchContent_MakeAvailable(rlImGui) + +include_directories(${rlImGui_SOURCE_DIR}) +include_directories(${CMAKE_SOURCE_DIR}/imgui) +include_directories(${CMAKE_SOURCE_DIR}/raylib/src) + +add_library(rlImGui STATIC + ${rlImGui_SOURCE_DIR}/rlImGui.cpp + ${rlImGui_SOURCE_DIR}/rlImGui.h + ${rlImGui_SOURCE_DIR}/imgui_impl_raylib.h + ${rlImGui_SOURCE_DIR}/rlImGuiColors.h +) + +target_sources(rlImGui PRIVATE + ${CMAKE_SOURCE_DIR}/imgui/imgui.cpp + ${CMAKE_SOURCE_DIR}/imgui/imgui_draw.cpp + ${CMAKE_SOURCE_DIR}/imgui/imgui_demo.cpp + ${CMAKE_SOURCE_DIR}/imgui/imgui_tables.cpp + ${CMAKE_SOURCE_DIR}/imgui/imgui_widgets.cpp + ${CMAKE_SOURCE_DIR}/imgui/backends/imgui_impl_opengl3.cpp +) + +target_link_libraries(rlImGui PRIVATE raylib imgui) + +if (APPLE) + target_link_libraries(rlImGui "-framework IOKit" "-framework Cocoa" "-framework OpenGL") +elseif(UNIX) + target_link_libraries(rlImGui PRIVATE GL m pthread dl X11) +elseif(WIN32) + target_link_libraries(rlImGui PRIVATE opengl32 gdi32 winmm) +endif() + +target_include_directories(rlImGui PUBLIC + ${rlImGui_SOURCE_DIR} + ${CMAKE_SOURCE_DIR}/imgui + ${CMAKE_SOURCE_DIR}/raylib/src +) \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index 5ec79c7..7b239d2 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,13 +1,19 @@ #include "raylib.h" +#include "rlImGui.h" #include "panel.h" +#include "imgui.h" int main() { const int screenWidth = 1920; const int screenHeight = 1080; + // Initialize Raylib InitWindow(screenWidth, screenHeight, "DMX Raylib UI"); SetTargetFPS(60); + // Initialize rlImGui + rlImGuiSetup(true); // Use true for dark theme, false for light theme + // Create the timeline and properties panels Panel timelinePanel = {{0, 0, screenWidth * 0.75f, screenHeight * 0.6f}, "Timeline", LIGHTGRAY, DARKGRAY, true}; Panel propertiesPanel = {{screenWidth * 0.75f, 0, screenWidth * 0.25f, screenHeight}, "Properties", LIGHTGRAY, DARKGRAY, true}; @@ -20,7 +26,19 @@ int main() { BeginDrawing(); ClearBackground(RAYWHITE); - // Draw panels + // Start ImGui frame + rlImGuiBegin(); + + // Create a simple ImGui window (you can expand this with more GUI elements) + ImGui::Begin("ImGui Panel"); + ImGui::Text("Hello, world!"); + // ImGui::SliderFloat("Slider", &timelinePanel.position.x, 0.0f, (float)screenWidth); + ImGui::End(); + + // End ImGui frame + rlImGuiEnd(); + + // Draw Raylib panels if (timelinePanel.isVisible) timelinePanel.Draw(); if (propertiesPanel.isVisible) propertiesPanel.Draw(); @@ -28,6 +46,9 @@ int main() { EndDrawing(); } + // Shutdown rlImGui + rlImGuiShutdown(); + CloseWindow(); return 0; }