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) 2000-2006 Torus Knot Software Ltd |
---|
8 | Also see acknowledgements in Readme.html |
---|
9 | |
---|
10 | This program is free software; you can redistribute it and/or modify it under |
---|
11 | the terms of the GNU Lesser General Public License as published by the Free Software |
---|
12 | Foundation; either version 2 of the License, or (at your option) any later |
---|
13 | version. |
---|
14 | |
---|
15 | This program is distributed in the hope that it will be useful, but WITHOUT |
---|
16 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
---|
17 | FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. |
---|
18 | |
---|
19 | You should have received a copy of the GNU Lesser General Public License along with |
---|
20 | this program; if not, write to the Free Software Foundation, Inc., 59 Temple |
---|
21 | Place - Suite 330, Boston, MA 02111-1307, USA, or go to |
---|
22 | http://www.gnu.org/copyleft/lesser.txt. |
---|
23 | |
---|
24 | You may alternatively use this source under the terms of a specific version of |
---|
25 | the OGRE Unrestricted License provided you have obtained such a license from |
---|
26 | Torus Knot Software Ltd. |
---|
27 | ----------------------------------------------------------------------------- |
---|
28 | */ |
---|
29 | #ifndef __GLPIXELFORMAT_H__ |
---|
30 | #define __GLPIXELFORMAT_H__ |
---|
31 | |
---|
32 | #include "OgreGLPrerequisites.h" |
---|
33 | #include "OgrePixelFormat.h" |
---|
34 | namespace Ogre { |
---|
35 | |
---|
36 | /** |
---|
37 | * Class to do pixel format mapping between GL and OGRE |
---|
38 | */ |
---|
39 | class _OgrePrivate GLPixelUtil |
---|
40 | { |
---|
41 | public: |
---|
42 | /** Takes the OGRE pixel format and returns the appropriate GL one |
---|
43 | @returns a GLenum describing the format, or 0 if there is no exactly matching |
---|
44 | one (and conversion is needed) |
---|
45 | */ |
---|
46 | static GLenum getGLOriginFormat(PixelFormat mFormat); |
---|
47 | |
---|
48 | /** Takes the OGRE pixel format and returns type that must be provided |
---|
49 | to GL as data type for reading it into the GPU |
---|
50 | @returns a GLenum describing the data type, or 0 if there is no exactly matching |
---|
51 | one (and conversion is needed) |
---|
52 | */ |
---|
53 | static GLenum getGLOriginDataType(PixelFormat mFormat); |
---|
54 | |
---|
55 | /** Takes the OGRE pixel format and returns the type that must be provided |
---|
56 | to GL as internal format. GL_NONE if no match exists. |
---|
57 | */ |
---|
58 | static GLenum getGLInternalFormat(PixelFormat mFormat); |
---|
59 | |
---|
60 | /** Takes the OGRE pixel format and returns the type that must be provided |
---|
61 | to GL as internal format. If no match exists, returns the closest match. |
---|
62 | */ |
---|
63 | static GLenum getClosestGLInternalFormat(PixelFormat mFormat); |
---|
64 | |
---|
65 | /** Function to get the closest matching OGRE format to an internal GL format. To be |
---|
66 | precise, the format will be chosen that is most efficient to transfer to the card |
---|
67 | without losing precision. |
---|
68 | @remarks It is valid for this function to always return PF_A8R8G8B8. |
---|
69 | */ |
---|
70 | static PixelFormat getClosestOGREFormat(GLenum fmt); |
---|
71 | |
---|
72 | /** Returns the maximum number of Mipmaps that can be generated until we reach |
---|
73 | the mininum format possible. This does not count the base level. |
---|
74 | @param width |
---|
75 | The width of the area |
---|
76 | @param height |
---|
77 | The height of the area |
---|
78 | @param depth |
---|
79 | The depth of the area |
---|
80 | @param format |
---|
81 | The format of the area |
---|
82 | @remarks |
---|
83 | In case that the format is non-compressed, this simply returns |
---|
84 | how many times we can divide this texture in 2 until we reach 1x1. |
---|
85 | For compressed formats, constraints apply on minimum size and alignment |
---|
86 | so this might differ. |
---|
87 | */ |
---|
88 | static size_t getMaxMipmaps(size_t width, size_t height, size_t depth, PixelFormat format); |
---|
89 | |
---|
90 | /** Returns next power-of-two size if required by render system, in case |
---|
91 | RSC_NON_POWER_OF_2_TEXTURES is supported it returns value as-is. |
---|
92 | */ |
---|
93 | static size_t optionalPO2(size_t value); |
---|
94 | }; |
---|
95 | }; |
---|
96 | |
---|
97 | #endif |
---|