2014-10-02 11:27:35 +00:00
|
|
|
/* RetroArch - A frontend for libretro.
|
|
|
|
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
2017-01-22 12:40:32 +00:00
|
|
|
* Copyright (C) 2011-2017 - Daniel De Matteis
|
2014-10-02 11:27:35 +00:00
|
|
|
*
|
|
|
|
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
|
|
|
* of the GNU General Public License as published by the Free Software Found-
|
|
|
|
* ation, either version 3 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
|
|
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE. See the GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along with RetroArch.
|
|
|
|
* If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2016-09-08 06:15:40 +00:00
|
|
|
#include <gfx/math/matrix_4x4.h>
|
2016-12-14 15:29:37 +00:00
|
|
|
#include <gfx/gl_capabilities.h>
|
2016-09-08 06:15:40 +00:00
|
|
|
|
2016-12-21 15:09:29 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "../../config.h"
|
|
|
|
#endif
|
|
|
|
|
2016-10-24 02:02:03 +00:00
|
|
|
#include "../drivers/gl_symlinks.h"
|
2016-09-05 05:44:17 +00:00
|
|
|
#include "../video_coord_array.h"
|
|
|
|
|
2016-05-10 00:32:49 +00:00
|
|
|
void gl_ff_vertex(const struct video_coords *coords)
|
2015-03-30 00:59:39 +00:00
|
|
|
{
|
|
|
|
#ifndef NO_GL_FF_VERTEX
|
|
|
|
/* Fall back to fixed function-style if needed and possible. */
|
|
|
|
glClientActiveTexture(GL_TEXTURE1);
|
|
|
|
glTexCoordPointer(2, GL_FLOAT, 0, coords->lut_tex_coord);
|
|
|
|
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
|
|
|
glClientActiveTexture(GL_TEXTURE0);
|
|
|
|
glVertexPointer(2, GL_FLOAT, 0, coords->vertex);
|
|
|
|
glEnableClientState(GL_VERTEX_ARRAY);
|
|
|
|
glColorPointer(4, GL_FLOAT, 0, coords->color);
|
|
|
|
glEnableClientState(GL_COLOR_ARRAY);
|
|
|
|
glTexCoordPointer(2, GL_FLOAT, 0, coords->tex_coord);
|
|
|
|
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2016-04-17 03:00:42 +00:00
|
|
|
void gl_ff_matrix(const math_matrix_4x4 *mat)
|
2015-03-30 00:59:39 +00:00
|
|
|
{
|
|
|
|
#ifndef NO_GL_FF_MATRIX
|
2016-02-14 02:47:33 +00:00
|
|
|
math_matrix_4x4 ident;
|
2015-03-30 00:59:39 +00:00
|
|
|
|
|
|
|
/* Fall back to fixed function-style if needed and possible. */
|
|
|
|
glMatrixMode(GL_PROJECTION);
|
|
|
|
glLoadMatrixf(mat->data);
|
|
|
|
glMatrixMode(GL_MODELVIEW);
|
2016-02-14 02:47:33 +00:00
|
|
|
matrix_4x4_identity(&ident);
|
|
|
|
glLoadMatrixf(ident.data);
|
2015-03-30 00:59:39 +00:00
|
|
|
#endif
|
|
|
|
}
|
2016-12-14 15:29:37 +00:00
|
|
|
|
2016-12-21 14:47:19 +00:00
|
|
|
static void gl_size_format(GLint* internalFormat)
|
2016-12-20 16:57:13 +00:00
|
|
|
{
|
2016-12-21 15:06:24 +00:00
|
|
|
#ifndef HAVE_PSGL
|
2016-12-20 16:57:13 +00:00
|
|
|
switch (*internalFormat)
|
|
|
|
{
|
|
|
|
case GL_RGB:
|
2016-12-21 14:47:19 +00:00
|
|
|
/* FIXME: PS3 does not support this, neither does it have GL_RGB565_OES. */
|
2016-12-20 16:57:13 +00:00
|
|
|
*internalFormat = GL_RGB565;
|
|
|
|
break;
|
|
|
|
case GL_RGBA:
|
|
|
|
#ifdef HAVE_OPENGLES2
|
|
|
|
*internalFormat = GL_RGBA8_OES;
|
|
|
|
#else
|
2016-12-26 20:00:38 +00:00
|
|
|
*internalFormat = GL_RGBA8;
|
2016-12-20 16:57:13 +00:00
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
}
|
2016-12-21 15:06:24 +00:00
|
|
|
#endif
|
2016-12-20 16:57:13 +00:00
|
|
|
}
|
2016-12-21 15:06:24 +00:00
|
|
|
|
2016-12-14 15:29:37 +00:00
|
|
|
/* This function should only be used without mipmaps
|
|
|
|
and when data == NULL */
|
2016-12-14 15:59:16 +00:00
|
|
|
void gl_load_texture_image(GLenum target,
|
2016-12-14 15:29:37 +00:00
|
|
|
GLint level,
|
|
|
|
GLint internalFormat,
|
|
|
|
GLsizei width,
|
|
|
|
GLsizei height,
|
|
|
|
GLint border,
|
|
|
|
GLenum format,
|
|
|
|
GLenum type,
|
|
|
|
const GLvoid * data)
|
|
|
|
{
|
|
|
|
#ifndef HAVE_PSGL
|
|
|
|
#ifdef HAVE_OPENGLES2
|
2016-12-31 04:14:30 +00:00
|
|
|
if (gl_check_capability(GL_CAPS_TEX_STORAGE_EXT) && internalFormat != GL_BGRA_EXT)
|
2016-12-14 18:29:14 +00:00
|
|
|
{
|
2016-12-21 14:47:19 +00:00
|
|
|
gl_size_format(&internalFormat);
|
2016-12-14 15:29:37 +00:00
|
|
|
glTexStorage2DEXT(target, 1, internalFormat, width, height);
|
2016-12-14 17:54:55 +00:00
|
|
|
}
|
2016-12-14 15:29:37 +00:00
|
|
|
#else
|
2016-12-30 17:42:26 +00:00
|
|
|
if (gl_check_capability(GL_CAPS_TEX_STORAGE) && internalFormat != GL_BGRA_EXT)
|
2016-12-14 18:29:14 +00:00
|
|
|
{
|
2016-12-21 14:47:19 +00:00
|
|
|
gl_size_format(&internalFormat);
|
2016-12-14 15:29:37 +00:00
|
|
|
glTexStorage2D(target, 1, internalFormat, width, height);
|
2016-12-14 17:54:55 +00:00
|
|
|
}
|
2016-12-14 15:29:37 +00:00
|
|
|
#endif
|
|
|
|
else
|
|
|
|
#endif
|
2016-12-20 16:57:13 +00:00
|
|
|
{
|
|
|
|
#ifdef HAVE_OPENGLES
|
|
|
|
if (gl_check_capability(GL_CAPS_GLES3_SUPPORTED))
|
|
|
|
#endif
|
2016-12-21 14:47:19 +00:00
|
|
|
gl_size_format(&internalFormat);
|
2016-12-14 15:29:37 +00:00
|
|
|
glTexImage2D(target, level, internalFormat, width, height, border, format, type, data);
|
2016-12-20 16:57:13 +00:00
|
|
|
}
|
2016-12-14 15:29:37 +00:00
|
|
|
}
|