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