BsDrawHelperTemplate.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #pragma once
  2. #include "BsPrerequisites.h"
  3. #include "BsDebugDrawMaterialInfo.h"
  4. #include "BsColor.h"
  5. #include "BsAABox.h"
  6. namespace BansheeEngine
  7. {
  8. /**
  9. * @brief Provides dimension-independant methods used for creating geometry
  10. * for various common shapes.
  11. */
  12. template <class T>
  13. class BS_EXPORT DrawHelperTemplate
  14. {
  15. protected:
  16. protected:
  17. /**
  18. * @brief Fills the provided buffers with vertices representing a pixel-wide polygon border.
  19. *
  20. * @param points Points defining the polygon. First point is assumed to be the start and end point.
  21. * @param color Color of the border.
  22. * @param outVertices Output buffer that will store the vertex position data.
  23. * @param outColors Output buffer that will store the vertex color data.
  24. * @param vertexOffset Offset in number of vertices from the start of the buffer to start writing at.
  25. * @param vertexStride Size of a single vertex, in bytes. (Same for both position and color buffer)
  26. * @param outIndices Output buffer that will store the index data. Indices are 32bit.
  27. * @param indexOffset Offset in number of indices from the start of the buffer to start writing at.
  28. */
  29. void pixelWirePolygon(const typename Vector<T>& points, const Color& color, UINT8* outVertices, UINT8* outColors,
  30. UINT32 vertexOffset, UINT32 vertexStride, UINT32* outIndices, UINT32 indexOffset)
  31. {
  32. INT32 numPoints = (INT32)points.size();
  33. UINT32 curVertOffset = vertexOffset;
  34. UINT32 curIdxOffset = indexOffset;
  35. for(INT32 i = 0, j = numPoints - 1; i < numPoints; j = i++)
  36. {
  37. pixelLine(points[j], points[i], color, outVertices, outColors, curVertOffset, vertexStride, outIndices, curIdxOffset);
  38. curVertOffset += 2;
  39. curIdxOffset += 2;
  40. }
  41. }
  42. };
  43. }