~baltix/+junk/irrlicht-test

« back to all changes in this revision

Viewing changes to source/Irrlicht/CSoftwareTexture2.h

  • Committer: Mantas Kriaučiūnas
  • Date: 2011-07-18 13:06:25 UTC
  • Revision ID: mantas@akl.lt-20110718130625-c5pvifp61e7kj1ol
Included whole irrlicht SVN libraries to work around launchpad recipe issue with quilt, see https://answers.launchpad.net/launchpad/+question/165193

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Copyright (C) 2002-2011 Nikolaus Gebhardt / Thomas Alten
 
2
// This file is part of the "Irrlicht Engine".
 
3
// For conditions of distribution and use, see copyright notice in irrlicht.h
 
4
 
 
5
#ifndef __C_SOFTWARE_2_TEXTURE_H_INCLUDED__
 
6
#define __C_SOFTWARE_2_TEXTURE_H_INCLUDED__
 
7
 
 
8
#include "SoftwareDriver2_compile_config.h"
 
9
 
 
10
#include "ITexture.h"
 
11
#include "CImage.h"
 
12
 
 
13
namespace irr
 
14
{
 
15
namespace video
 
16
{
 
17
 
 
18
/*!
 
19
        interface for a Video Driver dependent Texture.
 
20
*/
 
21
class CSoftwareTexture2 : public ITexture
 
22
{
 
23
public:
 
24
 
 
25
        //! constructor
 
26
        enum eTex2Flags
 
27
        {
 
28
                GEN_MIPMAP      = 1,
 
29
                IS_RENDERTARGET = 2,
 
30
                NP2_SIZE        = 4,
 
31
                HAS_ALPHA       = 8
 
32
        };
 
33
        CSoftwareTexture2(IImage* surface, const io::path& name, u32 flags, void* mipmapData=0);
 
34
 
 
35
        //! destructor
 
36
        virtual ~CSoftwareTexture2();
 
37
 
 
38
        //! lock function
 
39
        virtual void* lock(E_TEXTURE_LOCK_MODE mode=ETLM_READ_WRITE, u32 mipmapLevel=0)
 
40
        {
 
41
                if (Flags & GEN_MIPMAP)
 
42
                        MipMapLOD=mipmapLevel;
 
43
                return MipMap[MipMapLOD]->lock();
 
44
        }
 
45
 
 
46
        //! unlock function
 
47
        virtual void unlock()
 
48
        {
 
49
                MipMap[MipMapLOD]->unlock();
 
50
        }
 
51
 
 
52
        //! Returns original size of the texture.
 
53
        virtual const core::dimension2d<u32>& getOriginalSize() const
 
54
        {
 
55
                //return MipMap[0]->getDimension();
 
56
                return OrigSize;
 
57
        }
 
58
 
 
59
        //! Returns the size of the largest mipmap.
 
60
        f32 getLODFactor( const f32 texArea ) const
 
61
        {
 
62
                return OrigImageDataSizeInPixels * texArea;
 
63
                //return MipMap[0]->getImageDataSizeInPixels () * texArea;
 
64
        }
 
65
 
 
66
        //! Returns (=size) of the texture.
 
67
        virtual const core::dimension2d<u32>& getSize() const
 
68
        {
 
69
                return MipMap[MipMapLOD]->getDimension();
 
70
        }
 
71
 
 
72
        //! returns unoptimized surface
 
73
        virtual CImage* getImage() const
 
74
        {
 
75
                return MipMap[0];
 
76
        }
 
77
 
 
78
        //! returns texture surface
 
79
        virtual CImage* getTexture() const
 
80
        {
 
81
                return MipMap[MipMapLOD];
 
82
        }
 
83
 
 
84
 
 
85
        //! returns driver type of texture (=the driver, who created the texture)
 
86
        virtual E_DRIVER_TYPE getDriverType() const
 
87
        {
 
88
                return EDT_BURNINGSVIDEO;
 
89
        }
 
90
 
 
91
        //! returns color format of texture
 
92
        virtual ECOLOR_FORMAT getColorFormat() const
 
93
        {
 
94
                return BURNINGSHADER_COLOR_FORMAT;
 
95
        }
 
96
 
 
97
        //! returns pitch of texture (in bytes)
 
98
        virtual u32 getPitch() const
 
99
        {
 
100
                return MipMap[MipMapLOD]->getPitch();
 
101
        }
 
102
 
 
103
        //! Regenerates the mip map levels of the texture. Useful after locking and
 
104
        //! modifying the texture
 
105
        virtual void regenerateMipMapLevels(void* mipmapData=0);
 
106
 
 
107
        //! support mipmaps
 
108
        virtual bool hasMipMaps() const
 
109
        {
 
110
                return (Flags & GEN_MIPMAP ) != 0;
 
111
        }
 
112
 
 
113
        //! Returns if the texture has an alpha channel
 
114
        virtual bool hasAlpha() const
 
115
        {
 
116
                return (Flags & HAS_ALPHA ) != 0;
 
117
        }
 
118
 
 
119
        //! is a render target
 
120
        virtual bool isRenderTarget() const
 
121
        {
 
122
                return (Flags & IS_RENDERTARGET) != 0;
 
123
        }
 
124
 
 
125
private:
 
126
        f32 OrigImageDataSizeInPixels;
 
127
        core::dimension2d<u32> OrigSize;
 
128
 
 
129
        CImage * MipMap[SOFTWARE_DRIVER_2_MIPMAPPING_MAX];
 
130
 
 
131
        u32 MipMapLOD;
 
132
        u32 Flags;
 
133
        ECOLOR_FORMAT OriginalFormat;
 
134
};
 
135
 
 
136
 
 
137
} // end namespace video
 
138
} // end namespace irr
 
139
 
 
140
#endif
 
141