/* * Copyright (C) 2005 Ray Strode , * Matthias Clasen , * Søren Sandmann * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA * 02111-1307, USA. * * Originally written by: Ray Strode * * Later contributions by: Matthias Clasen * Søren Sandmann */ #include #include #include #include #include #include #include #include #include #include #include #include #include "gs-theme-window.h" static gchar *geometry = NULL; static GOptionEntry options[] = { {"geometry", 0, 0, G_OPTION_ARG_STRING, &geometry, N_("The initial size and position of window"), N_("WIDTHxHEIGHT+X+Y")}, {NULL} }; static gboolean expose (GtkWidget *da, GdkEventExpose *event, gpointer user_data) { GdkGLContext *glcontext = gtk_widget_get_gl_context(da); GdkGLDrawable *gldrawable = gtk_widget_get_gl_drawable(da); if (!gdk_gl_drawable_gl_begin(gldrawable, glcontext)) { g_assert_not_reached(); } glBegin(GL_QUADS); glColor3f(1, 0.6, 0); glNormal3f(0, 0, 1); glVertex2f(1, 1); glVertex2f(-1, 1); glVertex2f(-1, -1); glVertex2f(1, 0); glEnd(); if (gdk_gl_drawable_is_double_buffered(gldrawable)) gdk_gl_drawable_swap_buffers(gldrawable); else glFlush(); gdk_gl_drawable_gl_end(gldrawable); return TRUE; } static gboolean configure (GtkWidget *da, GdkEventConfigure *event, gpointer user_data) { GdkGLContext *glcontext = gtk_widget_get_gl_context(da); GdkGLDrawable *gldrawable = gtk_widget_get_gl_drawable(da); if (!gdk_gl_drawable_gl_begin(gldrawable, glcontext)) { g_assert_not_reached(); } glViewport(0, 0, da->allocation.width, da->allocation.height); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glMatrixMode(GL_MODELVIEW); glShadeModel(GL_SMOOTH); gdk_gl_drawable_gl_end(gldrawable); return TRUE; } int main (int argc, char *argv[]) { GtkWidget *window; GtkWidget *drawing_area; GdkGLConfig *glconfig; GtkStateType state; GError *error; error = NULL; gtk_init_with_args (&argc, &argv, _("DornerWorks ScreenSaver"), NULL, NULL, &error); gtk_gl_init(&argc, &argv); if (error != NULL) { g_printerr (_("%s. See --help for usage information.\n"), _(error->message)); g_error_free (error); return EX_SOFTWARE; } window = gs_theme_window_new (); g_signal_connect (G_OBJECT (window), "delete-event", G_CALLBACK (gtk_main_quit), NULL); drawing_area = gtk_drawing_area_new (); glconfig = gdk_gl_config_new_by_mode( GDK_GL_MODE_RGB | GDK_GL_MODE_DEPTH | GDK_GL_MODE_DOUBLE); if (!glconfig) { g_assert_not_reached(); } if (!gtk_widget_set_gl_capability(drawing_area, glconfig, NULL, TRUE, GDK_GL_RGBA_TYPE)) { g_assert_not_reached(); } g_signal_connect(drawing_area, "configure-event", G_CALLBACK(configure), NULL); g_signal_connect(drawing_area, "expose-event", G_CALLBACK(expose), NULL); gtk_widget_show (drawing_area); gtk_container_add (GTK_CONTAINER (window), drawing_area); if ((geometry == NULL) || !gtk_window_parse_geometry (GTK_WINDOW (window), geometry)) { gtk_window_set_default_size (GTK_WINDOW (window), 640, 480); } gtk_widget_show (window); gtk_main (); return EX_OK; }