BsGLPixelFormat.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #pragma once
  2. #include "BsGLPrerequisites.h"
  3. #include "BsPixelUtil.h"
  4. namespace BansheeEngine
  5. {
  6. /**
  7. * Class to do pixel format mapping between GL and OGRE
  8. */
  9. class BS_RSGL_EXPORT GLPixelUtil
  10. {
  11. public:
  12. /** Takes the engine pixel format and returns the appropriate GL one
  13. @returns a GLenum describing the format, or 0 if there is no exactly matching
  14. one (and conversion is needed)
  15. */
  16. static GLenum getGLOriginFormat(PixelFormat mFormat);
  17. /** Takes the engine pixel format and returns type that must be provided
  18. to GL as data type for reading it into the GPU
  19. @returns a GLenum describing the data type, or 0 if there is no exactly matching
  20. one (and conversion is needed)
  21. */
  22. static GLenum getGLOriginDataType(PixelFormat mFormat);
  23. /** Takes the engine pixel format and returns the type that must be provided
  24. to GL as internal format. GL_NONE if no match exists.
  25. @param mFormat The pixel format
  26. @param hwGamma Whether a hardware gamma-corrected version is requested
  27. */
  28. static GLenum getGLInternalFormat(PixelFormat mFormat, bool hwGamma = false);
  29. /** Takes the OGRE pixel format and returns the type that must be provided
  30. to GL as internal format. If no match exists, returns the closest match.
  31. @param mFormat The pixel format
  32. @param hwGamma Whether a hardware gamma-corrected version is requested
  33. */
  34. static GLenum getClosestGLInternalFormat(PixelFormat mFormat, bool hwGamma = false);
  35. /**
  36. * @brief Returns a valid type that should be used for creating a buffer for the specified
  37. * depth/stencil format.
  38. */
  39. static GLenum getDepthStencilTypeFromFormat(PixelFormat mFormat);
  40. /** Function to get the closest matching engine format to an internal GL format. To be
  41. precise, the format will be chosen that is most efficient to transfer to the card
  42. without losing precision.
  43. @remarks It is valid for this function to always return PF_A8R8G8B8.
  44. */
  45. static PixelFormat getClosestEngineFormat(GLenum fmt);
  46. /** Function to get the closest valid matching engine format to another engine format.
  47. */
  48. static PixelFormat getClosestValidFormat(PixelFormat fmt);
  49. /**
  50. * @brief Gets OpenGL format based on a compressed OpenGL internal format.
  51. * e.g. GL_COMPRESSED_RGBA_S3TC_DXT1_EXT will return GL_RGBA
  52. *
  53. */
  54. static GLenum getBaseFormatFromCompressedInternalFormat(GLenum internalFormat);
  55. /** Returns next power-of-two size if required by render system, in case
  56. RSC_NON_POWER_OF_2_TEXTURES is supported it returns value as-is.
  57. */
  58. static UINT32 optionalPO2(UINT32 value);
  59. };
  60. };