Code cleanup.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@798 dfc29bdd-3216-0410-991c-e03cc46cb475
master
hybrid 2007-07-17 23:47:10 +00:00
parent 80148ed319
commit 3f4fb37f5e
4 changed files with 33 additions and 31 deletions

View File

@ -165,6 +165,34 @@ COpenGLTexture::~COpenGLTexture()
}
ECOLOR_FORMAT COpenGLTexture::getBestColorFormat(ECOLOR_FORMAT format)
{
ECOLOR_FORMAT destFormat = ECF_A8R8G8B8;
switch (format)
{
case ECF_A1R5G5B5:
if (!Driver->getTextureCreationFlag(ETCF_ALWAYS_32_BIT))
destFormat = ECF_A1R5G5B5;
break;
case ECF_R5G6B5:
if (!Driver->getTextureCreationFlag(ETCF_ALWAYS_32_BIT))
destFormat = ECF_A1R5G5B5;
break;
case ECF_A8R8G8B8:
if (Driver->getTextureCreationFlag(ETCF_ALWAYS_16_BIT) ||
Driver->getTextureCreationFlag(ETCF_OPTIMIZED_FOR_SPEED))
destFormat = ECF_A1R5G5B5;
break;
case ECF_R8G8B8:
if (Driver->getTextureCreationFlag(ETCF_ALWAYS_16_BIT) ||
Driver->getTextureCreationFlag(ETCF_OPTIMIZED_FOR_SPEED))
destFormat = ECF_A1R5G5B5;
break;
}
return destFormat;
}
void COpenGLTexture::getImageData(IImage* image)
{
if (!image)
@ -190,28 +218,7 @@ void COpenGLTexture::getImageData(IImage* image)
nImageSize.Height = getTextureSizeFromSurfaceSize(ImageSize.Height);
}
ECOLOR_FORMAT destFormat = ECF_A8R8G8B8;
switch (image->getColorFormat())
{
case ECF_A1R5G5B5:
if (!Driver->getTextureCreationFlag(ETCF_ALWAYS_32_BIT))
destFormat = ECF_A1R5G5B5;
break;
case ECF_R5G6B5:
if (!Driver->getTextureCreationFlag(ETCF_ALWAYS_32_BIT))
destFormat = ECF_A1R5G5B5;
break;
case ECF_A8R8G8B8:
if (Driver->getTextureCreationFlag(ETCF_ALWAYS_16_BIT) ||
Driver->getTextureCreationFlag(ETCF_OPTIMIZED_FOR_SPEED))
destFormat = ECF_A1R5G5B5;
break;
case ECF_R8G8B8:
if (Driver->getTextureCreationFlag(ETCF_ALWAYS_16_BIT) ||
Driver->getTextureCreationFlag(ETCF_OPTIMIZED_FOR_SPEED))
destFormat = ECF_A1R5G5B5;
break;
}
ECOLOR_FORMAT destFormat = getBestColorFormat(image->getColorFormat());
if (ImageSize==nImageSize)
Image = new CImage(destFormat, image);
else

View File

@ -99,6 +99,10 @@ public:
private:
//! get the desired color format based on texture creation flags and the input format.
ECOLOR_FORMAT getBestColorFormat(ECOLOR_FORMAT format);
//! convert the image into an internal image with better properties for this driver.
void getImageData(IImage* image);
//! copies the the texture into an open gl texture.

View File

@ -1842,12 +1842,6 @@ IImage* CSoftwareDriver2::createScreenShot()
return new CImage(BackBuffer->getColorFormat(), BackBuffer);
}
//! Enables or disables a texture creation flag.
void CSoftwareDriver2::setTextureCreationFlag(E_TEXTURE_CREATION_FLAG flag, bool enabled)
{
CNullDriver::setTextureCreationFlag(flag,enabled);
}
//! returns a device dependent texture from a software surface (IImage)
//! THIS METHOD HAS TO BE OVERRIDDEN BY DERIVED DRIVERS WITH OWN TEXTURES

View File

@ -106,9 +106,6 @@ namespace video
//! Returns an image created from the last rendered frame.
virtual IImage* createScreenShot();
//! Enables or disables a texture creation flag.
virtual void setTextureCreationFlag(E_TEXTURE_CREATION_FLAG flag, bool enabled);
//! Returns the maximum amount of primitives (mostly vertices) which
//! the device is able to render with one drawIndexedTriangleList
//! call.