2009-04-03 14:35:49 +00:00
|
|
|
// Copyright (C) 2003-2009 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
|
|
|
|
2008-12-19 11:46:52 +00:00
|
|
|
#if defined GLTEST && GLTEST
|
|
|
|
#include "nGLUtil.h"
|
|
|
|
#else
|
2008-12-10 23:23:05 +00:00
|
|
|
#include "Config.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>
|
|
|
|
|
|
|
|
#else // linux basic definitions
|
|
|
|
|
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"
|
|
|
|
#undef HAVE_X11
|
|
|
|
#elif defined(HAVE_X11) && HAVE_X11
|
2008-12-08 04:46:09 +00:00
|
|
|
#define I_NEED_OS2_H // HAXXOR
|
|
|
|
#include <GL/glxew.h>
|
2008-12-23 19:50:34 +00:00
|
|
|
#include <X11/XKBlib.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>
|
2008-12-10 23:23:05 +00:00
|
|
|
#elif defined(HAVE_COCOA) && HAVE_COCOA
|
2008-12-08 04:46:09 +00:00
|
|
|
#include <GL/glew.h>
|
|
|
|
#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
|
|
|
#if defined(HAVE_X11) && HAVE_X11
|
|
|
|
#include <X11/Xlib.h>
|
|
|
|
#include <X11/Xutil.h>
|
|
|
|
#include <X11/keysym.h>
|
2008-12-10 23:23:05 +00:00
|
|
|
#if defined(HAVE_XXF86VM) && HAVE_XXF86VM
|
2008-12-08 04:46:09 +00:00
|
|
|
#include <X11/extensions/xf86vmode.h>
|
2008-12-10 23:23:05 +00:00
|
|
|
#endif // XXF86VM
|
|
|
|
#endif // X11
|
|
|
|
|
2008-12-08 04:46:09 +00:00
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
int screen;
|
2008-12-10 23:23:05 +00:00
|
|
|
#if defined(HAVE_COCOA) && HAVE_COCOA
|
2008-12-08 04:46:09 +00:00
|
|
|
NSWindow *cocoaWin;
|
|
|
|
NSOpenGLContext *cocoaCtx;
|
2008-12-10 23:23:05 +00:00
|
|
|
#elif defined(HAVE_X11) && HAVE_X11
|
2008-12-08 04:46:09 +00:00
|
|
|
Window win;
|
|
|
|
Display *dpy;
|
|
|
|
GLXContext ctx;
|
|
|
|
XSetWindowAttributes attr;
|
|
|
|
Bool fs;
|
|
|
|
Bool doubleBuffered;
|
2008-12-10 23:23:05 +00:00
|
|
|
#if defined(HAVE_XXF86VM) && HAVE_XXF86VM
|
2008-12-08 04:46:09 +00:00
|
|
|
XF86VidModeModeInfo deskMode;
|
2008-12-10 23:23:05 +00:00
|
|
|
#endif // XXF86VM
|
|
|
|
#endif // X11
|
|
|
|
#if defined(USE_WX) && USE_WX
|
2008-12-11 11:37:26 +00:00
|
|
|
wxGLCanvas *glCanvas;
|
|
|
|
wxFrame *frame;
|
|
|
|
wxGLContext *glCtxt;
|
2008-12-10 23:23:05 +00:00
|
|
|
#endif
|
2008-12-08 04:46:09 +00:00
|
|
|
int x, y;
|
|
|
|
unsigned int width, height;
|
|
|
|
unsigned int depth;
|
|
|
|
} 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
|
|
|
|
|
|
|
#endif // GLTEST ??
|
|
|
|
|
2009-04-03 14:35:49 +00:00
|
|
|
#endif // _GLINIT_H_
|