dd_mesh.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #ifndef DD_MESH_H
  2. #define DD_MESH_H
  3. enum dd_primitives {
  4. DD_PRIMITIVE_TRIANGLE,
  5. DD_PRIMITIVE_RECTANGLE,
  6. DD_PRIMITIVE_BOX,
  7. };
  8. #include "dd_opengl.h"
  9. #include "dd_matrix.h"
  10. #if DD_PLATFORM_ANDROID
  11. #include <jni.h>
  12. extern JavaVM* jvm;
  13. extern JNIEnv *jniEnv;
  14. extern jclass *clazz;
  15. #endif
  16. /* Generic mesh that holds all the data needed to draw a mesh
  17. * like colors or normals
  18. * vcount : number of vertices
  19. * v : array of pointers to vertex data
  20. * c : array of pointers to vertex colours
  21. * A mesh must be initialized before it can be drawn. The only proper
  22. * way to do that is with "filetomesh()" (from "filetomesh.h")
  23. */
  24. struct dd_mesh {
  25. int vcount;
  26. int dirtyVertices;
  27. float *v;
  28. void (*draw)(struct dd_mesh *);
  29. void (*clean)(struct dd_mesh *);
  30. void (*set_primitive)(struct dd_mesh *m, enum dd_primitives shape);
  31. void (*load)(struct dd_mesh *m, const char *filename);
  32. void (*copy)(struct dd_mesh *, struct dd_mesh *);
  33. };
  34. // constructor
  35. void dd_mesh_create(struct dd_mesh *);
  36. /* Free and Draw functions */
  37. void dd_mesh_clean(struct dd_mesh *m);
  38. void dd_mesh_draw(struct dd_mesh *m);
  39. // functions to give the mesh its shape
  40. void dd_mesh_set_primitive(struct dd_mesh *m, enum dd_primitives shape);
  41. void dd_mesh_load(struct dd_mesh *m, const char *filename);
  42. void dd_mesh_copy(struct dd_mesh *dest, struct dd_mesh *src);
  43. #endif /* MESH_H */