Logical reorderring of the GUI boot sequence. Also a little clean up in the OpenGL...
[dolphin.git] / Source / Plugins / Plugin_VideoOGL / Src / GLUtil.h
blob6ab3736289fca9241cd3c20ea17126b32706b765
1 // Copyright (C) 2003 Dolphin Project.
3 // This program is free software: you can redistribute it and/or modify
4 // it under the terms of the GNU General Public License as published by
5 // the Free Software Foundation, version 2.0.
7 // This program is distributed in the hope that it will be useful,
8 // but WITHOUT ANY WARRANTY; without even the implied warranty of
9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 // GNU General Public License 2.0 for more details.
12 // A copy of the GPL 2.0 should have been included with the program.
13 // If not, see http://www.gnu.org/licenses/
15 // Official SVN repository and contact information can be found at
16 // http://code.google.com/p/dolphin-emu/
18 #ifndef _GLINIT_H_
19 #define _GLINIT_H_
21 #include "VideoConfig.h"
22 #include "MathUtil.h"
23 #include "pluginspecs_video.h"
25 #ifdef _WIN32
27 #define GLEW_STATIC
29 #include <GLew/glew.h>
30 #include <GLew/wglew.h>
31 #include <GLew/gl.h>
32 #include <GLew/glext.h>
34 #else // linux and apple basic definitions
36 #if defined(USE_WX) && USE_WX
37 #include <GL/glew.h>
38 #include "wx/wx.h"
39 #include "wx/glcanvas.h"
41 #elif defined(HAVE_X11) && HAVE_X11
42 #include <GL/glxew.h>
43 #include <X11/XKBlib.h>
44 #include <X11/Xlib.h>
45 #include <X11/keysym.h>
46 #include "Thread.h"
47 #if defined(HAVE_XRANDR) && HAVE_XRANDR
48 #include <X11/extensions/Xrandr.h>
49 #endif // XRANDR
51 #elif defined(USE_SDL) && USE_SDL
52 #include <GL/glew.h>
53 #include <SDL.h>
55 #elif defined(HAVE_COCOA) && HAVE_COCOA
56 #include <GL/glew.h>
57 #include "cocoaGL.h"
58 #endif // end USE_WX
60 #if defined(__APPLE__)
61 #include <OpenGL/gl.h>
62 #else
63 #include <GL/gl.h>
64 #endif
66 #endif // linux basic definitions
68 #ifndef GL_DEPTH24_STENCIL8_EXT // allows FBOs to support stencils
69 #define GL_DEPTH_STENCIL_EXT 0x84F9
70 #define GL_UNSIGNED_INT_24_8_EXT 0x84FA
71 #define GL_DEPTH24_STENCIL8_EXT 0x88F0
72 #define GL_TEXTURE_STENCIL_SIZE_EXT 0x88F1
73 #endif
75 #ifndef _WIN32
77 #include <sys/stat.h>
78 #include <sys/types.h>
80 typedef struct {
81 int screen;
82 #if defined(HAVE_COCOA) && HAVE_COCOA
83 NSWindow *cocoaWin;
84 NSOpenGLContext *cocoaCtx;
85 #elif defined(HAVE_X11) && HAVE_X11
86 Window win;
87 Window parent;
88 Display *dpy;
89 XVisualInfo *vi;
90 GLXContext ctx;
91 XSetWindowAttributes attr;
92 Common::Thread *xEventThread;
93 #if defined(HAVE_XRANDR) && HAVE_XRANDR
94 XRRScreenConfiguration *screenConfig;
95 Rotation screenRotation;
96 int deskSize, fullSize;
97 #endif // XRANDR
98 #endif // X11
99 #if defined(USE_WX) && USE_WX
100 wxGLCanvas *glCanvas;
101 wxPanel *panel;
102 wxGLContext *glCtxt;
103 #endif
104 int x, y;
105 unsigned int width, height;
106 } GLWindow;
108 extern GLWindow GLWin;
110 #endif
112 // Public OpenGL util
114 // Initialization / upkeep
115 bool OpenGL_Create(SVideoInitialize &_VideoInitialize, int _width, int _height);
116 void OpenGL_Shutdown();
117 void OpenGL_Update();
118 bool OpenGL_MakeCurrent();
119 void OpenGL_SwapBuffers();
121 // Get status
122 u32 OpenGL_GetBackbufferWidth();
123 u32 OpenGL_GetBackbufferHeight();
125 // Set things
126 void OpenGL_SetWindowText(const char *text);
128 // Error reporting - use the convenient macros.
129 void OpenGL_ReportARBProgramError();
130 GLuint OpenGL_ReportGLError(const char *function, const char *file, int line);
131 bool OpenGL_ReportFBOError(const char *function, const char *file, int line);
133 #if 1
134 #define GL_REPORT_ERROR() OpenGL_ReportGLError (__FUNCTION__, __FILE__, __LINE__)
135 #define GL_REPORT_PROGRAM_ERROR() OpenGL_ReportARBProgramError()
136 #define GL_REPORT_FBO_ERROR() OpenGL_ReportFBOError (__FUNCTION__, __FILE__, __LINE__)
137 #else
138 #define GL_REPORT_ERROR() GL_NO_ERROR
139 #define GL_REPORT_PROGRAM_ERROR()
140 #define GL_REPORT_FBO_ERROR()
141 #endif
143 #if defined(_DEBUG) || defined(DEBUGFAST)
144 #define GL_REPORT_ERRORD() OpenGL_ReportGLError(__FUNCTION__, __FILE__, __LINE__)
145 #else
146 #define GL_REPORT_ERRORD()
147 #endif
149 #include <Cg/cg.h>
150 #include <Cg/cgGL.h>
152 extern CGcontext g_cgcontext;
153 extern CGprofile g_cgvProf, g_cgfProf;
155 #endif // _GLINIT_H_