summaryrefslogtreecommitdiff
path: root/src/render/gl_3d.h
diff options
context:
space:
mode:
authornavewindre <boneyaard@gmail.com>2025-09-03 20:10:09 +0200
committernavewindre <boneyaard@gmail.com>2025-09-03 20:10:09 +0200
commitf8b92ce3aa08b1445c9f956d8166830946562d12 (patch)
tree94e63a5aec9f8f52b577f56799e0c9201fd976a5 /src/render/gl_3d.h
a
Diffstat (limited to 'src/render/gl_3d.h')
-rw-r--r--src/render/gl_3d.h69
1 files changed, 69 insertions, 0 deletions
diff --git a/src/render/gl_3d.h b/src/render/gl_3d.h
new file mode 100644
index 0000000..531c3a3
--- /dev/null
+++ b/src/render/gl_3d.h
@@ -0,0 +1,69 @@
+#pragma once
+#include "gl_batch.h"
+#include "../util/matrix.h"
+
+// magic number sue me. yes this float is representable exactly.
+const F32 SCREEN_INVALID_POS = -2137000.f;
+
+struct VERTEX3D {
+ VEC3 pos;
+ VEC2 uv;
+ CLR clr;
+ U8 sampler;
+};
+
+using GL_BATCH3D = GL_BATCH<VERTEX3D>;
+struct GL_3D : GL_SHADER_PROGRAM {
+ F32 aspect;
+ MAT4 projmat;
+
+ VEC2 winsize;
+};
+
+// shader init -----------------------------------------------------------
+extern GL_3D* gl_3d_init( GL_DATA* gl, VEC2 screensize, const char* shadername );
+// sets up projection matrix and sends it to the gpu ------------------------------------------------------------
+extern void gl_3d_projection_setup( GL_SHADER_PROGRAM* gl3d, VEC3 pos, F32 fov_deg, F32 yaw, F32 pitch, F32 near, F32 far, VEC2 winsize );
+extern void gl_3d_batch_setup( GL_BATCH3D* batch );
+
+// takes a triangle fan not set of triangles
+extern void gl_3d_polygon(
+ GL_SHADER_PROGRAM* gl3d,
+ VERTEX3D* vertices,
+ U32 vertices_count,
+ GL_TEX2D* tex
+);
+
+// calculates triangle set from triangle fan before sending to batch
+extern void gl_3d_polygon_fan(
+ GL_BATCH3D* batch,
+ VERTEX3D* vertices,
+ U32 vertices_count,
+ GL_TEX2D* tex
+);
+
+// draws a set of triangles
+extern void gl_3d_polygon(
+ GL_BATCH3D* batch,
+ VERTEX3D* vertices,
+ U32 vertices_count,
+ GL_TEX2D* tex
+);
+
+extern void gl_3d_plane(
+ GL_SHADER_PROGRAM* gl3d,
+ VEC3 pos,
+ VEC2 size,
+ VEC2 rot,
+ GL_TEX2D* tex,
+ CLR col = CLR::WHITE()
+);
+
+extern void gl_3d_plane(
+ GL_BATCH3D* batch,
+ VEC3 pos,
+ VEC2 size,
+ VEC2 rot,
+ GL_TEX2D* tex,
+ CLR col = CLR::WHITE()
+);