IndexBuffer.pkg 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. $#include "Graphics/IndexBuffer.h"
  2. class IndexBuffer : public Object
  3. {
  4. IndexBuffer();
  5. ~IndexBuffer();
  6. void SetShadowed(bool enable);
  7. bool SetSize(unsigned indexCount, bool largeIndices, bool dynamic = false);
  8. tolua_outside bool IndexBufferSetData @ SetData(VectorBuffer& data);
  9. tolua_outside bool IndexBufferSetDataRange @ SetDataRange(VectorBuffer& data, unsigned start, unsigned count, bool discard = false);
  10. tolua_outside VectorBuffer IndexBufferGetData @ GetData();
  11. bool IsShadowed() const;
  12. bool IsDynamic() const;
  13. unsigned GetIndexCount() const;
  14. unsigned GetIndexSize() const;
  15. tolua_property__is_set bool shadowed;
  16. tolua_readonly tolua_property__is_set bool dynamic;
  17. tolua_readonly tolua_property__get_set unsigned indexCount;
  18. tolua_readonly tolua_property__get_set unsigned indexSize;
  19. };
  20. ${
  21. #define TOLUA_DISABLE_tolua_GraphicsLuaAPI_IndexBuffer_new00
  22. static int tolua_GraphicsLuaAPI_IndexBuffer_new00(lua_State* tolua_S)
  23. {
  24. return ToluaNewObject<IndexBuffer>(tolua_S);
  25. }
  26. #define TOLUA_DISABLE_tolua_GraphicsLuaAPI_IndexBuffer_new00_local
  27. static int tolua_GraphicsLuaAPI_IndexBuffer_new00_local(lua_State* tolua_S)
  28. {
  29. return ToluaNewObjectGC<IndexBuffer>(tolua_S);
  30. }
  31. static bool IndexBufferSetData(IndexBuffer* dest, VectorBuffer& src)
  32. {
  33. // Make sure there is enough data
  34. if (dest->GetIndexCount() && src.GetSize() >= dest->GetIndexCount() * dest->GetIndexSize())
  35. return dest->SetData(&src.GetBuffer()[0]);
  36. else
  37. return false;
  38. }
  39. static bool IndexBufferSetDataRange(IndexBuffer* dest, VectorBuffer& src, unsigned start, unsigned count, bool discard)
  40. {
  41. // Make sure there is enough data
  42. if (dest->GetIndexCount() && src.GetSize() >= count * dest->GetIndexSize())
  43. return dest->SetDataRange(&src.GetBuffer()[0], start, count, discard);
  44. else
  45. return false;
  46. }
  47. static VectorBuffer IndexBufferGetData(IndexBuffer* src)
  48. {
  49. VectorBuffer ret;
  50. void* data = src->Lock(0, src->GetIndexCount(), false);
  51. if (data)
  52. {
  53. ret.Write(data, src->GetIndexCount() * src->GetIndexSize());
  54. ret.Seek(0);
  55. src->Unlock();
  56. }
  57. return ret;
  58. }
  59. $}