From aa08815e7c1dd83898e09c86dd6e3362eea918d4 Mon Sep 17 00:00:00 2001 From: John Alanbrook Date: Wed, 31 May 2023 17:09:02 +0000 Subject: [PATCH] sprite gui render --- Makefile | 5 ----- source/engine/sprite.c | 5 ++--- source/engine/sprite.h | 2 +- source/shaders/spritevert.glsl | 1 + 4 files changed, 4 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index 918129a..6fffe86 100755 --- a/Makefile +++ b/Makefile @@ -52,15 +52,10 @@ endef edirs != find source -type d -name include subengs = sound 3d -ifeq ($(ED), 1) - subengs += editor -endif - ifeq ($(DBG), 1) subengs += debug endif - edirs += source/engine $(addprefix source/engine/, $(subengs)) source/engine/thirdparty/Nuklear ehead != find source/engine source/engine/sound source/engine/debug source/engine/editor -maxdepth 1 -type f -name *.h eobjects != find source/engine -type f -name '*.c' | sed -r 's|^(.*)\.c|$(objprefix)/\1.o|' # Gets all .c files and makes .o refs diff --git a/source/engine/sprite.c b/source/engine/sprite.c index b606ee6..ec65d21 100644 --- a/source/engine/sprite.c +++ b/source/engine/sprite.c @@ -210,11 +210,10 @@ void sprite_setanim(struct sprite *sprite, struct TexAnim *anim, int frame) { sprite->frame = anim->st_frames[frame]; } -void gui_draw_img(const char *img, float x, float y) { +void gui_draw_img(const char *img, HMM_Vec2 pos, float scale, float angle) { sg_apply_pipeline(pip_sprite); struct Texture *tex = texture_loadfromfile(img); - HMM_Vec2 pos = {x, y}; - HMM_Vec2 size = {1.f, 1.f}; + HMM_Vec2 size = {scale, scale}; HMM_Vec2 offset = {0.f, 0.f}; tex_draw(tex, pos, 0.f, size, offset, tex_get_rect(tex), color_white); } diff --git a/source/engine/sprite.h b/source/engine/sprite.h index baa6550..5d78597 100644 --- a/source/engine/sprite.h +++ b/source/engine/sprite.h @@ -41,7 +41,7 @@ void sprite_draw_all(); unsigned int incrementAnimFrame(unsigned int interval, struct sprite *sprite); void sprite_flush(); -void gui_draw_img(const char *img, float x, float y); +void gui_draw_img(const char *img, HMM_Vec2 pos); #endif diff --git a/source/shaders/spritevert.glsl b/source/shaders/spritevert.glsl index 4721a3a..711737c 100644 --- a/source/shaders/spritevert.glsl +++ b/source/shaders/spritevert.glsl @@ -2,6 +2,7 @@ layout (location = 0) in vec4 vertex; out vec2 texcoords; +uniform mat4 proj; uniform mat4 mpv; void main()