Fix asset bundling to work on Windows
This commit is contained in:
parent
af3692fd11
commit
0b21febc6b
|
@ -1,3 +1,4 @@
|
||||||
/shrooms-vb
|
/shrooms-vb
|
||||||
/shrooms-vb.exe
|
/shrooms-vb.exe
|
||||||
.vscode
|
.vscode
|
||||||
|
output
|
8
assets.h
8
assets.h
|
@ -3,10 +3,10 @@
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
extern const uint8_t asset_lefteye_start;
|
extern const uint8_t _binary_assets_lefteye_bin_start;
|
||||||
const uint8_t *LEFT_EYE_DEFAULT = &asset_lefteye_start;
|
const uint8_t *LEFT_EYE_DEFAULT = &_binary_assets_lefteye_bin_start;
|
||||||
|
|
||||||
extern const uint8_t asset_righteye_start;
|
extern const uint8_t _binary_assets_righteye_bin_start;
|
||||||
const uint8_t *RIGHT_EYE_DEFAULT = &asset_righteye_start;
|
const uint8_t *RIGHT_EYE_DEFAULT = &_binary_assets_righteye_bin_start;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,15 +0,0 @@
|
||||||
.section .note.GNU-stack,"",@progbits
|
|
||||||
.section .bindata, "a", @progbits
|
|
||||||
|
|
||||||
.global asset_lefteye_start
|
|
||||||
.type asset_lefteye_start, @object
|
|
||||||
.global asset_righteye_start
|
|
||||||
.type asset_righteye_start, @object
|
|
||||||
|
|
||||||
.section .bindata
|
|
||||||
.balign 64
|
|
||||||
asset_lefteye_start:
|
|
||||||
.incbin "assets/lefteye.bin"
|
|
||||||
.balign 64
|
|
||||||
asset_righteye_start:
|
|
||||||
.incbin "assets/righteye.bin"
|
|
12
graphics.c
12
graphics.c
|
@ -23,15 +23,15 @@ int gfxInit(GraphicsContext *gfx) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
gfx->winSurface = SDL_GetWindowSurface(gfx->window);
|
gfx->renderer = SDL_CreateRenderer(gfx->window, -1, 0);
|
||||||
if (!gfx->winSurface) {
|
if (!gfx->renderer) {
|
||||||
fprintf(stderr, "Error getting surface: %s\n", SDL_GetError());
|
fprintf(stderr, "Error creating renderer: %s\n", SDL_GetError());
|
||||||
goto cleanup_window;
|
goto cleanup_window;
|
||||||
}
|
}
|
||||||
|
|
||||||
gfx->renderer = SDL_GetRenderer(gfx->window);
|
gfx->winSurface = SDL_GetWindowSurface(gfx->window);
|
||||||
if (!gfx->renderer) {
|
if (!gfx->winSurface) {
|
||||||
fprintf(stderr, "Error getting renderer: %s\n", SDL_GetError());
|
fprintf(stderr, "Error getting surface: %s\n", SDL_GetError());
|
||||||
goto cleanup_window;
|
goto cleanup_window;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
51
makefile
51
makefile
|
@ -1,19 +1,42 @@
|
||||||
CC?=gcc
|
CC?=gcc
|
||||||
|
LD?=ld
|
||||||
SHROOMSFLAGS=shrooms-vb-core/core/vb.c -I shrooms-vb-core/core
|
SHROOMSFLAGS=shrooms-vb-core/core/vb.c -I shrooms-vb-core/core
|
||||||
SDL2FLAGS=$(shell pkg-config sdl2 --cflags --libs)
|
SDL2FLAGS=$(shell pkg-config sdl2 --cflags --libs) -mconsole
|
||||||
|
|
||||||
.PHONY: clean
|
.PHONY: clean build
|
||||||
clean:
|
clean:
|
||||||
ifeq ($(OS),WINDOWS_NT)
|
@rm -rf shrooms-vb output
|
||||||
@del shrooms-vb.exe
|
|
||||||
else
|
|
||||||
@rm -f shrooms-vb
|
|
||||||
endif
|
|
||||||
|
|
||||||
build:
|
CFILES := $(foreach dir,./,$(notdir $(wildcard $(dir)/*.c)))
|
||||||
@$(CC) audio.c cli.c controller.c game.c graphics.c main.c assets/assets.s -I . \
|
BINFILES := $(foreach dir,assets/,$(notdir $(wildcard $(dir)/*.bin)))
|
||||||
$(SHROOMSFLAGS) $(SDL2FLAGS) \
|
|
||||||
-D POSIX_C_SOURCE=199309L \
|
COBJS := $(CFILES:%.c=output/%.o)
|
||||||
-o shrooms-vb \
|
SHROOMSOBJS := output/vb.o
|
||||||
-O3 -fno-strict-aliasing \
|
BINOBJS := $(BINFILES:%.bin=output/%.o)
|
||||||
-Werror -std=c90 -Wall -Wextra -Wpedantic
|
|
||||||
|
OFILES := $(COBJS) $(SHROOMSOBJS) $(BINOBJS)
|
||||||
|
|
||||||
|
output/%.o: %.c
|
||||||
|
@mkdir -p output
|
||||||
|
@$(CC) -c -o $@ $< -I . \
|
||||||
|
-I shrooms-vb-core/core $(SDL2FLAGS) \
|
||||||
|
-D _POSIX_C_SOURCE=199309L \
|
||||||
|
-O3 -flto -fno-strict-aliasing \
|
||||||
|
-Werror -std=c11 -Wall -Wextra -Wpedantic
|
||||||
|
|
||||||
|
output/vb.o: shrooms-vb-core/core/vb.c
|
||||||
|
@mkdir -p output
|
||||||
|
@$(CC) -c -o $@ $< -I . \
|
||||||
|
-I shrooms-vb-core/core $(SDL2FLAGS) \
|
||||||
|
-D _POSIX_C_SOURCE=199309L \
|
||||||
|
-O3 -flto -fno-strict-aliasing \
|
||||||
|
-Werror -std=c11 -Wall -Wextra -Wpedantic
|
||||||
|
|
||||||
|
output/%.o: assets/%.bin
|
||||||
|
@mkdir -p output
|
||||||
|
@$(LD) -r -b binary -o $@ $<
|
||||||
|
|
||||||
|
shrooms-vb: $(OFILES)
|
||||||
|
@$(CC) -o $@ $(OFILES) $(SDL2FLAGS) -flto
|
||||||
|
|
||||||
|
build: shrooms-vb
|
Loading…
Reference in New Issue