BsD3D9HLSLProgramFactory.cpp 1.8 KB

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