2012-04-21 21:13:50 +00:00
|
|
|
/* RetroArch - A frontend for libretro.
|
2012-01-08 00:08:18 +00:00
|
|
|
* Copyright (C) 2010-2012 - 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"
|
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
|
|
|
|
2011-12-07 00:13:06 +00:00
|
|
|
#if defined(__APPLE__)
|
2011-03-14 21:09:35 +00:00
|
|
|
#include <OpenGL/gl.h>
|
|
|
|
#include <OpenGL/glext.h>
|
2011-12-07 00:13:06 +00:00
|
|
|
#elif defined(__CELLOS_LV2__)
|
2011-11-30 17:32:45 +00:00
|
|
|
#include <PSGL/psgl.h>
|
|
|
|
#include <PSGL/psglu.h>
|
|
|
|
#include <GLES/glext.h>
|
|
|
|
#else
|
2011-03-14 21:09:35 +00:00
|
|
|
#define GL_GLEXT_PROTOTYPES
|
|
|
|
#include <GL/gl.h>
|
|
|
|
#include <GL/glext.h>
|
|
|
|
#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-04-21 21:25:32 +00:00
|
|
|
RARCH_ERR("GL: Invalid value. (You're not alone.)\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_STACK_OVERFLOW:
|
2012-04-21 21:25:32 +00:00
|
|
|
RARCH_ERR("GL: Stack overflow. (wtf)\n");
|
2011-01-11 21:13:55 +00:00
|
|
|
break;
|
|
|
|
case GL_STACK_UNDERFLOW:
|
2012-04-21 21:25:32 +00:00
|
|
|
RARCH_ERR("GL: Stack underflow. (:v)\n");
|
2011-01-11 21:13:55 +00:00
|
|
|
break;
|
|
|
|
case GL_OUT_OF_MEMORY:
|
2012-04-21 21:25:32 +00:00
|
|
|
RARCH_ERR("GL: Out of memory. Harhar.\n");
|
2011-01-11 21:13:55 +00:00
|
|
|
break;
|
|
|
|
case GL_NO_ERROR:
|
|
|
|
return true;
|
|
|
|
default:
|
2012-04-21 21:25:32 +00:00
|
|
|
RARCH_ERR("Non specified error :v\n");
|
2011-01-11 21:13:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2011-03-27 18:29:47 +00:00
|
|
|
enum gl_scale_type
|
|
|
|
{
|
2012-04-21 21:25:32 +00:00
|
|
|
RARCH_SCALE_ABSOLUTE,
|
|
|
|
RARCH_SCALE_INPUT,
|
|
|
|
RARCH_SCALE_VIEWPORT
|
2011-03-27 18:29:47 +00:00
|
|
|
};
|
|
|
|
|
2011-03-14 21:51:03 +00:00
|
|
|
struct gl_fbo_scale
|
|
|
|
{
|
2011-03-27 18:29:47 +00:00
|
|
|
enum gl_scale_type type_x;
|
|
|
|
enum gl_scale_type type_y;
|
2011-03-14 21:51:03 +00:00
|
|
|
float scale_x;
|
|
|
|
float scale_y;
|
2011-03-27 18:29:47 +00:00
|
|
|
unsigned abs_x;
|
|
|
|
unsigned abs_y;
|
2011-03-14 21:51:03 +00:00
|
|
|
bool valid;
|
2011-03-14 21:09:35 +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
|
|
|
};
|
|
|
|
|
2011-05-18 20:11:34 +00:00
|
|
|
// Windows ... <_<
|
2011-05-22 16:48:43 +00:00
|
|
|
#if (defined(HAVE_XML) || defined(HAVE_CG)) && defined(_WIN32)
|
2011-05-18 20:40:42 +00:00
|
|
|
extern PFNGLCLIENTACTIVETEXTUREPROC pglClientActiveTexture;
|
|
|
|
extern PFNGLACTIVETEXTUREPROC pglActiveTexture;
|
2011-05-18 20:11:34 +00:00
|
|
|
#else
|
|
|
|
#define pglClientActiveTexture glClientActiveTexture
|
|
|
|
#define pglActiveTexture glActiveTexture
|
|
|
|
#endif
|
|
|
|
|
2012-05-26 04:45:55 +00:00
|
|
|
void rarch_gl_set_vsync(unsigned enabled);
|
|
|
|
|
2011-01-11 21:13:55 +00:00
|
|
|
#endif
|