switch to premake
This commit is contained in:
parent
7d230f2ccf
commit
8ab0f72f56
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1,3 +1,3 @@
|
||||||
*.a
|
*.a
|
||||||
obj/
|
obj/
|
||||||
examples/*.exe
|
bin/
|
||||||
|
|
83
Makefile
83
Makefile
|
@ -1,25 +1,58 @@
|
||||||
LIBRARY=libgearlib.a
|
# Alternative GNU Make workspace makefile autogenerated by Premake
|
||||||
|
|
||||||
CC:=gcc
|
ifndef config
|
||||||
AR=ar
|
config=debug
|
||||||
CFLAGS=-O3 -Iinclude -g
|
endif
|
||||||
LDFLAGS=-lglfw -lm
|
|
||||||
|
ifndef verbose
|
||||||
CFILES=$(shell cd src && find -L * -type f -name '*.c')
|
SILENT = @
|
||||||
OBJDIR=obj
|
endif
|
||||||
OBJ=$(addprefix $(OBJDIR)/, $(CFILES:.c=.o))
|
|
||||||
|
ifeq ($(config),debug)
|
||||||
$(LIBRARY): $(OBJ) Makefile
|
gearlib_config = debug
|
||||||
$(AR) rcs $(LIBRARY) $(OBJ)
|
test_config = debug
|
||||||
|
|
||||||
obj/%.o: src/%.c
|
else ifeq ($(config),release)
|
||||||
mkdir -p $(OBJDIR)
|
gearlib_config = release
|
||||||
$(CC) $(CFLAGS) -c $< -o $@
|
test_config = release
|
||||||
|
|
||||||
run: $(LIBRARY)
|
else
|
||||||
make -C examples test
|
$(error "invalid configuration $(config)")
|
||||||
cd examples && ./test
|
endif
|
||||||
|
|
||||||
clean:
|
PROJECTS := gearlib test
|
||||||
rm -rf $(OBJ) $(LIBRARY)
|
|
||||||
make -C examples clean
|
.PHONY: all clean help $(PROJECTS)
|
||||||
|
|
||||||
|
all: $(PROJECTS)
|
||||||
|
|
||||||
|
gearlib:
|
||||||
|
ifneq (,$(gearlib_config))
|
||||||
|
@echo "==== Building gearlib ($(gearlib_config)) ===="
|
||||||
|
@${MAKE} --no-print-directory -C . -f gearlib.make config=$(gearlib_config)
|
||||||
|
endif
|
||||||
|
|
||||||
|
test: gearlib
|
||||||
|
ifneq (,$(test_config))
|
||||||
|
@echo "==== Building test ($(test_config)) ===="
|
||||||
|
@${MAKE} --no-print-directory -C . -f test.make config=$(test_config)
|
||||||
|
endif
|
||||||
|
|
||||||
|
clean:
|
||||||
|
@${MAKE} --no-print-directory -C . -f gearlib.make clean
|
||||||
|
@${MAKE} --no-print-directory -C . -f test.make clean
|
||||||
|
|
||||||
|
help:
|
||||||
|
@echo "Usage: make [config=name] [target]"
|
||||||
|
@echo ""
|
||||||
|
@echo "CONFIGURATIONS:"
|
||||||
|
@echo " debug"
|
||||||
|
@echo " release"
|
||||||
|
@echo ""
|
||||||
|
@echo "TARGETS:"
|
||||||
|
@echo " all (default)"
|
||||||
|
@echo " clean"
|
||||||
|
@echo " gearlib"
|
||||||
|
@echo " test"
|
||||||
|
@echo ""
|
||||||
|
@echo "For more information, see https://github.com/premake/premake-core/wiki"
|
|
@ -4,11 +4,11 @@ CFLAGS = -O3 -I../include
|
||||||
LDFLAGS = -L ../ -lglfw -lgearlib -lm
|
LDFLAGS = -L ../ -lglfw -lgearlib -lm
|
||||||
|
|
||||||
CFILES=$(shell find -L * -type f -name '*.c')
|
CFILES=$(shell find -L * -type f -name '*.c')
|
||||||
BINARIES=$(CFILES:.c=.exe)
|
BINARIES=$(CFILES:.c=)
|
||||||
|
|
||||||
all: $(BINARIES)
|
all: $(BINARIES)
|
||||||
|
|
||||||
%.exe: %.c
|
%: %.c
|
||||||
$(CC) $< -o $@ $(CFLAGS) $(LDFLAGS)
|
$(CC) $< -o $@ $(CFLAGS) $(LDFLAGS)
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
|
|
39
examples/quad.c
Normal file
39
examples/quad.c
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
#include <gearlib.h>
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
Window window = create_window(800, 600, "textures");
|
||||||
|
glfwSwapInterval(0); // fps unlock
|
||||||
|
setup_quads();
|
||||||
|
|
||||||
|
Camera* camera = create_camera(vec2(0.0f, 0.0f));
|
||||||
|
UniformBuffer* camera_buffer = create_uniform_buffer(sizeof(CameraMatrices));
|
||||||
|
|
||||||
|
double time = glfwGetTime();
|
||||||
|
|
||||||
|
while (!glfwWindowShouldClose(window)) {
|
||||||
|
process_input(window);
|
||||||
|
update_camera(camera, window);
|
||||||
|
set_uniform_data(camera_buffer, camera->m);
|
||||||
|
|
||||||
|
glClearColor(vec4_spread(BLUE));
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
|
||||||
|
draw_quad(vec2(10, 10), vec2(500, 500), RED);
|
||||||
|
|
||||||
|
flush();
|
||||||
|
|
||||||
|
double end_time = glfwGetTime();
|
||||||
|
double frame_time = end_time - time;
|
||||||
|
time = end_time;
|
||||||
|
|
||||||
|
double fps = 1.0 / frame_time;
|
||||||
|
printf("frame_time: %lf fps: %lf\n", frame_time, fps);
|
||||||
|
|
||||||
|
glfwSwapBuffers(window);
|
||||||
|
glfwPollEvents();
|
||||||
|
}
|
||||||
|
|
||||||
|
glfwDestroyWindow(window);
|
||||||
|
glfwTerminate();
|
||||||
|
return 0;
|
||||||
|
}
|
193
gearlib.make
Normal file
193
gearlib.make
Normal file
|
@ -0,0 +1,193 @@
|
||||||
|
# Alternative GNU Make project makefile autogenerated by Premake
|
||||||
|
|
||||||
|
ifndef config
|
||||||
|
config=debug
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifndef verbose
|
||||||
|
SILENT = @
|
||||||
|
endif
|
||||||
|
|
||||||
|
.PHONY: clean prebuild
|
||||||
|
|
||||||
|
SHELLTYPE := posix
|
||||||
|
ifeq (.exe,$(findstring .exe,$(ComSpec)))
|
||||||
|
SHELLTYPE := msdos
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Configurations
|
||||||
|
# #############################################
|
||||||
|
|
||||||
|
RESCOMP = windres
|
||||||
|
INCLUDES += -Iinclude -Iinclude/gearlib
|
||||||
|
FORCE_INCLUDE +=
|
||||||
|
ALL_CPPFLAGS += $(CPPFLAGS) -MD -MP $(DEFINES) $(INCLUDES)
|
||||||
|
ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES)
|
||||||
|
LIBS += -lglfw -lm
|
||||||
|
LDDEPS +=
|
||||||
|
LINKCMD = $(AR) -rcs "$@" $(OBJECTS)
|
||||||
|
define PREBUILDCMDS
|
||||||
|
endef
|
||||||
|
define PRELINKCMDS
|
||||||
|
endef
|
||||||
|
define POSTBUILDCMDS
|
||||||
|
endef
|
||||||
|
|
||||||
|
ifeq ($(config),debug)
|
||||||
|
TARGETDIR = bin/Debug/gearlib
|
||||||
|
TARGET = $(TARGETDIR)/libgearlib.a
|
||||||
|
OBJDIR = obj/Debug/gearlib
|
||||||
|
DEFINES += -DDEBUG
|
||||||
|
ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -g
|
||||||
|
ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -g
|
||||||
|
ALL_LDFLAGS += $(LDFLAGS)
|
||||||
|
|
||||||
|
else ifeq ($(config),release)
|
||||||
|
TARGETDIR = bin/Release/gearlib
|
||||||
|
TARGET = $(TARGETDIR)/libgearlib.a
|
||||||
|
OBJDIR = obj/Release/gearlib
|
||||||
|
DEFINES += -DNDEBUG
|
||||||
|
ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -O2
|
||||||
|
ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -O2
|
||||||
|
ALL_LDFLAGS += $(LDFLAGS) -s
|
||||||
|
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Per File Configurations
|
||||||
|
# #############################################
|
||||||
|
|
||||||
|
|
||||||
|
# File sets
|
||||||
|
# #############################################
|
||||||
|
|
||||||
|
GENERATED :=
|
||||||
|
OBJECTS :=
|
||||||
|
|
||||||
|
GENERATED += $(OBJDIR)/batch.o
|
||||||
|
GENERATED += $(OBJDIR)/camera.o
|
||||||
|
GENERATED += $(OBJDIR)/debugging.o
|
||||||
|
GENERATED += $(OBJDIR)/events.o
|
||||||
|
GENERATED += $(OBJDIR)/gl.o
|
||||||
|
GENERATED += $(OBJDIR)/implementations.o
|
||||||
|
GENERATED += $(OBJDIR)/init.o
|
||||||
|
GENERATED += $(OBJDIR)/quad.o
|
||||||
|
GENERATED += $(OBJDIR)/renderer.o
|
||||||
|
GENERATED += $(OBJDIR)/shaders.o
|
||||||
|
GENERATED += $(OBJDIR)/textures.o
|
||||||
|
GENERATED += $(OBJDIR)/uniform_buffer.o
|
||||||
|
OBJECTS += $(OBJDIR)/batch.o
|
||||||
|
OBJECTS += $(OBJDIR)/camera.o
|
||||||
|
OBJECTS += $(OBJDIR)/debugging.o
|
||||||
|
OBJECTS += $(OBJDIR)/events.o
|
||||||
|
OBJECTS += $(OBJDIR)/gl.o
|
||||||
|
OBJECTS += $(OBJDIR)/implementations.o
|
||||||
|
OBJECTS += $(OBJDIR)/init.o
|
||||||
|
OBJECTS += $(OBJDIR)/quad.o
|
||||||
|
OBJECTS += $(OBJDIR)/renderer.o
|
||||||
|
OBJECTS += $(OBJDIR)/shaders.o
|
||||||
|
OBJECTS += $(OBJDIR)/textures.o
|
||||||
|
OBJECTS += $(OBJDIR)/uniform_buffer.o
|
||||||
|
|
||||||
|
# Rules
|
||||||
|
# #############################################
|
||||||
|
|
||||||
|
all: $(TARGET)
|
||||||
|
@:
|
||||||
|
|
||||||
|
$(TARGET): $(GENERATED) $(OBJECTS) $(LDDEPS) | $(TARGETDIR)
|
||||||
|
$(PRELINKCMDS)
|
||||||
|
@echo Linking gearlib
|
||||||
|
$(SILENT) $(LINKCMD)
|
||||||
|
$(POSTBUILDCMDS)
|
||||||
|
|
||||||
|
$(TARGETDIR):
|
||||||
|
@echo Creating $(TARGETDIR)
|
||||||
|
ifeq (posix,$(SHELLTYPE))
|
||||||
|
$(SILENT) mkdir -p $(TARGETDIR)
|
||||||
|
else
|
||||||
|
$(SILENT) mkdir $(subst /,\\,$(TARGETDIR))
|
||||||
|
endif
|
||||||
|
|
||||||
|
$(OBJDIR):
|
||||||
|
@echo Creating $(OBJDIR)
|
||||||
|
ifeq (posix,$(SHELLTYPE))
|
||||||
|
$(SILENT) mkdir -p $(OBJDIR)
|
||||||
|
else
|
||||||
|
$(SILENT) mkdir $(subst /,\\,$(OBJDIR))
|
||||||
|
endif
|
||||||
|
|
||||||
|
clean:
|
||||||
|
@echo Cleaning gearlib
|
||||||
|
ifeq (posix,$(SHELLTYPE))
|
||||||
|
$(SILENT) rm -f $(TARGET)
|
||||||
|
$(SILENT) rm -rf $(GENERATED)
|
||||||
|
$(SILENT) rm -rf $(OBJDIR)
|
||||||
|
else
|
||||||
|
$(SILENT) if exist $(subst /,\\,$(TARGET)) del $(subst /,\\,$(TARGET))
|
||||||
|
$(SILENT) if exist $(subst /,\\,$(GENERATED)) del /s /q $(subst /,\\,$(GENERATED))
|
||||||
|
$(SILENT) if exist $(subst /,\\,$(OBJDIR)) rmdir /s /q $(subst /,\\,$(OBJDIR))
|
||||||
|
endif
|
||||||
|
|
||||||
|
prebuild: | $(OBJDIR)
|
||||||
|
$(PREBUILDCMDS)
|
||||||
|
|
||||||
|
ifneq (,$(PCH))
|
||||||
|
$(OBJECTS): $(GCH) | $(PCH_PLACEHOLDER)
|
||||||
|
$(GCH): $(PCH) | prebuild
|
||||||
|
@echo $(notdir $<)
|
||||||
|
$(SILENT) $(CC) -x c-header $(ALL_CFLAGS) -o "$@" -MF "$(@:%.gch=%.d)" -c "$<"
|
||||||
|
$(PCH_PLACEHOLDER): $(GCH) | $(OBJDIR)
|
||||||
|
ifeq (posix,$(SHELLTYPE))
|
||||||
|
$(SILENT) touch "$@"
|
||||||
|
else
|
||||||
|
$(SILENT) echo $null >> "$@"
|
||||||
|
endif
|
||||||
|
else
|
||||||
|
$(OBJECTS): | prebuild
|
||||||
|
endif
|
||||||
|
|
||||||
|
|
||||||
|
# File Rules
|
||||||
|
# #############################################
|
||||||
|
|
||||||
|
$(OBJDIR)/batch.o: src/batch.c
|
||||||
|
@echo "$(notdir $<)"
|
||||||
|
$(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<"
|
||||||
|
$(OBJDIR)/camera.o: src/camera.c
|
||||||
|
@echo "$(notdir $<)"
|
||||||
|
$(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<"
|
||||||
|
$(OBJDIR)/debugging.o: src/debugging.c
|
||||||
|
@echo "$(notdir $<)"
|
||||||
|
$(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<"
|
||||||
|
$(OBJDIR)/events.o: src/events.c
|
||||||
|
@echo "$(notdir $<)"
|
||||||
|
$(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<"
|
||||||
|
$(OBJDIR)/gl.o: src/gl.c
|
||||||
|
@echo "$(notdir $<)"
|
||||||
|
$(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<"
|
||||||
|
$(OBJDIR)/implementations.o: src/implementations.c
|
||||||
|
@echo "$(notdir $<)"
|
||||||
|
$(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<"
|
||||||
|
$(OBJDIR)/init.o: src/init.c
|
||||||
|
@echo "$(notdir $<)"
|
||||||
|
$(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<"
|
||||||
|
$(OBJDIR)/quad.o: src/quad.c
|
||||||
|
@echo "$(notdir $<)"
|
||||||
|
$(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<"
|
||||||
|
$(OBJDIR)/renderer.o: src/renderer.c
|
||||||
|
@echo "$(notdir $<)"
|
||||||
|
$(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<"
|
||||||
|
$(OBJDIR)/shaders.o: src/shaders.c
|
||||||
|
@echo "$(notdir $<)"
|
||||||
|
$(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<"
|
||||||
|
$(OBJDIR)/textures.o: src/textures.c
|
||||||
|
@echo "$(notdir $<)"
|
||||||
|
$(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<"
|
||||||
|
$(OBJDIR)/uniform_buffer.o: src/uniform_buffer.c
|
||||||
|
@echo "$(notdir $<)"
|
||||||
|
$(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<"
|
||||||
|
|
||||||
|
-include $(OBJECTS:%.o=%.d)
|
||||||
|
ifneq (,$(PCH))
|
||||||
|
-include $(PCH_PLACEHOLDER).d
|
||||||
|
endif
|
|
@ -3,18 +3,19 @@
|
||||||
|
|
||||||
#define MAX_VERTICES 2500
|
#define MAX_VERTICES 2500
|
||||||
|
|
||||||
#include <colors.h>
|
#include <gearlib/slibs.h>
|
||||||
#include <raymath.h>
|
#include <gearlib/colors.h>
|
||||||
#include <init.h>
|
#include <gearlib/raymath.h>
|
||||||
#include <shaders.h>
|
#include <gearlib/init.h>
|
||||||
#include <events.h>
|
#include <gearlib/shaders.h>
|
||||||
#include <debugging.h>
|
#include <gearlib/events.h>
|
||||||
#include <vertex.h>
|
#include <gearlib/debugging.h>
|
||||||
#include <renderer.h>
|
#include <gearlib/vertex.h>
|
||||||
#include <camera.h>
|
#include <gearlib/renderer.h>
|
||||||
#include <batch.h>
|
#include <gearlib/camera.h>
|
||||||
#include <quad.h>
|
#include <gearlib/batch.h>
|
||||||
#include <textures.h>
|
#include <gearlib/quad.h>
|
||||||
#include <uniform_buffer.h>
|
#include <gearlib/textures.h>
|
||||||
|
#include <gearlib/uniform_buffer.h>
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
#include <gearlib.h>
|
#include <gearlib.h>
|
||||||
#include <slibs.h>
|
|
||||||
|
|
||||||
typedef struct BatchStats {
|
typedef struct BatchStats {
|
||||||
uint32_t draw_calls;
|
uint32_t draw_calls;
|
|
@ -1,7 +1,7 @@
|
||||||
#ifndef __INIT_H__
|
#ifndef __INIT_H__
|
||||||
#define __INIT_H__
|
#define __INIT_H__
|
||||||
|
|
||||||
#include <opengl.h>
|
#include <gearlib/opengl.h>
|
||||||
|
|
||||||
typedef GLFWwindow* Window;
|
typedef GLFWwindow* Window;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#ifndef __OPENGL_H__
|
#ifndef __OPENGL_H__
|
||||||
#define __OPENGL_H__
|
#define __OPENGL_H__
|
||||||
|
|
||||||
#include <glad/gl.h>
|
#include <gearlib/glad/gl.h>
|
||||||
#include <GLFW/glfw3.h>
|
#include <GLFW/glfw3.h>
|
||||||
|
|
||||||
#endif
|
#endif
|
|
@ -11,12 +11,7 @@
|
||||||
|
|
||||||
#define sl_auto(name, x) typeof(x) name = x
|
#define sl_auto(name, x) typeof(x) name = x
|
||||||
|
|
||||||
#define sl_new(type, ...) \
|
#define sl_new(type) calloc(sizeof(type), 1)
|
||||||
({ \
|
|
||||||
type *ptr = malloc(sizeof(type)); \
|
|
||||||
*ptr = (type){__VA_ARGS__}; \
|
|
||||||
ptr; \
|
|
||||||
})
|
|
||||||
|
|
||||||
#define sl_init(type, ...) \
|
#define sl_init(type, ...) \
|
||||||
(type) { __VA_ARGS__ }
|
(type) { __VA_ARGS__ }
|
38
premake5.lua
Normal file
38
premake5.lua
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
workspace "gearlib"
|
||||||
|
configurations { "Debug", "Release" }
|
||||||
|
|
||||||
|
project "gearlib"
|
||||||
|
kind "StaticLib"
|
||||||
|
language "C"
|
||||||
|
targetdir "bin/%{cfg.buildcfg}/gearlib"
|
||||||
|
|
||||||
|
files { "include/**.h", "src/**.c" }
|
||||||
|
includedirs { "include", "include/gearlib" }
|
||||||
|
links { "glfw", "m" }
|
||||||
|
|
||||||
|
filter "configurations:Debug"
|
||||||
|
defines { "DEBUG" }
|
||||||
|
symbols "On"
|
||||||
|
|
||||||
|
filter "configurations:Release"
|
||||||
|
defines { "NDEBUG" }
|
||||||
|
optimize "On"
|
||||||
|
|
||||||
|
project "test"
|
||||||
|
kind "ConsoleApp"
|
||||||
|
language "C"
|
||||||
|
targetdir "bin/%{cfg.buildcfg}/test"
|
||||||
|
|
||||||
|
files { "examples/test.c" }
|
||||||
|
includedirs { "include", "include/gearlib" }
|
||||||
|
links { "glfw", "gearlib", "m" }
|
||||||
|
|
||||||
|
debugdir "examples"
|
||||||
|
|
||||||
|
filter "configurations:Debug"
|
||||||
|
defines { "DEBUG" }
|
||||||
|
symbols "On"
|
||||||
|
|
||||||
|
filter "configurations:Release"
|
||||||
|
defines { "NDEBUG" }
|
||||||
|
optimize "On"
|
10
src/batch.c
10
src/batch.c
|
@ -1,11 +1,10 @@
|
||||||
#include <gearlib.h>
|
#include <gearlib.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <slibs.h>
|
|
||||||
|
|
||||||
BatchList batches = { 0 };
|
BatchList batches = { 0 };
|
||||||
|
|
||||||
RenderBatch* create_batch(size_t vert_size, uint32_t max_verts) {
|
RenderBatch* create_batch(size_t vert_size, uint32_t max_verts) {
|
||||||
RenderBatch* batch = calloc(sizeof(RenderBatch), 1);
|
RenderBatch* batch = sl_new(RenderBatch);
|
||||||
sl_vec_push(batches, batch);
|
sl_vec_push(batches, batch);
|
||||||
|
|
||||||
glCreateBuffers(1, &batch->vbo);
|
glCreateBuffers(1, &batch->vbo);
|
||||||
|
@ -36,13 +35,6 @@ void flush_batch(RenderBatch* batch) {
|
||||||
|
|
||||||
glUseProgram(batch->shader);
|
glUseProgram(batch->shader);
|
||||||
|
|
||||||
/*glUniformMatrix4fv(0, 1, GL_FALSE,
|
|
||||||
mat4ToFloat(mat4Multiply(batch->camera->view, batch->camera->projection)));*/
|
|
||||||
|
|
||||||
|
|
||||||
//glUniformMatrix4fv(1, 1, GL_FALSE, mat4ToFloat(batch->camera->view));
|
|
||||||
//glUniformMatrix4fv(2, 1, GL_FALSE, mat4ToFloat(batch->camera->projection));
|
|
||||||
|
|
||||||
if(batch->flush_callback != NULL)
|
if(batch->flush_callback != NULL)
|
||||||
batch->flush_callback(batch);
|
batch->flush_callback(batch);
|
||||||
|
|
||||||
|
|
|
@ -2,9 +2,9 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
Camera* create_camera(vec2 pos) {
|
Camera* create_camera(vec2 pos) {
|
||||||
Camera* camera = calloc(sizeof(Camera), 1);
|
Camera* camera = sl_new(Camera);
|
||||||
camera->position = vec3(pos, -3.0f);
|
camera->position = vec3(pos, -3.0f);
|
||||||
camera->m = calloc(sizeof(CameraMatrices), 1);
|
camera->m = sl_new(CameraMatrices);
|
||||||
|
|
||||||
return camera;
|
return camera;
|
||||||
}
|
}
|
||||||
|
|
|
@ -104,7 +104,7 @@ RenderBatch* create_texture_quad_batch() {
|
||||||
compile_shader("assets/texture.vert", GL_VERTEX_SHADER),
|
compile_shader("assets/texture.vert", GL_VERTEX_SHADER),
|
||||||
compile_shader("assets/texture.frag", GL_FRAGMENT_SHADER), 0);
|
compile_shader("assets/texture.frag", GL_FRAGMENT_SHADER), 0);
|
||||||
|
|
||||||
texture_quad_batch->data = calloc(sizeof(TextureQuadBatchData), 1);
|
texture_quad_batch->data = sl_new(TextureQuadBatchData);
|
||||||
texture_quad_batch->flush_callback = &texture_flush_callback;
|
texture_quad_batch->flush_callback = &texture_flush_callback;
|
||||||
|
|
||||||
batch_add_attrib(texture_quad_batch, (VertexAttrib){
|
batch_add_attrib(texture_quad_batch, (VertexAttrib){
|
||||||
|
|
140
test.make
Normal file
140
test.make
Normal file
|
@ -0,0 +1,140 @@
|
||||||
|
# Alternative GNU Make project makefile autogenerated by Premake
|
||||||
|
|
||||||
|
ifndef config
|
||||||
|
config=debug
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifndef verbose
|
||||||
|
SILENT = @
|
||||||
|
endif
|
||||||
|
|
||||||
|
.PHONY: clean prebuild
|
||||||
|
|
||||||
|
SHELLTYPE := posix
|
||||||
|
ifeq (.exe,$(findstring .exe,$(ComSpec)))
|
||||||
|
SHELLTYPE := msdos
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Configurations
|
||||||
|
# #############################################
|
||||||
|
|
||||||
|
RESCOMP = windres
|
||||||
|
INCLUDES += -Iinclude -Iinclude/gearlib
|
||||||
|
FORCE_INCLUDE +=
|
||||||
|
ALL_CPPFLAGS += $(CPPFLAGS) -MD -MP $(DEFINES) $(INCLUDES)
|
||||||
|
ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES)
|
||||||
|
LINKCMD = $(CC) -o "$@" $(OBJECTS) $(RESOURCES) $(ALL_LDFLAGS) $(LIBS)
|
||||||
|
define PREBUILDCMDS
|
||||||
|
endef
|
||||||
|
define PRELINKCMDS
|
||||||
|
endef
|
||||||
|
define POSTBUILDCMDS
|
||||||
|
endef
|
||||||
|
|
||||||
|
ifeq ($(config),debug)
|
||||||
|
TARGETDIR = bin/Debug/test
|
||||||
|
TARGET = $(TARGETDIR)/test
|
||||||
|
OBJDIR = obj/Debug/test
|
||||||
|
DEFINES += -DDEBUG
|
||||||
|
ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -g
|
||||||
|
ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -g
|
||||||
|
LIBS += bin/Debug/gearlib/libgearlib.a -lglfw -lm
|
||||||
|
LDDEPS += bin/Debug/gearlib/libgearlib.a
|
||||||
|
ALL_LDFLAGS += $(LDFLAGS)
|
||||||
|
|
||||||
|
else ifeq ($(config),release)
|
||||||
|
TARGETDIR = bin/Release/test
|
||||||
|
TARGET = $(TARGETDIR)/test
|
||||||
|
OBJDIR = obj/Release/test
|
||||||
|
DEFINES += -DNDEBUG
|
||||||
|
ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -O2
|
||||||
|
ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -O2
|
||||||
|
LIBS += bin/Release/gearlib/libgearlib.a -lglfw -lm
|
||||||
|
LDDEPS += bin/Release/gearlib/libgearlib.a
|
||||||
|
ALL_LDFLAGS += $(LDFLAGS) -s
|
||||||
|
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Per File Configurations
|
||||||
|
# #############################################
|
||||||
|
|
||||||
|
|
||||||
|
# File sets
|
||||||
|
# #############################################
|
||||||
|
|
||||||
|
GENERATED :=
|
||||||
|
OBJECTS :=
|
||||||
|
|
||||||
|
GENERATED += $(OBJDIR)/test.o
|
||||||
|
OBJECTS += $(OBJDIR)/test.o
|
||||||
|
|
||||||
|
# Rules
|
||||||
|
# #############################################
|
||||||
|
|
||||||
|
all: $(TARGET)
|
||||||
|
@:
|
||||||
|
|
||||||
|
$(TARGET): $(GENERATED) $(OBJECTS) $(LDDEPS) | $(TARGETDIR)
|
||||||
|
$(PRELINKCMDS)
|
||||||
|
@echo Linking test
|
||||||
|
$(SILENT) $(LINKCMD)
|
||||||
|
$(POSTBUILDCMDS)
|
||||||
|
|
||||||
|
$(TARGETDIR):
|
||||||
|
@echo Creating $(TARGETDIR)
|
||||||
|
ifeq (posix,$(SHELLTYPE))
|
||||||
|
$(SILENT) mkdir -p $(TARGETDIR)
|
||||||
|
else
|
||||||
|
$(SILENT) mkdir $(subst /,\\,$(TARGETDIR))
|
||||||
|
endif
|
||||||
|
|
||||||
|
$(OBJDIR):
|
||||||
|
@echo Creating $(OBJDIR)
|
||||||
|
ifeq (posix,$(SHELLTYPE))
|
||||||
|
$(SILENT) mkdir -p $(OBJDIR)
|
||||||
|
else
|
||||||
|
$(SILENT) mkdir $(subst /,\\,$(OBJDIR))
|
||||||
|
endif
|
||||||
|
|
||||||
|
clean:
|
||||||
|
@echo Cleaning test
|
||||||
|
ifeq (posix,$(SHELLTYPE))
|
||||||
|
$(SILENT) rm -f $(TARGET)
|
||||||
|
$(SILENT) rm -rf $(GENERATED)
|
||||||
|
$(SILENT) rm -rf $(OBJDIR)
|
||||||
|
else
|
||||||
|
$(SILENT) if exist $(subst /,\\,$(TARGET)) del $(subst /,\\,$(TARGET))
|
||||||
|
$(SILENT) if exist $(subst /,\\,$(GENERATED)) del /s /q $(subst /,\\,$(GENERATED))
|
||||||
|
$(SILENT) if exist $(subst /,\\,$(OBJDIR)) rmdir /s /q $(subst /,\\,$(OBJDIR))
|
||||||
|
endif
|
||||||
|
|
||||||
|
prebuild: | $(OBJDIR)
|
||||||
|
$(PREBUILDCMDS)
|
||||||
|
|
||||||
|
ifneq (,$(PCH))
|
||||||
|
$(OBJECTS): $(GCH) | $(PCH_PLACEHOLDER)
|
||||||
|
$(GCH): $(PCH) | prebuild
|
||||||
|
@echo $(notdir $<)
|
||||||
|
$(SILENT) $(CC) -x c-header $(ALL_CFLAGS) -o "$@" -MF "$(@:%.gch=%.d)" -c "$<"
|
||||||
|
$(PCH_PLACEHOLDER): $(GCH) | $(OBJDIR)
|
||||||
|
ifeq (posix,$(SHELLTYPE))
|
||||||
|
$(SILENT) touch "$@"
|
||||||
|
else
|
||||||
|
$(SILENT) echo $null >> "$@"
|
||||||
|
endif
|
||||||
|
else
|
||||||
|
$(OBJECTS): | prebuild
|
||||||
|
endif
|
||||||
|
|
||||||
|
|
||||||
|
# File Rules
|
||||||
|
# #############################################
|
||||||
|
|
||||||
|
$(OBJDIR)/test.o: examples/test.c
|
||||||
|
@echo "$(notdir $<)"
|
||||||
|
$(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<"
|
||||||
|
|
||||||
|
-include $(OBJECTS:%.o=%.d)
|
||||||
|
ifneq (,$(PCH))
|
||||||
|
-include $(PCH_PLACEHOLDER).d
|
||||||
|
endif
|
Loading…
Reference in a new issue