lovr/src/graphics/mesh.h

80 lines
2.3 KiB
C
Raw Normal View History

#include "graphics/shader.h"
#include "graphics/material.h"
2018-02-11 01:27:29 +00:00
#include "data/vertexData.h"
2017-03-11 22:13:49 +00:00
#include "math/math.h"
#include "lib/glfw.h"
2018-02-11 01:27:29 +00:00
#include "util.h"
2017-03-11 22:13:49 +00:00
#pragma once
typedef enum {
MESH_POINTS = GL_POINTS,
2017-11-26 03:49:22 +00:00
MESH_LINES = GL_LINES,
MESH_LINE_STRIP = GL_LINE_STRIP,
2017-03-11 22:13:49 +00:00
MESH_TRIANGLE_STRIP = GL_TRIANGLE_STRIP,
MESH_TRIANGLES = GL_TRIANGLES,
MESH_TRIANGLE_FAN = GL_TRIANGLE_FAN
} MeshDrawMode;
typedef enum {
MESH_STATIC = GL_STATIC_DRAW,
MESH_DYNAMIC = GL_DYNAMIC_DRAW,
MESH_STREAM = GL_STREAM_DRAW
} MeshUsage;
typedef struct Mesh Mesh;
2017-03-11 22:13:49 +00:00
typedef struct {
Mesh *mesh;
int attribute;
int instanceDivisor;
} MeshAttachment;
typedef vec_t(MeshAttachment) vec_meshattachment_t;
struct Mesh {
2017-03-11 22:13:49 +00:00
Ref ref;
2018-02-11 01:27:29 +00:00
VertexData* vertexData;
IndexPointer indices;
2018-01-27 20:51:41 +00:00
size_t indexCount;
size_t indexSize;
int enabledAttributes;
2017-10-31 08:14:09 +00:00
bool attributesDirty;
bool isMapped;
2017-03-12 01:27:18 +00:00
int mapStart;
size_t mapCount;
2018-01-27 20:51:41 +00:00
bool isRangeEnabled;
int rangeStart;
int rangeCount;
2017-03-11 22:13:49 +00:00
MeshDrawMode drawMode;
MeshUsage usage;
GLuint vao;
GLuint vbo;
GLuint ibo;
Material* material;
Shader* lastShader;
vec_meshattachment_t attachments;
bool isAnAttachment;
};
2017-03-11 22:13:49 +00:00
Mesh* lovrMeshCreate(VertexData* vertexData, MeshDrawMode drawMode, MeshUsage usage);
2018-02-26 08:59:03 +00:00
void lovrMeshDestroy(void* ref);
void lovrMeshDraw(Mesh* mesh, mat4 transform, float* pose, int instances);
2018-01-27 02:58:36 +00:00
VertexFormat* lovrMeshGetVertexFormat(Mesh* mesh);
2017-03-11 22:28:44 +00:00
MeshDrawMode lovrMeshGetDrawMode(Mesh* mesh);
2017-10-22 14:20:40 +00:00
void lovrMeshSetDrawMode(Mesh* mesh, MeshDrawMode drawMode);
2017-03-11 22:28:44 +00:00
int lovrMeshGetVertexCount(Mesh* mesh);
2018-02-11 01:27:29 +00:00
IndexPointer lovrMeshGetVertexMap(Mesh* mesh, size_t* count);
void lovrMeshSetVertexMap(Mesh* mesh, void* data, size_t count);
2017-10-31 08:14:09 +00:00
bool lovrMeshIsAttributeEnabled(Mesh* mesh, const char* name);
void lovrMeshSetAttributeEnabled(Mesh* mesh, const char* name, bool enabled);
bool lovrMeshIsRangeEnabled(Mesh* mesh);
2017-03-11 22:28:44 +00:00
void lovrMeshSetRangeEnabled(Mesh* mesh, char isEnabled);
void lovrMeshGetDrawRange(Mesh* mesh, int* start, int* count);
2017-10-22 14:20:40 +00:00
void lovrMeshSetDrawRange(Mesh* mesh, int start, int count);
Material* lovrMeshGetMaterial(Mesh* mesh);
void lovrMeshSetMaterial(Mesh* mesh, Material* material);
2018-02-11 01:27:29 +00:00
VertexPointer lovrMeshMap(Mesh* mesh, int start, size_t count, bool read, bool write);
2017-03-12 01:27:18 +00:00
void lovrMeshUnmap(Mesh* mesh);
void lovrMeshAttach(Mesh *attachTo, Mesh* attachThis, int attribute, int instanceDivisor);