summaryrefslogtreecommitdiff
path: root/shared_cpp/Renderer3d.h
diff options
context:
space:
mode:
authorMatthew Kosarek <mattkae@protonmail.com>2021-06-17 20:02:20 -0400
committerMatthew Kosarek <mattkae@protonmail.com>2021-06-17 20:02:20 -0400
commit4079e69fe4107d2a50b122dbd58710bbeb10ace2 (patch)
tree2ea0bb6857ad913e54974eb380b3612709559615 /shared_cpp/Renderer3d.h
parent19b0a3cafe144e8e77974bb0c9c63141a812e30d (diff)
(WIP) Getting started in 3d land
Diffstat (limited to 'shared_cpp/Renderer3d.h')
-rw-r--r--shared_cpp/Renderer3d.h47
1 files changed, 47 insertions, 0 deletions
diff --git a/shared_cpp/Renderer3d.h b/shared_cpp/Renderer3d.h
new file mode 100644
index 0000000..64288ad
--- /dev/null
+++ b/shared_cpp/Renderer3d.h
@@ -0,0 +1,47 @@
+#pragma once
+
+#include "types.h"
+#include "Shader.h"
+#include "mathlib.h"
+
+struct Camera3d;
+struct WebglContext;
+
+struct Renderer3d {
+ uint32 shader;
+
+ struct {
+ int32 position;
+ int32 color;
+ int32 normal;
+ } attributes;
+
+ struct {
+ int32 projection;
+ int32 view;
+ int32 model;
+ } uniforms;
+
+ void load(WebglContext* context);
+ void render(Camera3d* camera);
+ void unload();
+};
+
+struct Vertex3d {
+ Vector3 position;
+ Vector3 normal;
+ Vector4 color;
+};
+
+struct Mesh3d {
+ uint32 vao;
+ uint32 vbo;
+ uint32 ebo;
+ uint32 numIndices = 0;
+
+ Mat4x4 model;
+
+ void load(Vertex3d* vertices, uint32 numVertices, uint32* indices, uint32 numIndices, Renderer3d* renderer);
+ void render(Renderer3d* renderer, GLenum drawType = GL_TRIANGLES);
+ void unload();
+};