BsGLTextureManager.cpp 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. #include "BsGLTextureManager.h"
  4. #include "RenderAPI/BsRenderAPI.h"
  5. #include "BsGLRenderTexture.h"
  6. #include "BsGLPixelFormat.h"
  7. namespace bs
  8. {
  9. GLTextureManager::GLTextureManager(ct::GLSupport& support)
  10. :TextureManager(), mGLSupport(support)
  11. {
  12. }
  13. GLTextureManager::~GLTextureManager()
  14. {
  15. }
  16. SPtr<RenderTexture> GLTextureManager::createRenderTextureImpl(const RENDER_TEXTURE_DESC& desc)
  17. {
  18. GLRenderTexture* tex = new (bs_alloc<GLRenderTexture>()) GLRenderTexture(desc);
  19. return bs_core_ptr<GLRenderTexture>(tex);
  20. }
  21. PixelFormat GLTextureManager::getNativeFormat(TextureType ttype, PixelFormat format, int usage, bool hwGamma)
  22. {
  23. // Check if this is a valid rendertarget format
  24. if(usage & TU_RENDERTARGET)
  25. return ct::GLRTTManager::instance().getSupportedAlternative(format);
  26. return ct::GLPixelUtil::getClosestSupportedPF(format, ttype, usage);
  27. }
  28. namespace ct
  29. {
  30. GLTextureManager::GLTextureManager(GLSupport& support)
  31. :mGLSupport(support)
  32. { }
  33. SPtr<Texture> GLTextureManager::createTextureInternal(const TEXTURE_DESC& desc,
  34. const SPtr<PixelData>& initialData, GpuDeviceFlags deviceMask)
  35. {
  36. GLTexture* tex = new (bs_alloc<GLTexture>()) GLTexture(mGLSupport, desc, initialData, deviceMask);
  37. SPtr<GLTexture> texPtr = bs_shared_ptr<GLTexture>(tex);
  38. texPtr->_setThisPtr(texPtr);
  39. return texPtr;
  40. }
  41. SPtr<RenderTexture> GLTextureManager::createRenderTextureInternal(const RENDER_TEXTURE_DESC& desc,
  42. UINT32 deviceIdx)
  43. {
  44. SPtr<GLRenderTexture> texPtr = bs_shared_ptr_new<GLRenderTexture>(desc, deviceIdx);
  45. texPtr->_setThisPtr(texPtr);
  46. return texPtr;
  47. }
  48. }
  49. }