lovr/src/graphics/mesh.h

68 lines
2.2 KiB
C
Raw Normal View History

2018-09-26 00:10:09 +00:00
#include "data/modelData.h"
#include "graphics/material.h"
2018-03-22 15:45:05 +00:00
#include "graphics/shader.h"
#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;
bool integer;
2018-12-08 03:11:14 +00:00
bool enabled;
} MeshAttribute;
typedef map_t(MeshAttribute) map_attribute_t;
typedef struct {
Ref ref;
DrawMode mode;
VertexFormat format;
Buffer* vertexBuffer;
Buffer* indexBuffer;
uint32_t vertexCount;
uint32_t indexCount;
size_t indexSize;
2019-01-17 22:14:13 +00:00
size_t indexOffset;
uint32_t drawStart;
uint32_t drawCount;
Material* material;
map_attribute_t attributes;
MeshAttribute layout[MAX_ATTRIBUTES];
2019-02-05 23:57:22 +00:00
uint16_t divisors[MAX_ATTRIBUTES];
GPU_MESH_FIELDS
} Mesh;
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);
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);
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);
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);
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);
Material* lovrMeshGetMaterial(Mesh* mesh);
void lovrMeshSetMaterial(Mesh* mesh, Material* material);