Make color format method available to all texture types.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@2803 dfc29bdd-3216-0410-991c-e03cc46cb475
master
hybrid 2009-11-04 15:08:14 +00:00
parent 14e47232ea
commit 9f7c98bb38
2 changed files with 97 additions and 95 deletions

View File

@ -120,6 +120,99 @@ ECOLOR_FORMAT COpenGLTexture::getBestColorFormat(ECOLOR_FORMAT format)
}
GLint COpenGLTexture::getOpenGLFormatAndParametersFromColorFormat(ECOLOR_FORMAT format,
GLint& filtering,
GLenum& colorformat,
GLenum& type)
{
// default
filtering = GL_LINEAR;
colorformat = GL_RGBA;
type = GL_UNSIGNED_BYTE;
switch(format)
{
// Floating Point texture formats. Thanks to Patryk "Nadro" Nadrowski.
case ECF_R16F:
{
#ifdef GL_ARB_texture_rg
filtering = GL_NEAREST;
colorformat = GL_RED;
type = GL_FLOAT;
return GL_R16F;
#else
return GL_RGB8;
#endif
}
case ECF_G16R16F:
{
#ifdef GL_ARB_texture_rg
filtering = GL_NEAREST;
colorformat = GL_RG;
type = GL_FLOAT;
return GL_RG16F;
#else
return GL_RGB8;
#endif
}
case ECF_A16B16G16R16F:
{
#ifdef GL_ARB_texture_rg
filtering = GL_NEAREST;
colorformat = GL_RGBA;
type = GL_FLOAT;
return GL_RGBA16F_ARB;
#else
return GL_RGBA8;
#endif
}
case ECF_R32F:
{
#ifdef GL_ARB_texture_rg
filtering = GL_NEAREST;
colorformat = GL_RED;
type = GL_FLOAT;
return GL_R32F;
#else
return GL_RGB8;
#endif
}
case ECF_G32R32F:
{
#ifdef GL_ARB_texture_rg
filtering = GL_NEAREST;
colorformat = GL_RG;
type = GL_FLOAT;
return GL_RG32F;
#else
return GL_RGB8;
#endif
}
case ECF_A32B32G32R32F:
{
#ifdef GL_ARB_texture_float
filtering = GL_NEAREST;
colorformat = GL_RGBA;
type = GL_FLOAT;
return GL_RGBA32F_ARB;
#else
return GL_RGBA8;
#endif
}
default:
{
return GL_RGBA8;
}
}
}
void COpenGLTexture::getImageData(IImage* image)
{
if (!image)
@ -492,98 +585,6 @@ COpenGLFBOTexture::COpenGLFBOTexture(const core::dimension2d<u32>& size,
unbindRTT();
}
GLint COpenGLFBOTexture::getOpenGLFormatAndParametersFromColorFormat(ECOLOR_FORMAT format,
GLint& filtering,
GLenum& colorformat,
GLenum& type)
{
// default
filtering = GL_LINEAR;
colorformat = GL_RGBA;
type = GL_UNSIGNED_BYTE;
switch(format)
{
// Floating Point texture formats. Thanks to Patryk "Nadro" Nadrowski.
case ECF_R16F:
{
#ifdef GL_ARB_texture_rg
filtering = GL_NEAREST;
colorformat = GL_RED;
type = GL_FLOAT;
return GL_R16F;
#else
return GL_RGB8;
#endif
}
case ECF_G16R16F:
{
#ifdef GL_ARB_texture_rg
filtering = GL_NEAREST;
colorformat = GL_RG;
type = GL_FLOAT;
return GL_RG16F;
#else
return GL_RGB8;
#endif
}
case ECF_A16B16G16R16F:
{
#ifdef GL_ARB_texture_rg
filtering = GL_NEAREST;
colorformat = GL_RGBA;
type = GL_FLOAT;
return GL_RGBA16F_ARB;
#else
return GL_RGBA8;
#endif
}
case ECF_R32F:
{
#ifdef GL_ARB_texture_rg
filtering = GL_NEAREST;
colorformat = GL_RED;
type = GL_FLOAT;
return GL_R32F;
#else
return GL_RGB8;
#endif
}
case ECF_G32R32F:
{
#ifdef GL_ARB_texture_rg
filtering = GL_NEAREST;
colorformat = GL_RG;
type = GL_FLOAT;
return GL_RG32F;
#else
return GL_RGB8;
#endif
}
case ECF_A32B32G32R32F:
{
#ifdef GL_ARB_texture_float
filtering = GL_NEAREST;
colorformat = GL_RGBA;
type = GL_FLOAT;
return GL_RGBA32F_ARB;
#else
return GL_RGBA8;
#endif
}
default:
{
return GL_RGBA8;
}
}
}
//! destructor
COpenGLFBOTexture::~COpenGLFBOTexture()

View File

@ -110,6 +110,10 @@ protected:
//! get the desired color format based on texture creation flags and the input format.
ECOLOR_FORMAT getBestColorFormat(ECOLOR_FORMAT format);
//! Get the OpenGL color format parameters based on the given Irrlicht color format
GLint getOpenGLFormatAndParametersFromColorFormat(
ECOLOR_FORMAT format, GLint& filtering, GLenum& colorformat, GLenum& type);
//! convert the image into an internal image with better properties for this driver.
void getImageData(IImage* image);
@ -159,9 +163,6 @@ public:
ITexture* DepthTexture;
protected:
GLint getOpenGLFormatAndParametersFromColorFormat(
ECOLOR_FORMAT format, GLint& filtering, GLenum& colorformat, GLenum& type);
GLuint ColorFrameBuffer;
};