rs_mesh.c 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #ifndef __LP64__
  2. #include "rs_core.rsh"
  3. #include "rs_graphics.rsh"
  4. #include "rs_structs.h"
  5. /**
  6. * Mesh
  7. */
  8. extern uint32_t __attribute__((overloadable))
  9. rsgMeshGetVertexAllocationCount(rs_mesh m) {
  10. Mesh_t *mesh = (Mesh_t *)m.p;
  11. if (mesh == NULL) {
  12. return 0;
  13. }
  14. return mesh->mHal.state.vertexBuffersCount;
  15. }
  16. extern uint32_t __attribute__((overloadable))
  17. rsgMeshGetPrimitiveCount(rs_mesh m) {
  18. Mesh_t *mesh = (Mesh_t *)m.p;
  19. if (mesh == NULL) {
  20. return 0;
  21. }
  22. return mesh->mHal.state.primitivesCount;
  23. }
  24. extern rs_allocation __attribute__((overloadable))
  25. rsgMeshGetVertexAllocation(rs_mesh m, uint32_t index) {
  26. Mesh_t *mesh = (Mesh_t *)m.p;
  27. if (mesh == NULL || index >= mesh->mHal.state.vertexBuffersCount) {
  28. rs_allocation nullAlloc = RS_NULL_OBJ;
  29. return nullAlloc;
  30. }
  31. rs_allocation returnAlloc = {mesh->mHal.state.vertexBuffers[index]};
  32. rs_allocation rs_retval = RS_NULL_OBJ;
  33. rsSetObject(&rs_retval, returnAlloc);
  34. return rs_retval;
  35. }
  36. extern rs_allocation __attribute__((overloadable))
  37. rsgMeshGetIndexAllocation(rs_mesh m, uint32_t index) {
  38. Mesh_t *mesh = (Mesh_t *)m.p;
  39. if (mesh == NULL || index >= mesh->mHal.state.primitivesCount) {
  40. rs_allocation nullAlloc = RS_NULL_OBJ;
  41. return nullAlloc;
  42. }
  43. rs_allocation returnAlloc = {mesh->mHal.state.indexBuffers[index]};
  44. rs_allocation rs_retval = RS_NULL_OBJ;
  45. rsSetObject(&rs_retval, returnAlloc);
  46. return rs_retval;
  47. }
  48. extern rs_primitive __attribute__((overloadable))
  49. rsgMeshGetPrimitive(rs_mesh m, uint32_t index) {
  50. 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. }
  56. #endif