Use dummy texture in null driver and software texture only in software driver. Use the dimension function for optimal texture sizes instead of local one.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@2397 dfc29bdd-3216-0410-991c-e03cc46cb475
master
hybrid 2009-05-17 23:37:02 +00:00
parent 352e1955a5
commit 274c52d5e0
5 changed files with 14 additions and 26 deletions

View File

@ -3,7 +3,6 @@
// For conditions of distribution and use, see copyright notice in irrlicht.h
#include "CNullDriver.h"
#include "CSoftwareTexture.h"
#include "os.h"
#include "CImage.h"
#include "CAttributes.h"
@ -529,11 +528,7 @@ ITexture* CNullDriver::addTexture(const core::dimension2d<u32>& size,
//! THIS METHOD HAS TO BE OVERRIDDEN BY DERIVED DRIVERS WITH OWN TEXTURES
ITexture* CNullDriver::createDeviceDependentTexture(IImage* surface, const core::string<c16>& name)
{
#ifdef _IRR_COMPILE_WITH_SOFTWARE_
return new CSoftwareTexture(surface, name);
#else
return 0;
#endif
return new SDummyTexture(name);
}

View File

@ -239,6 +239,14 @@ bool CSoftwareDriver::endScene()
}
//! returns a device dependent texture from a software surface (IImage)
//! THIS METHOD HAS TO BE OVERRIDDEN BY DERIVED DRIVERS WITH OWN TEXTURES
ITexture* CSoftwareDriver::createDeviceDependentTexture(IImage* surface, const core::string<c16>& name)
{
return new CSoftwareTexture(surface, name);
}
//! sets a render target
bool CSoftwareDriver::setRenderTarget(video::ITexture* texture, bool clearBackBuffer,
bool clearZBuffer, SColor color)

View File

@ -99,6 +99,10 @@ namespace video
//! Returns the transformation set by setTransform
virtual const core::matrix4& getTransform(E_TRANSFORMATION_STATE state) const;
//! returns a device dependent texture from a software surface (IImage)
//! THIS METHOD HAS TO BE OVERRIDDEN BY DERIVED DRIVERS WITH OWN TEXTURES
virtual video::ITexture* createDeviceDependentTexture(IImage* surface, const core::string<c16>& name);
//! Creates a render target texture.
virtual ITexture* addRenderTargetTexture(const core::dimension2d<u32>& size,
const core::string<c16>& name);

View File

@ -23,11 +23,8 @@ CSoftwareTexture::CSoftwareTexture(IImage* image, const core::string<c16>& name,
if (image)
{
core::dimension2d<u32> optSize;
OrigSize = image->getDimension();
optSize.Width = getTextureSizeFromSurfaceSize(OrigSize.Width);
optSize.Height = getTextureSizeFromSurfaceSize(OrigSize.Height);
core::dimension2d<u32> optSize=OrigSize.getOptimalSize();
Image = new CImage(ECF_A1R5G5B5, image);
@ -109,18 +106,6 @@ CImage* CSoftwareTexture::getTexture()
//! returns the size of a texture which would be the optimize size for rendering it
inline s32 CSoftwareTexture::getTextureSizeFromSurfaceSize(s32 size) const
{
s32 ts = 0x01;
while(ts < size)
ts <<= 1;
return ts;
}
//! returns driver type of texture (=the driver, who created the texture)
E_DRIVER_TYPE CSoftwareTexture::getDriverType() const
{

View File

@ -61,10 +61,6 @@ public:
virtual bool isRenderTarget() const;
private:
//! returns the size of a texture which would be the optimize size for rendering it
inline s32 getTextureSizeFromSurfaceSize(s32 size) const;
CImage* Image;
CImage* Texture;
core::dimension2d<u32> OrigSize;