]> Pileus Git - grits/blobdiff - src/gtkgl.c
Update windowing system tests
[grits] / src / gtkgl.c
index 9a2909aaa77a83d219ce41b01078a7be807f2f7c..052f56256238cee402e9a48c138def126b92c2db 100644 (file)
@@ -1,9 +1,26 @@
+/*
+ * 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)
 {
@@ -36,7 +53,7 @@ void gtk_gl_disable(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)
@@ -56,6 +73,8 @@ 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);
 
@@ -97,7 +116,7 @@ void gtk_gl_disable(GtkWidget *widget)
 /************************
  * Win32 implementation *
  ************************/
-#elif defined(USE_WGL)
+#elif defined(SYS_WIN)
 #include <windows.h>
 #include <gdk/gdkwin32.h>
 static void on_realize(GtkWidget *widget, gpointer _)
@@ -171,11 +190,43 @@ void gtk_gl_disable(GtkWidget *widget)
 /**************************
  * 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)
+{
+}
 
 
 /****************************