mirror of https://github.com/bjornbytes/lovr.git
DrawMode -> DrawStyle; MeshDrawMode -> DrawMode;
Renaming enums doesn't really have an impact on the API usage, just the docs and internal naming of things.
This commit is contained in:
parent
c3dcf03194
commit
a67f59000f
|
@ -74,6 +74,7 @@ extern const char* ControllerAxes[];
|
|||
extern const char* ControllerButtons[];
|
||||
extern const char* ControllerHands[];
|
||||
extern const char* DrawModes[];
|
||||
extern const char* DrawStyles[];
|
||||
extern const char* EventTypes[];
|
||||
extern const char* FilterModes[];
|
||||
extern const char* HeadsetDrivers[];
|
||||
|
@ -85,7 +86,6 @@ extern const char* JointTypes[];
|
|||
extern const char* MaterialColors[];
|
||||
extern const char* MaterialScalars[];
|
||||
extern const char* MaterialTextures[];
|
||||
extern const char* MeshDrawModes[];
|
||||
extern const char* ShaderTypes[];
|
||||
extern const char* ShapeTypes[];
|
||||
extern const char* SourceTypes[];
|
||||
|
|
|
@ -69,8 +69,19 @@ const char* CompareModes[] = {
|
|||
};
|
||||
|
||||
const char* DrawModes[] = {
|
||||
[DRAW_MODE_FILL] = "fill",
|
||||
[DRAW_MODE_LINE] = "line",
|
||||
[DRAW_POINTS] = "points",
|
||||
[DRAW_LINES] = "lines",
|
||||
[DRAW_LINE_STRIP] = "linestrip",
|
||||
[DRAW_LINE_LOOP] = "lineloop",
|
||||
[DRAW_TRIANGLE_STRIP] = "strip",
|
||||
[DRAW_TRIANGLES] = "triangles",
|
||||
[DRAW_TRIANGLE_FAN] = "fan",
|
||||
NULL
|
||||
};
|
||||
|
||||
const char* DrawStyles[] = {
|
||||
[STYLE_FILL] = "fill",
|
||||
[STYLE_LINE] = "line",
|
||||
NULL
|
||||
};
|
||||
|
||||
|
@ -112,17 +123,6 @@ const char* MaterialTextures[] = {
|
|||
NULL
|
||||
};
|
||||
|
||||
const char* MeshDrawModes[] = {
|
||||
[MESH_POINTS] = "points",
|
||||
[MESH_LINES] = "lines",
|
||||
[MESH_LINE_STRIP] = "linestrip",
|
||||
[MESH_LINE_LOOP] = "lineloop",
|
||||
[MESH_TRIANGLE_STRIP] = "strip",
|
||||
[MESH_TRIANGLES] = "triangles",
|
||||
[MESH_TRIANGLE_FAN] = "fan",
|
||||
NULL
|
||||
};
|
||||
|
||||
const char* ShaderTypes[] = {
|
||||
[SHADER_GRAPHICS] = "graphics",
|
||||
[SHADER_COMPUTE] = "compute",
|
||||
|
@ -723,12 +723,12 @@ static int l_lovrGraphicsLine(lua_State* L) {
|
|||
}
|
||||
|
||||
static int l_lovrGraphicsTriangle(lua_State* L) {
|
||||
DrawMode drawMode = DRAW_MODE_FILL;
|
||||
DrawStyle style = STYLE_FILL;
|
||||
Material* material = NULL;
|
||||
if (lua_isuserdata(L, 1)) {
|
||||
material = luax_checktype(L, 1, Material);
|
||||
} else {
|
||||
drawMode = luaL_checkoption(L, 1, NULL, DrawModes);
|
||||
style = luaL_checkoption(L, 1, NULL, DrawStyles);
|
||||
}
|
||||
|
||||
float points[9];
|
||||
|
@ -737,35 +737,35 @@ static int l_lovrGraphicsTriangle(lua_State* L) {
|
|||
for (int i = 0; i < 9; i++) {
|
||||
points[i] = luaL_checknumber(L, i + 2);
|
||||
}
|
||||
lovrGraphicsTriangle(drawMode, material, points);
|
||||
lovrGraphicsTriangle(style, material, points);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int l_lovrGraphicsPlane(lua_State* L) {
|
||||
DrawMode drawMode = DRAW_MODE_FILL;
|
||||
DrawStyle style = STYLE_FILL;
|
||||
Material* material = NULL;
|
||||
if (lua_isuserdata(L, 1)) {
|
||||
material = luax_checktype(L, 1, Material);
|
||||
} else {
|
||||
drawMode = luaL_checkoption(L, 1, NULL, DrawModes);
|
||||
style = luaL_checkoption(L, 1, NULL, DrawStyles);
|
||||
}
|
||||
float transform[16];
|
||||
luax_readmat4(L, 2, transform, 2, NULL);
|
||||
lovrGraphicsPlane(drawMode, material, transform);
|
||||
lovrGraphicsPlane(style, material, transform);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int luax_rectangularprism(lua_State* L, int scaleComponents) {
|
||||
DrawMode drawMode = DRAW_MODE_FILL;
|
||||
DrawStyle style = STYLE_FILL;
|
||||
Material* material = NULL;
|
||||
if (lua_isuserdata(L, 1)) {
|
||||
material = luax_checktype(L, 1, Material);
|
||||
} else {
|
||||
drawMode = luaL_checkoption(L, 1, NULL, DrawModes);
|
||||
style = luaL_checkoption(L, 1, NULL, DrawStyles);
|
||||
}
|
||||
float transform[16];
|
||||
luax_readmat4(L, 2, transform, scaleComponents, NULL);
|
||||
lovrGraphicsBox(drawMode, material, transform);
|
||||
lovrGraphicsBox(style, material, transform);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -778,12 +778,12 @@ static int l_lovrGraphicsBox(lua_State* L) {
|
|||
}
|
||||
|
||||
static int l_lovrGraphicsArc(lua_State* L) {
|
||||
DrawMode drawMode = DRAW_MODE_FILL;
|
||||
DrawStyle style = STYLE_FILL;
|
||||
Material* material = NULL;
|
||||
if (lua_isuserdata(L, 1)) {
|
||||
material = luax_checktype(L, 1, Material);
|
||||
} else {
|
||||
drawMode = luaL_checkoption(L, 1, NULL, DrawModes);
|
||||
style = luaL_checkoption(L, 1, NULL, DrawStyles);
|
||||
}
|
||||
ArcMode arcMode = ARC_MODE_PIE;
|
||||
int index = 2;
|
||||
|
@ -795,22 +795,22 @@ static int l_lovrGraphicsArc(lua_State* L) {
|
|||
float theta1 = luaL_optnumber(L, index++, 0);
|
||||
float theta2 = luaL_optnumber(L, index++, 2 * M_PI);
|
||||
int segments = luaL_optinteger(L, index, 64) * (MIN(fabsf(theta2 - theta1), 2 * M_PI) / (2 * M_PI));
|
||||
lovrGraphicsArc(drawMode, arcMode, material, transform, theta1, theta2, segments);
|
||||
lovrGraphicsArc(style, arcMode, material, transform, theta1, theta2, segments);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int l_lovrGraphicsCircle(lua_State* L) {
|
||||
DrawMode drawMode = DRAW_MODE_FILL;
|
||||
DrawStyle style = STYLE_FILL;
|
||||
Material* material = NULL;
|
||||
if (lua_isuserdata(L, 1)) {
|
||||
material = luax_checktype(L, 1, Material);
|
||||
} else {
|
||||
drawMode = luaL_checkoption(L, 1, NULL, DrawModes);
|
||||
style = luaL_checkoption(L, 1, NULL, DrawStyles);
|
||||
}
|
||||
float transform[16];
|
||||
int index = luax_readmat4(L, 2, transform, 1, NULL);
|
||||
int segments = luaL_optnumber(L, index, 32);
|
||||
lovrGraphicsCircle(drawMode, material, transform, segments);
|
||||
lovrGraphicsCircle(style, material, transform, segments);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1152,10 +1152,10 @@ static int l_lovrGraphicsNewMesh(lua_State* L) {
|
|||
vertexFormatAppend(&format, "lovrTexCoord", ATTR_FLOAT, 2);
|
||||
}
|
||||
|
||||
MeshDrawMode drawMode = luaL_checkoption(L, drawModeIndex, "fan", MeshDrawModes);
|
||||
DrawMode mode = luaL_checkoption(L, drawModeIndex, "fan", DrawModes);
|
||||
BufferUsage usage = luaL_checkoption(L, drawModeIndex + 1, "dynamic", BufferUsages);
|
||||
bool readable = lua_toboolean(L, drawModeIndex + 2);
|
||||
Mesh* mesh = lovrMeshCreate(count, format, drawMode, usage, readable);
|
||||
Mesh* mesh = lovrMeshCreate(count, format, mode, usage, readable);
|
||||
|
||||
if (dataIndex) {
|
||||
VertexPointer vertices = { .raw = lovrMeshMapVertices(mesh, 0) };
|
||||
|
|
|
@ -87,14 +87,14 @@ int l_lovrMeshDraw(lua_State* L) {
|
|||
|
||||
int l_lovrMeshGetDrawMode(lua_State* L) {
|
||||
Mesh* mesh = luax_checktype(L, 1, Mesh);
|
||||
lua_pushstring(L, MeshDrawModes[lovrMeshGetDrawMode(mesh)]);
|
||||
lua_pushstring(L, DrawModes[lovrMeshGetDrawMode(mesh)]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int l_lovrMeshSetDrawMode(lua_State* L) {
|
||||
Mesh* mesh = luax_checktype(L, 1, Mesh);
|
||||
MeshDrawMode drawMode = luaL_checkoption(L, 2, NULL, MeshDrawModes);
|
||||
lovrMeshSetDrawMode(mesh, drawMode);
|
||||
DrawMode mode = luaL_checkoption(L, 2, NULL, DrawModes);
|
||||
lovrMeshSetDrawMode(mesh, mode);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -97,7 +97,7 @@ void lovrGraphicsSetWindow(WindowFlags* flags) {
|
|||
vertexFormatAppend(&format, "lovrPosition", ATTR_FLOAT, 3);
|
||||
vertexFormatAppend(&format, "lovrNormal", ATTR_FLOAT, 3);
|
||||
vertexFormatAppend(&format, "lovrTexCoord", ATTR_FLOAT, 2);
|
||||
state.defaultMesh = lovrMeshCreate(MAX_VERTICES, format, MESH_TRIANGLES, USAGE_STREAM, false);
|
||||
state.defaultMesh = lovrMeshCreate(MAX_VERTICES, format, DRAW_TRIANGLES, USAGE_STREAM, false);
|
||||
|
||||
state.vertexMap = lovrBufferCreate(MAX_VERTICES * sizeof(uint8_t), NULL, USAGE_STREAM, false);
|
||||
lovrMeshAttachAttribute(state.defaultMesh, "lovrDrawID", &(MeshAttribute) {
|
||||
|
@ -591,23 +591,23 @@ void lovrGraphicsDraw(DrawCommand* draw) {
|
|||
|
||||
void lovrGraphicsPoints(uint32_t count) {
|
||||
lovrGraphicsDraw(&(DrawCommand) {
|
||||
.mode = MESH_POINTS,
|
||||
.mode = DRAW_POINTS,
|
||||
.vertex.count = count
|
||||
});
|
||||
}
|
||||
|
||||
void lovrGraphicsLine(uint32_t count) {
|
||||
lovrGraphicsDraw(&(DrawCommand) {
|
||||
.mode = MESH_LINE_STRIP,
|
||||
.mode = DRAW_LINE_STRIP,
|
||||
.vertex.count = count
|
||||
});
|
||||
}
|
||||
|
||||
void lovrGraphicsTriangle(DrawMode mode, Material* material, float points[9]) {
|
||||
if (mode == DRAW_MODE_LINE) {
|
||||
void lovrGraphicsTriangle(DrawStyle style, Material* material, float points[9]) {
|
||||
if (style == STYLE_LINE) {
|
||||
lovrGraphicsDraw(&(DrawCommand) {
|
||||
.material = material,
|
||||
.mode = MESH_LINE_LOOP,
|
||||
.mode = DRAW_LINE_LOOP,
|
||||
.vertex.count = 3,
|
||||
.vertex.data = (float[]) {
|
||||
points[0], points[1], points[2], 0, 0, 0, 0, 0,
|
||||
|
@ -620,7 +620,7 @@ void lovrGraphicsTriangle(DrawMode mode, Material* material, float points[9]) {
|
|||
vec3_cross(vec3_init(normal, &points[0]), &points[3]);
|
||||
lovrGraphicsDraw(&(DrawCommand) {
|
||||
.material = material,
|
||||
.mode = MESH_TRIANGLES,
|
||||
.mode = DRAW_TRIANGLES,
|
||||
.vertex.count = 3,
|
||||
.vertex.data = (float[]) {
|
||||
points[0], points[1], points[2], normal[0], normal[1], normal[2], 0, 0,
|
||||
|
@ -631,12 +631,12 @@ void lovrGraphicsTriangle(DrawMode mode, Material* material, float points[9]) {
|
|||
}
|
||||
}
|
||||
|
||||
void lovrGraphicsPlane(DrawMode mode, Material* material, mat4 transform) {
|
||||
if (mode == DRAW_MODE_LINE) {
|
||||
void lovrGraphicsPlane(DrawStyle style, Material* material, mat4 transform) {
|
||||
if (style == STYLE_LINE) {
|
||||
lovrGraphicsDraw(&(DrawCommand) {
|
||||
.transform = transform,
|
||||
.material = material,
|
||||
.mode = MESH_LINE_LOOP,
|
||||
.mode = DRAW_LINE_LOOP,
|
||||
.vertex.count = 4,
|
||||
.vertex.data = (float[]) {
|
||||
-.5, .5, 0, 0, 0, 0, 0, 0,
|
||||
|
@ -645,11 +645,11 @@ void lovrGraphicsPlane(DrawMode mode, Material* material, mat4 transform) {
|
|||
-.5, -.5, 0, 0, 0, 0, 0, 0
|
||||
}
|
||||
});
|
||||
} else if (mode == DRAW_MODE_FILL) {
|
||||
} else {
|
||||
lovrGraphicsDraw(&(DrawCommand) {
|
||||
.transform = transform,
|
||||
.material = material,
|
||||
.mode = MESH_TRIANGLES,
|
||||
.mode = DRAW_TRIANGLES,
|
||||
.vertex.count = 4,
|
||||
.vertex.data = (float[]) {
|
||||
-.5, .5, 0, 0, 0, -1, 0, 1,
|
||||
|
@ -663,12 +663,12 @@ void lovrGraphicsPlane(DrawMode mode, Material* material, mat4 transform) {
|
|||
}
|
||||
}
|
||||
|
||||
void lovrGraphicsBox(DrawMode mode, Material* material, mat4 transform) {
|
||||
if (mode == DRAW_MODE_LINE) {
|
||||
void lovrGraphicsBox(DrawStyle style, Material* material, mat4 transform) {
|
||||
if (style == STYLE_LINE) {
|
||||
lovrGraphicsDraw(&(DrawCommand) {
|
||||
.transform = transform,
|
||||
.material = material,
|
||||
.mode = MESH_LINES,
|
||||
.mode = DRAW_LINES,
|
||||
.vertex.count = 8,
|
||||
.vertex.data = (float[]) {
|
||||
// Front
|
||||
|
@ -693,7 +693,7 @@ void lovrGraphicsBox(DrawMode mode, Material* material, mat4 transform) {
|
|||
lovrGraphicsDraw(&(DrawCommand) {
|
||||
.transform = transform,
|
||||
.material = material,
|
||||
.mode = MESH_TRIANGLES,
|
||||
.mode = DRAW_TRIANGLES,
|
||||
.vertex.count = 24,
|
||||
.vertex.data = (float[]) {
|
||||
// Front
|
||||
|
@ -740,7 +740,7 @@ void lovrGraphicsBox(DrawMode mode, Material* material, mat4 transform) {
|
|||
}
|
||||
}
|
||||
|
||||
void lovrGraphicsArc(DrawMode mode, ArcMode arcMode, Material* material, mat4 transform, float theta1, float theta2, int segments) {
|
||||
void lovrGraphicsArc(DrawStyle style, ArcMode arcMode, Material* material, mat4 transform, float theta1, float theta2, int segments) {
|
||||
if (fabsf(theta1 - theta2) >= 2 * M_PI) {
|
||||
theta1 = 0;
|
||||
theta2 = 2 * M_PI;
|
||||
|
@ -769,13 +769,13 @@ void lovrGraphicsArc(DrawMode mode, ArcMode arcMode, Material* material, mat4 tr
|
|||
lovrGraphicsDraw(&(DrawCommand) {
|
||||
.transform = transform,
|
||||
.material = material,
|
||||
.mode = mode == DRAW_MODE_LINE ? (arcMode == ARC_MODE_OPEN ? MESH_LINE_STRIP : MESH_LINE_LOOP) : MESH_TRIANGLE_FAN,
|
||||
.mode = style == STYLE_LINE ? (arcMode == ARC_MODE_OPEN ? DRAW_LINE_STRIP : DRAW_LINE_LOOP) : DRAW_TRIANGLE_FAN,
|
||||
.vertex.count = count
|
||||
});
|
||||
}
|
||||
|
||||
void lovrGraphicsCircle(DrawMode mode, Material* material, mat4 transform, int segments) {
|
||||
lovrGraphicsArc(mode, ARC_MODE_OPEN, material, transform, 0, 2 * M_PI, segments);
|
||||
void lovrGraphicsCircle(DrawStyle style, Material* material, mat4 transform, int segments) {
|
||||
lovrGraphicsArc(style, ARC_MODE_OPEN, material, transform, 0, 2 * M_PI, segments);
|
||||
}
|
||||
|
||||
void lovrGraphicsCylinder(Material* material, float x1, float y1, float z1, float x2, float y2, float z2, float r1, float r2, bool capped, int segments) {
|
||||
|
@ -870,7 +870,7 @@ void lovrGraphicsCylinder(Material* material, float x1, float y1, float z1, floa
|
|||
|
||||
lovrGraphicsDraw(&(DrawCommand) {
|
||||
.material = material,
|
||||
.mode = MESH_TRIANGLES,
|
||||
.mode = DRAW_TRIANGLES,
|
||||
.vertex.count = vertexCount,
|
||||
.index.count = indexCount
|
||||
});
|
||||
|
@ -909,7 +909,7 @@ void lovrGraphicsSphere(Material* material, mat4 transform, int segments) {
|
|||
lovrGraphicsDraw(&(DrawCommand) {
|
||||
.transform = transform,
|
||||
.material = material,
|
||||
.mode = MESH_TRIANGLES,
|
||||
.mode = DRAW_TRIANGLES,
|
||||
.vertex.count = vertexCount,
|
||||
.index.count = indexCount
|
||||
});
|
||||
|
@ -924,7 +924,7 @@ void lovrGraphicsSkybox(Texture* texture, float angle, float ax, float ay, float
|
|||
.shader = type == TEXTURE_CUBE ? SHADER_CUBE : SHADER_PANO,
|
||||
.diffuseTexture = type == TEXTURE_2D ? texture : NULL,
|
||||
.environmentMap = type == TEXTURE_CUBE ? texture : NULL,
|
||||
.mode = MESH_TRIANGLE_STRIP,
|
||||
.mode = DRAW_TRIANGLE_STRIP,
|
||||
.vertex.count = 4,
|
||||
.vertex.data = (float[]) {
|
||||
-1, 1, 1, 0, 0, 0, 0, 0,
|
||||
|
@ -954,7 +954,7 @@ void lovrGraphicsPrint(const char* str, mat4 transform, float wrap, HorizontalAl
|
|||
lovrGraphicsDraw(&(DrawCommand) {
|
||||
.shader = SHADER_FONT,
|
||||
.diffuseTexture = font->texture,
|
||||
.mode = MESH_TRIANGLES,
|
||||
.mode = DRAW_TRIANGLES,
|
||||
.vertex.count = vertexCount
|
||||
});
|
||||
lovrGraphicsPopPipeline();
|
||||
|
@ -968,7 +968,7 @@ void lovrGraphicsFill(Texture* texture, float u, float v, float w, float h) {
|
|||
.mono = true,
|
||||
.shader = SHADER_FILL,
|
||||
.diffuseTexture = texture,
|
||||
.mode = MESH_TRIANGLE_STRIP,
|
||||
.mode = DRAW_TRIANGLE_STRIP,
|
||||
.vertex.count = 4,
|
||||
.vertex.data = (float[]) {
|
||||
-1, 1, 0, 0, 0, 0, u, v + h,
|
||||
|
|
|
@ -53,9 +53,9 @@ typedef enum {
|
|||
} CompareMode;
|
||||
|
||||
typedef enum {
|
||||
DRAW_MODE_FILL,
|
||||
DRAW_MODE_LINE
|
||||
} DrawMode;
|
||||
STYLE_FILL,
|
||||
STYLE_LINE
|
||||
} DrawStyle;
|
||||
|
||||
typedef enum {
|
||||
STENCIL_REPLACE,
|
||||
|
@ -122,7 +122,7 @@ typedef struct {
|
|||
|
||||
typedef struct {
|
||||
Mesh* mesh;
|
||||
MeshDrawMode mode;
|
||||
DrawMode mode;
|
||||
struct { uint32_t count; float* data; } vertex;
|
||||
struct { uint32_t count; uint16_t* data; } index;
|
||||
DefaultShader shader;
|
||||
|
@ -230,11 +230,11 @@ void lovrGraphicsFlush();
|
|||
void lovrGraphicsDraw(DrawCommand* draw);
|
||||
void lovrGraphicsPoints(uint32_t count);
|
||||
void lovrGraphicsLine(uint32_t count);
|
||||
void lovrGraphicsTriangle(DrawMode mode, Material* material, float points[9]);
|
||||
void lovrGraphicsPlane(DrawMode mode, Material* material, mat4 transform);
|
||||
void lovrGraphicsBox(DrawMode mode, Material* material, mat4 transform);
|
||||
void lovrGraphicsArc(DrawMode mode, ArcMode, Material* material, mat4 transform, float theta1, float theta2, int segments);
|
||||
void lovrGraphicsCircle(DrawMode mode, Material* material, mat4 transform, int segments);
|
||||
void lovrGraphicsTriangle(DrawStyle style, Material* material, float points[9]);
|
||||
void lovrGraphicsPlane(DrawStyle style, Material* material, mat4 transform);
|
||||
void lovrGraphicsBox(DrawStyle style, Material* material, mat4 transform);
|
||||
void lovrGraphicsArc(DrawStyle style, ArcMode, Material* material, mat4 transform, float theta1, float theta2, int segments);
|
||||
void lovrGraphicsCircle(DrawStyle style, Material* material, mat4 transform, int segments);
|
||||
void lovrGraphicsCylinder(Material* material, float x1, float y1, float z1, float x2, float y2, float z2, float r1, float r2, bool capped, int segments);
|
||||
void lovrGraphicsSphere(Material* material, mat4 transform, int segments);
|
||||
void lovrGraphicsSkybox(Texture* texture, float angle, float ax, float ay, float az);
|
||||
|
|
|
@ -22,18 +22,18 @@ typedef struct {
|
|||
typedef map_t(MeshAttribute) map_attribute_t;
|
||||
|
||||
typedef enum {
|
||||
MESH_POINTS,
|
||||
MESH_LINES,
|
||||
MESH_LINE_STRIP,
|
||||
MESH_LINE_LOOP,
|
||||
MESH_TRIANGLE_STRIP,
|
||||
MESH_TRIANGLES,
|
||||
MESH_TRIANGLE_FAN
|
||||
} MeshDrawMode;
|
||||
DRAW_POINTS,
|
||||
DRAW_LINES,
|
||||
DRAW_LINE_STRIP,
|
||||
DRAW_LINE_LOOP,
|
||||
DRAW_TRIANGLE_STRIP,
|
||||
DRAW_TRIANGLES,
|
||||
DRAW_TRIANGLE_FAN
|
||||
} DrawMode;
|
||||
|
||||
typedef struct Mesh Mesh;
|
||||
|
||||
Mesh* lovrMeshCreate(uint32_t count, VertexFormat format, MeshDrawMode drawMode, BufferUsage usage, bool readable);
|
||||
Mesh* lovrMeshCreate(uint32_t count, VertexFormat format, DrawMode drawMode, BufferUsage usage, bool readable);
|
||||
void lovrMeshDestroy(void* ref);
|
||||
void lovrMeshAttachAttribute(Mesh* mesh, const char* name, MeshAttribute* attribute);
|
||||
void lovrMeshDetachAttribute(Mesh* mesh, const char* name);
|
||||
|
@ -43,8 +43,8 @@ bool lovrMeshIsDirty(Mesh* mesh);
|
|||
void lovrMeshDraw(Mesh* mesh, int instances);
|
||||
VertexFormat* lovrMeshGetVertexFormat(Mesh* mesh);
|
||||
bool lovrMeshIsReadable(Mesh* mesh);
|
||||
MeshDrawMode lovrMeshGetDrawMode(Mesh* mesh);
|
||||
void lovrMeshSetDrawMode(Mesh* mesh, MeshDrawMode drawMode);
|
||||
DrawMode lovrMeshGetDrawMode(Mesh* mesh);
|
||||
void lovrMeshSetDrawMode(Mesh* mesh, DrawMode mode);
|
||||
int lovrMeshGetVertexCount(Mesh* mesh);
|
||||
bool lovrMeshIsAttributeEnabled(Mesh* mesh, const char* name);
|
||||
void lovrMeshSetAttributeEnabled(Mesh* mesh, const char* name, bool enabled);
|
||||
|
|
|
@ -62,7 +62,7 @@ Model* lovrModelCreate(ModelData* modelData) {
|
|||
model->modelData = modelData;
|
||||
model->aabbDirty = true;
|
||||
|
||||
model->mesh = lovrMeshCreate(modelData->vertexData->count, modelData->vertexData->format, MESH_TRIANGLES, USAGE_STATIC, false);
|
||||
model->mesh = lovrMeshCreate(modelData->vertexData->count, modelData->vertexData->format, DRAW_TRIANGLES, USAGE_STATIC, false);
|
||||
void* vertices = lovrMeshMapVertices(model->mesh, 0);
|
||||
memcpy(vertices, modelData->vertexData->blob.data, modelData->vertexData->count * modelData->vertexData->format.stride);
|
||||
lovrMeshFlushVertices(model->mesh, 0, modelData->vertexData->count * modelData->vertexData->format.stride);
|
||||
|
|
|
@ -151,7 +151,7 @@ struct Mesh {
|
|||
Ref ref;
|
||||
uint32_t vao;
|
||||
uint32_t count;
|
||||
MeshDrawMode drawMode;
|
||||
DrawMode mode;
|
||||
VertexFormat format;
|
||||
bool readable;
|
||||
bool dirty;
|
||||
|
@ -310,15 +310,15 @@ static GLenum convertAccess(UniformAccess access) {
|
|||
}
|
||||
#endif
|
||||
|
||||
static GLenum convertMeshDrawMode(MeshDrawMode mode) {
|
||||
static GLenum convertDrawMode(DrawMode mode) {
|
||||
switch (mode) {
|
||||
case MESH_POINTS: return GL_POINTS;
|
||||
case MESH_LINES: return GL_LINES;
|
||||
case MESH_LINE_STRIP: return GL_LINE_STRIP;
|
||||
case MESH_LINE_LOOP: return GL_LINE_LOOP;
|
||||
case MESH_TRIANGLE_STRIP: return GL_TRIANGLE_STRIP;
|
||||
case MESH_TRIANGLES: return GL_TRIANGLES;
|
||||
case MESH_TRIANGLE_FAN: return GL_TRIANGLE_FAN;
|
||||
case DRAW_POINTS: return GL_POINTS;
|
||||
case DRAW_LINES: return GL_LINES;
|
||||
case DRAW_LINE_STRIP: return GL_LINE_STRIP;
|
||||
case DRAW_LINE_LOOP: return GL_LINE_LOOP;
|
||||
case DRAW_TRIANGLE_STRIP: return GL_TRIANGLE_STRIP;
|
||||
case DRAW_TRIANGLES: return GL_TRIANGLES;
|
||||
case DRAW_TRIANGLE_FAN: return GL_TRIANGLE_FAN;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2277,14 +2277,14 @@ Buffer* lovrShaderBlockGetBuffer(ShaderBlock* block) {
|
|||
|
||||
// Mesh
|
||||
|
||||
Mesh* lovrMeshCreate(uint32_t count, VertexFormat format, MeshDrawMode drawMode, BufferUsage usage, bool readable) {
|
||||
Mesh* lovrMeshCreate(uint32_t count, VertexFormat format, DrawMode mode, BufferUsage usage, bool readable) {
|
||||
Mesh* mesh = lovrAlloc(Mesh, lovrMeshDestroy);
|
||||
if (!mesh) return NULL;
|
||||
|
||||
mesh->count = count;
|
||||
mesh->mode = mode;
|
||||
mesh->format = format;
|
||||
mesh->readable = readable;
|
||||
mesh->drawMode = drawMode;
|
||||
mesh->usage = usage;
|
||||
mesh->vbo = lovrBufferCreate(count * format.stride, NULL, usage, readable);
|
||||
glGenVertexArrays(1, &mesh->vao);
|
||||
|
@ -2425,7 +2425,7 @@ bool lovrMeshIsDirty(Mesh* mesh) {
|
|||
}
|
||||
|
||||
void lovrMeshDraw(Mesh* mesh, int instances) {
|
||||
GLenum glDrawMode = convertMeshDrawMode(mesh->drawMode);
|
||||
GLenum glDrawMode = convertDrawMode(mesh->mode);
|
||||
|
||||
if (mesh->indexCount > 0) {
|
||||
size_t count = mesh->rangeCount ? mesh->rangeCount : mesh->indexCount;
|
||||
|
@ -2456,13 +2456,13 @@ bool lovrMeshIsReadable(Mesh* mesh) {
|
|||
return mesh->readable;
|
||||
}
|
||||
|
||||
MeshDrawMode lovrMeshGetDrawMode(Mesh* mesh) {
|
||||
return mesh->drawMode;
|
||||
DrawMode lovrMeshGetDrawMode(Mesh* mesh) {
|
||||
return mesh->mode;
|
||||
}
|
||||
|
||||
void lovrMeshSetDrawMode(Mesh* mesh, MeshDrawMode drawMode) {
|
||||
if (mesh->drawMode != drawMode) {
|
||||
mesh->drawMode = drawMode;
|
||||
void lovrMeshSetDrawMode(Mesh* mesh, DrawMode mode) {
|
||||
if (mesh->mode != mode) {
|
||||
mesh->mode = mode;
|
||||
mesh->dirty = true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue