2
0

BsD3D9HLSLProgramFactory.cpp 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. #include "BsD3D9HLSLProgramFactory.h"
  4. #include "BsD3D9GpuProgram.h"
  5. namespace BansheeEngine
  6. {
  7. String D3D9HLSLProgramFactory::LANGUAGE_NAME = "hlsl9";
  8. D3D9HLSLProgramFactory::D3D9HLSLProgramFactory()
  9. {
  10. }
  11. D3D9HLSLProgramFactory::~D3D9HLSLProgramFactory()
  12. {
  13. }
  14. const String& D3D9HLSLProgramFactory::getLanguage() const
  15. {
  16. return LANGUAGE_NAME;
  17. }
  18. SPtr<GpuProgramCore> D3D9HLSLProgramFactory::create(const String& source, const String& entryPoint,
  19. GpuProgramType gptype, GpuProgramProfile profile, bool requiresAdjacency)
  20. {
  21. SPtr<GpuProgramCore> gpuProg;
  22. if (gptype == GPT_VERTEX_PROGRAM)
  23. {
  24. D3D9GpuVertexProgramCore* prog = new (bs_alloc<D3D9GpuVertexProgramCore>())
  25. D3D9GpuVertexProgramCore(source, entryPoint, profile);
  26. gpuProg = bs_shared_ptr<D3D9GpuVertexProgramCore>(prog);
  27. }
  28. else if (gptype == GPT_FRAGMENT_PROGRAM)
  29. {
  30. D3D9GpuFragmentProgramCore* prog = new (bs_alloc<D3D9GpuFragmentProgramCore>())
  31. D3D9GpuFragmentProgramCore(source, entryPoint, profile);
  32. gpuProg = bs_shared_ptr<D3D9GpuFragmentProgramCore>(prog);
  33. }
  34. if (gpuProg != nullptr)
  35. gpuProg->_setThisPtr(gpuProg);
  36. return gpuProg;
  37. }
  38. SPtr<GpuProgramCore> D3D9HLSLProgramFactory::create(GpuProgramType type)
  39. {
  40. SPtr<GpuProgramCore> gpuProg;
  41. if (type == GPT_VERTEX_PROGRAM)
  42. {
  43. D3D9GpuVertexProgramCore* prog = new (bs_alloc<D3D9GpuVertexProgramCore>())
  44. D3D9GpuVertexProgramCore("", "", GPP_NONE);
  45. gpuProg = bs_shared_ptr<D3D9GpuVertexProgramCore>(prog);
  46. }
  47. else if (type == GPT_FRAGMENT_PROGRAM)
  48. {
  49. D3D9GpuFragmentProgramCore* prog = new (bs_alloc<D3D9GpuFragmentProgramCore>())
  50. D3D9GpuFragmentProgramCore("", "", GPP_NONE);
  51. gpuProg = bs_shared_ptr<D3D9GpuFragmentProgramCore>(prog);
  52. }
  53. if (gpuProg != nullptr)
  54. gpuProg->_setThisPtr(gpuProg);
  55. return gpuProg;
  56. }
  57. }