Bug fixes: - Release static GL objects (UBOs, logo texture) before the context is destroyed via new Renderer::shutdown() - Fix max point/spot light warnings never firing - Show frame time in ms instead of seconds - Size the viewport framebuffer in physical pixels on HiDPI displays - Stop double-flipping OBJ UVs; add flip_uvs option to load_obj for models with a top-left UV origin (backpack) Build: - Track header dependencies (-MMD -MP) so header edits trigger rebuilds - Create build/ automatically Error handling: - Add gldebug module: KHR_debug output routed to the logger in debug builds, object labels, and error/status string helpers - Validate inputs and check GL errors when creating textures, meshes, framebuffers, uniform buffers and shaders; FrameBuffer::resize() and Renderer::init() now report failure Resources: - Add ResourceCache: shares textures and shaders by path and substitutes fallbacks (magenta checkerboard texture, unlit shader, cube mesh) for assets that fail to load; specular maps are optional - load_obj never fails, a broken model becomes a fallback cube - Renderer draws submeshes with broken materials using the fallback material instead of skipping them - Add Texture::create_from_pixels, Shader::create_from_source and Mesh::create_cube - Cache uniform locations in Shader, looked up with string_view so hits don't allocate; missing uniforms warn once Performance: - Add CpuTimer and GpuTimer (GL_TIME_ELAPSED, non-blocking readback) and a Performance section in the UI with averaged overlay numbers - Sample material textures once per fragment and apply material colors after accumulating lights - Pass camera position through CameraBlock instead of inverting the view matrix per fragment - Compute the normal matrix on the CPU instead of per vertex - Skip spot light work for fragments outside the outer cone
83 lines
2.4 KiB
Makefile
83 lines
2.4 KiB
Makefile
CXX := clang++
|
|
CXXFLAGS := -Wall -Wextra -std=c++17
|
|
CC := clang
|
|
CFLAGS := -Wall -Wextra
|
|
DEPFLAGS := -MMD -MP
|
|
|
|
INCLUDES := -I./src/ \
|
|
-I./vendor/glad/include/ \
|
|
-I./vendor/glm/ \
|
|
-I./vendor/imgui/ \
|
|
-I./vendor/imgui/backends/ \
|
|
-I./vendor/stb/ \
|
|
-I./vendor/tinyobjloader/ \
|
|
|
|
LDFLAGS := -lglfw -lGL -lm
|
|
|
|
TARGET := build/fan
|
|
|
|
OBJS := build/camera.o \
|
|
build/framebuffer.o \
|
|
build/gldebug.o \
|
|
build/loader.o \
|
|
build/main.o \
|
|
build/material.o \
|
|
build/mesh.o \
|
|
build/renderer.o \
|
|
build/resourcecache.o \
|
|
build/scene.o \
|
|
build/shader.o \
|
|
build/texture.o \
|
|
build/timer.o \
|
|
build/transform.o \
|
|
build/uniformbuffer.o \
|
|
build/utils.o \
|
|
build/window.o \
|
|
build/glad.o \
|
|
build/stb_image.o \
|
|
build/tiny_obj_loader.o \
|
|
|
|
IMGUI_OBJS := build/imgui.o build/imgui_demo.o build/imgui_draw.o \
|
|
build/imgui_tables.o build/imgui_widgets.o \
|
|
build/imgui_impl_glfw.o build/imgui_impl_opengl3.o
|
|
|
|
.PHONY: all clean
|
|
|
|
all: $(TARGET)
|
|
|
|
$(TARGET): $(OBJS) $(IMGUI_OBJS) | build
|
|
$(CXX) $(CXXFLAGS) -o $@ $^ $(LDFLAGS)
|
|
|
|
build/%.o: src/%.cpp | build
|
|
$(CXX) $(CXXFLAGS) $(DEPFLAGS) $(INCLUDES) -c $< -o $@
|
|
|
|
build/glad.o: vendor/glad/src/gl.c | build
|
|
$(CC) $(CFLAGS) -I./vendor/glad/include/ -c $< -o $@
|
|
|
|
build/stb_image.o: vendor/stb/stb_image.h | build
|
|
$(CC) $(CFLAGS) -DSTB_IMAGE_IMPLEMENTATION -xc -c $< -o $@
|
|
|
|
build/tiny_obj_loader.o: vendor/tinyobjloader/tiny_obj_loader.h | build
|
|
$(CXX) $(CXXFLAGS) -DTINYOBJLOADER_IMPLEMENTATION -xc++ -c $< -o $@
|
|
|
|
define imgui_rule
|
|
build/$(1): vendor/imgui/$(2) | build
|
|
$(CXX) $(CXXFLAGS) -I./vendor/imgui/ -c $$< -o $$@
|
|
endef
|
|
|
|
$(eval $(call imgui_rule,imgui.o,imgui.cpp))
|
|
$(eval $(call imgui_rule,imgui_demo.o,imgui_demo.cpp))
|
|
$(eval $(call imgui_rule,imgui_draw.o,imgui_draw.cpp))
|
|
$(eval $(call imgui_rule,imgui_tables.o,imgui_tables.cpp))
|
|
$(eval $(call imgui_rule,imgui_widgets.o,imgui_widgets.cpp))
|
|
$(eval $(call imgui_rule,imgui_impl_glfw.o,backends/imgui_impl_glfw.cpp))
|
|
$(eval $(call imgui_rule,imgui_impl_opengl3.o,backends/imgui_impl_opengl3.cpp))
|
|
|
|
build:
|
|
mkdir -p build
|
|
|
|
clean:
|
|
rm -f build/*.o build/*.d $(TARGET)
|
|
|
|
-include $(OBJS:.o=.d)
|