Added OpenGL support for pixel formats A8/L8/LA8
Former-commit-id: b17942f7bf22daf90ddf5d8093da6c26b64a67ce
This commit is contained in:
@@ -1463,10 +1463,41 @@ void NzOpenGL::SetViewport(const NzRecti& viewport)
|
||||
|
||||
bool NzOpenGL::TranslateFormat(nzPixelFormat pixelFormat, Format* format, FormatType type)
|
||||
{
|
||||
// Par défaut
|
||||
format->swizzle[0] = GL_RED;
|
||||
format->swizzle[1] = GL_GREEN;
|
||||
format->swizzle[2] = GL_BLUE;
|
||||
format->swizzle[3] = GL_ALPHA;
|
||||
|
||||
switch (pixelFormat)
|
||||
{
|
||||
case nzPixelFormat_A8:
|
||||
return false; ///FIXME: Tester le mode d'OpenGL pour se permettre une fonctionnalité dépréciée ?
|
||||
if (type == FormatType_Texture) // Format supporté uniquement par les textures
|
||||
{
|
||||
if (GetVersion() >= 300)
|
||||
{
|
||||
format->dataFormat = GL_RED;
|
||||
format->dataType = GL_UNSIGNED_BYTE;
|
||||
format->internalFormat = GL_R8;
|
||||
|
||||
// Simulation du format
|
||||
format->swizzle[0] = GL_ONE;
|
||||
format->swizzle[1] = GL_ONE;
|
||||
format->swizzle[2] = GL_ONE;
|
||||
format->swizzle[3] = GL_RED;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Le bon vieux format GL_ALPHA
|
||||
format->dataFormat = GL_ALPHA;
|
||||
format->dataType = GL_UNSIGNED_BYTE;
|
||||
format->internalFormat = GL_ALPHA;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
|
||||
case nzPixelFormat_BGR8:
|
||||
format->dataFormat = GL_BGR;
|
||||
@@ -1499,8 +1530,58 @@ bool NzOpenGL::TranslateFormat(nzPixelFormat pixelFormat, Format* format, Format
|
||||
return true;
|
||||
|
||||
case nzPixelFormat_L8:
|
||||
if (type == FormatType_Texture) // Format supporté uniquement par les textures
|
||||
{
|
||||
if (GetVersion() >= 300)
|
||||
{
|
||||
format->dataFormat = GL_RED;
|
||||
format->dataType = GL_UNSIGNED_BYTE;
|
||||
format->internalFormat = GL_R8;
|
||||
|
||||
// Simulation du format
|
||||
format->swizzle[0] = GL_RED;
|
||||
format->swizzle[1] = GL_RED;
|
||||
format->swizzle[2] = GL_RED;
|
||||
format->swizzle[3] = GL_ONE;
|
||||
}
|
||||
else
|
||||
{
|
||||
format->dataFormat = 0x1909; // GL_LUMINANCE
|
||||
format->dataType = GL_UNSIGNED_BYTE;
|
||||
format->internalFormat = 0x1909; // GL_LUMINANCE
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
|
||||
case nzPixelFormat_LA8:
|
||||
return false;
|
||||
if (type == FormatType_Texture) // Format supporté uniquement par les textures
|
||||
{
|
||||
if (GetVersion() >= 300)
|
||||
{
|
||||
format->dataFormat = GL_RG;
|
||||
format->dataType = GL_UNSIGNED_BYTE;
|
||||
format->internalFormat = GL_RG8;
|
||||
|
||||
// Simulation du format
|
||||
format->swizzle[0] = GL_RED;
|
||||
format->swizzle[1] = GL_RED;
|
||||
format->swizzle[2] = GL_RED;
|
||||
format->swizzle[3] = GL_GREEN;
|
||||
}
|
||||
else
|
||||
{
|
||||
format->dataFormat = 0x190A; // GL_LUMINANCE_ALPHA
|
||||
format->dataType = GL_UNSIGNED_BYTE;
|
||||
format->internalFormat = 0x190A; // GL_LUMINANCE_ALPHA;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
|
||||
case nzPixelFormat_R8:
|
||||
format->dataFormat = GL_RED;
|
||||
|
||||
Reference in New Issue
Block a user