1
// Copyright (C) 2002-2011 Nikolaus Gebhardt
2
// This file is part of the "Irrlicht Engine".
3
// For conditions of distribution and use, see copyright notice in irrlicht.h
5
#include "IrrCompileConfig.h"
6
#ifdef _IRR_COMPILE_WITH_SOFTWARE_
8
#include "CSoftwareTexture.h"
17
CSoftwareTexture::CSoftwareTexture(IImage* image, const io::path& name,
18
bool renderTarget, void* mipmapData)
19
: ITexture(name), Texture(0), IsRenderTarget(renderTarget)
22
setDebugName("CSoftwareTexture");
27
OrigSize = image->getDimension();
28
core::dimension2d<u32> optSize=OrigSize.getOptimalSize();
30
Image = new CImage(ECF_A1R5G5B5, OrigSize);
33
if (optSize == OrigSize)
40
Texture = new CImage(ECF_A1R5G5B5, optSize);
41
Image->copyToScaling(Texture);
49
CSoftwareTexture::~CSoftwareTexture()
61
void* CSoftwareTexture::lock(E_TEXTURE_LOCK_MODE mode, u32 mipmapLevel)
69
void CSoftwareTexture::unlock()
73
os::Printer::log("Performance warning, slow unlock of non power of 2 texture.", ELL_WARNING);
74
Image->copyToScaling(Texture);
81
//! Returns original size of the texture.
82
const core::dimension2d<u32>& CSoftwareTexture::getOriginalSize() const
88
//! Returns (=size) of the texture.
89
const core::dimension2d<u32>& CSoftwareTexture::getSize() const
91
return Image->getDimension();
95
//! returns unoptimized surface
96
CImage* CSoftwareTexture::getImage()
103
//! returns texture surface
104
CImage* CSoftwareTexture::getTexture()
111
//! returns driver type of texture (=the driver, who created the texture)
112
E_DRIVER_TYPE CSoftwareTexture::getDriverType() const
119
//! returns color format of texture
120
ECOLOR_FORMAT CSoftwareTexture::getColorFormat() const
127
//! returns pitch of texture (in bytes)
128
u32 CSoftwareTexture::getPitch() const
130
return Image->getDimension().Width * 2;
134
//! Regenerates the mip map levels of the texture. Useful after locking and
135
//! modifying the texture
136
void CSoftwareTexture::regenerateMipMapLevels(void* mipmapData)
138
// our software textures don't have mip maps
141
bool CSoftwareTexture::isRenderTarget() const
143
return IsRenderTarget;
147
} // end namespace video
148
} // end namespace irr
150
#endif // _IRR_COMPILE_WITH_SOFTWARE_