BsGLTextureManager.cpp 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. #include "BsGLTextureManager.h"
  4. #include "BsRenderAPI.h"
  5. #include "BsGLRenderTexture.h"
  6. #include "BsGLPixelFormat.h"
  7. namespace BansheeEngine
  8. {
  9. GLTextureManager::GLTextureManager(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 GLRTTManager::instance().getSupportedAlternative(format);
  26. return GLPixelUtil::getClosestValidFormat(format);
  27. }
  28. GLTextureCoreManager::GLTextureCoreManager(GLSupport& support)
  29. :mGLSupport(support)
  30. { }
  31. SPtr<TextureCore> GLTextureCoreManager::createTextureInternal(const TEXTURE_DESC& desc,
  32. const SPtr<PixelData>& initialData, GpuDeviceFlags deviceMask)
  33. {
  34. GLTextureCore* tex = new (bs_alloc<GLTextureCore>()) GLTextureCore(mGLSupport, desc, initialData, deviceMask);
  35. SPtr<GLTextureCore> texPtr = bs_shared_ptr<GLTextureCore>(tex);
  36. texPtr->_setThisPtr(texPtr);
  37. return texPtr;
  38. }
  39. SPtr<RenderTextureCore> GLTextureCoreManager::createRenderTextureInternal(const RENDER_TEXTURE_DESC_CORE& desc,
  40. GpuDeviceFlags deviceMask)
  41. {
  42. SPtr<GLRenderTextureCore> texPtr = bs_shared_ptr_new<GLRenderTextureCore>(desc, deviceMask);
  43. texPtr->_setThisPtr(texPtr);
  44. return texPtr;
  45. }
  46. }