orange quad test working
This commit is contained in:
parent
b113b26ceb
commit
83ba6c75b4
62
dwss.c
62
dwss.c
@ -39,6 +39,8 @@
|
||||
#include <gtk/gtk.h>
|
||||
#include <gtk/gtkgl.h>
|
||||
|
||||
#include <GL/gl.h>
|
||||
|
||||
#include "gs-theme-window.h"
|
||||
|
||||
static gchar *geometry = NULL;
|
||||
@ -50,6 +52,61 @@ static GOptionEntry options[] = {
|
||||
{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[])
|
||||
@ -101,6 +158,11 @@ main (int argc,
|
||||
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);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user