CmGLPixelFormat.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /*
  2. -----------------------------------------------------------------------------
  3. This source file is part of OGRE
  4. (Object-oriented Graphics Rendering Engine)
  5. For the latest info, see http://www.ogre3d.org/
  6. Copyright (c) 2000-2011 Torus Knot Software Ltd
  7. Permission is hereby granted, free of charge, to any person obtaining a copy
  8. of this software and associated documentation files (the "Software"), to deal
  9. in the Software without restriction, including without limitation the rights
  10. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  11. copies of the Software, and to permit persons to whom the Software is
  12. furnished to do so, subject to the following conditions:
  13. The above copyright notice and this permission notice shall be included in
  14. all copies or substantial portions of the Software.
  15. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  21. THE SOFTWARE.
  22. -----------------------------------------------------------------------------
  23. */
  24. #ifndef __GLPIXELFORMAT_H__
  25. #define __GLPIXELFORMAT_H__
  26. #include "CmGLPrerequisites.h"
  27. #include "CmPixelUtil.h"
  28. namespace CamelotEngine {
  29. /**
  30. * Class to do pixel format mapping between GL and OGRE
  31. */
  32. class CM_RSGL_EXPORT GLPixelUtil
  33. {
  34. public:
  35. /** Takes the OGRE pixel format and returns the appropriate GL one
  36. @returns a GLenum describing the format, or 0 if there is no exactly matching
  37. one (and conversion is needed)
  38. */
  39. static GLenum getGLOriginFormat(PixelFormat mFormat);
  40. /** Takes the OGRE pixel format and returns type that must be provided
  41. to GL as data type for reading it into the GPU
  42. @returns a GLenum describing the data type, or 0 if there is no exactly matching
  43. one (and conversion is needed)
  44. */
  45. static GLenum getGLOriginDataType(PixelFormat mFormat);
  46. /** Takes the OGRE pixel format and returns the type that must be provided
  47. to GL as internal format. GL_NONE if no match exists.
  48. @param mFormat The pixel format
  49. @param hwGamma Whether a hardware gamma-corrected version is requested
  50. */
  51. static GLenum getGLInternalFormat(PixelFormat mFormat, bool hwGamma = false);
  52. /** Takes the OGRE pixel format and returns the type that must be provided
  53. to GL as internal format. If no match exists, returns the closest match.
  54. @param mFormat The pixel format
  55. @param hwGamma Whether a hardware gamma-corrected version is requested
  56. */
  57. static GLenum getClosestGLInternalFormat(PixelFormat mFormat, bool hwGamma = false);
  58. /** Function to get the closest matching OGRE format to an internal GL format. To be
  59. precise, the format will be chosen that is most efficient to transfer to the card
  60. without losing precision.
  61. @remarks It is valid for this function to always return PF_A8R8G8B8.
  62. */
  63. static PixelFormat getClosestOGREFormat(GLenum fmt);
  64. /** Returns the maximum number of Mipmaps that can be generated until we reach
  65. the mininum format possible. This does not count the base level.
  66. @param width
  67. The width of the area
  68. @param height
  69. The height of the area
  70. @param depth
  71. The depth of the area
  72. @param format
  73. The format of the area
  74. @remarks
  75. In case that the format is non-compressed, this simply returns
  76. how many times we can divide this texture in 2 until we reach 1x1.
  77. For compressed formats, constraints apply on minimum size and alignment
  78. so this might differ.
  79. */
  80. static size_t getMaxMipmaps(size_t width, size_t height, size_t depth, PixelFormat format);
  81. /** Returns next power-of-two size if required by render system, in case
  82. RSC_NON_POWER_OF_2_TEXTURES is supported it returns value as-is.
  83. */
  84. static size_t optionalPO2(size_t value);
  85. };
  86. };
  87. #endif