CmHardwareBufferManager.cpp 4.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /*
  2. -----------------------------------------------------------------------------
  3. This source file is part of OGRE
  4. (Object-oriented Graphics Rendering Engine)
  5. For the latest info, see http://www.ogre3d.org/
  6. Copyright (c) 2000-2011 Torus Knot Software Ltd
  7. Permission is hereby granted, free of charge, to any person obtaining a copy
  8. of this software and associated documentation files (the "Software"), to deal
  9. in the Software without restriction, including without limitation the rights
  10. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  11. copies of the Software, and to permit persons to whom the Software is
  12. furnished to do so, subject to the following conditions:
  13. The above copyright notice and this permission notice shall be included in
  14. all copies or substantial portions of the Software.
  15. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  21. THE SOFTWARE.
  22. -----------------------------------------------------------------------------
  23. */
  24. #include "CmHardwareBufferManager.h"
  25. #include "CmVertexData.h"
  26. #include "CmIndexData.h"
  27. #include "CmGpuBuffer.h"
  28. #include "CmVertexDeclaration.h"
  29. #include "CmGpuParamBlockBuffer.h"
  30. namespace CamelotFramework {
  31. //-----------------------------------------------------------------------
  32. HardwareBufferManager::HardwareBufferManager()
  33. {
  34. }
  35. //-----------------------------------------------------------------------
  36. HardwareBufferManager::~HardwareBufferManager()
  37. {
  38. }
  39. //-----------------------------------------------------------------------
  40. VertexDeclarationPtr HardwareBufferManager::createVertexDeclaration(void)
  41. {
  42. VertexDeclarationPtr decl = createVertexDeclarationImpl();
  43. decl->setThisPtr(decl);
  44. decl->initialize();
  45. return decl;
  46. }
  47. //-----------------------------------------------------------------------
  48. VertexBufferPtr HardwareBufferManager::createVertexBuffer(UINT32 vertexSize, UINT32 numVerts, GpuBufferUsage usage, bool streamOut)
  49. {
  50. assert (numVerts > 0);
  51. VertexBufferPtr vbuf = createVertexBufferImpl(vertexSize, numVerts, usage, streamOut);
  52. vbuf->setThisPtr(vbuf);
  53. vbuf->initialize();
  54. return vbuf;
  55. }
  56. //-----------------------------------------------------------------------
  57. IndexBufferPtr HardwareBufferManager::createIndexBuffer(IndexBuffer::IndexType itype, UINT32 numIndexes, GpuBufferUsage usage)
  58. {
  59. assert (numIndexes > 0);
  60. IndexBufferPtr ibuf = createIndexBufferImpl(itype, numIndexes, usage);
  61. ibuf->setThisPtr(ibuf);
  62. ibuf->initialize();
  63. return ibuf;
  64. }
  65. //-----------------------------------------------------------------------
  66. GpuParamBlockBufferPtr HardwareBufferManager::createGpuParamBlockBuffer(UINT32 size, GpuParamBlockUsage usage)
  67. {
  68. GpuParamBlockBufferPtr paramBlockPtr = createGpuParamBlockBufferImpl();
  69. paramBlockPtr->setThisPtr(paramBlockPtr);
  70. paramBlockPtr->initialize(size, usage);
  71. return paramBlockPtr;
  72. }
  73. //-----------------------------------------------------------------------
  74. GpuBufferPtr HardwareBufferManager::createGpuBuffer(UINT32 elementCount, UINT32 elementSize,
  75. GpuBufferType type, GpuBufferUsage usage, bool randomGpuWrite, bool useCounter)
  76. {
  77. GpuBufferPtr gbuf = createGpuBufferImpl(elementCount, elementSize, type, usage, randomGpuWrite, useCounter);
  78. gbuf->setThisPtr(gbuf);
  79. gbuf->initialize();
  80. return gbuf;
  81. }
  82. //-----------------------------------------------------------------------
  83. VertexDeclarationPtr HardwareBufferManager::createVertexDeclarationImpl(void)
  84. {
  85. return VertexDeclarationPtr(CM_NEW(VertexDeclaration, PoolAlloc) VertexDeclaration(), &CoreObject::_deleteDelayed<VertexDeclaration, PoolAlloc>);
  86. }
  87. }