Commit 3f4fb37f authored by hybrid's avatar hybrid

Code cleanup.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@798 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 80148ed3
...@@ -165,6 +165,34 @@ COpenGLTexture::~COpenGLTexture() ...@@ -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) void COpenGLTexture::getImageData(IImage* image)
{ {
if (!image) if (!image)
...@@ -190,28 +218,7 @@ void COpenGLTexture::getImageData(IImage* image) ...@@ -190,28 +218,7 @@ void COpenGLTexture::getImageData(IImage* image)
nImageSize.Height = getTextureSizeFromSurfaceSize(ImageSize.Height); nImageSize.Height = getTextureSizeFromSurfaceSize(ImageSize.Height);
} }
ECOLOR_FORMAT destFormat = ECF_A8R8G8B8; ECOLOR_FORMAT destFormat = getBestColorFormat(image->getColorFormat());
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;
}
if (ImageSize==nImageSize) if (ImageSize==nImageSize)
Image = new CImage(destFormat, image); Image = new CImage(destFormat, image);
else else
......
...@@ -99,6 +99,10 @@ public: ...@@ -99,6 +99,10 @@ public:
private: 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); void getImageData(IImage* image);
//! copies the the texture into an open gl texture. //! copies the the texture into an open gl texture.
......
...@@ -1842,12 +1842,6 @@ IImage* CSoftwareDriver2::createScreenShot() ...@@ -1842,12 +1842,6 @@ IImage* CSoftwareDriver2::createScreenShot()
return new CImage(BackBuffer->getColorFormat(), BackBuffer); 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) //! returns a device dependent texture from a software surface (IImage)
//! THIS METHOD HAS TO BE OVERRIDDEN BY DERIVED DRIVERS WITH OWN TEXTURES //! THIS METHOD HAS TO BE OVERRIDDEN BY DERIVED DRIVERS WITH OWN TEXTURES
......
...@@ -106,9 +106,6 @@ namespace video ...@@ -106,9 +106,6 @@ namespace video
//! Returns an image created from the last rendered frame. //! Returns an image created from the last rendered frame.
virtual IImage* createScreenShot(); 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 //! Returns the maximum amount of primitives (mostly vertices) which
//! the device is able to render with one drawIndexedTriangleList //! the device is able to render with one drawIndexedTriangleList
//! call. //! call.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment