pattermon rendered (many things to rework/fix)

This commit is contained in:
Matthew 2025-05-08 20:48:12 +10:00
parent d2b5e54c3b
commit 5ff767e916
4 changed files with 21 additions and 8 deletions

View File

@ -59,6 +59,7 @@ static void gRunCycle(gGameCtx *ctx, pGameInput *inputs, u32 i_count)
gHandleInputs(inputs, i_count); gHandleInputs(inputs, i_count);
/*
if (gButton(ctx, "Show 2", 150.0f, 150.0f, 200.0f, 200.0f)) if (gButton(ctx, "Show 2", 150.0f, 150.0f, 200.0f, 200.0f))
{ {
gWindow(ctx, "Window 2", 500.0f, 500.0f, 600.0f, 600.0f); gWindow(ctx, "Window 2", 500.0f, 500.0f, 600.0f, 600.0f);
@ -73,12 +74,14 @@ static void gRunCycle(gGameCtx *ctx, pGameInput *inputs, u32 i_count)
{ {
gWindow(ctx, "Window 3", 250.0f, 500.0f, 400.0f, 650.0f); gWindow(ctx, "Window 3", 250.0f, 500.0f, 400.0f, 650.0f);
} }
*/
rViewportSize(&ctx->pc.res); rViewportSize(&ctx->pc.res);
rDescHandle pattermon = rTextureCreateAndUpload(PATTERMON_OBESE); rDescHandle pattermon = rTextureCreateAndUpload(PATTERMON_OBESE);
gWindow(ctx, "Pattermon", 100.0f, 100.0f, 300.0f, 300.0f, pattermon);
rawptr vert_buffer = rBufferGUIVertMapping(); rawptr vert_buffer = rBufferGUIVertMapping();
rawptr idx_buffer = rBufferGUIIdxMapping(); rawptr idx_buffer = rBufferGUIIdxMapping();
@ -226,12 +229,12 @@ static b32 gButton(gGameCtx *ctx, char *label, f32 x0, f32 y0, f32 x1, f32 y1)
btn->pressed = !btn->pressed; btn->pressed = !btn->pressed;
} }
gRect(&ctx->gui, btn->p0, btn->p1, (Vec4){ .r = 0.1f, .g = 0.9f, .b = 0.4f, .a = 1.0f }); //gRect(&ctx->gui, btn->p0, btn->p1, (Vec4){ .r = 0.1f, .g = 0.9f, .b = 0.4f, .a = 1.0f });
return btn->pressed; return btn->pressed;
} }
static b32 gWindow(gGameCtx *ctx, char *title, f32 x0, f32 y0, f32 x1, f32 y1) static b32 gWindow(gGameCtx *ctx, char *title, f32 x0, f32 y0, f32 x1, f32 y1, rDescHandle handle)
{ {
gWindowWidget *win = NULL; gWindowWidget *win = NULL;
u32 id = HashFromString(String8CStr(title)); u32 id = HashFromString(String8CStr(title));
@ -306,17 +309,18 @@ static b32 gWindow(gGameCtx *ctx, char *title, f32 x0, f32 y0, f32 x1, f32 y1)
ctx->gui.has_grabbed = true; ctx->gui.has_grabbed = true;
} }
gRect(&ctx->gui, win->p0, win->p1, (Vec4){ .r = 0.1f, .g = 0.3f, .b = 0.8f, .a = 1.0f }); gRect(&ctx->gui, win->p0, win->p1, (Vec4){ .r = 0.1f, .g = 0.3f, .b = 0.8f, .a = 1.0f }, handle);
return true; return true;
} }
static void gRect(gUICtx *ctx, Vec2 p0, Vec2 p1, Vec4 col) static void gRect(gUICtx *ctx, Vec2 p0, Vec2 p1, Vec4 col, rDescHandle handle)
{ {
ctx->vertices[ctx->vertices_len].p0 = p0; ctx->vertices[ctx->vertices_len].p0 = p0;
ctx->vertices[ctx->vertices_len].p1 = p1; ctx->vertices[ctx->vertices_len].p1 = p1;
ctx->vertices[ctx->vertices_len].col = col; ctx->vertices[ctx->vertices_len].col = col;
ctx->vertices[ctx->vertices_len].tex_idx = handle.desc_index;
ctx->vertices_len += 1; ctx->vertices_len += 1;

View File

@ -57,6 +57,6 @@ static void gHandleInputs(pGameInput *inputs, u32 count);
// ::Game::GUI::Functions::Header:: // ::Game::GUI::Functions::Header::
static inline void gPrepareGUICtx(gGameCtx *ctx); static inline void gPrepareGUICtx(gGameCtx *ctx);
static void gRect(gUICtx *ctx, Vec2 p0, Vec2 p1, Vec4 col); static void gRect(gUICtx *ctx, Vec2 p0, Vec2 p1, Vec4 col, rDescHandle handle);
static b32 gWindow(gGameCtx *ctx, c8 *title, f32 x0, f32 y0, f32 x1, f32 y1); static b32 gWindow(gGameCtx *ctx, c8 *title, f32 x0, f32 y0, f32 x1, f32 y1, rDescHandle handle);
static b32 gButton(gGameCtx *ctx, c8 *label, f32 x0, f32 y0, f32 x1, f32 y1); static b32 gButton(gGameCtx *ctx, c8 *label, f32 x0, f32 y0, f32 x1, f32 y1);

View File

@ -2,14 +2,17 @@
#extension GL_EXT_buffer_reference : require #extension GL_EXT_buffer_reference : require
#extension GL_GOOGLE_include_directive : require #extension GL_GOOGLE_include_directive : require
#extension GL_EXT_nonuniform_qualifier : require
#include "structures.glsl" #include "structures.glsl"
layout (location = 0) in vec4 in_color; layout (location = 0) in vec4 in_color;
layout (location = 1) in vec2 in_uv;
layout (location = 2) flat in uint in_image;
layout (location = 0) out vec4 out_frag_col; layout (location = 0) out vec4 out_frag_col;
void main() void main()
{ {
out_frag_col = in_color; out_frag_col = texture(sampler2D(Textures[in_image], SamplerNearest), in_uv);
} }

View File

@ -2,6 +2,7 @@
#extension GL_EXT_buffer_reference : require #extension GL_EXT_buffer_reference : require
#extension GL_GOOGLE_include_directive : require #extension GL_GOOGLE_include_directive : require
#extension GL_EXT_nonuniform_qualifier : require
#include "structures.glsl" #include "structures.glsl"
@ -11,6 +12,8 @@ layout (location = 2) in vec4 in_col;
layout (location = 3) in uint in_image; layout (location = 3) in uint in_image;
layout (location = 0) out vec4 out_color; layout (location = 0) out vec4 out_color;
layout (location = 1) out vec2 out_uv;
layout (location = 2) out uint out_image;
void main() void main()
{ {
@ -20,7 +23,10 @@ void main()
gl_VertexIndex == 2 ? vec2(in_gui_pos_1.x, in_gui_pos_1.y) : gl_VertexIndex == 2 ? vec2(in_gui_pos_1.x, in_gui_pos_1.y) :
gl_VertexIndex == 3 ? vec2(in_gui_pos_1.x, in_gui_pos_0.y) : vec2(0.0, 0.0); gl_VertexIndex == 3 ? vec2(in_gui_pos_1.x, in_gui_pos_0.y) : vec2(0.0, 0.0);
out_uv = vec2(2 * dst_pos.x / PC.res.x - 1, 2 * dst_pos.y / PC.res.y - 1);
out_color = in_col; out_color = in_col;
out_image = in_image;
gl_Position = vec4(2 * dst_pos.x / PC.res.x - 1, gl_Position = vec4(2 * dst_pos.x / PC.res.x - 1,
2 * dst_pos.y / PC.res.y - 1, 2 * dst_pos.y / PC.res.y - 1,
0, 0,