mirror of
https://github.com/thepigeongenerator/mcaselector-lite.git
synced 2025-12-18 20:55:44 +01:00
Compare commits
9 Commits
f5450232b4
...
8443d786e5
| Author | SHA1 | Date | |
|---|---|---|---|
| 8443d786e5 | |||
| f205a0e9aa | |||
| 03daaf86e8 | |||
| af9ae6d4f2 | |||
| 0c59b3066b | |||
| 7677c7e047 | |||
| a14ef55262 | |||
| d340bbe40b | |||
| 0f6a2579b9 |
7
.github/workflows/ci.yaml
vendored
7
.github/workflows/ci.yaml
vendored
@@ -30,8 +30,9 @@ jobs:
|
||||
- uses: actions/cache@v4
|
||||
with:
|
||||
path: lib/obj/
|
||||
key: ${{runner.os}}-lib/obj-${{github.sha}}
|
||||
restore-keys: ${{runner.os}}-lib/obj-
|
||||
- run: make -j libs -B
|
||||
# I swear to god, if runner.arch displays x64 for x86_64, I will eat a potato.
|
||||
key: ${{runner.os}}_${{runner.arch}}-lib/obj-${{github.sha}}
|
||||
restore-keys: ${{runner.os}}_${{runner.arch}}-lib/obj-
|
||||
- run: make -Bj libs
|
||||
- run: make -j all
|
||||
- run: make -j test
|
||||
|
||||
23
Makefile
23
Makefile
@@ -5,7 +5,7 @@
|
||||
NAME = mcaselector-lite
|
||||
DEBUG ?= 0
|
||||
CC ?= cc
|
||||
LD ?= ld
|
||||
LD ?= cc
|
||||
|
||||
# setting default compilation flags
|
||||
# some of which are able to be overwritten, others are always appended
|
||||
@@ -62,20 +62,25 @@ lib/obj/%/: lib/%/
|
||||
|
||||
# link together a runtime binary
|
||||
bin/$(NAME): $(OBJ)
|
||||
$(info [CC/LD] $@)
|
||||
$(info [LD] $@)
|
||||
@mkdir -p $(@D)
|
||||
@$(CC) -o $@ $^ $(LDFLAGS) $(LDLIBS)
|
||||
@$(LD) -o $@ $^ $(LDFLAGS) $(LDLIBS)
|
||||
|
||||
# link together a testing binary
|
||||
bin/TEST_$(NAME): $(TOBJ) $(filter-out obj/src/main.o,$(OBJ))
|
||||
$(info [CC/LD] $@)
|
||||
@mkdir -p $(@D)
|
||||
@$(CC) -o $@ $^ $(LDFLAGS) $(LDLIBS)
|
||||
|
||||
obj/res/%.o: res/%
|
||||
$(info [LD] $@)
|
||||
@mkdir -p $(@D)
|
||||
@$(LD) -r -b binary -o $@ $<
|
||||
@$(LD) -o $@ $^ $(LDFLAGS) $(LDLIBS)
|
||||
|
||||
obj/res/%.c: res/%
|
||||
$(info [XXD] $@)
|
||||
@mkdir -p $(@D)
|
||||
@xxd -i -n $(patsubst res/%,%,$<) $< $@
|
||||
|
||||
obj/res/%.o: obj/res/%.c
|
||||
$(info [CC] $@)
|
||||
@mkdir -p $(@D)
|
||||
@$(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $<
|
||||
|
||||
obj/%.o: %.c
|
||||
$(info [CC] $@)
|
||||
|
||||
@@ -23,28 +23,28 @@ void error_dbg(uint ln, const char *restrict file, const char *restrict fmt, ...
|
||||
void error_inf(uint ln, const char *restrict file, const char *restrict fmt, ...) {
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
error_log(stdout, "\033[93mINF\033[0m", ln, file, fmt, ap);
|
||||
error_log(stdout, "\033[94mINF\033[0m", ln, file, fmt, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
void error_war(uint ln, const char *restrict file, const char *restrict fmt, ...) {
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
error_log(stdout, "\033[91mWAR\033[0m", ln, file, fmt, ap);
|
||||
error_log(stdout, "\033[93mWAR\033[0m", ln, file, fmt, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
void error_err(uint ln, const char *restrict file, const char *restrict fmt, ...) {
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
error_log(stdout, "\033[mFAT\033[0m", ln, file, fmt, ap);
|
||||
error_log(stdout, "\033[91mERR\033[0m", ln, file, fmt, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
void error_fat(uint ln, const char *restrict file, const char *restrict fmt, ...) {
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
error_log(stdout, "\033[mFAT\033[0m", ln, file, fmt, ap);
|
||||
error_log(stdout, "\033[101mFAT\033[0m", ln, file, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
exit(EXIT_FAILURE);
|
||||
|
||||
@@ -8,20 +8,14 @@
|
||||
|
||||
#include "../error.h"
|
||||
|
||||
#define NAM_S(name) _binary_res_##name##_start // name of a start variable
|
||||
#define NAM_E(name) _binary_res_##name##_end // name of an end variable
|
||||
|
||||
// macro for generating the variable declarations
|
||||
#define DEF_GLSL(name) \
|
||||
extern const char NAM_S(name)[]; \
|
||||
extern const char NAM_E(name)[]
|
||||
|
||||
// NOTE: we are currently just sucking up the memory costs for ease. We can either include the source files themselves. Or use compression, where I'd prefer the latter for ease of installation.
|
||||
// NOLINTBEGIN (bugprone-reserved-identifier)
|
||||
DEF_GLSL(sh_vert_glsl);
|
||||
DEF_GLSL(sh_frag_glsl);
|
||||
DEF_GLSL(sh_geom_glsl);
|
||||
// NOLINTEND
|
||||
extern const char sh_vert_glsl[];
|
||||
extern const char sh_frag_glsl[];
|
||||
extern const char sh_geom_glsl[];
|
||||
extern const uint sh_vert_glsl_len;
|
||||
extern const uint sh_frag_glsl_len;
|
||||
extern const uint sh_geom_glsl_len;
|
||||
|
||||
/* compile a shader */
|
||||
static GLuint shader_compile(GLenum type, const char *src, size_t len) {
|
||||
@@ -36,17 +30,16 @@ static GLuint shader_compile(GLenum type, const char *src, size_t len) {
|
||||
char log[ilen];
|
||||
glGetShaderInfoLog(shader, ilen, &ilen, log);
|
||||
log[ilen - 1] = '\0'; // terminate the string one character sooner since the log includes a newline
|
||||
error("error whilst compiling shader type '0X%X': '%s'", type, log);
|
||||
error("error whilst compiling shader type '0x%X': '%s'", type, log);
|
||||
}
|
||||
|
||||
return shader;
|
||||
}
|
||||
|
||||
#define COMPILE_NAME(_type, _name) shader_compile(_type, NAM_S(_name), (uintptr_t)NAM_E(_name) - (uintptr_t)NAM_S(_name))
|
||||
int shader_init(GLuint pipe) {
|
||||
GLuint vs = COMPILE_NAME(GL_VERTEX_SHADER, sh_vert_glsl);
|
||||
GLuint fs = COMPILE_NAME(GL_FRAGMENT_SHADER, sh_frag_glsl);
|
||||
GLuint gs = COMPILE_NAME(GL_GEOMETRY_SHADER, sh_geom_glsl);
|
||||
GLuint vs = shader_compile(GL_VERTEX_SHADER, sh_vert_glsl, sh_vert_glsl_len);
|
||||
GLuint fs = shader_compile(GL_FRAGMENT_SHADER, sh_frag_glsl, sh_frag_glsl_len);
|
||||
GLuint gs = shader_compile(GL_GEOMETRY_SHADER, sh_geom_glsl, sh_geom_glsl_len);
|
||||
|
||||
glAttachShader(pipe, vs);
|
||||
glAttachShader(pipe, fs);
|
||||
|
||||
Reference in New Issue
Block a user