2009-07-28 21:32:10 +00:00
|
|
|
// Copyright (C) 2003 Dolphin Project.
|
2008-12-08 04:46:09 +00: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 14:35:49 +00:00
|
|
|
#ifndef _GLINIT_H_
|
|
|
|
#define _GLINIT_H_
|
2008-12-08 04:46:09 +00:00
|
|
|
|
2009-09-13 09:23:30 +00:00
|
|
|
#include "VideoConfig.h"
|
2009-07-15 00:51:24 +00:00
|
|
|
#include "MathUtil.h"
|
2011-01-10 23:48:59 +00:00
|
|
|
#include "Thread.h"
|
2008-12-08 04:46:09 +00:00
|
|
|
|
|
|
|
#ifdef _WIN32
|
|
|
|
#define GLEW_STATIC
|
2010-09-09 17:52:52 +00:00
|
|
|
#include <GL/glew.h>
|
|
|
|
#include <GL/wglew.h>
|
2011-01-10 23:48:59 +00:00
|
|
|
#elif defined HAVE_X11 && HAVE_X11
|
2008-12-08 04:46:09 +00:00
|
|
|
#include <GL/glxew.h>
|
2011-01-10 23:48:59 +00:00
|
|
|
#include <GL/gl.h>
|
2010-03-15 23:25:11 +00:00
|
|
|
#include <X11/Xlib.h>
|
|
|
|
#include <X11/keysym.h>
|
2011-01-10 23:48:59 +00:00
|
|
|
#elif defined __APPLE__
|
2010-06-04 02:58:35 +00:00
|
|
|
#include <GL/glew.h>
|
2011-01-10 23:48:59 +00:00
|
|
|
#import <AppKit/AppKit.h>
|
2008-12-08 04:46:09 +00:00
|
|
|
#endif
|
2008-12-10 23:23:05 +00:00
|
|
|
|
2011-01-10 23:48:59 +00:00
|
|
|
#if defined USE_WX && USE_WX
|
|
|
|
#include "wx/wx.h"
|
|
|
|
#include "wx/glcanvas.h"
|
2011-01-10 16:18:41 +00:00
|
|
|
#endif
|
2008-12-08 04:46:09 +00:00
|
|
|
|
|
|
|
#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 23:23:05 +00:00
|
|
|
#ifndef _WIN32
|
|
|
|
|
2008-12-08 04:46:09 +00:00
|
|
|
#include <sys/types.h>
|
|
|
|
|
|
|
|
typedef struct {
|
2010-07-16 21:56:40 +00:00
|
|
|
#if defined(USE_WX) && USE_WX
|
|
|
|
wxGLCanvas *glCanvas;
|
|
|
|
wxGLContext *glCtxt;
|
2011-01-10 16:18:41 +00:00
|
|
|
wxPanel *panel;
|
2010-07-16 21:56:40 +00:00
|
|
|
#elif defined(__APPLE__)
|
2010-06-04 04:59:07 +00:00
|
|
|
NSWindow *cocoaWin;
|
|
|
|
NSOpenGLContext *cocoaCtx;
|
|
|
|
#elif defined(HAVE_X11) && HAVE_X11
|
2010-07-16 21:56:40 +00:00
|
|
|
int screen;
|
2010-02-20 04:18:19 +00:00
|
|
|
Window win;
|
2010-04-12 01:33:10 +00:00
|
|
|
Window parent;
|
2011-03-02 05:16:49 +00:00
|
|
|
// dpy used for glx stuff, evdpy for window events etc.
|
|
|
|
// evdpy is to be used by XEventThread only
|
2010-09-19 23:40:03 +00:00
|
|
|
Display *dpy, *evdpy;
|
2010-02-20 04:18:19 +00:00
|
|
|
XVisualInfo *vi;
|
|
|
|
GLXContext ctx;
|
|
|
|
XSetWindowAttributes attr;
|
2011-01-27 20:47:58 +00:00
|
|
|
std::thread xEventThread;
|
2010-02-20 04:18:19 +00:00
|
|
|
int x, y;
|
|
|
|
unsigned int width, height;
|
2011-01-10 16:18:41 +00:00
|
|
|
#endif
|
2008-12-08 04:46:09 +00:00
|
|
|
} GLWindow;
|
|
|
|
|
|
|
|
extern GLWindow GLWin;
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2009-03-22 11:21:44 +00:00
|
|
|
// Public OpenGL util
|
|
|
|
|
2009-03-08 19:19:51 +00:00
|
|
|
// Initialization / upkeep
|
2011-02-25 21:14:13 +00:00
|
|
|
bool OpenGL_Create(void *&);
|
2009-03-08 19:19:51 +00:00
|
|
|
void OpenGL_Shutdown();
|
|
|
|
void OpenGL_Update();
|
2008-12-08 04:46:09 +00:00
|
|
|
bool OpenGL_MakeCurrent();
|
|
|
|
void OpenGL_SwapBuffers();
|
2009-03-08 19:19:51 +00:00
|
|
|
|
|
|
|
// Get status
|
|
|
|
u32 OpenGL_GetBackbufferWidth();
|
|
|
|
u32 OpenGL_GetBackbufferHeight();
|
|
|
|
|
|
|
|
// Set things
|
2008-12-08 04:46:09 +00:00
|
|
|
void OpenGL_SetWindowText(const char *text);
|
2009-03-08 19:19:51 +00:00
|
|
|
|
2009-03-22 11:21:44 +00: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 10:48:49 +00:00
|
|
|
#if defined(_DEBUG) || defined(DEBUGFAST)
|
2010-08-04 14:00:59 +00: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 11:21:44 +00:00
|
|
|
#define GL_REPORT_PROGRAM_ERROR() OpenGL_ReportARBProgramError()
|
|
|
|
#else
|
|
|
|
#define GL_REPORT_ERROR() GL_NO_ERROR
|
2010-08-04 14:00:59 +00: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-08 04:46:09 +00:00
|
|
|
#endif
|
2009-03-22 11:21:44 +00:00
|
|
|
|
2010-07-24 10:24:16 +00:00
|
|
|
#if defined __APPLE__ || defined __linux__ || defined _WIN32
|
2009-09-03 20:37:35 +00:00
|
|
|
#include <Cg/cg.h>
|
|
|
|
#include <Cg/cgGL.h>
|
2010-07-24 10:24:16 +00:00
|
|
|
#define HAVE_CG 1
|
2009-09-03 20:37:35 +00:00
|
|
|
extern CGcontext g_cgcontext;
|
|
|
|
extern CGprofile g_cgvProf, g_cgfProf;
|
2010-07-24 10:24:16 +00:00
|
|
|
#endif
|
2009-09-03 20:37:35 +00:00
|
|
|
|
2010-10-23 19:55:19 +00: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!
|
2011-12-11 09:10:03 +00:00
|
|
|
#define USE_DUAL_SOURCE_BLEND
|
|
|
|
|
|
|
|
// Can't get defined on my system for some reason...
|
|
|
|
#ifndef GL_ONE_MINUS_SRC1_ALPHA
|
|
|
|
#define GL_ONE_MINUS_SRC1_ALPHA 0x88FB
|
|
|
|
#endif
|
2010-10-23 19:55:19 +00:00
|
|
|
|
2009-04-03 14:35:49 +00:00
|
|
|
#endif // _GLINIT_H_
|