2017-11-26 03:02:28 +00:00
|
|
|
#include "graphics/material.h"
|
2018-03-22 15:45:05 +00:00
|
|
|
#include "graphics/shader.h"
|
2018-02-11 01:27:29 +00:00
|
|
|
#include "data/vertexData.h"
|
2018-12-08 03:11:14 +00:00
|
|
|
#include "lib/map/map.h"
|
2018-07-04 20:51:35 +00:00
|
|
|
#include <stdbool.h>
|
2017-03-11 22:13:49 +00:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2018-12-08 03:11:14 +00:00
|
|
|
#define MAX_ATTRIBUTES 16
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
Buffer* buffer;
|
|
|
|
AttributeType type;
|
|
|
|
int components;
|
|
|
|
size_t offset;
|
|
|
|
int stride;
|
|
|
|
int divisor;
|
|
|
|
bool enabled;
|
|
|
|
} MeshAttribute;
|
|
|
|
|
|
|
|
typedef map_t(MeshAttribute) map_attribute_t;
|
2018-03-13 23:12:12 +00:00
|
|
|
|
2017-03-11 22:13:49 +00:00
|
|
|
typedef enum {
|
2018-07-05 03:11:52 +00:00
|
|
|
MESH_POINTS,
|
|
|
|
MESH_LINES,
|
|
|
|
MESH_LINE_STRIP,
|
|
|
|
MESH_LINE_LOOP,
|
|
|
|
MESH_TRIANGLE_STRIP,
|
|
|
|
MESH_TRIANGLES,
|
|
|
|
MESH_TRIANGLE_FAN
|
2017-03-11 22:13:49 +00:00
|
|
|
} MeshDrawMode;
|
|
|
|
|
2018-03-04 22:07:54 +00:00
|
|
|
typedef struct Mesh Mesh;
|
|
|
|
|
2018-12-07 23:57:45 +00:00
|
|
|
Mesh* lovrMeshCreate(uint32_t count, VertexFormat format, MeshDrawMode drawMode, BufferUsage usage, bool readable);
|
2018-02-26 08:59:03 +00:00
|
|
|
void lovrMeshDestroy(void* ref);
|
2018-12-08 03:11:14 +00:00
|
|
|
void lovrMeshAttachAttribute(Mesh* mesh, const char* name, MeshAttribute* attribute);
|
2018-03-13 23:12:12 +00:00
|
|
|
void lovrMeshDetachAttribute(Mesh* mesh, const char* name);
|
2018-12-08 03:11:14 +00:00
|
|
|
MeshAttribute* lovrMeshGetAttribute(Mesh* mesh, const char* name);
|
2018-08-31 23:37:30 +00:00
|
|
|
void lovrMeshBind(Mesh* mesh, Shader* shader, int divisorMultiplier);
|
2018-08-31 13:03:35 +00:00
|
|
|
void lovrMeshDraw(Mesh* mesh, int instances);
|
2018-01-27 02:58:36 +00:00
|
|
|
VertexFormat* lovrMeshGetVertexFormat(Mesh* mesh);
|
2018-12-07 23:57:45 +00:00
|
|
|
bool lovrMeshIsReadable(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);
|
2017-10-31 08:14:09 +00:00
|
|
|
bool lovrMeshIsAttributeEnabled(Mesh* mesh, const char* name);
|
|
|
|
void lovrMeshSetAttributeEnabled(Mesh* mesh, const char* name, bool enabled);
|
2018-06-04 02:00:31 +00:00
|
|
|
void lovrMeshGetDrawRange(Mesh* mesh, uint32_t* start, uint32_t* count);
|
|
|
|
void lovrMeshSetDrawRange(Mesh* mesh, uint32_t start, uint32_t count);
|
2017-11-26 03:02:28 +00:00
|
|
|
Material* lovrMeshGetMaterial(Mesh* mesh);
|
|
|
|
void lovrMeshSetMaterial(Mesh* mesh, Material* material);
|
2018-12-07 23:57:45 +00:00
|
|
|
void* lovrMeshMapVertices(Mesh* mesh, size_t offset);
|
|
|
|
void lovrMeshFlushVertices(Mesh* mesh, size_t offset, size_t size);
|
|
|
|
void* lovrMeshMapIndices(Mesh* mesh, uint32_t count, size_t indexSize);
|
|
|
|
void lovrMeshFlushIndices(Mesh* mesh);
|
|
|
|
void* lovrMeshReadIndices(Mesh* mesh, uint32_t* count, size_t* indexSize);
|