MTek-GDL 0.100.4-muffintrap
Loading...
Searching...
No Matches
mgdl-mesh.h
1#pragma once
2
3#include <mgdl/mgdl-opengl.h>
4#include <mgdl/mgdl-types.h>
5
6/* Contains vertex data that is needed for
7 * rendering the mesh
8 * positions, normals, uvs, indices
9 */
10struct Mesh
11{
12 GLushort* indices;
13 GLsizei indexCount;
14 u32 vertexCount;
15 GLushort indexCounter;
16 GLfloat* positions;
17 GLfloat* normals;
18 GLfloat* uvs;
19 GLfloat* colors;
20 const char* name;
21};
22typedef struct Mesh Mesh;
23
24
25#ifdef __cplusplus
26extern "C"
27{
28#endif
38 sizetype Mesh_Init(Mesh* mesh, sizetype vertexCount, sizetype indexCount, u32 creationFlags);
39
40 V3f Mesh_GetPosition(Mesh* mesh, GLushort index);
41 V3f Mesh_GetNormal(Mesh* mesh, GLushort index);
42 V3f Mesh_GetPositionFromArray(Mesh* mesh, sizetype index);
43 V3f Mesh_GetNormalFromArray(Mesh* mesh, sizetype index);
44
45 void Mesh_SetDrawingIndex(Mesh* mesh,sizetype index, GLushort drawIndex);
46 void Mesh_SetPositionToArray(Mesh* mesh,sizetype index, V3f position);
47 void Mesh_SetNormalToArray(Mesh* mesh,sizetype index, V3f normal);
48 void Mesh_SetUVToArray(Mesh* mesh,sizetype index, vec2 uv);
49 bool Mesh_GetTriangleIndices(Mesh* mesh,GLsizei triangleIndex, GLushort* outA, GLushort* outB, GLushort* outC);
50
51 void Mesh_DebugPrint(Mesh* mesh);
52
53
54 void Mesh_SetupVertexArrays(Mesh* mesh);
55 void Mesh_DrawElements(Mesh* mesh);
56 // TODO void Mesh_DrawElementsPartially(Mesh* mesh, float start, float amount);
57 void Mesh_DrawPoints(Mesh* mesh);
58 void Mesh_DrawLines(Mesh* mesh);
59 void Mesh_DrawNormals(Mesh* mesh);
60 void Mesh_CalculateMatcapUVs(Mesh* mesh, MTX4x4 modelViewMatrix, MTX4x4 normalMatrix);
61
62 // Setting vertices into arrays : returns the index of vertex in GLushort
63
64 // SetPosition must be called first, just like in drawing
65 GLushort Mesh_AddPosition(Mesh* mesh, V3f vertex);
66 void Mesh_AddNormal(Mesh* mesh, V3f normal);
67 void Mesh_AddUV(Mesh* mesh, vec2 normal);
68 void Mesh_AddColor(Mesh* mesh, V3f color);
69 u32 Mesh_AddTriangle(Mesh* mesh, GLushort indexA, GLushort indexB, GLushort indexC, u32 index);
70
71
72 Mesh* Mesh_CreateIcosahedron(u32 creationFlags);
73 Mesh* Mesh_CreateQuad(u32 creationFlags);
74 Mesh* Mesh_CreateStar(float centerThickness, float pointRadius, float sharpness, int pointAmount, bool bothSides, u32 creationFlags);
75
76 // Instant drawing
77 void Mesh_DrawStarBorder(float thickness, float pointRadius, float sharpness, int pointAmount);
78 Mesh* Mesh_CreateStarBorder(float borderThickness, float pointRadius, float sharpness, int pointAmount, u32 creationFlags);
79
80 // TODO Mesh* Mesh_CreateRibbonPolygonCross(Mesh* bezierCurvePoints, int crossSectionPoints, float crossSectionRadius, int segmentsPerBezier);
81
82 // TODO Mesh* Mesh_CreateRibbonMeshCross(Mesh* bezierCurvePoints, Mesh* crossSectionPoints, float crossSectionScale, int segmentsPerBezier);
83
84 // TODO Mesh* Mesh_CreateCloud(float radius, int segments, float randomness);
85
86
87#ifdef __cplusplus
88}
89#endif
Library types, macros, defines and enums header.
Definition mgdl-mesh.h:11
GLushort indexCounter
Definition mgdl-mesh.h:15