diff --git a/.gitignore b/.gitignore index f4ec456..e2ae3dd 100644 --- a/.gitignore +++ b/.gitignore @@ -30,7 +30,11 @@ resource_debug_output.txt *.dylib # IDE-specific files -.vscode/ +.vscode/* +!.vscode/c_cpp_properties.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json .idea/ *.sdf *.suo @@ -47,4 +51,4 @@ resource_debug_output.txt # OS files .DS_Store -Thumbs.db \ No newline at end of file +Thumbs.db diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json new file mode 100644 index 0000000..b682d97 --- /dev/null +++ b/.vscode/c_cpp_properties.json @@ -0,0 +1,67 @@ +{ + "version": 4, + "configurations": [ + { + "name": "Win32", + "intelliSenseMode": "windows-msvc-x64", + "compilerPath": "cl.exe", + "cStandard": "c17", + "cppStandard": "c++17", + "compileCommands": "${workspaceFolder}/build/compile_commands.json", + "includePath": [ + "${workspaceFolder}/src/**", + "${workspaceFolder}/src/engine/**", + "${workspaceFolder}/src/editor/**", + "${workspaceFolder}/src/math/**", + "${workspaceFolder}/src/utils/**", + "${workspaceFolder}/vendor/**", + "${workspaceFolder}/build/_deps/**/include", + "${workspaceFolder}/build/_deps/imgui-src", + "${workspaceFolder}/build/_deps/imgui-src/backends" + ], + "browse": { + "path": [ + "${workspaceFolder}/src", + "${workspaceFolder}/src/engine", + "${workspaceFolder}/src/editor", + "${workspaceFolder}/src/math", + "${workspaceFolder}/src/utils", + "${workspaceFolder}/vendor" + ], + "limitSymbolsToIncludedHeaders": true + }, + "configurationProvider": "ms-vscode.cmake-tools" + }, + { + "name": "Linux", + "intelliSenseMode": "linux-gcc-x64", + "compilerPath": "/usr/bin/clang++", + "cStandard": "c17", + "cppStandard": "c++17", + "compileCommands": "${workspaceFolder}/build/compile_commands.json", + "includePath": [ + "${workspaceFolder}/src/**", + "${workspaceFolder}/src/engine/**", + "${workspaceFolder}/src/editor/**", + "${workspaceFolder}/src/math/**", + "${workspaceFolder}/src/utils/**", + "${workspaceFolder}/vendor/**", + "${workspaceFolder}/build/_deps/**/include", + "${workspaceFolder}/build/_deps/imgui-src", + "${workspaceFolder}/build/_deps/imgui-src/backends" + ], + "browse": { + "path": [ + "${workspaceFolder}/src", + "${workspaceFolder}/src/engine", + "${workspaceFolder}/src/editor", + "${workspaceFolder}/src/math", + "${workspaceFolder}/src/utils", + "${workspaceFolder}/vendor" + ], + "limitSymbolsToIncludedHeaders": true + }, + "configurationProvider": "ms-vscode.cmake-tools" + } + ] +} \ No newline at end of file diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..bcf9b69 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,8 @@ +{ + "recommendations": [ + "ms-vscode.cmake-tools", + "ms-vscode.cpptools", + "vadimcn.vscode-lldb", + "esbenp.prettier-vscode" + ] +} \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..118bfa6 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,40 @@ +{ + "version": "0.0.1", + "configurations": [ + { + "name": "Voltray (Windows CodeLLDB)", + "type": "lldb", + "request": "launch", + "program": "${workspaceFolder}/build/Debug/Voltray.exe", + "cwd": "${workspaceFolder}/build/Debug", + "preLaunchTask": "Build Voltray (Debug)" + }, + { + "name": "Voltray (Windows Debug MSVC)", + "type": "cppvsdbg", + "request": "launch", + "program": "${workspaceFolder}/build/Debug/Voltray.exe", + "cwd": "${workspaceFolder}/build/Debug", + "preLaunchTask": "Build Voltray (Debug)", + "stopAtEntry": false, + "console": "integratedTerminal" + }, + { + "name": "Voltray (Linux/macOS Debug)", + "type": "cppdbg", + "request": "launch", + "program": "${workspaceFolder}/build/Voltray", + "cwd": "${workspaceFolder}/build", + "preLaunchTask": "Build Voltray (Debug)", + "stopAtEntry": false, + "externalConsole": false, + "MIMode": "gdb", + "linux": { + "MIMode": "gdb" + }, + "osx": { + "MIMode": "lldb" + } + } + ] +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..a7fc381 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,32 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "Build Voltray (Debug)", + "type": "shell", + "command": "bash", + "args": [ + "${workspaceFolder}/scripts/build.sh", + "Debug" + ], + "windows": { + "command": "cmd", + "args": [ + "/c", + "${workspaceFolder}\\scripts\\build.bat", + "Debug" + ] + }, + "problemMatcher": [], + "group": { + "kind": "build", + "isDefault": true + }, + "presentation": { + "reveal": "always", + "panel": "shared", + "clear": true + } + } + ] +} diff --git a/README.md b/README.md index 771f34f..1ed9849 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ # Voltray + A modern, cross-platform C++ real-time rendering engine with an integrated editor. ![Voltray Editor](screenshots/Screenshot-1.png) @@ -16,23 +17,44 @@ A modern, cross-platform C++ real-time rendering engine with an integrated edito --- ## About + Voltray is a comprehensive 3D graphics engine designed for learning, experimentation, and educational purposes. It features a clean architecture, extensible design, and professional-grade development practices. ## Features -* **Real-Time 3D Rendering**: OpenGL 4.6 pipeline -* **Integrated Editor**: ImGui-based workspace -* **Cross-Platform**: Windows, Linux, macOS Support + +- **Real-Time 3D Rendering**: OpenGL 4.6 pipeline +- **Integrated Editor**: ImGui-based workspace +- **Cross-Platform**: Windows, Linux, macOS Support ## Getting Started ### Prerequisites -* **C++17 Compiler** (MSVC, GCC, Clang) -* **CMake 3.17+** -* **Git** + +- **C++17 Compiler** + - **Windows**: MSVC (Install "Desktop development with C++" workload via Visual Studio Installer to get `cl.exe`) + - **Linux**: GCC or Clang (`sudo apt install build-essential clang`) + - **macOS**: Clang (via Xcode Command Line Tools) +- **CMake 3.17+** +- **Git** + +### IDE Setup (VS Code and forks like Cursor) + +To get full C++ IntelliSense and debugging working: + +1. Install the recommended extensions: **C/C++** (`ms-vscode.cpptools`), **CMake Tools** (`ms-vscode.cmake-tools`), and **CodeLLDB** (`vadimcn.vscode-lldb`). +2. Open the project folder in your IDE. +3. When prompted by CMake Tools, select the appropriate compiler kit (e.g., `Visual Studio Community 2022 Release - ...` on Windows, or `Clang` / `GCC` on Linux). +4. CMake Tools will automatically configure the project and generate the `compile_commands.json` needed for IntelliSense after build. + +**Debugging on Windows**: + +- For **VS Code**, use the `"Voltray (Windows Debug MSVC)"` launch configuration. +- For **Cursor or Antigravity** (where Microsoft's `cppvsdbg` is unsupported), use the `"Voltray (Windows CodeLLDB)"` launch configuration instead. ### Build Instructions **Windows**: + ```cmd git clone https://github.com/MomdAli/Voltray.git cd Voltray @@ -40,6 +62,7 @@ build.bat ``` **Linux/macOS**: + ```bash git clone https://github.com/MomdAli/Voltray.git cd Voltray @@ -50,16 +73,19 @@ chmod +x build.sh ## Usage ### Running the Editor + After building the project, navigate to the `build` directory (or `build\Release` on Windows) and run the `Voltray` executable. ### Basic Controls -* **Orbit Camera**: Middle Mouse Button + Drag -* **Pan Camera**: Shift + Middle Mouse Button + Drag -* **Zoom**: Mouse Wheel -* **Select Object**: Left Click on object in Viewport -* **Transform Object**: Use the **Inspector** panel to modify position, rotation, and scale. + +- **Orbit Camera**: Middle Mouse Button + Drag +- **Pan Camera**: Shift + Middle Mouse Button + Drag +- **Zoom**: Mouse Wheel +- **Select Object**: Left Click on object in Viewport +- **Transform Object**: Use the **Inspector** panel to modify position, rotation, and scale. ## License + This project is licensed under the **Apache License 2.0**. See the [LICENSE](LICENSE) file for details. --- diff --git a/scripts/build.bat b/scripts/build.bat index 859d1d0..f4ec836 100644 --- a/scripts/build.bat +++ b/scripts/build.bat @@ -1,48 +1,36 @@ @echo off setlocal -REM === CONFIG === -set BUILD_TYPE=Release -set GENERATOR="Visual Studio 17 2022" -set BUILD_DIR=build -set BUILD_DOC=voltray-docs - -REM === GENERATE PROJECT FILES === -echo Configuring project with CMake... -cmake -B %BUILD_DIR% -G %GENERATOR% -A x64 -DCMAKE_BUILD_TYPE=%BUILD_TYPE% +set BUILD_TYPE=%~1 +if "%BUILD_TYPE%"=="" set BUILD_TYPE=Debug + +set SCRIPT_DIR=%~dp0 +for %%I in ("%SCRIPT_DIR%..") do set REPO_ROOT=%%~fI +set BUILD_DIR=%REPO_ROOT%\build +set GENERATOR=Visual Studio 17 2022 +set FETCHCONTENT_FLAG=-DFETCHCONTENT_UPDATES_DISCONNECTED=ON + +if exist "%BUILD_DIR%\_deps\glfw-src" ( + if exist "%BUILD_DIR%\_deps\assimp-src" ( + if exist "%BUILD_DIR%\_deps\imgui-src" ( + set FETCHCONTENT_FLAG=-DFETCHCONTENT_FULLY_DISCONNECTED=ON + ) + ) +) +echo Configuring Voltray %BUILD_TYPE%... +cmake -S "%REPO_ROOT%" -B "%BUILD_DIR%" -G "%GENERATOR%" -A x64 -DCMAKE_BUILD_TYPE=%BUILD_TYPE% -DCMAKE_EXPORT_COMPILE_COMMANDS=ON %FETCHCONTENT_FLAG% if errorlevel 1 ( echo Failed to configure the project. exit /b 1 ) -REM === BUILD PROJECT === -echo Building project... -cmake --build %BUILD_DIR% --config %BUILD_TYPE% - +echo Building Voltray %BUILD_TYPE%... +cmake --build "%BUILD_DIR%" --config %BUILD_TYPE% if errorlevel 1 ( echo Build failed. exit /b 1 ) -echo Build successful! - - -echo Generating documentation... -cmake --build %BUILD_DIR% --target doc --config %BUILD_TYPE% - -REM === RUN THE ENGINE === -set EXE_PATH=%BUILD_DIR%\%BUILD_TYPE%\Voltray.exe -set EXE_DIR=%BUILD_DIR%\%BUILD_TYPE% - -if exist "%EXE_PATH%" ( - echo Running Voltray... - pushd "%EXE_DIR%" - Voltray.exe - popd -) else ( - echo Error: Voltray.exe not found at %EXE_PATH% -) - -endlocal -pause +echo Build successful. +endlocal \ No newline at end of file diff --git a/scripts/build.sh b/scripts/build.sh index b140a03..cab8f7e 100644 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -1,117 +1,29 @@ -#!/bin/bash -set -e +#!/usr/bin/env bash +set -euo pipefail -# === CONFIG === -BUILD_TYPE=Release -BUILD_DIR=build +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +REPO_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd)" +BUILD_TYPE="${1:-Debug}" +BUILD_DIR="${REPO_ROOT}/build" +FETCHCONTENT_FLAG="-DFETCHCONTENT_UPDATES_DISCONNECTED=ON" -# Clean up any existing build directory if running in WSL -if grep -q Microsoft /proc/version 2>/dev/null; then - echo "WSL environment detected, cleaning build directory..." - rm -rf "$BUILD_DIR" +if [ -d "${BUILD_DIR}/_deps/glfw-src" ] && [ -d "${BUILD_DIR}/_deps/assimp-src" ] && [ -d "${BUILD_DIR}/_deps/imgui-src" ]; then + FETCHCONTENT_FLAG="-DFETCHCONTENT_FULLY_DISCONNECTED=ON" fi -# Detect available generator -if command -v ninja &> /dev/null; then +if command -v ninja >/dev/null 2>&1; then GENERATOR="Ninja" - echo "Using Ninja build system..." -elif command -v make &> /dev/null; then +elif command -v make >/dev/null 2>&1; then GENERATOR="Unix Makefiles" - echo "Using Make build system..." else - echo "Neither Ninja nor Make build systems found. Installing required packages..." - if command -v apt-get &> /dev/null; then - # Debian/Ubuntu - echo "Installing build tools and dependencies..." - sudo apt-get update - sudo apt-get install -y cmake build-essential ninja-build g++ xorg-dev libgl1-mesa-dev libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev - GENERATOR="Ninja" - else - echo "Unsupported package manager. Please install CMake, a C++ compiler, and Ninja or Make manually." - exit 1 - fi -fi - -# === GENERATE PROJECT FILES === -echo "Configuring project with CMake..." - -# Check for ccache to speed up compilation -if command -v ccache &> /dev/null; then - echo "Using ccache for faster compilation..." - CMAKE_CCACHE_FLAGS="-DCMAKE_CXX_COMPILER_LAUNCHER=ccache" -else - CMAKE_CCACHE_FLAGS="" -fi - -# Additional flags for WSL/Linux to handle compiler warnings -if grep -q Microsoft /proc/version 2>/dev/null || [ "$(uname)" == "Linux" ]; then - echo "Linux/WSL environment detected, adding compiler flags for external dependencies..." - cmake -B "$BUILD_DIR" -G "$GENERATOR" -DCMAKE_BUILD_TYPE=$BUILD_TYPE \ - -DCMAKE_CXX_FLAGS="-Wno-error=array-bounds -Wno-error=stringop-overflow" \ - -DASSIMP_WARNINGS_AS_ERRORS=OFF \ - $CMAKE_CCACHE_FLAGS -else - cmake -B "$BUILD_DIR" -G "$GENERATOR" -DCMAKE_BUILD_TYPE=$BUILD_TYPE \ - $CMAKE_CCACHE_FLAGS -fi - -if [ $? -ne 0 ]; then - echo "Failed to configure the project." - exit 1 -fi - -# === BUILD PROJECT === -echo "Building project..." - -# Determine number of parallel jobs -if [ "$(uname)" == "Darwin" ]; then - JOBS=$(sysctl -n hw.ncpu) -elif command -v nproc &> /dev/null; then - JOBS=$(nproc) -else - JOBS=4 # fallback -fi - -echo "Building with $JOBS parallel jobs..." -cmake --build "$BUILD_DIR" --config $BUILD_TYPE --parallel $JOBS - -if [ $? -ne 0 ]; then - echo "Build failed." + echo "Neither Ninja nor Make was found. Install one of them first." exit 1 fi -echo "Build successful!" +echo "Configuring Voltray (${BUILD_TYPE})..." +cmake -S "${REPO_ROOT}" -B "${BUILD_DIR}" -G "${GENERATOR}" -DCMAKE_BUILD_TYPE="${BUILD_TYPE}" -DCMAKE_EXPORT_COMPILE_COMMANDS=ON "${FETCHCONTENT_FLAG}" -# === GENERATE DOCUMENTATION === -echo "Generating documentation..." -cmake --build "$BUILD_DIR" --target doc --config $BUILD_TYPE +echo "Building Voltray (${BUILD_TYPE})..." +cmake --build "${BUILD_DIR}" --config "${BUILD_TYPE}" --parallel -# === RUN THE ENGINE === -# Check if we're on macOS, Linux or WSL and adjust paths accordingly -if [ "$(uname)" == "Darwin" ]; then - # macOS path - EXE_PATH="$BUILD_DIR/Voltray" - EXE_DIR="$BUILD_DIR" -elif grep -q Microsoft /proc/version 2>/dev/null; then - # WSL path - need to use Windows path format for executable - echo "WSL environment detected, won't attempt to run the executable directly." - echo "Please run the executable from Windows environment." - exit 0 -else - # Regular Linux path - EXE_PATH="$BUILD_DIR/Voltray" - EXE_DIR="$BUILD_DIR" -fi - -if [ -z "$EXE_PATH" ]; then - echo "Environment not supported for automatic execution." - exit 0 -elif [ -f "$EXE_PATH" ]; then - echo "Running Voltray..." - cd "$EXE_DIR" - ./Voltray - cd - > /dev/null -else - echo "Error: Voltray executable not found at $EXE_PATH" - exit 1 -fi \ No newline at end of file +echo "Build successful." \ No newline at end of file