From 7228b2e1a2d0a8399facce3493d71a3569d250d5 Mon Sep 17 00:00:00 2001 From: mattkae Date: Fri, 23 Dec 2022 12:47:10 -0500 Subject: Improved the makefile considerably --- themes/src/Renderer2d.h | 54 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 themes/src/Renderer2d.h (limited to 'themes/src/Renderer2d.h') diff --git a/themes/src/Renderer2d.h b/themes/src/Renderer2d.h new file mode 100644 index 0000000..909f088 --- /dev/null +++ b/themes/src/Renderer2d.h @@ -0,0 +1,54 @@ +#pragma once + +#include "WebglContext.h" +#include "types.h" +#include "Shader.h" +#include "mathlib.h" + +struct WebglContext; + +struct Renderer2d { + WebglContext* context = NULL; + Mat4x4 projection; + u32 shader; + Vector4 clearColor; + + struct { + i32 position; + i32 color; + i32 vMatrix; + } attributes; + + struct { + i32 projection; + i32 model; + } uniforms; + + void load(WebglContext* context); + void render(); + void unload(); +}; + +struct Vertex2D { + Vector2 position; + Vector4 color; + Mat4x4 vMatrix; +}; + +struct Mesh2D { + u32 vao; + u32 vbo; + u32 ebo = 0; + u32 numVertices = 0; + u32 numIndices = 0; + Mat4x4 model; + + void load(Vertex2D* vertices, u32 numVertices, Renderer2d* renderer); + void load(Vertex2D* vertices, + u32 numVertices, + u32* indices, + u32 numIndices, + Renderer2d* renderer); + void render(Renderer2d* renderer, GLenum drawType = GL_TRIANGLES); + void unload(); +}; -- cgit v1.2.1