2018-09-26 00:10:09 +00:00
|
|
|
#include "data/modelData.h"
|
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-12-19 07:53:51 +00:00
|
|
|
#include "graphics/opengl.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;
|
|
|
|
size_t offset;
|
2018-12-10 23:18:42 +00:00
|
|
|
size_t stride;
|
|
|
|
AttributeType type;
|
|
|
|
uint8_t components;
|
|
|
|
uint8_t divisor;
|
2018-12-10 23:58:50 +00:00
|
|
|
bool integer;
|
2018-12-08 03:11:14 +00:00
|
|
|
bool enabled;
|
|
|
|
} MeshAttribute;
|
|
|
|
|
|
|
|
typedef map_t(MeshAttribute) map_attribute_t;
|
2018-03-13 23:12:12 +00:00
|
|
|
|
2018-12-19 07:53:51 +00:00
|
|
|
typedef struct {
|
|
|
|
Ref ref;
|
|
|
|
DrawMode mode;
|
|
|
|
VertexFormat format;
|
2018-12-27 21:50:42 +00:00
|
|
|
Buffer* vertexBuffer;
|
|
|
|
Buffer* indexBuffer;
|
|
|
|
uint32_t vertexCount;
|
2018-12-19 07:53:51 +00:00
|
|
|
uint32_t indexCount;
|
|
|
|
size_t indexSize;
|
2019-01-17 22:14:13 +00:00
|
|
|
size_t indexOffset;
|
2018-12-27 21:50:42 +00:00
|
|
|
uint32_t drawStart;
|
|
|
|
uint32_t drawCount;
|
2018-12-19 07:53:51 +00:00
|
|
|
Material* material;
|
|
|
|
map_attribute_t attributes;
|
|
|
|
MeshAttribute layout[MAX_ATTRIBUTES];
|
2019-02-05 23:57:22 +00:00
|
|
|
uint16_t divisors[MAX_ATTRIBUTES];
|
2018-12-19 07:53:51 +00:00
|
|
|
GPU_MESH_FIELDS
|
|
|
|
} Mesh;
|
2018-03-04 22:07:54 +00:00
|
|
|
|
2019-01-04 03:43:35 +00:00
|
|
|
Mesh* lovrMeshInit(Mesh* mesh, DrawMode mode, VertexFormat format, Buffer* vertexBuffer, uint32_t vertexCount);
|
2018-09-26 00:10:09 +00:00
|
|
|
Mesh* lovrMeshInitEmpty(Mesh* mesh, DrawMode drawMode);
|
2018-12-19 08:25:20 +00:00
|
|
|
#define lovrMeshCreate(...) lovrMeshInit(lovrAlloc(Mesh), __VA_ARGS__)
|
2018-09-26 00:10:09 +00:00
|
|
|
#define lovrMeshCreateEmpty(...) lovrMeshInitEmpty(lovrAlloc(Mesh), __VA_ARGS__)
|
2018-02-26 08:59:03 +00:00
|
|
|
void lovrMeshDestroy(void* ref);
|
2018-12-27 21:50:42 +00:00
|
|
|
VertexFormat* lovrMeshGetVertexFormat(Mesh* mesh);
|
|
|
|
Buffer* lovrMeshGetVertexBuffer(Mesh* mesh);
|
|
|
|
Buffer* lovrMeshGetIndexBuffer(Mesh* mesh);
|
2019-01-17 22:14:13 +00:00
|
|
|
void lovrMeshSetIndexBuffer(Mesh* mesh, Buffer* buffer, uint32_t indexCount, size_t indexSize, size_t offset);
|
2018-12-27 21:50:42 +00:00
|
|
|
uint32_t lovrMeshGetVertexCount(Mesh* mesh);
|
|
|
|
uint32_t lovrMeshGetIndexCount(Mesh* mesh);
|
|
|
|
size_t lovrMeshGetIndexSize(Mesh* mesh);
|
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);
|
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-12-27 21:50:42 +00:00
|
|
|
DrawMode lovrMeshGetDrawMode(Mesh* mesh);
|
|
|
|
void lovrMeshSetDrawMode(Mesh* mesh, DrawMode mode);
|
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);
|