+/*
+ * Copyright (C) 2009-2011 Andy Spencer <andy753421@gmail.com>
+ *
+ * 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, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * 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 for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
#include <gtk/gtk.h>
/***************************
* GtkGlExt implementation *
***************************/
-#if defined(USE_GTKGLEXT)
+#if defined(SYS_GTKGLEXT)
#include <gtk/gtkgl.h>
void gtk_gl_enable(GtkWidget *widget)
{
/**********************
* X11 implementation *
**********************/
-#elif defined(USE_GLX)
+#elif defined(SYS_X11)
#include <GL/glx.h>
#include <gdk/gdkx.h>
void gtk_gl_enable(GtkWidget *widget)
GLX_DEPTH_SIZE, 1,
None};
XVisualInfo *xvinfo = glXChooseVisual(xdisplay, nscreen, attribs);
+ if (!xvinfo)
+ g_error("GtkGl: enable - unable to get valid OpenGL Visual");
GLXContext context = glXCreateContext(xdisplay, xvinfo, NULL, False);
g_object_set_data(G_OBJECT(widget), "glcontext", context);
/************************
* Win32 implementation *
************************/
-#elif defined(USE_WGL)
+#elif defined(SYS_WIN)
#include <windows.h>
#include <gdk/gdkwin32.h>
static void on_realize(GtkWidget *widget, gpointer _)
/**************************
* Mac OSX implementation *
**************************/
-#elif defined(USE_CGL)
-void gtk_gl_enable(GtkWidget *widget) { }
-void gtk_gl_begin(GtkWidget *widget) { }
-void gtk_gl_end(GtkWidget *widget) { }
-void gtk_gl_disable(GtkWidget *widget) { }
+#elif defined(SYS_MAC)
+void gtk_gl_enable(GtkWidget *widget)
+{
+ CGDisplayCapture( kCGDirectMainDisplay );
+ CGLPixelFormatAttribute attribs[] =
+ {
+ kCGLPFANoRecovery,
+ kCGLPFADoubleBuffer,
+ kCGLPFAFullScreen,
+ kCGLPFAStencilSize, ( CGLPixelFormatAttribute ) 8,
+ kCGLPFADisplayMask, ( CGLPixelFormatAttribute ) CGDisplayIDToOpenGLDisplayMask( kCGDirectMainDisplay ),
+ ( CGLPixelFormatAttribute ) NULL
+ };
+
+ CGLPixelFormatObj pixelFormatObj;
+ GLint numPixelFormats;
+ CGLChoosePixelFormat( attribs, &pixelFormatObj, &numPixelFormats );
+
+ CGLCreateContext( pixelFormatObj, NULL, &contextObj );
+
+ CGLDestroyPixelFormat( pixelFormatObj );
+
+ CGLSetCurrentContext( contextObj );
+ CGLSetFullScreen( contextObj );
+}
+
+void gtk_gl_begin(GtkWidget *widget)
+{
+}
+
+void gtk_gl_end(GtkWidget *widget)
+{
+}
+
+void gtk_gl_disable(GtkWidget *widget)
+{
+}
/****************************