DXBuffer.cpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #include "DXBuffer.h"
  2. using namespace Framework;
  3. // Contents of the DXBuffer class
  4. // Constructor
  5. // bind: The usage purpose of the buffer. Example: D3D11_BIND_INDEX_BUFFER,
  6. // D3D11_BIND_VERTEX_BUFFER. eLaen: Length of a single element in bytes
  7. DXBuffer::DXBuffer(int eLen)
  8. : ReferenceCounter()
  9. {
  10. data = 0;
  11. changed = 0;
  12. len = 0;
  13. elLen = eLen;
  14. }
  15. // Destructor
  16. DXBuffer::~DXBuffer() {}
  17. // Sets the changed flag so that data is re-copied on the next call to
  18. // 'copy'
  19. void DXBuffer::setChanged()
  20. {
  21. changed = 1;
  22. }
  23. // Changes the length of the buffer on the next call to 'copy'
  24. // laen: The length in bytes
  25. void DXBuffer::setLength(__int64 len)
  26. {
  27. if (this->len != len)
  28. {
  29. this->len = len;
  30. changed = 1;
  31. }
  32. }
  33. // Sets what will be copied on the next call to 'copy'
  34. // data: A pointer to the data
  35. void DXBuffer::setData(void* data, bool shureChanged)
  36. {
  37. if (this->data != data || shureChanged)
  38. {
  39. this->data = data;
  40. changed = 1;
  41. }
  42. }
  43. // Returns the length of an element in bytes
  44. int DXBuffer::getElementLength() const
  45. {
  46. return elLen;
  47. }
  48. // Returns the number of elements in the buffer
  49. __int64 DXBuffer::getElementCount() const
  50. {
  51. return len / elLen;
  52. }