aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/irrlicht-1.8.1/source/Irrlicht/CSoftwareTexture.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/irrlicht-1.8.1/source/Irrlicht/CSoftwareTexture.cpp')
-rw-r--r--libraries/irrlicht-1.8.1/source/Irrlicht/CSoftwareTexture.cpp151
1 files changed, 151 insertions, 0 deletions
diff --git a/libraries/irrlicht-1.8.1/source/Irrlicht/CSoftwareTexture.cpp b/libraries/irrlicht-1.8.1/source/Irrlicht/CSoftwareTexture.cpp
new file mode 100644
index 0000000..b446e7d
--- /dev/null
+++ b/libraries/irrlicht-1.8.1/source/Irrlicht/CSoftwareTexture.cpp
@@ -0,0 +1,151 @@
1// Copyright (C) 2002-2012 Nikolaus Gebhardt
2// This file is part of the "Irrlicht Engine".
3// For conditions of distribution and use, see copyright notice in irrlicht.h
4
5#include "IrrCompileConfig.h"
6#ifdef _IRR_COMPILE_WITH_SOFTWARE_
7
8#include "CSoftwareTexture.h"
9#include "os.h"
10
11namespace irr
12{
13namespace video
14{
15
16//! constructor
17CSoftwareTexture::CSoftwareTexture(IImage* image, const io::path& name,
18 bool renderTarget, void* mipmapData)
19: ITexture(name), Texture(0), IsRenderTarget(renderTarget)
20{
21 #ifdef _DEBUG
22 setDebugName("CSoftwareTexture");
23 #endif
24
25 if (image)
26 {
27 OrigSize = image->getDimension();
28 core::dimension2d<u32> optSize=OrigSize.getOptimalSize();
29
30 Image = new CImage(ECF_A1R5G5B5, OrigSize);
31 image->copyTo(Image);
32
33 if (optSize == OrigSize)
34 {
35 Texture = Image;
36 Texture->grab();
37 }
38 else
39 {
40 Texture = new CImage(ECF_A1R5G5B5, optSize);
41 Image->copyToScaling(Texture);
42 }
43 }
44}
45
46
47
48//! destructor
49CSoftwareTexture::~CSoftwareTexture()
50{
51 if (Image)
52 Image->drop();
53
54 if (Texture)
55 Texture->drop();
56}
57
58
59
60//! lock function
61void* CSoftwareTexture::lock(E_TEXTURE_LOCK_MODE mode, u32 mipmapLevel)
62{
63 return Image->lock();
64}
65
66
67
68//! unlock function
69void CSoftwareTexture::unlock()
70{
71 if (Image != Texture)
72 {
73 os::Printer::log("Performance warning, slow unlock of non power of 2 texture.", ELL_WARNING);
74 Image->copyToScaling(Texture);
75 }
76
77 Image->unlock();
78}
79
80
81//! Returns original size of the texture.
82const core::dimension2d<u32>& CSoftwareTexture::getOriginalSize() const
83{
84 return OrigSize;
85}
86
87
88//! Returns (=size) of the texture.
89const core::dimension2d<u32>& CSoftwareTexture::getSize() const
90{
91 return Image->getDimension();
92}
93
94
95//! returns unoptimized surface
96CImage* CSoftwareTexture::getImage()
97{
98 return Image;
99}
100
101
102
103//! returns texture surface
104CImage* CSoftwareTexture::getTexture()
105{
106 return Texture;
107}
108
109
110
111//! returns driver type of texture (=the driver, who created the texture)
112E_DRIVER_TYPE CSoftwareTexture::getDriverType() const
113{
114 return EDT_SOFTWARE;
115}
116
117
118
119//! returns color format of texture
120ECOLOR_FORMAT CSoftwareTexture::getColorFormat() const
121{
122 return ECF_A1R5G5B5;
123}
124
125
126
127//! returns pitch of texture (in bytes)
128u32 CSoftwareTexture::getPitch() const
129{
130 return Image->getDimension().Width * 2;
131}
132
133
134//! Regenerates the mip map levels of the texture. Useful after locking and
135//! modifying the texture
136void CSoftwareTexture::regenerateMipMapLevels(void* mipmapData)
137{
138 // our software textures don't have mip maps
139}
140
141bool CSoftwareTexture::isRenderTarget() const
142{
143 return IsRenderTarget;
144}
145
146
147} // end namespace video
148} // end namespace irr
149
150#endif // _IRR_COMPILE_WITH_SOFTWARE_
151