BsD3D9HLSLProgramFactory.cpp 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. //__________________________ Banshee Project - A modern game development toolkit _________________________________//
  2. //_____________________________________ www.banshee-project.com __________________________________________________//
  3. //________________________ Copyright (c) 2014 Marko Pintera. All rights reserved. ________________________________//
  4. #include "BsD3D9HLSLProgramFactory.h"
  5. #include "BsString.h"
  6. #include "BsD3D9GpuProgram.h"
  7. namespace BansheeEngine
  8. {
  9. String D3D9HLSLProgramFactory::LANGUAGE_NAME = "hlsl";
  10. D3D9HLSLProgramFactory::D3D9HLSLProgramFactory()
  11. {
  12. }
  13. D3D9HLSLProgramFactory::~D3D9HLSLProgramFactory()
  14. {
  15. }
  16. const String& D3D9HLSLProgramFactory::getLanguage() const
  17. {
  18. return LANGUAGE_NAME;
  19. }
  20. GpuProgramPtr D3D9HLSLProgramFactory::create(const String& source, const String& entryPoint,
  21. GpuProgramType gptype, GpuProgramProfile profile, const Vector<HGpuProgInclude>* includes, bool requiresAdjacency)
  22. {
  23. if (gptype == GPT_VERTEX_PROGRAM)
  24. {
  25. D3D9GpuVertexProgram* prog = new (bs_alloc<D3D9GpuVertexProgram, PoolAlloc>())
  26. D3D9GpuVertexProgram(source, entryPoint, profile, includes);
  27. return bs_core_ptr<D3D9GpuVertexProgram, PoolAlloc>(prog);
  28. }
  29. else if (gptype == GPT_FRAGMENT_PROGRAM)
  30. {
  31. D3D9GpuFragmentProgram* prog = new (bs_alloc<D3D9GpuFragmentProgram, PoolAlloc>())
  32. D3D9GpuFragmentProgram(source, entryPoint, profile, includes);
  33. return bs_core_ptr<D3D9GpuFragmentProgram, PoolAlloc>(prog);
  34. }
  35. return nullptr;
  36. }
  37. GpuProgramPtr D3D9HLSLProgramFactory::create(GpuProgramType type)
  38. {
  39. if (type == GPT_VERTEX_PROGRAM)
  40. {
  41. D3D9GpuVertexProgram* prog = new (bs_alloc<D3D9GpuVertexProgram, PoolAlloc>())
  42. D3D9GpuVertexProgram("", "", GPP_NONE, nullptr);
  43. return bs_core_ptr<D3D9GpuVertexProgram, PoolAlloc>(prog);
  44. }
  45. else if (type == GPT_FRAGMENT_PROGRAM)
  46. {
  47. D3D9GpuFragmentProgram* prog = new (bs_alloc<D3D9GpuFragmentProgram, PoolAlloc>())
  48. D3D9GpuFragmentProgram("", "", GPP_NONE, nullptr);
  49. return bs_core_ptr<D3D9GpuFragmentProgram, PoolAlloc>(prog);
  50. }
  51. return nullptr;
  52. }
  53. }