BsD3D9HLSLProgramFactory.cpp 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #include "BsD3D9HLSLProgramFactory.h"
  2. #include "BsString.h"
  3. #include "BsD3D9GpuProgram.h"
  4. namespace BansheeEngine
  5. {
  6. String D3D9HLSLProgramFactory::LANGUAGE_NAME = "hlsl";
  7. D3D9HLSLProgramFactory::D3D9HLSLProgramFactory()
  8. {
  9. }
  10. D3D9HLSLProgramFactory::~D3D9HLSLProgramFactory()
  11. {
  12. }
  13. const String& D3D9HLSLProgramFactory::getLanguage() const
  14. {
  15. return LANGUAGE_NAME;
  16. }
  17. GpuProgramPtr D3D9HLSLProgramFactory::create(const String& source, const String& entryPoint,
  18. GpuProgramType gptype, GpuProgramProfile profile, const Vector<HGpuProgInclude>* includes, bool requiresAdjacency)
  19. {
  20. if (gptype == GPT_VERTEX_PROGRAM)
  21. {
  22. D3D9GpuVertexProgram* prog = new (bs_alloc<D3D9GpuVertexProgram, PoolAlloc>())
  23. D3D9GpuVertexProgram(source, entryPoint, profile, includes);
  24. return bs_core_ptr<D3D9GpuVertexProgram, PoolAlloc>(prog);
  25. }
  26. else if (gptype == GPT_FRAGMENT_PROGRAM)
  27. {
  28. D3D9GpuFragmentProgram* prog = new (bs_alloc<D3D9GpuFragmentProgram, PoolAlloc>())
  29. D3D9GpuFragmentProgram(source, entryPoint, profile, includes);
  30. return bs_core_ptr<D3D9GpuFragmentProgram, PoolAlloc>(prog);
  31. }
  32. return nullptr;
  33. }
  34. GpuProgramPtr D3D9HLSLProgramFactory::create(GpuProgramType type)
  35. {
  36. if (type == GPT_VERTEX_PROGRAM)
  37. {
  38. D3D9GpuVertexProgram* prog = new (bs_alloc<D3D9GpuVertexProgram, PoolAlloc>())
  39. D3D9GpuVertexProgram("", "", GPP_NONE, nullptr);
  40. return bs_core_ptr<D3D9GpuVertexProgram, PoolAlloc>(prog);
  41. }
  42. else if (type == GPT_FRAGMENT_PROGRAM)
  43. {
  44. D3D9GpuFragmentProgram* prog = new (bs_alloc<D3D9GpuFragmentProgram, PoolAlloc>())
  45. D3D9GpuFragmentProgram("", "", GPP_NONE, nullptr);
  46. return bs_core_ptr<D3D9GpuFragmentProgram, PoolAlloc>(prog);
  47. }
  48. return nullptr;
  49. }
  50. }