blob: bb533bc4bc5a7d54a943f23909f5fbb5b0efbd52 [file] [log] [blame]
Alex Sakhartchouk4a048eb2012-03-20 14:07:34 -07001#include "rs_core.rsh"
2#include "rs_graphics.rsh"
Alex Sakhartchoukff522552012-03-21 10:52:59 -07003#include "rs_structs.h"
Alex Sakhartchouk4a048eb2012-03-20 14:07:34 -07004
5/**
6* Mesh
7*/
8extern uint32_t __attribute__((overloadable))
Alex Sakhartchouk3cbc3da2012-03-22 10:27:44 -07009 rsgMeshGetVertexAllocationCount(rs_mesh m) {
Alex Sakhartchouk4a048eb2012-03-20 14:07:34 -070010 Mesh_t *mesh = (Mesh_t *)m.p;
11 if (mesh == NULL) {
12 return 0;
13 }
14 return mesh->mHal.state.vertexBuffersCount;
15}
16
17extern uint32_t __attribute__((overloadable))
Alex Sakhartchouk3cbc3da2012-03-22 10:27:44 -070018 rsgMeshGetPrimitiveCount(rs_mesh m) {
Alex Sakhartchouk4a048eb2012-03-20 14:07:34 -070019 Mesh_t *mesh = (Mesh_t *)m.p;
20 if (mesh == NULL) {
21 return 0;
22 }
23 return mesh->mHal.state.primitivesCount;
24}
25
26extern rs_allocation __attribute__((overloadable))
Alex Sakhartchouk3cbc3da2012-03-22 10:27:44 -070027 rsgMeshGetVertexAllocation(rs_mesh m, uint32_t index) {
Alex Sakhartchouk4a048eb2012-03-20 14:07:34 -070028 Mesh_t *mesh = (Mesh_t *)m.p;
29 if (mesh == NULL || index >= mesh->mHal.state.vertexBuffersCount) {
30 rs_allocation nullAlloc = {0};
31 return nullAlloc;
32 }
33 rs_allocation returnAlloc = {mesh->mHal.state.vertexBuffers[index]};
34 return returnAlloc;
35}
36
37extern rs_allocation __attribute__((overloadable))
Alex Sakhartchouk3cbc3da2012-03-22 10:27:44 -070038 rsgMeshGetIndexAllocation(rs_mesh m, uint32_t index) {
Alex Sakhartchouk4a048eb2012-03-20 14:07:34 -070039 Mesh_t *mesh = (Mesh_t *)m.p;
40 if (mesh == NULL || index >= mesh->mHal.state.primitivesCount) {
41 rs_allocation nullAlloc = {0};
42 return nullAlloc;
43 }
44 rs_allocation returnAlloc = {mesh->mHal.state.indexBuffers[index]};
45 return returnAlloc;
46}
47
48extern rs_primitive __attribute__((overloadable))
Alex Sakhartchouk3cbc3da2012-03-22 10:27:44 -070049 rsgMeshGetPrimitive(rs_mesh m, uint32_t index) {
Alex Sakhartchouk4a048eb2012-03-20 14:07:34 -070050 Mesh_t *mesh = (Mesh_t *)m.p;
51 if (mesh == NULL || index >= mesh->mHal.state.primitivesCount) {
52 return RS_PRIMITIVE_INVALID;
53 }
54 return mesh->mHal.state.primitives[index];
55}