2012-04-21 21:13:50 +00:00
|
|
|
/* RetroArch - A frontend for libretro.
|
2014-01-01 00:50:59 +00:00
|
|
|
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
2011-01-11 21:13:55 +00:00
|
|
|
*
|
2012-04-21 21:13:50 +00:00
|
|
|
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
2011-01-11 21:13:55 +00:00
|
|
|
* 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.
|
|
|
|
*
|
2012-04-21 21:13:50 +00:00
|
|
|
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
2011-01-11 21:13:55 +00:00
|
|
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE. See the GNU General Public License for more details.
|
|
|
|
*
|
2012-04-21 21:31:57 +00:00
|
|
|
* You should have received a copy of the GNU General Public License along with RetroArch.
|
2011-01-11 21:13:55 +00:00
|
|
|
* If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __GL_COMMON_H
|
|
|
|
#define __GL_COMMON_H
|
|
|
|
|
2011-11-30 17:31:09 +00:00
|
|
|
#include "../general.h"
|
2012-05-27 00:04:50 +00:00
|
|
|
#include "fonts/fonts.h"
|
2012-08-09 20:33:32 +00:00
|
|
|
#include "math/matrix.h"
|
2012-09-24 23:26:22 +00:00
|
|
|
#include "gfx_context.h"
|
2012-10-01 22:58:43 +00:00
|
|
|
#include "scaler/scaler.h"
|
2012-12-14 23:27:30 +00:00
|
|
|
#include "fonts/gl_font.h"
|
2013-04-06 09:30:56 +00:00
|
|
|
#include "shader_parse.h"
|
2011-05-18 20:11:34 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
2011-11-30 17:31:09 +00:00
|
|
|
#include "../config.h"
|
2011-05-18 20:11:34 +00:00
|
|
|
#endif
|
2011-01-11 21:13:55 +00:00
|
|
|
|
2012-09-10 21:17:48 +00:00
|
|
|
#include <string.h>
|
|
|
|
|
2012-10-20 03:08:53 +00:00
|
|
|
#ifdef HAVE_EGL
|
|
|
|
#include <EGL/egl.h>
|
|
|
|
#include <EGL/eglext.h>
|
|
|
|
#endif
|
|
|
|
|
2013-07-05 16:15:42 +00:00
|
|
|
#include "glsym/glsym.h"
|
2011-03-14 21:09:35 +00:00
|
|
|
|
2014-03-09 15:50:18 +00:00
|
|
|
#define context_get_video_size_func(gl, win, height) gl->ctx_driver->get_video_size(gl, win, height)
|
|
|
|
#define context_update_window_title_func(gl) gl->ctx_driver->update_window_title(gl)
|
|
|
|
#define context_destroy_func(gl) gl->ctx_driver->destroy(gl)
|
|
|
|
#define context_translate_aspect_func(gl, width, height) gl->ctx_driver->translate_aspect(gl, width, height)
|
|
|
|
#define context_set_resize_func(gl, width, height) gl->ctx_driver->set_resize(gl, width, height)
|
|
|
|
#define context_swap_buffers_func(gl) gl->ctx_driver->swap_buffers(gl)
|
|
|
|
#define context_swap_interval_func(gl, var) gl->ctx_driver->swap_interval(gl, var)
|
|
|
|
#define context_has_focus_func(gl) gl->ctx_driver->has_focus(gl)
|
2014-04-19 14:59:26 +00:00
|
|
|
#define context_bind_hw_render(gl, enable) if (gl->shared_context_use && gl->ctx_driver->bind_hw_render) gl->ctx_driver->bind_hw_render(gl, enable)
|
2014-03-09 15:50:18 +00:00
|
|
|
#define context_check_window_func(gl, quit, resize, width, height, frame_count) \
|
|
|
|
gl->ctx_driver->check_window(gl, quit, resize, width, height, frame_count)
|
2012-12-02 09:49:17 +00:00
|
|
|
|
2014-03-09 15:50:18 +00:00
|
|
|
#define context_set_video_mode_func(gl, width, height, fullscreen) gl->ctx_driver->set_video_mode(gl, width, height, fullscreen)
|
|
|
|
#define context_input_driver_func(gl, input, input_data) gl->ctx_driver->input_driver(gl, input, input_data)
|
2012-11-03 08:18:31 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_EGL
|
2014-03-09 15:50:18 +00:00
|
|
|
#define context_init_egl_image_buffer_func(gl, video) gl->ctx_driver->init_egl_image_buffer(gl, video)
|
|
|
|
#define context_write_egl_image_func(gl, frame, width, height, pitch, base_size, tex_index, img) \
|
|
|
|
gl->ctx_driver->write_egl_image(gl, frame, width, height, pitch, base_size, tex_index,img)
|
2012-11-03 08:18:31 +00:00
|
|
|
#endif
|
|
|
|
|
2014-08-12 03:28:43 +00:00
|
|
|
#if (!defined(HAVE_OPENGLES) || defined(HAVE_OPENGLES3))
|
2014-04-19 15:22:25 +00:00
|
|
|
#define HAVE_GL_ASYNC_READBACK
|
|
|
|
#endif
|
|
|
|
|
2014-05-22 18:23:02 +00:00
|
|
|
#if defined(HAVE_PSGL)
|
|
|
|
#define RARCH_GL_FRAMEBUFFER GL_FRAMEBUFFER_OES
|
2014-05-22 18:32:51 +00:00
|
|
|
#define RARCH_GL_FRAMEBUFFER_COMPLETE GL_FRAMEBUFFER_COMPLETE_OES
|
|
|
|
#define RARCH_GL_COLOR_ATTACHMENT0 GL_COLOR_ATTACHMENT0_EXT
|
2014-05-22 18:30:21 +00:00
|
|
|
#elif defined(OSX_PPC)
|
2014-05-22 18:23:02 +00:00
|
|
|
#define RARCH_GL_FRAMEBUFFER GL_FRAMEBUFFER_EXT
|
2014-05-22 18:32:51 +00:00
|
|
|
#define RARCH_GL_FRAMEBUFFER_COMPLETE GL_FRAMEBUFFER_COMPLETE_EXT
|
|
|
|
#define RARCH_GL_COLOR_ATTACHMENT0 GL_COLOR_ATTACHMENT0_EXT
|
2014-05-22 18:23:02 +00:00
|
|
|
#else
|
|
|
|
#define RARCH_GL_FRAMEBUFFER GL_FRAMEBUFFER
|
2014-05-22 18:32:51 +00:00
|
|
|
#define RARCH_GL_FRAMEBUFFER_COMPLETE GL_FRAMEBUFFER_COMPLETE
|
|
|
|
#define RARCH_GL_COLOR_ATTACHMENT0 GL_COLOR_ATTACHMENT0
|
2014-05-22 18:23:02 +00:00
|
|
|
#endif
|
|
|
|
|
2014-05-22 18:44:33 +00:00
|
|
|
#if defined(HAVE_OPENGLES2)
|
|
|
|
#define RARCH_GL_RENDERBUFFER GL_RENDERBUFFER
|
|
|
|
#define RARCH_GL_DEPTH24_STENCIL8 GL_DEPTH24_STENCIL8_OES
|
2014-05-22 18:58:32 +00:00
|
|
|
#define RARCH_GL_DEPTH_ATTACHMENT GL_DEPTH_ATTACHMENT
|
|
|
|
#define RARCH_GL_STENCIL_ATTACHMENT GL_STENCIL_ATTACHMENT
|
2014-05-22 18:45:41 +00:00
|
|
|
#elif defined(OSX_PPC)
|
|
|
|
#define RARCH_GL_RENDERBUFFER GL_RENDERBUFFER_EXT
|
|
|
|
#define RARCH_GL_DEPTH24_STENCIL8 GL_DEPTH24_STENCIL8_EXT
|
2014-05-22 18:58:32 +00:00
|
|
|
#define RARCH_GL_DEPTH_ATTACHMENT GL_DEPTH_ATTACHMENT_EXT
|
|
|
|
#define RARCH_GL_STENCIL_ATTACHMENT GL_STENCIL_ATTACHMENT_EXT
|
2014-05-27 20:15:25 +00:00
|
|
|
#elif defined(HAVE_PSGL) && !defined(HAVE_GCMGL)
|
|
|
|
#define RARCH_GL_RENDERBUFFER GL_RENDERBUFFER_OES
|
|
|
|
#define RARCH_GL_DEPTH24_STENCIL8 GL_DEPTH24_STENCIL8_SCE
|
|
|
|
#define RARCH_GL_DEPTH_ATTACHMENT GL_DEPTH_ATTACHMENT_OES
|
|
|
|
#define RARCH_GL_STENCIL_ATTACHMENT GL_STENCIL_ATTACHMENT_OES
|
2014-05-22 18:44:33 +00:00
|
|
|
#else
|
|
|
|
#define RARCH_GL_RENDERBUFFER GL_RENDERBUFFER
|
|
|
|
#define RARCH_GL_DEPTH24_STENCIL8 GL_DEPTH24_STENCIL8
|
2014-05-22 18:58:32 +00:00
|
|
|
#define RARCH_GL_DEPTH_ATTACHMENT GL_DEPTH_ATTACHMENT
|
|
|
|
#define RARCH_GL_STENCIL_ATTACHMENT GL_STENCIL_ATTACHMENT
|
2014-05-22 18:44:33 +00:00
|
|
|
#endif
|
|
|
|
|
2014-05-22 19:00:17 +00:00
|
|
|
#ifdef OSX_PPC
|
|
|
|
#define RARCH_GL_MAX_RENDERBUFFER_SIZE GL_MAX_RENDERBUFFER_SIZE_EXT
|
2014-05-27 20:15:25 +00:00
|
|
|
#elif defined(HAVE_PSGL) && !defined(HAVE_GCMGL)
|
|
|
|
#define RARCH_GL_MAX_RENDERBUFFER_SIZE GL_MAX_RENDERBUFFER_SIZE_OES
|
2014-05-22 19:00:17 +00:00
|
|
|
#else
|
|
|
|
#define RARCH_GL_MAX_RENDERBUFFER_SIZE GL_MAX_RENDERBUFFER_SIZE
|
|
|
|
#endif
|
|
|
|
|
2014-05-27 20:15:25 +00:00
|
|
|
#if defined(HAVE_PSGL) && !defined(HAVE_GCMGL)
|
|
|
|
#define glGenerateMipmap glGenerateMipmapOES
|
|
|
|
#endif
|
|
|
|
|
2014-05-27 20:27:16 +00:00
|
|
|
#ifdef HAVE_FBO
|
|
|
|
|
|
|
|
#if defined(__APPLE__) || defined(HAVE_PSGL)
|
|
|
|
#define GL_RGBA32F GL_RGBA32F_ARB
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2011-01-11 21:13:55 +00:00
|
|
|
static inline bool gl_check_error(void)
|
|
|
|
{
|
|
|
|
int error = glGetError();
|
|
|
|
switch (error)
|
|
|
|
{
|
|
|
|
case GL_INVALID_ENUM:
|
2012-04-21 21:25:32 +00:00
|
|
|
RARCH_ERR("GL: Invalid enum.\n");
|
2011-01-11 21:13:55 +00:00
|
|
|
break;
|
|
|
|
case GL_INVALID_VALUE:
|
2012-09-10 21:17:48 +00:00
|
|
|
RARCH_ERR("GL: Invalid value.\n");
|
2011-01-11 21:13:55 +00:00
|
|
|
break;
|
|
|
|
case GL_INVALID_OPERATION:
|
2012-04-21 21:25:32 +00:00
|
|
|
RARCH_ERR("GL: Invalid operation.\n");
|
2011-01-11 21:13:55 +00:00
|
|
|
break;
|
|
|
|
case GL_OUT_OF_MEMORY:
|
2012-09-10 21:17:48 +00:00
|
|
|
RARCH_ERR("GL: Out of memory.\n");
|
2011-01-11 21:13:55 +00:00
|
|
|
break;
|
|
|
|
case GL_NO_ERROR:
|
|
|
|
return true;
|
|
|
|
default:
|
2012-09-10 21:17:48 +00:00
|
|
|
RARCH_ERR("Non specified GL error.\n");
|
2011-01-11 21:13:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-05-26 13:21:51 +00:00
|
|
|
static inline unsigned get_alignment(unsigned pitch)
|
|
|
|
{
|
|
|
|
if (pitch & 1)
|
|
|
|
return 1;
|
|
|
|
if (pitch & 2)
|
|
|
|
return 2;
|
|
|
|
if (pitch & 4)
|
|
|
|
return 4;
|
|
|
|
return 8;
|
|
|
|
}
|
|
|
|
|
2011-03-14 21:09:35 +00:00
|
|
|
struct gl_fbo_rect
|
|
|
|
{
|
2011-03-14 22:48:19 +00:00
|
|
|
unsigned img_width;
|
|
|
|
unsigned img_height;
|
2011-03-27 19:21:46 +00:00
|
|
|
unsigned max_img_width;
|
|
|
|
unsigned max_img_height;
|
2011-03-14 21:09:35 +00:00
|
|
|
unsigned width;
|
|
|
|
unsigned height;
|
2011-03-14 21:51:03 +00:00
|
|
|
};
|
2011-03-14 21:09:35 +00:00
|
|
|
|
2012-05-27 21:14:46 +00:00
|
|
|
struct gl_ortho
|
2012-05-27 20:39:29 +00:00
|
|
|
{
|
2012-05-27 21:14:46 +00:00
|
|
|
GLfloat left;
|
|
|
|
GLfloat right;
|
|
|
|
GLfloat bottom;
|
|
|
|
GLfloat top;
|
2012-05-27 21:33:31 +00:00
|
|
|
GLfloat znear;
|
|
|
|
GLfloat zfar;
|
2012-05-27 21:14:46 +00:00
|
|
|
};
|
2012-05-27 20:39:29 +00:00
|
|
|
|
2011-05-23 15:41:52 +00:00
|
|
|
struct gl_tex_info
|
|
|
|
{
|
|
|
|
GLuint tex;
|
2011-07-03 13:39:35 +00:00
|
|
|
GLfloat input_size[2];
|
|
|
|
GLfloat tex_size[2];
|
|
|
|
GLfloat coord[8];
|
2011-05-23 15:41:52 +00:00
|
|
|
};
|
|
|
|
|
2012-08-14 21:32:55 +00:00
|
|
|
struct gl_coords
|
|
|
|
{
|
|
|
|
const GLfloat *vertex;
|
|
|
|
const GLfloat *color;
|
|
|
|
const GLfloat *tex_coord;
|
2012-09-11 21:32:00 +00:00
|
|
|
const GLfloat *lut_tex_coord;
|
2014-06-07 19:18:58 +00:00
|
|
|
unsigned vertices;
|
2012-08-14 21:32:55 +00:00
|
|
|
};
|
|
|
|
|
2012-11-14 21:51:08 +00:00
|
|
|
typedef struct gl_shader_backend gl_shader_backend_t;
|
|
|
|
|
2012-05-26 13:21:51 +00:00
|
|
|
#define MAX_SHADERS 16
|
2013-07-06 20:10:09 +00:00
|
|
|
#define MAX_TEXTURES 8
|
2012-05-26 13:21:51 +00:00
|
|
|
|
|
|
|
typedef struct gl
|
|
|
|
{
|
2012-10-09 15:47:48 +00:00
|
|
|
const gfx_ctx_driver_t *ctx_driver;
|
2012-11-14 21:51:08 +00:00
|
|
|
const gl_shader_backend_t *shader;
|
|
|
|
|
2012-05-26 13:21:51 +00:00
|
|
|
bool vsync;
|
2013-07-06 20:10:09 +00:00
|
|
|
GLuint texture[MAX_TEXTURES];
|
2012-05-26 13:21:51 +00:00
|
|
|
unsigned tex_index; // For use with PREV.
|
2013-07-06 20:10:09 +00:00
|
|
|
unsigned textures;
|
|
|
|
struct gl_tex_info prev_info[MAX_TEXTURES];
|
2014-05-11 11:13:38 +00:00
|
|
|
GLuint tex_mag_filter;
|
|
|
|
GLuint tex_min_filter;
|
|
|
|
bool tex_mipmap;
|
2012-05-26 13:21:51 +00:00
|
|
|
|
|
|
|
void *empty_buf;
|
2012-10-01 22:58:43 +00:00
|
|
|
|
2012-09-15 13:17:34 +00:00
|
|
|
void *conv_buffer;
|
2012-10-01 22:58:43 +00:00
|
|
|
struct scaler_ctx scaler;
|
2012-05-26 13:21:51 +00:00
|
|
|
|
|
|
|
unsigned frame_count;
|
|
|
|
|
|
|
|
#ifdef HAVE_FBO
|
|
|
|
// Render-to-texture, multipass shaders
|
|
|
|
GLuint fbo[MAX_SHADERS];
|
|
|
|
GLuint fbo_texture[MAX_SHADERS];
|
|
|
|
struct gl_fbo_rect fbo_rect[MAX_SHADERS];
|
2013-04-06 09:30:56 +00:00
|
|
|
struct gfx_fbo_scale fbo_scale[MAX_SHADERS];
|
2012-05-26 13:21:51 +00:00
|
|
|
int fbo_pass;
|
|
|
|
bool fbo_inited;
|
2013-03-27 15:15:15 +00:00
|
|
|
|
2013-07-06 20:10:09 +00:00
|
|
|
GLuint hw_render_fbo[MAX_TEXTURES];
|
|
|
|
GLuint hw_render_depth[MAX_TEXTURES];
|
2013-03-27 15:15:15 +00:00
|
|
|
bool hw_render_fbo_init;
|
2013-03-29 01:50:42 +00:00
|
|
|
bool hw_render_depth_init;
|
2013-12-04 11:55:51 +00:00
|
|
|
bool has_fp_fbo;
|
2014-05-11 11:13:38 +00:00
|
|
|
bool has_srgb_fbo;
|
2014-06-05 15:41:10 +00:00
|
|
|
bool has_srgb_fbo_gles3;
|
2012-05-26 13:21:51 +00:00
|
|
|
#endif
|
2013-05-18 19:53:26 +00:00
|
|
|
bool hw_render_use;
|
2014-04-19 14:59:26 +00:00
|
|
|
bool shared_context_use;
|
2012-05-26 13:21:51 +00:00
|
|
|
|
|
|
|
bool should_resize;
|
|
|
|
bool quitting;
|
|
|
|
bool fullscreen;
|
|
|
|
bool keep_aspect;
|
|
|
|
unsigned rotation;
|
|
|
|
|
|
|
|
unsigned full_x, full_y;
|
|
|
|
|
|
|
|
unsigned win_width;
|
|
|
|
unsigned win_height;
|
2012-10-27 22:38:31 +00:00
|
|
|
struct rarch_viewport vp;
|
|
|
|
unsigned vp_out_width;
|
|
|
|
unsigned vp_out_height;
|
2013-07-06 20:10:09 +00:00
|
|
|
unsigned last_width[MAX_TEXTURES];
|
|
|
|
unsigned last_height[MAX_TEXTURES];
|
2012-05-26 13:21:51 +00:00
|
|
|
unsigned tex_w, tex_h;
|
|
|
|
GLfloat tex_coords[8];
|
2012-12-23 23:21:42 +00:00
|
|
|
math_matrix mvp, mvp_no_rot;
|
2012-05-26 13:21:51 +00:00
|
|
|
|
2012-08-14 21:32:55 +00:00
|
|
|
struct gl_coords coords;
|
2013-06-30 20:24:07 +00:00
|
|
|
const GLfloat *vertex_ptr;
|
|
|
|
const GLfloat *white_color_ptr;
|
2012-08-14 21:32:55 +00:00
|
|
|
|
2012-05-26 13:45:00 +00:00
|
|
|
GLuint pbo;
|
2013-01-03 00:18:19 +00:00
|
|
|
|
2012-10-19 23:12:02 +00:00
|
|
|
GLenum internal_fmt;
|
|
|
|
GLenum texture_type; // RGB565 or ARGB
|
2012-05-26 13:21:51 +00:00
|
|
|
GLenum texture_fmt;
|
2013-08-15 22:30:54 +00:00
|
|
|
GLenum wrap_mode;
|
2012-05-26 13:21:51 +00:00
|
|
|
unsigned base_size; // 2 or 4
|
2013-10-29 22:21:15 +00:00
|
|
|
#ifdef HAVE_OPENGLES
|
|
|
|
bool support_unpack_row_length;
|
2014-01-01 20:42:31 +00:00
|
|
|
#else
|
|
|
|
bool have_es2_compat;
|
2013-10-29 22:21:15 +00:00
|
|
|
#endif
|
2012-05-26 13:21:51 +00:00
|
|
|
|
2012-12-14 19:25:40 +00:00
|
|
|
// Fonts
|
2014-06-07 19:18:58 +00:00
|
|
|
const gl_font_renderer_t *font_driver;
|
|
|
|
void *font_handle;
|
2012-09-24 23:26:22 +00:00
|
|
|
|
2012-10-20 03:08:53 +00:00
|
|
|
bool egl_images;
|
2013-07-06 20:10:09 +00:00
|
|
|
video_info_t video_info;
|
2012-11-21 15:24:28 +00:00
|
|
|
|
2012-12-23 17:36:58 +00:00
|
|
|
#ifdef HAVE_OVERLAY
|
2013-10-15 14:06:59 +00:00
|
|
|
unsigned overlays;
|
2012-12-20 10:16:22 +00:00
|
|
|
bool overlay_enable;
|
2013-01-11 15:23:04 +00:00
|
|
|
bool overlay_full_screen;
|
2014-06-13 15:46:53 +00:00
|
|
|
GLuint *overlay_tex;
|
|
|
|
GLfloat *overlay_vertex_coord;
|
|
|
|
GLfloat *overlay_tex_coord;
|
|
|
|
GLfloat *overlay_color_coord;
|
2012-12-23 17:36:58 +00:00
|
|
|
#endif
|
2012-12-19 12:26:11 +00:00
|
|
|
|
2014-04-19 15:22:25 +00:00
|
|
|
#ifdef HAVE_GL_ASYNC_READBACK
|
2012-11-21 15:24:28 +00:00
|
|
|
// PBOs used for asynchronous viewport readbacks.
|
|
|
|
GLuint pbo_readback[4];
|
2014-04-27 08:40:24 +00:00
|
|
|
bool pbo_readback_valid[4];
|
2012-11-21 15:24:28 +00:00
|
|
|
bool pbo_readback_enable;
|
|
|
|
unsigned pbo_readback_index;
|
2012-11-21 21:12:56 +00:00
|
|
|
struct scaler_ctx pbo_readback_scaler;
|
2012-11-21 15:24:28 +00:00
|
|
|
#endif
|
2014-02-06 20:35:57 +00:00
|
|
|
void *readback_buffer_screenshot;
|
2012-12-07 07:00:46 +00:00
|
|
|
|
2013-11-08 03:36:16 +00:00
|
|
|
#if defined(HAVE_MENU)
|
2014-06-10 00:15:29 +00:00
|
|
|
GLuint menu_texture;
|
|
|
|
bool menu_texture_enable;
|
|
|
|
bool menu_texture_full_screen;
|
|
|
|
GLfloat menu_texture_alpha;
|
2013-02-28 01:20:29 +00:00
|
|
|
#endif
|
|
|
|
|
2013-05-03 12:04:29 +00:00
|
|
|
#ifdef HAVE_GL_SYNC
|
2013-05-26 11:43:24 +00:00
|
|
|
#define MAX_FENCES 4
|
2013-05-04 20:48:24 +00:00
|
|
|
bool have_sync;
|
2013-05-26 11:43:24 +00:00
|
|
|
GLsync fences[MAX_FENCES];
|
|
|
|
unsigned fence_count;
|
2013-05-03 12:04:29 +00:00
|
|
|
#endif
|
2013-06-22 13:06:56 +00:00
|
|
|
|
|
|
|
bool core_context;
|
|
|
|
GLuint vao;
|
2012-05-26 13:21:51 +00:00
|
|
|
} gl_t;
|
|
|
|
|
2012-09-11 07:55:03 +00:00
|
|
|
#if defined(HAVE_PSGL)
|
2012-10-19 23:12:02 +00:00
|
|
|
#define RARCH_GL_INTERNAL_FORMAT32 GL_ARGB_SCE
|
2014-01-01 20:42:31 +00:00
|
|
|
#define RARCH_GL_INTERNAL_FORMAT16 GL_RGB5 // TODO: Verify if this is really 565 or just 555.
|
2012-10-19 23:12:02 +00:00
|
|
|
#define RARCH_GL_TEXTURE_TYPE32 GL_BGRA
|
|
|
|
#define RARCH_GL_TEXTURE_TYPE16 GL_BGRA
|
2012-10-02 18:16:55 +00:00
|
|
|
#define RARCH_GL_FORMAT32 GL_UNSIGNED_INT_8_8_8_8_REV
|
2012-10-22 01:56:28 +00:00
|
|
|
#define RARCH_GL_FORMAT16 GL_RGB5
|
2012-09-09 22:36:25 +00:00
|
|
|
#elif defined(HAVE_OPENGLES)
|
2012-12-11 22:36:15 +00:00
|
|
|
// Imgtec/SGX headers have this missing.
|
|
|
|
#ifndef GL_BGRA_EXT
|
|
|
|
#define GL_BGRA_EXT 0x80E1
|
|
|
|
#endif
|
2013-02-06 14:54:15 +00:00
|
|
|
#ifdef IOS
|
|
|
|
#define RARCH_GL_INTERNAL_FORMAT32 GL_RGBA // Stupid Apple
|
|
|
|
#else
|
2012-10-19 23:12:02 +00:00
|
|
|
#define RARCH_GL_INTERNAL_FORMAT32 GL_BGRA_EXT
|
2013-02-06 14:54:15 +00:00
|
|
|
#endif
|
2012-10-19 23:12:02 +00:00
|
|
|
#define RARCH_GL_INTERNAL_FORMAT16 GL_RGB
|
|
|
|
#define RARCH_GL_TEXTURE_TYPE32 GL_BGRA_EXT
|
|
|
|
#define RARCH_GL_TEXTURE_TYPE16 GL_RGB
|
2012-09-15 13:17:34 +00:00
|
|
|
#define RARCH_GL_FORMAT32 GL_UNSIGNED_BYTE
|
2012-10-19 23:12:02 +00:00
|
|
|
#define RARCH_GL_FORMAT16 GL_UNSIGNED_SHORT_5_6_5
|
2012-05-27 16:46:20 +00:00
|
|
|
#else
|
2012-10-19 23:12:02 +00:00
|
|
|
// On desktop, we always use 32-bit.
|
2014-01-01 20:42:31 +00:00
|
|
|
#define RARCH_GL_INTERNAL_FORMAT32 GL_RGBA8
|
|
|
|
#define RARCH_GL_INTERNAL_FORMAT16 GL_RGBA8
|
2012-10-19 23:12:02 +00:00
|
|
|
#define RARCH_GL_TEXTURE_TYPE32 GL_BGRA
|
|
|
|
#define RARCH_GL_TEXTURE_TYPE16 GL_BGRA
|
2012-05-26 14:29:02 +00:00
|
|
|
#define RARCH_GL_FORMAT32 GL_UNSIGNED_INT_8_8_8_8_REV
|
2012-10-01 22:58:43 +00:00
|
|
|
#define RARCH_GL_FORMAT16 GL_UNSIGNED_INT_8_8_8_8_REV
|
2014-01-01 20:42:31 +00:00
|
|
|
|
|
|
|
// GL_RGB565 internal format isn't in desktop GL until 4.1 core (ARB_ES2_compatibility).
|
|
|
|
// Check for this.
|
|
|
|
#ifndef GL_RGB565
|
|
|
|
#define GL_RGB565 0x8D62
|
|
|
|
#endif
|
|
|
|
#define RARCH_GL_INTERNAL_FORMAT16_565 GL_RGB565
|
|
|
|
#define RARCH_GL_TEXTURE_TYPE16_565 GL_RGB
|
|
|
|
#define RARCH_GL_FORMAT16_565 GL_UNSIGNED_SHORT_5_6_5
|
2012-05-27 16:46:20 +00:00
|
|
|
#endif
|
2012-05-26 14:29:02 +00:00
|
|
|
|
2012-09-15 13:17:34 +00:00
|
|
|
// Platform specific workarounds/hacks.
|
2012-10-22 23:03:57 +00:00
|
|
|
#if defined(__CELLOS_LV2__)
|
2014-01-05 17:48:09 +00:00
|
|
|
#define NO_GL_READ_PIXELS
|
2013-11-02 02:03:28 +00:00
|
|
|
|
|
|
|
// Performance hacks
|
2014-02-25 21:01:46 +00:00
|
|
|
#ifdef HAVE_GCMGL
|
2013-11-02 02:03:28 +00:00
|
|
|
extern GLvoid* glMapBufferTextureReferenceRA( GLenum target, GLenum access );
|
|
|
|
extern GLboolean glUnmapBufferTextureReferenceRA( GLenum target );
|
2013-11-02 13:44:13 +00:00
|
|
|
extern void glBufferSubDataTextureReferenceRA( GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data );
|
2013-11-02 02:03:28 +00:00
|
|
|
#define glMapBuffer(target, access) glMapBufferTextureReferenceRA(target, access)
|
|
|
|
#define glUnmapBuffer(target) glUnmapBufferTextureReferenceRA(target)
|
2013-11-02 13:44:13 +00:00
|
|
|
#define glBufferSubData(target, offset, size, data) glBufferSubDataTextureReferenceRA(target, offset, size, data)
|
2013-11-02 02:03:28 +00:00
|
|
|
#endif
|
2012-09-15 13:17:34 +00:00
|
|
|
#endif
|
|
|
|
|
2012-09-25 02:07:36 +00:00
|
|
|
#if defined(HAVE_OPENGL_MODERN) || defined(HAVE_OPENGLES2) || defined(HAVE_PSGL)
|
2012-09-15 13:17:34 +00:00
|
|
|
#define NO_GL_FF_VERTEX
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(HAVE_OPENGL_MODERN) || defined(HAVE_OPENGLES2) || defined(HAVE_PSGL)
|
|
|
|
#define NO_GL_FF_MATRIX
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(HAVE_OPENGLES2) // TODO: Figure out exactly what.
|
|
|
|
#define NO_GL_CLAMP_TO_BORDER
|
|
|
|
#endif
|
|
|
|
|
2013-10-29 22:21:15 +00:00
|
|
|
#if defined(HAVE_OPENGLES)
|
|
|
|
#ifndef GL_UNPACK_ROW_LENGTH
|
|
|
|
#define GL_UNPACK_ROW_LENGTH 0x0CF2
|
|
|
|
#endif
|
|
|
|
|
2014-05-11 11:13:38 +00:00
|
|
|
#ifndef GL_SRGB_ALPHA_EXT
|
|
|
|
#define GL_SRGB_ALPHA_EXT 0x8C42
|
|
|
|
#endif
|
2012-09-15 13:17:34 +00:00
|
|
|
#endif
|
|
|
|
|
2014-06-17 15:08:46 +00:00
|
|
|
void gl_set_projection(gl_t *gl, struct gl_ortho *ortho, bool allow_rotate);
|
|
|
|
void gl_set_viewport(gl_t *gl, unsigned width, unsigned height, bool force_full, bool allow_rotate);
|
|
|
|
void gl_shader_set_coords(gl_t *gl, const struct gl_coords *coords, const math_matrix *mat);
|
2012-05-27 10:26:43 +00:00
|
|
|
|
2014-06-17 15:08:46 +00:00
|
|
|
void gl_init_fbo(gl_t *gl, unsigned width, unsigned height);
|
|
|
|
void gl_deinit_fbo(gl_t *gl);
|
2012-06-05 16:11:42 +00:00
|
|
|
|
2013-08-15 22:30:54 +00:00
|
|
|
static inline GLenum gl_wrap_type_to_enum(enum gfx_wrap_type type)
|
|
|
|
{
|
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
#ifndef HAVE_OPENGLES
|
|
|
|
case RARCH_WRAP_BORDER:
|
|
|
|
return GL_CLAMP_TO_BORDER;
|
|
|
|
#else
|
|
|
|
case RARCH_WRAP_BORDER:
|
|
|
|
#endif
|
|
|
|
case RARCH_WRAP_EDGE:
|
|
|
|
return GL_CLAMP_TO_EDGE;
|
|
|
|
case RARCH_WRAP_REPEAT:
|
|
|
|
return GL_REPEAT;
|
|
|
|
case RARCH_WRAP_MIRRORED_REPEAT:
|
|
|
|
return GL_MIRRORED_REPEAT;
|
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-11 21:13:55 +00:00
|
|
|
#endif
|
2012-12-19 12:26:11 +00:00
|
|
|
|