Fix up some texture format code

This commit is contained in:
Logan McNaughton 2016-12-20 08:57:13 -08:00
parent 3449324ab4
commit 3392f3996b
2 changed files with 24 additions and 26 deletions

View File

@ -51,6 +51,22 @@ void gl_ff_matrix(const math_matrix_4x4 *mat)
#endif
}
void size_format(GLint* internalFormat)
{
switch (*internalFormat)
{
case GL_RGB:
*internalFormat = GL_RGB565;
break;
case GL_RGBA:
#ifdef HAVE_OPENGLES2
*internalFormat = GL_RGBA8_OES;
#else
*internalFormat = GL_RGBA8;
#endif
break;
}
}
/* This function should only be used without mipmaps
and when data == NULL */
void gl_load_texture_image(GLenum target,
@ -67,36 +83,23 @@ void gl_load_texture_image(GLenum target,
#ifdef HAVE_OPENGLES2
if (gl_check_capability(GL_CAPS_TEX_STORAGE_EXT))
{
switch (internalFormat)
{
case GL_RGB:
internalFormat = GL_RGB565;
break;
case GL_RGBA:
internalFormat = GL_RGBA8_OES;
break;
case GL_BGRA_EXT:
internalFormat = GL_BGRA8_EXT;
break;
}
size_format(&internalFormat);
glTexStorage2DEXT(target, 1, internalFormat, width, height);
}
#else
if (gl_check_capability(GL_CAPS_TEX_STORAGE))
{
switch (internalFormat)
{
case GL_RGB:
internalFormat = GL_RGB565;
break;
case GL_RGBA:
internalFormat = GL_RGBA8;
break;
}
size_format(&internalFormat);
glTexStorage2D(target, 1, internalFormat, width, height);
}
#endif
else
#endif
{
#ifdef HAVE_OPENGLES
if (gl_check_capability(GL_CAPS_GLES3_SUPPORTED))
#endif
size_format(&internalFormat);
glTexImage2D(target, level, internalFormat, width, height, border, format, type, data);
}
}

View File

@ -121,12 +121,7 @@
#ifndef GL_BGRA8_EXT
#define GL_BGRA8_EXT 0x93A1
#endif
#ifdef IOS
/* Stupid Apple. */
#define RARCH_GL_INTERNAL_FORMAT32 GL_RGBA
#else
#define RARCH_GL_INTERNAL_FORMAT32 GL_BGRA_EXT
#endif
#define RARCH_GL_INTERNAL_FORMAT16 GL_RGB
#define RARCH_GL_TEXTURE_TYPE32 GL_BGRA_EXT
#define RARCH_GL_TEXTURE_TYPE16 GL_RGB