summaryrefslogtreecommitdiff
path: root/libs/pwyazh
diff options
context:
space:
mode:
authorpryazha <pryadeiniv@mail.ru>2025-01-23 19:39:54 +0500
committerpryazha <pryadeiniv@mail.ru>2025-01-23 19:39:54 +0500
commitbf1c59565096ac9774493846cfb15e259d3b0e66 (patch)
tree82e8182af128580b6f38437feccba8c0f48abdc1 /libs/pwyazh
parent1ee094199af9c169e1ccaa53c7b0c186c4a3639e (diff)
restructure
Diffstat (limited to 'libs/pwyazh')
-rw-r--r--libs/pwyazh/mesh.h19
-rw-r--r--libs/pwyazh/pwyazh.h2
-rw-r--r--libs/pwyazh/pwyazh_GL.h8
-rw-r--r--libs/pwyazh/types.h14
4 files changed, 26 insertions, 17 deletions
diff --git a/libs/pwyazh/mesh.h b/libs/pwyazh/mesh.h
index 9443a13..c703beb 100644
--- a/libs/pwyazh/mesh.h
+++ b/libs/pwyazh/mesh.h
@@ -1,6 +1,20 @@
#ifndef MESH_H
#define MESH_H
+typedef struct {
+ V3F pos;
+ V3F normal;
+ V2F tex_coords;
+} Vertex;
+
+typedef struct {
+ U32 vao;
+ Vertex *vertices;
+ U32 vertex_count;
+ U32 *indices;
+ U32 index_count;
+} Mesh;
+
Vertex
vertex(V3F pos, V3F normal, V2F tex_coords)
{
@@ -68,9 +82,12 @@ mesh_init(Arena *arena,
void
mesh_draw(Mesh *mesh)
{
+ if (!mesh)
+ return;
+
glBindVertexArray(mesh->vao);
glDrawElements(GL_TRIANGLES, mesh->index_count, GL_UNSIGNED_INT, 0);
glBindVertexArray(0);
}
-#endif /* MESH_H */ \ No newline at end of file
+#endif /* MESH_H */
diff --git a/libs/pwyazh/pwyazh.h b/libs/pwyazh/pwyazh.h
index 0eede02..7231d68 100644
--- a/libs/pwyazh/pwyazh.h
+++ b/libs/pwyazh/pwyazh.h
@@ -18,6 +18,4 @@
#include "strings.h"
-#include "mesh.h"
-
#endif /* PWYAZH_H */
diff --git a/libs/pwyazh/pwyazh_GL.h b/libs/pwyazh/pwyazh_GL.h
new file mode 100644
index 0000000..6611ce5
--- /dev/null
+++ b/libs/pwyazh/pwyazh_GL.h
@@ -0,0 +1,8 @@
+#ifndef PWYAZH_GL_H
+#define PWYAZH_GL_H
+
+/* OpenGL related stuff. Some types and helpers */
+
+#include "mesh.h"
+
+#endif /* PWYAZH_GL_H */
diff --git a/libs/pwyazh/types.h b/libs/pwyazh/types.h
index 1e16449..0704299 100644
--- a/libs/pwyazh/types.h
+++ b/libs/pwyazh/types.h
@@ -55,20 +55,6 @@ typedef struct {
String8Node *last;
} String8List;
-typedef struct {
- V3F pos;
- V3F normal;
- V2F tex_coords;
-} Vertex;
-
-typedef struct {
- U32 vao;
- Vertex *vertices;
- U32 vertex_count;
- U32 *indices;
- U32 index_count;
-} Mesh;
-
static F32 pi_F32 = 3.14159265359f;
#endif /* TYPES_H */