2009-07-28 15:32:10 -06:00
|
|
|
// Copyright (C) 2003 Dolphin Project.
|
2008-12-07 21:46:09 -07:00
|
|
|
|
|
|
|
// This program 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 Foundation, version 2.0.
|
|
|
|
|
|
|
|
// This program 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 2.0 for more details.
|
|
|
|
|
|
|
|
// A copy of the GPL 2.0 should have been included with the program.
|
|
|
|
// If not, see http://www.gnu.org/licenses/
|
|
|
|
|
|
|
|
// Official SVN repository and contact information can be found at
|
|
|
|
// http://code.google.com/p/dolphin-emu/
|
|
|
|
|
2009-04-03 08:35:49 -06:00
|
|
|
#ifndef _GLINIT_H_
|
|
|
|
#define _GLINIT_H_
|
2008-12-07 21:46:09 -07:00
|
|
|
|
2009-09-13 03:23:30 -06:00
|
|
|
#include "VideoConfig.h"
|
2009-07-14 18:51:24 -06:00
|
|
|
#include "MathUtil.h"
|
2008-12-07 21:46:09 -07:00
|
|
|
#include "pluginspecs_video.h"
|
|
|
|
|
|
|
|
#ifdef _WIN32
|
|
|
|
|
|
|
|
#define GLEW_STATIC
|
|
|
|
|
2010-09-09 11:52:52 -06:00
|
|
|
#include <GL/glew.h>
|
|
|
|
#include <GL/wglew.h>
|
2008-12-07 21:46:09 -07:00
|
|
|
|
2010-03-15 17:25:11 -06:00
|
|
|
#else // linux and apple basic definitions
|
2008-12-07 21:46:09 -07:00
|
|
|
|
2008-12-10 16:23:05 -07:00
|
|
|
#if defined(USE_WX) && USE_WX
|
|
|
|
#include <GL/glew.h>
|
|
|
|
#include "wx/wx.h"
|
|
|
|
#include "wx/glcanvas.h"
|
2010-03-15 17:25:11 -06:00
|
|
|
|
2008-12-10 16:23:05 -07:00
|
|
|
#elif defined(HAVE_X11) && HAVE_X11
|
2008-12-07 21:46:09 -07:00
|
|
|
#include <GL/glxew.h>
|
2010-03-15 17:25:11 -06:00
|
|
|
#include <X11/Xlib.h>
|
|
|
|
#include <X11/keysym.h>
|
|
|
|
#include "Thread.h"
|
|
|
|
|
2010-06-03 22:59:07 -06:00
|
|
|
#elif defined(__APPLE__)
|
2010-06-03 20:58:35 -06:00
|
|
|
#include <GL/glew.h>
|
2010-06-03 22:59:07 -06:00
|
|
|
#include "cocoaGL.h"
|
2008-12-10 16:23:05 -07:00
|
|
|
#endif // end USE_WX
|
2008-12-07 21:46:09 -07:00
|
|
|
|
|
|
|
#if defined(__APPLE__)
|
|
|
|
#include <OpenGL/gl.h>
|
|
|
|
#else
|
|
|
|
#include <GL/gl.h>
|
|
|
|
#endif
|
2008-12-10 16:23:05 -07:00
|
|
|
|
2008-12-07 21:46:09 -07:00
|
|
|
#endif // linux basic definitions
|
|
|
|
|
|
|
|
#ifndef GL_DEPTH24_STENCIL8_EXT // allows FBOs to support stencils
|
|
|
|
#define GL_DEPTH_STENCIL_EXT 0x84F9
|
|
|
|
#define GL_UNSIGNED_INT_24_8_EXT 0x84FA
|
|
|
|
#define GL_DEPTH24_STENCIL8_EXT 0x88F0
|
|
|
|
#define GL_TEXTURE_STENCIL_SIZE_EXT 0x88F1
|
|
|
|
#endif
|
|
|
|
|
2008-12-10 16:23:05 -07:00
|
|
|
#ifndef _WIN32
|
|
|
|
|
2008-12-07 21:46:09 -07:00
|
|
|
#include <sys/types.h>
|
|
|
|
|
|
|
|
typedef struct {
|
2010-07-16 15:56:40 -06:00
|
|
|
#if defined(USE_WX) && USE_WX
|
|
|
|
wxGLCanvas *glCanvas;
|
|
|
|
wxPanel *panel;
|
|
|
|
wxGLContext *glCtxt;
|
|
|
|
#elif defined(__APPLE__)
|
2010-06-03 22:59:07 -06:00
|
|
|
NSWindow *cocoaWin;
|
|
|
|
NSOpenGLContext *cocoaCtx;
|
|
|
|
#elif defined(HAVE_X11) && HAVE_X11
|
2010-07-16 15:56:40 -06:00
|
|
|
int screen;
|
2010-02-19 21:18:19 -07:00
|
|
|
Window win;
|
2010-04-11 19:33:10 -06:00
|
|
|
Window parent;
|
2010-09-19 17:40:03 -06:00
|
|
|
// dpy (mainly) used for glx stuff, evdpy for window events etc.
|
|
|
|
// used to keep the two threads from eating each others events
|
|
|
|
// evdpy is to be used by XEventThread only (when it is running)
|
|
|
|
Display *dpy, *evdpy;
|
2010-02-19 21:18:19 -07:00
|
|
|
XVisualInfo *vi;
|
|
|
|
GLXContext ctx;
|
|
|
|
XSetWindowAttributes attr;
|
2010-03-15 17:25:11 -06:00
|
|
|
Common::Thread *xEventThread;
|
2010-02-19 21:18:19 -07:00
|
|
|
int x, y;
|
2010-07-16 15:56:40 -06:00
|
|
|
#endif
|
2010-02-19 21:18:19 -07:00
|
|
|
unsigned int width, height;
|
2008-12-07 21:46:09 -07:00
|
|
|
} GLWindow;
|
|
|
|
|
|
|
|
extern GLWindow GLWin;
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2009-03-22 05:21:44 -06:00
|
|
|
// Public OpenGL util
|
|
|
|
|
2009-03-08 13:19:51 -06:00
|
|
|
// Initialization / upkeep
|
2008-12-07 21:46:09 -07:00
|
|
|
bool OpenGL_Create(SVideoInitialize &_VideoInitialize, int _width, int _height);
|
2009-03-08 13:19:51 -06:00
|
|
|
void OpenGL_Shutdown();
|
|
|
|
void OpenGL_Update();
|
2008-12-07 21:46:09 -07:00
|
|
|
bool OpenGL_MakeCurrent();
|
|
|
|
void OpenGL_SwapBuffers();
|
2009-03-08 13:19:51 -06:00
|
|
|
|
|
|
|
// Get status
|
|
|
|
u32 OpenGL_GetBackbufferWidth();
|
|
|
|
u32 OpenGL_GetBackbufferHeight();
|
|
|
|
|
|
|
|
// Set things
|
2008-12-07 21:46:09 -07:00
|
|
|
void OpenGL_SetWindowText(const char *text);
|
2009-03-08 13:19:51 -06:00
|
|
|
|
2009-03-22 05:21:44 -06:00
|
|
|
// Error reporting - use the convenient macros.
|
|
|
|
void OpenGL_ReportARBProgramError();
|
|
|
|
GLuint OpenGL_ReportGLError(const char *function, const char *file, int line);
|
|
|
|
bool OpenGL_ReportFBOError(const char *function, const char *file, int line);
|
|
|
|
|
2010-08-03 04:48:49 -06:00
|
|
|
#if defined(_DEBUG) || defined(DEBUGFAST)
|
2010-08-04 08:00:59 -06:00
|
|
|
#define GL_REPORT_ERROR() OpenGL_ReportGLError(__FUNCTION__, __FILE__, __LINE__)
|
|
|
|
#define GL_REPORT_ERRORD() OpenGL_ReportGLError(__FUNCTION__, __FILE__, __LINE__)
|
|
|
|
#define GL_REPORT_FBO_ERROR() OpenGL_ReportFBOError(__FUNCTION__, __FILE__, __LINE__)
|
2009-03-22 05:21:44 -06:00
|
|
|
#define GL_REPORT_PROGRAM_ERROR() OpenGL_ReportARBProgramError()
|
|
|
|
#else
|
|
|
|
#define GL_REPORT_ERROR() GL_NO_ERROR
|
2010-08-04 08:00:59 -06:00
|
|
|
#define GL_REPORT_ERRORD() (void)GL_NO_ERROR
|
|
|
|
#define GL_REPORT_FBO_ERROR() (void)true
|
|
|
|
#define GL_REPORT_PROGRAM_ERROR() (void)0
|
2008-12-07 21:46:09 -07:00
|
|
|
#endif
|
2009-03-22 05:21:44 -06:00
|
|
|
|
2010-07-24 04:24:16 -06:00
|
|
|
#if defined __APPLE__ || defined __linux__ || defined _WIN32
|
2009-09-03 14:37:35 -06:00
|
|
|
#include <Cg/cg.h>
|
|
|
|
#include <Cg/cgGL.h>
|
2010-07-24 04:24:16 -06:00
|
|
|
#define HAVE_CG 1
|
2009-09-03 14:37:35 -06:00
|
|
|
extern CGcontext g_cgcontext;
|
|
|
|
extern CGprofile g_cgvProf, g_cgfProf;
|
2010-07-24 04:24:16 -06:00
|
|
|
#endif
|
2009-09-03 14:37:35 -06:00
|
|
|
|
2010-10-23 13:55:19 -06:00
|
|
|
// XXX: Dual-source blending in OpenGL does not work correctly yet. To make it
|
|
|
|
// work, we may need to use glBindFragDataLocation. To use that, we need to
|
|
|
|
// use GLSL shaders across the whole pipeline. Yikes!
|
2010-10-24 12:26:28 -06:00
|
|
|
//#define USE_DUAL_SOURCE_BLEND
|
2010-10-23 13:55:19 -06:00
|
|
|
|
2009-04-03 08:35:49 -06:00
|
|
|
#endif // _GLINIT_H_
|