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"
|
2008-12-08 04:46:09 +00:00
|
|
|
#include "pluginspecs_video.h"
|
|
|
|
|
|
|
|
#ifdef _WIN32
|
|
|
|
|
|
|
|
#define GLEW_STATIC
|
|
|
|
|
|
|
|
#include <GLew/glew.h>
|
|
|
|
#include <GLew/wglew.h>
|
|
|
|
#include <GLew/gl.h>
|
|
|
|
#include <GLew/glext.h>
|
|
|
|
|
2010-03-15 23:25:11 +00:00
|
|
|
#else // linux and apple basic definitions
|
2008-12-08 04:46:09 +00:00
|
|
|
|
2008-12-10 23:23:05 +00:00
|
|
|
#if defined(USE_WX) && USE_WX
|
|
|
|
#include <GL/glew.h>
|
|
|
|
#include "wx/wx.h"
|
|
|
|
#include "wx/glcanvas.h"
|
2010-03-15 23:25:11 +00:00
|
|
|
|
2008-12-10 23:23:05 +00:00
|
|
|
#elif defined(HAVE_X11) && HAVE_X11
|
2008-12-08 04:46:09 +00:00
|
|
|
#include <GL/glxew.h>
|
2008-12-23 19:50:34 +00:00
|
|
|
#include <X11/XKBlib.h>
|
2010-03-15 23:25:11 +00:00
|
|
|
#include <X11/Xlib.h>
|
|
|
|
#include <X11/keysym.h>
|
|
|
|
#include "Thread.h"
|
|
|
|
|
2008-12-13 23:19:56 +00:00
|
|
|
#elif defined(USE_SDL) && USE_SDL
|
|
|
|
#include <GL/glew.h>
|
2008-12-14 00:31:47 +00:00
|
|
|
#include <SDL.h>
|
2010-06-04 02:58:35 +00:00
|
|
|
|
2010-06-04 04:59:07 +00:00
|
|
|
#elif defined(__APPLE__)
|
2010-06-04 02:58:35 +00:00
|
|
|
#include <GL/glew.h>
|
2010-06-04 04:59:07 +00:00
|
|
|
#include "cocoaGL.h"
|
2008-12-10 23:23:05 +00:00
|
|
|
#endif // end USE_WX
|
2008-12-08 04:46:09 +00:00
|
|
|
|
|
|
|
#if defined(__APPLE__)
|
|
|
|
#include <OpenGL/gl.h>
|
|
|
|
#else
|
|
|
|
#include <GL/gl.h>
|
|
|
|
#endif
|
2008-12-10 23:23:05 +00:00
|
|
|
|
2008-12-08 04:46:09 +00: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 23:23:05 +00:00
|
|
|
#ifndef _WIN32
|
|
|
|
|
2008-12-08 04:46:09 +00:00
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
|
|
|
typedef struct {
|
2010-02-20 04:18:19 +00:00
|
|
|
int screen;
|
2010-06-04 04:59:07 +00:00
|
|
|
#if defined(__APPLE__)
|
|
|
|
NSWindow *cocoaWin;
|
|
|
|
NSOpenGLContext *cocoaCtx;
|
|
|
|
#elif defined(HAVE_X11) && HAVE_X11
|
2010-02-20 04:18:19 +00:00
|
|
|
Window win;
|
2010-04-12 01:33:10 +00:00
|
|
|
Window parent;
|
2010-02-20 04:18:19 +00:00
|
|
|
Display *dpy;
|
|
|
|
XVisualInfo *vi;
|
|
|
|
GLXContext ctx;
|
|
|
|
XSetWindowAttributes attr;
|
2010-03-15 23:25:11 +00:00
|
|
|
Common::Thread *xEventThread;
|
2010-06-04 04:59:07 +00:00
|
|
|
#endif // X11
|
|
|
|
#if defined(USE_WX) && USE_WX
|
2010-02-20 04:18:19 +00:00
|
|
|
wxGLCanvas *glCanvas;
|
2010-04-12 01:33:10 +00:00
|
|
|
wxPanel *panel;
|
2010-02-20 04:18:19 +00:00
|
|
|
wxGLContext *glCtxt;
|
2008-12-10 23:23:05 +00:00
|
|
|
#endif
|
2010-02-20 04:18:19 +00:00
|
|
|
int x, y;
|
|
|
|
unsigned int width, height;
|
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
|
2008-12-08 04:46:09 +00:00
|
|
|
bool OpenGL_Create(SVideoInitialize &_VideoInitialize, int _width, int _height);
|
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);
|
|
|
|
|
|
|
|
#if 1
|
|
|
|
#define GL_REPORT_ERROR() OpenGL_ReportGLError (__FUNCTION__, __FILE__, __LINE__)
|
|
|
|
#define GL_REPORT_PROGRAM_ERROR() OpenGL_ReportARBProgramError()
|
|
|
|
#define GL_REPORT_FBO_ERROR() OpenGL_ReportFBOError (__FUNCTION__, __FILE__, __LINE__)
|
|
|
|
#else
|
|
|
|
#define GL_REPORT_ERROR() GL_NO_ERROR
|
|
|
|
#define GL_REPORT_PROGRAM_ERROR()
|
|
|
|
#define GL_REPORT_FBO_ERROR()
|
2008-12-19 11:46:52 +00:00
|
|
|
#endif
|
2009-03-22 11:21:44 +00:00
|
|
|
|
|
|
|
#if defined(_DEBUG) || defined(DEBUGFAST)
|
|
|
|
#define GL_REPORT_ERRORD() OpenGL_ReportGLError(__FUNCTION__, __FILE__, __LINE__)
|
|
|
|
#else
|
2009-06-13 22:08:01 +00:00
|
|
|
#define GL_REPORT_ERRORD()
|
2008-12-08 04:46:09 +00:00
|
|
|
#endif
|
2009-03-22 11:21:44 +00:00
|
|
|
|
2009-09-03 20:37:35 +00:00
|
|
|
#include <Cg/cg.h>
|
|
|
|
#include <Cg/cgGL.h>
|
|
|
|
|
|
|
|
extern CGcontext g_cgcontext;
|
|
|
|
extern CGprofile g_cgvProf, g_cgfProf;
|
|
|
|
|
2009-04-03 14:35:49 +00:00
|
|
|
#endif // _GLINIT_H_
|