Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/OgreMain/include/OgreDDSCodec.h @ 3

Last change on this file since 3 was 3, checked in by anonymous, 17 years ago

=update

File size: 3.2 KB
Line 
1/*
2-----------------------------------------------------------------------------
3This source file is part of OGRE
4(Object-oriented Graphics Rendering Engine)
5For the latest info, see http://www.ogre3d.org/
6
7Copyright (c) 2000-2006 Torus Knot Software Ltd
8Also see acknowledgements in Readme.html
9
10This program is free software; you can redistribute it and/or modify it under
11the terms of the GNU Lesser General Public License as published by the Free Software
12Foundation; either version 2 of the License, or (at your option) any later
13version.
14
15This program is distributed in the hope that it will be useful, but WITHOUT
16ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
18
19You should have received a copy of the GNU Lesser General Public License along with
20this program; if not, write to the Free Software Foundation, Inc., 59 Temple
21Place - Suite 330, Boston, MA 02111-1307, USA, or go to
22http://www.gnu.org/copyleft/lesser.txt.
23
24You may alternatively use this source under the terms of a specific version of
25the OGRE Unrestricted License provided you have obtained such a license from
26Torus Knot Software Ltd.
27-----------------------------------------------------------------------------
28*/
29#ifndef __OgreDDSCodec_H__
30#define __OgreDDSCodec_H__
31
32#include "OgreImageCodec.h"
33namespace Ogre {
34
35        // Forward declarations
36        struct DXTColourBlock;
37        struct DXTExplicitAlphaBlock;
38        struct DXTInterpolatedAlphaBlock;
39
40    /** Codec specialized in loading DDS (Direct Draw Surface) images.
41        @remarks
42                We implement our own codec here since we need to be able to keep DXT
43                data compressed if the card supports it.
44    */
45    class _OgreExport DDSCodec : public ImageCodec
46    {
47    private:
48        String mType;
49
50        void flipEndian(void * pData, size_t size, size_t count) const;
51            void flipEndian(void * pData, size_t size) const;
52
53                PixelFormat convertFourCCFormat(uint32 fourcc) const;
54                PixelFormat convertPixelFormat(uint32 rgbBits, uint32 rMask, 
55                        uint32 gMask, uint32 bMask, uint32 aMask) const;
56
57                /// Unpack DXT colours into array of 16 colour values
58                void unpackDXTColour(PixelFormat pf, const DXTColourBlock& block, ColourValue* pCol) const;
59                /// Unpack DXT alphas into array of 16 colour values
60                void unpackDXTAlpha(const DXTExplicitAlphaBlock& block, ColourValue* pCol) const;
61                /// Unpack DXT alphas into array of 16 colour values
62                void unpackDXTAlpha(const DXTInterpolatedAlphaBlock& block, ColourValue* pCol) const;
63
64                /// Single registered codec instance
65                static DDSCodec* msInstance;
66        public:
67        DDSCodec();
68        virtual ~DDSCodec() { }
69
70        /// @copydoc Codec::code
71        DataStreamPtr code(MemoryDataStreamPtr& input, CodecDataPtr& pData) const;
72        /// @copydoc Codec::codeToFile
73        void codeToFile(MemoryDataStreamPtr& input, const String& outFileName, CodecDataPtr& pData) const;
74        /// @copydoc Codec::decode
75        DecodeResult decode(DataStreamPtr& input) const;
76
77       
78        virtual String getType() const;       
79
80                /// Static method to startup and register the DDS codec
81                static void startup(void);
82                /// Static method to shutdown and unregister the DDS codec
83                static void shutdown(void);
84
85    };
86
87} // namespace
88
89#endif
90
Note: See TracBrowser for help on using the repository browser.