Browse Source

Split visualizer into example/ sub-project

- Move renderer.h/cpp and ui_renderer.h/cpp to example/src/
- Move main.cpp to example/src/
- Move raylib and raygui submodules to example/ext/
- Keep tomlc17 submodule at root (library-only dependency)
- Root Makefile builds liborbit.a static library + tests
- example/Makefile builds orbit_sim, links liborbit.a
- All build artifacts go to ./build/ via recursive BUILD_DIR
- Remove example/tests/ (sim configs run from project root)
main
cinnaboot 3 months ago
parent
commit
e8167a90f5
  1. 10
      .gitmodules
  2. 78
      Makefile
  3. 42
      example/Makefile
  4. 1
      example/ext/raygui
  5. 1
      example/ext/raylib
  6. 0
      example/src/main.cpp
  7. 0
      example/src/renderer.cpp
  8. 0
      example/src/renderer.h
  9. 2
      example/src/ui_renderer.cpp
  10. 0
      example/src/ui_renderer.h
  11. 1
      ext/raygui
  12. 1
      ext/raylib

10
.gitmodules vendored

@ -1,9 +1,9 @@
[submodule "ext/raylib"]
path = ext/raylib
url = https://github.com/raysan5/raylib.git
[submodule "ext/tomlc17"] [submodule "ext/tomlc17"]
path = ext/tomlc17 path = ext/tomlc17
url = https://github.com/cktan/tomlc17 url = https://github.com/cktan/tomlc17
[submodule "ext/raygui"] [submodule "example/ext/raylib"]
path = ext/raygui path = example/ext/raylib
url = https://github.com/raysan5/raylib.git
[submodule "example/ext/raygui"]
path = example/ext/raygui
url = https://github.com/raysan5/raygui.git url = https://github.com/raysan5/raygui.git

78
Makefile

@ -1,87 +1,57 @@
# Compiler and flags
CXX = g++ CXX = g++
CXXFLAGS = -Wall -Wextra -g -ggdb3 -std=c++14 \ CXXFLAGS = -Wall -Wextra -g -ggdb3 -std=c++14 \
-I./src \ -I./src \
-isystem./ext/tomlc17/src \ -isystem./ext/tomlc17/src
-isystem./ext/raylib/src \ LDFLAGS = -lm
-isystem./ext/raygui/src \
-isystem./ext/raygui/styles
LDFLAGS = -L./ext/raylib/src -lraylib -lm -lpthread -ldl -lrt -lX11
# Directories
SRC_DIR = src SRC_DIR = src
BUILD_DIR ?= build BUILD_DIR ?= build
RAYLIB_DIR = ext/raylib/src
TARGET = ${BUILD_DIR}/orbit_sim
TEST_DIR = tests TEST_DIR = tests
TEST_TARGET = ${BUILD_DIR}/orbit_test
# Source files (exclude old mission planning files)
CPP_SOURCES := $(wildcard $(SRC_DIR)/*.cpp) CPP_SOURCES := $(wildcard $(SRC_DIR)/*.cpp)
C_SOURCES = ext/tomlc17/src/tomlc17.c C_SOURCES = ext/tomlc17/src/tomlc17.c
TEST_SOURCES := $(wildcard $(TEST_DIR)/*.cpp) TEST_SOURCES := $(wildcard $(TEST_DIR)/*.cpp)
# Object files
CPP_OBJECTS = $(CPP_SOURCES:$(SRC_DIR)/%.cpp=$(BUILD_DIR)/%.o) CPP_OBJECTS = $(CPP_SOURCES:$(SRC_DIR)/%.cpp=$(BUILD_DIR)/%.o)
C_OBJECTS = $(BUILD_DIR)/tomlc17.o C_OBJECTS = $(BUILD_DIR)/tomlc17.o
TEST_OBJECTS := $(patsubst $(TEST_DIR)/%.cpp, $(BUILD_DIR)/%.o, $(TEST_SOURCES)) TEST_OBJECTS := $(patsubst $(TEST_DIR)/%.cpp, $(BUILD_DIR)/%.o, $(TEST_SOURCES))
# Default target (updates ctags if available) LIBRARY = $(BUILD_DIR)/liborbit.a
all: raylib $(BUILD_DIR) $(TARGET)
@command -v ctags >/dev/null 2>&1 && ctags -R tests/ src/ || true
# Build raylib all: lib test-build example
raylib:
@if [ ! -f $(RAYLIB_DIR)/libraylib.a ]; then \
echo "Building raylib..."; \
cd $(RAYLIB_DIR) && $(MAKE) PLATFORM=PLATFORM_DESKTOP; \
fi
# Create build directory
$(BUILD_DIR): $(BUILD_DIR):
mkdir -p $(BUILD_DIR) mkdir -p $(BUILD_DIR)
# Link the executable
$(TARGET): $(C_OBJECTS) $(CPP_OBJECTS) raylib
$(CXX) $(C_OBJECTS) $(CPP_OBJECTS) -o $(TARGET) $(LDFLAGS)
# Compile C++ source files
$(CPP_OBJECTS): $(BUILD_DIR)/%.o : $(SRC_DIR)/%.cpp $(CPP_OBJECTS): $(BUILD_DIR)/%.o : $(SRC_DIR)/%.cpp
$(CXX) $(CXXFLAGS) -c $< -o $@ $(CXX) $(CXXFLAGS) -c $< -o $@
# Compile C source files
$(C_OBJECTS): $(BUILD_DIR)/%.o : $(C_SOURCES) $(C_OBJECTS): $(BUILD_DIR)/%.o : $(C_SOURCES)
$(CC) -Wall -Wextra -g -ggdb3 -std=c99 -I./src -I./ext/tomlc17/src -c $< -o $@ $(CC) -Wall -Wextra -g -ggdb3 -std=c99 -I./src -I./ext/tomlc17/src -c $< -o $@
# Clean build files lib: $(BUILD_DIR) $(C_OBJECTS) $(CPP_OBJECTS)
clean: ar rcs $(LIBRARY) $(C_OBJECTS) $(CPP_OBJECTS)
rm -rf $(BUILD_DIR) $(TARGET) $(TEST_TARGET) @echo "Built $(LIBRARY)"
# Clean everything including raylib
clean-all: clean
cd $(RAYLIB_DIR) && $(MAKE) clean
# Rebuild
rebuild: clean all
$(TEST_OBJECTS): $(BUILD_DIR)/%.o : $(TEST_DIR)/%.cpp $(TEST_OBJECTS): $(BUILD_DIR)/%.o : $(TEST_DIR)/%.cpp
$(CXX) $(CXXFLAGS) -c $< -o $@ $(CXX) $(CXXFLAGS) -c $< -o $@
# Build automated test suite test-build: lib $(BUILD_DIR) $(TEST_OBJECTS)
test-build: $(BUILD_DIR) $(C_OBJECTS) $(CPP_OBJECTS) $(TEST_OBJECTS) $(CXX) $(TEST_OBJECTS) -o $(BUILD_DIR)/orbit_test -L$(BUILD_DIR) -lorbit -lCatch2Main -lCatch2 -lm
$(CXX) $(C_OBJECTS) $(TEST_OBJECTS) \
build/test_utilities.o \
build/physics.o \
build/orbital_mechanics.o \
build/simulation.o \
build/config_loader.o \
build/config_validator.o \
build/maneuver.o \
build/rendezvous.o \
-o $(TEST_TARGET) -lCatch2Main -lCatch2 -lm
# Run automated test suite
test: test-build test: test-build
./$(TEST_TARGET) ./$(BUILD_DIR)/orbit_test
example: lib
$(MAKE) -C example all BUILD_DIR=../$(BUILD_DIR)
clean:
rm -rf $(BUILD_DIR) $(LIBRARY)
$(MAKE) -C example clean
clean-all: clean
$(MAKE) -C example clean-all
rebuild: clean all
.PHONY: all clean clean-all rebuild test test-build raylib ctags .PHONY: all lib test-build test example clean clean-all rebuild

42
example/Makefile

@ -0,0 +1,42 @@
CXX = g++
CXXFLAGS = -Wall -Wextra -g -ggdb3 -std=c++14 \
-I./src \
-I../src \
-isystem./ext/raylib/src \
-isystem./ext/raygui/src \
-isystem./ext/raygui/styles
LDFLAGS = -L./ext/raylib/src -lraylib -lm -lpthread -ldl -lrt -lX11
SRC_DIR = src
BUILD_DIR ?= build
RAYLIB_DIR = ext/raylib/src
CPP_SOURCES := $(wildcard $(SRC_DIR)/*.cpp)
CPP_OBJECTS = $(CPP_SOURCES:$(SRC_DIR)/%.cpp=$(BUILD_DIR)/%.o)
TARGET = ${BUILD_DIR}/orbit_sim
raylib:
@if [ ! -f $(RAYLIB_DIR)/libraylib.a ]; then \
cd $(RAYLIB_DIR) && $(MAKE) PLATFORM=PLATFORM_DESKTOP; \
fi
$(BUILD_DIR):
mkdir -p $(BUILD_DIR)
$(TARGET): $(CPP_OBJECTS) raylib
$(CXX) $(CPP_OBJECTS) -o $(TARGET) -L$(BUILD_DIR) -lorbit $(LDFLAGS)
$(CPP_OBJECTS): $(BUILD_DIR)/%.o : $(SRC_DIR)/%.cpp
$(CXX) $(CXXFLAGS) -c $< -o $@
clean:
rm -f $(TARGET)
@for f in $(CPP_SOURCES); do rm -f $(BUILD_DIR)/$$(basename $${f%.cpp}.o); done
rebuild: clean all
all: raylib $(BUILD_DIR) $(TARGET)
.PHONY: all clean raylib rebuild

1
example/ext/raygui

@ -0,0 +1 @@
Subproject commit 3b2855842ab578a034f827c38cf8f62c042fc983

1
example/ext/raylib

@ -0,0 +1 @@
Subproject commit 72a341a37fbd9ccc1d8ec284ff20aeb5b991ad75

0
src/main.cpp → example/src/main.cpp

0
src/renderer.cpp → example/src/renderer.cpp

0
src/renderer.h → example/src/renderer.h

2
src/ui_renderer.cpp → example/src/ui_renderer.cpp

@ -1045,7 +1045,7 @@ void render_maneuver_dialog(SimulationState* sim, RenderState* render_state, UIS
return; return;
} }
const char* tabs[] = {"Create Maneuver", "Hohmann Transfer", "Edit Maneuver"}; char* tabs[] = {(char*)"Create Maneuver", (char*)"Hohmann Transfer", (char*)"Edit Maneuver"};
int tab_count = 3; int tab_count = 3;
Rectangle tab_bounds = {x + 8, y + 30, width - 16, 25}; Rectangle tab_bounds = {x + 8, y + 30, width - 16, 25};
GuiTabBar(tab_bounds, tabs, tab_count, (int*)&ui_state->maneuver_dialog.active_tab); GuiTabBar(tab_bounds, tabs, tab_count, (int*)&ui_state->maneuver_dialog.active_tab);

0
src/ui_renderer.h → example/src/ui_renderer.h

1
ext/raygui

@ -1 +0,0 @@
Subproject commit 9a1c183d8539e2470635b22f92bdaefaf5218aaa

1
ext/raylib

@ -1 +0,0 @@
Subproject commit ca89934ed5af9161f781a9b35b808b765dc40f3a
Loading…
Cancel
Save