2403f060eb
So when PACKET_SDL_EVENT was SDL_USEREVENT, things worked fine in the main loop it would see SDL_USEREVENT and send it off to my_SDL_UserEvent. But when I started adding more events, the SDL_UserEvent paradigm given in the SDL Wiki stopped working. The example here is broken: https://wiki.libsdl.org/SDL_AddTimer The example here is working and "correct": https://wiki.libsdl.org/SDL_UserEvent All SDL_RegisterEvents is increase a static counter. SDL doesn't actually use these events anyway. It's purely symbolic, as far as I can tell. So anyway. Now events work after a bunch of debugging. SHADER_PROGRAM_REFRESH is the second user event I've done. The ShaderProgram runs an SDL_TimerID that looks at mVertexPath, mGeometryPath if present, and mFragmentPath. mVertexPath and mFragmentPath are required by Compile3ShaderBuffers. In the future I'd like to change the way this class behaves.
196 lines
4.2 KiB
Makefile
196 lines
4.2 KiB
Makefile
.PHONY: all clean
|
|
.POSIX:
|
|
|
|
# {{{ Flags
|
|
SRCDIR := src
|
|
OBJDIR := .o
|
|
DEPDIR := .d
|
|
TESTDIR := test
|
|
TEST_BINDIR := $(TESTDIR)/bin
|
|
MKDIR := mkdir -p
|
|
# }}}
|
|
|
|
PROGS := main_client main_server
|
|
|
|
IMGUI_INCLUDE := -Iimgui -Iimgui/backends
|
|
IMGUI_SRCS := \
|
|
imgui/backends/imgui_impl_glfw.cpp \
|
|
imgui/backends/imgui_impl_opengl3.cpp \
|
|
imgui/imgui.cpp \
|
|
imgui/imgui_demo.cpp \
|
|
imgui/imgui_draw.cpp \
|
|
imgui/imgui_tables.cpp \
|
|
imgui/imgui_widgets.cpp
|
|
|
|
SRCS := $(wildcard $(SRCDIR)/*.cpp) $(IMGUI_SRCS) $(wildcard $(TESTDIR)/*.cpp)
|
|
OBJS := $(patsubst %,$(OBJDIR)/%.o,$(basename $(SRCS)))
|
|
DEPS := $(patsubst %,$(DEPDIR)/%.d,$(basename $(SRCS)))
|
|
|
|
COMMON_OBJS := \
|
|
$(OBJDIR)/src/lib_lua_common.o \
|
|
$(OBJDIR)/src/lib_SDL_common.o \
|
|
$(OBJDIR)/src/lib_SDL_Log.o \
|
|
$(OBJDIR)/src/signal_common.o \
|
|
$(OBJDIR)/src/UDPbase.o \
|
|
$(OBJDIR)/src/UDPpacketVBuffer.o \
|
|
$(OBJDIR)/src/util.o
|
|
|
|
SERVER_OBJS := \
|
|
$(OBJDIR)/src/server_main.o \
|
|
$(OBJDIR)/src/Server.o \
|
|
$(COMMON_OBJS)
|
|
|
|
CLIENT_OBJS := \
|
|
$(OBJDIR)/src/camera.o \
|
|
$(OBJDIR)/src/client_main.o \
|
|
$(OBJDIR)/src/cube.o \
|
|
$(OBJDIR)/src/FileIO.o \
|
|
$(OBJDIR)/src/lib_GL_common.o \
|
|
$(OBJDIR)/src/object.o \
|
|
$(OBJDIR)/src/quad.o \
|
|
$(OBJDIR)/src/shader.o \
|
|
$(COMMON_OBJS)
|
|
|
|
IMGUI_OBJS := $(patsubst %,$(OBJDIR)/%.o,$(basename $(IMGUI_SRCS)))
|
|
|
|
TEST_OBJ_COMMON := \
|
|
$(OBJDIR)/src/FileIO.o \
|
|
$(COMMON_OBJS)
|
|
|
|
|
|
TESTS := test_FileIO test_lua test_UDPpacketBufferV
|
|
TEST_PROGS := $(addprefix $(TEST_BINDIR)/,$(TESTS))
|
|
|
|
$(shell $(MKDIR) $(dir $(OBJS)) >/dev/null)
|
|
$(shell $(MKDIR) $(dir $(DEPS)) >/dev/null)
|
|
$(shell $(MKDIR) $(dir $(TEST_PROGS)) >/dev/null)
|
|
|
|
# {{{ Flags
|
|
CC := gcc
|
|
CXX := g++
|
|
LD := g++
|
|
ifeq ($(CLANG),1)
|
|
CC := clang-12
|
|
CXX := clang++-12
|
|
LD := clang-12
|
|
endif
|
|
|
|
SRCDIR := src
|
|
OBJDIR := .o
|
|
DEPDIR := .d
|
|
|
|
RM := rm -rf
|
|
|
|
PKGS := SDL2_image SDL2_mixer SDL2_ttf SDL2_net sdl2 gl glew lua54
|
|
CPPFLAGS := $(shell pkg-config --cflags $(PKGS))
|
|
LDLIBS := $(shell pkg-config --libs $(PKGS)) -lm
|
|
|
|
DEFS := -D_FILE_OFFSET_BITS=64
|
|
INCS := -Iinclude $(IMGUI_INCLUDE)
|
|
|
|
DEBUG := -g
|
|
ifeq ($(D),1)
|
|
DEBUG := -ggdb
|
|
OPT := -O0
|
|
DEFS += -DDEBUG=1
|
|
endif
|
|
|
|
OPT := -O0
|
|
ifeq ($(O),1)
|
|
OPT := -O1 -g
|
|
endif
|
|
ifeq ($(O),2)
|
|
OPT := -O2 -g
|
|
endif
|
|
ifeq ($(O),3)
|
|
OPT := -O3 -g0
|
|
endif
|
|
|
|
ifeq ($(LTO),1)
|
|
LDFLAGS += -flto -fwhole-program
|
|
endif
|
|
|
|
ifeq ($(PG),1)
|
|
CFLAGS += -pg -coverage
|
|
endif
|
|
|
|
ifeq ($(PEDANTIC),1)
|
|
CFLAGS += -pedantic
|
|
endif
|
|
|
|
CFLAGS += -std=c99
|
|
CXXFLAGS += -std=c++14
|
|
CPPFLAGS += -fPIC -W -Wextra -Wall $(DEFS) $(DEBUG) $(INCS) $(OPT)
|
|
|
|
# flags required for dependency generation; passed to compilers
|
|
DEPFLAGS = -MT $@ -MD -MP -MF $(DEPDIR)/$*.Td
|
|
|
|
# compile C source files
|
|
COMPILE.c = $(CC) $(DEPFLAGS) $(CFLAGS) $(CPPFLAGS) -c -o $@
|
|
# compile C++ source files
|
|
COMPILE.cc = $(CXX) $(DEPFLAGS) $(CXXFLAGS) $(CPPFLAGS) -c -o $@
|
|
# link object files to binary
|
|
LINK.o = $(LD) $(LDFLAGS) -o $@
|
|
LINK.so = $(LD) $(LDFLAGS) -o $@ -shared
|
|
# precompile step
|
|
PRECOMPILE =
|
|
# postcompile step
|
|
POSTCOMPILE = mv -f $(DEPDIR)/$*.Td $(DEPDIR)/$*.d
|
|
|
|
# }}}
|
|
|
|
.SUFFIXES: .c .cc .cpp .cxx .o .1
|
|
|
|
all: $(OBJS) $(PROGS)
|
|
|
|
main_client: $(CLIENT_OBJS)
|
|
$(LINK.o) $^ $(LDLIBS)
|
|
|
|
main_server: $(SERVER_OBJS)
|
|
$(LINK.o) $^ $(LDLIBS)
|
|
|
|
test: $(TEST_PROGS)
|
|
@echo $(TEST_PROGS)
|
|
|
|
$(TEST_BINDIR)/test_FileIO: $(OBJDIR)/test/test_FileIO.o $(TEST_OBJ_COMMON) $(OBJDIR)/src/util.o
|
|
$(LINK.o) $^ $(LDLIBS)
|
|
|
|
$(TEST_BINDIR)/test_lua: $(OBJDIR)/test/test_lua.o $(TEST_OBJ_COMMON) $(OBJDIR)/src/lib_lua_common.o
|
|
$(LINK.o) $^ $(LDLIBS)
|
|
|
|
$(TEST_BINDIR)/test_UDPpacketBufferV: $(OBJDIR)/test/test_UDPpacketBufferV.o $(TEST_OBJ_COMMON) $(OBJDIR)/src/UDPbase.o $(OBJDIR)/src/lib_SDL_common.o
|
|
$(LINK.o) $^ $(LDLIBS)
|
|
|
|
$(OBJDIR)/%.o: %.c
|
|
$(OBJDIR)/%.o: %.c $(DEPDIR)/%.d
|
|
$(PRECOMPILE)
|
|
$(COMPILE.c) $<
|
|
$(POSTCOMPILE)
|
|
|
|
$(OBJDIR)/%.o: %.cpp
|
|
$(OBJDIR)/%.o: %.cpp $(DEPDIR)/%.d
|
|
$(PRECOMPILE)
|
|
$(COMPILE.cc) $<
|
|
$(POSTCOMPILE)
|
|
|
|
$(OBJDIR)/%.o: %.cc
|
|
$(OBJDIR)/%.o: %.cc $(DEPDIR)/%.d
|
|
$(PRECOMPILE)
|
|
$(COMPILE.cc) $<
|
|
$(POSTCOMPILE)
|
|
|
|
$(OBJDIR)/%.o: %.cxx
|
|
$(OBJDIR)/%.o: %.cxx $(DEPDIR)/%.d
|
|
$(PRECOMPILE)
|
|
$(COMPILE.cc) $<
|
|
$(POSTCOMPILE)
|
|
|
|
clean:
|
|
@echo $(RM) $(DEPDIR) $(OBJDIR) $(PROGS)
|
|
@echo $(RM) $(TEST_PROGS)
|
|
|
|
.PRECIOUS: $(DEPDIR)/%.d
|
|
$(DEPDIR)/%.d: ;
|
|
|
|
-include $(DEPS)
|