Mercurial > hg > mxe-octave-anirudha
annotate src/gtkglext-test.c @ 3013:bcc26ffe9a0f
use variable for --host and --build configure arguments
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Sun, 02 Jun 2013 12:40:32 -0400 |
parents | 99516e73b368 |
children |
rev | line source |
---|---|
2351
8a6c466753e2
Improve comment style of all test programs
Volker Grabsch <vog@notjusthosting.com>
parents:
2333
diff
changeset
|
1 /* |
8a6c466753e2
Improve comment style of all test programs
Volker Grabsch <vog@notjusthosting.com>
parents:
2333
diff
changeset
|
2 * This file is part of MXE. |
2353
99516e73b368
Move doc/index.html -> index.html
Volker Grabsch <vog@notjusthosting.com>
parents:
2351
diff
changeset
|
3 * See index.html for further information. |
2351
8a6c466753e2
Improve comment style of all test programs
Volker Grabsch <vog@notjusthosting.com>
parents:
2333
diff
changeset
|
4 */ |
964
9fb37f10b037
test program for package gtkglext (by Martin Gerhardy)
Volker Grabsch <vog@notjusthosting.com>
parents:
diff
changeset
|
5 |
9fb37f10b037
test program for package gtkglext (by Martin Gerhardy)
Volker Grabsch <vog@notjusthosting.com>
parents:
diff
changeset
|
6 #include <gtk/gtk.h> |
9fb37f10b037
test program for package gtkglext (by Martin Gerhardy)
Volker Grabsch <vog@notjusthosting.com>
parents:
diff
changeset
|
7 #include <gtk/gtkgl.h> |
9fb37f10b037
test program for package gtkglext (by Martin Gerhardy)
Volker Grabsch <vog@notjusthosting.com>
parents:
diff
changeset
|
8 #include <GL/gl.h> |
9fb37f10b037
test program for package gtkglext (by Martin Gerhardy)
Volker Grabsch <vog@notjusthosting.com>
parents:
diff
changeset
|
9 |
9fb37f10b037
test program for package gtkglext (by Martin Gerhardy)
Volker Grabsch <vog@notjusthosting.com>
parents:
diff
changeset
|
10 static gboolean eventExpose(GtkWidget *gl, GdkEventExpose *e, gpointer userData) |
9fb37f10b037
test program for package gtkglext (by Martin Gerhardy)
Volker Grabsch <vog@notjusthosting.com>
parents:
diff
changeset
|
11 { |
9fb37f10b037
test program for package gtkglext (by Martin Gerhardy)
Volker Grabsch <vog@notjusthosting.com>
parents:
diff
changeset
|
12 GdkGLContext *ctx = gtk_widget_get_gl_context(gl); |
9fb37f10b037
test program for package gtkglext (by Martin Gerhardy)
Volker Grabsch <vog@notjusthosting.com>
parents:
diff
changeset
|
13 GdkGLDrawable *drawable = gtk_widget_get_gl_drawable(gl); |
9fb37f10b037
test program for package gtkglext (by Martin Gerhardy)
Volker Grabsch <vog@notjusthosting.com>
parents:
diff
changeset
|
14 |
969
a57c09f1b3f2
avoid warnings in the test program of package gtkglext
Volker Grabsch <vog@notjusthosting.com>
parents:
964
diff
changeset
|
15 (void)e; |
a57c09f1b3f2
avoid warnings in the test program of package gtkglext
Volker Grabsch <vog@notjusthosting.com>
parents:
964
diff
changeset
|
16 (void)userData; |
a57c09f1b3f2
avoid warnings in the test program of package gtkglext
Volker Grabsch <vog@notjusthosting.com>
parents:
964
diff
changeset
|
17 |
964
9fb37f10b037
test program for package gtkglext (by Martin Gerhardy)
Volker Grabsch <vog@notjusthosting.com>
parents:
diff
changeset
|
18 gdk_gl_drawable_gl_begin(drawable, ctx); |
9fb37f10b037
test program for package gtkglext (by Martin Gerhardy)
Volker Grabsch <vog@notjusthosting.com>
parents:
diff
changeset
|
19 |
9fb37f10b037
test program for package gtkglext (by Martin Gerhardy)
Volker Grabsch <vog@notjusthosting.com>
parents:
diff
changeset
|
20 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); |
9fb37f10b037
test program for package gtkglext (by Martin Gerhardy)
Volker Grabsch <vog@notjusthosting.com>
parents:
diff
changeset
|
21 |
9fb37f10b037
test program for package gtkglext (by Martin Gerhardy)
Volker Grabsch <vog@notjusthosting.com>
parents:
diff
changeset
|
22 if (!gdk_gl_drawable_is_double_buffered(drawable)) |
9fb37f10b037
test program for package gtkglext (by Martin Gerhardy)
Volker Grabsch <vog@notjusthosting.com>
parents:
diff
changeset
|
23 glFinish(); |
9fb37f10b037
test program for package gtkglext (by Martin Gerhardy)
Volker Grabsch <vog@notjusthosting.com>
parents:
diff
changeset
|
24 else |
9fb37f10b037
test program for package gtkglext (by Martin Gerhardy)
Volker Grabsch <vog@notjusthosting.com>
parents:
diff
changeset
|
25 gdk_gl_drawable_swap_buffers(drawable); |
9fb37f10b037
test program for package gtkglext (by Martin Gerhardy)
Volker Grabsch <vog@notjusthosting.com>
parents:
diff
changeset
|
26 |
9fb37f10b037
test program for package gtkglext (by Martin Gerhardy)
Volker Grabsch <vog@notjusthosting.com>
parents:
diff
changeset
|
27 gdk_gl_drawable_gl_end(drawable); |
9fb37f10b037
test program for package gtkglext (by Martin Gerhardy)
Volker Grabsch <vog@notjusthosting.com>
parents:
diff
changeset
|
28 |
9fb37f10b037
test program for package gtkglext (by Martin Gerhardy)
Volker Grabsch <vog@notjusthosting.com>
parents:
diff
changeset
|
29 return TRUE; |
9fb37f10b037
test program for package gtkglext (by Martin Gerhardy)
Volker Grabsch <vog@notjusthosting.com>
parents:
diff
changeset
|
30 } |
9fb37f10b037
test program for package gtkglext (by Martin Gerhardy)
Volker Grabsch <vog@notjusthosting.com>
parents:
diff
changeset
|
31 |
9fb37f10b037
test program for package gtkglext (by Martin Gerhardy)
Volker Grabsch <vog@notjusthosting.com>
parents:
diff
changeset
|
32 static gboolean eventConfigure(GtkWidget *gl, GdkEventConfigure *e, gpointer userData) |
9fb37f10b037
test program for package gtkglext (by Martin Gerhardy)
Volker Grabsch <vog@notjusthosting.com>
parents:
diff
changeset
|
33 { |
9fb37f10b037
test program for package gtkglext (by Martin Gerhardy)
Volker Grabsch <vog@notjusthosting.com>
parents:
diff
changeset
|
34 const guint width = gl->allocation.width; |
9fb37f10b037
test program for package gtkglext (by Martin Gerhardy)
Volker Grabsch <vog@notjusthosting.com>
parents:
diff
changeset
|
35 const guint height = gl->allocation.height; |
9fb37f10b037
test program for package gtkglext (by Martin Gerhardy)
Volker Grabsch <vog@notjusthosting.com>
parents:
diff
changeset
|
36 |
969
a57c09f1b3f2
avoid warnings in the test program of package gtkglext
Volker Grabsch <vog@notjusthosting.com>
parents:
964
diff
changeset
|
37 (void)e; |
a57c09f1b3f2
avoid warnings in the test program of package gtkglext
Volker Grabsch <vog@notjusthosting.com>
parents:
964
diff
changeset
|
38 (void)userData; |
a57c09f1b3f2
avoid warnings in the test program of package gtkglext
Volker Grabsch <vog@notjusthosting.com>
parents:
964
diff
changeset
|
39 |
964
9fb37f10b037
test program for package gtkglext (by Martin Gerhardy)
Volker Grabsch <vog@notjusthosting.com>
parents:
diff
changeset
|
40 glLoadIdentity(); |
9fb37f10b037
test program for package gtkglext (by Martin Gerhardy)
Volker Grabsch <vog@notjusthosting.com>
parents:
diff
changeset
|
41 glViewport(0, 0, width, height); |
9fb37f10b037
test program for package gtkglext (by Martin Gerhardy)
Volker Grabsch <vog@notjusthosting.com>
parents:
diff
changeset
|
42 glOrtho(-3.5, 3.5, -3.5 * (GLfloat)height / (GLfloat)width, |
9fb37f10b037
test program for package gtkglext (by Martin Gerhardy)
Volker Grabsch <vog@notjusthosting.com>
parents:
diff
changeset
|
43 3.5 * (GLfloat)height / (GLfloat)width, -3.5, 3.5); |
9fb37f10b037
test program for package gtkglext (by Martin Gerhardy)
Volker Grabsch <vog@notjusthosting.com>
parents:
diff
changeset
|
44 |
9fb37f10b037
test program for package gtkglext (by Martin Gerhardy)
Volker Grabsch <vog@notjusthosting.com>
parents:
diff
changeset
|
45 return TRUE; |
9fb37f10b037
test program for package gtkglext (by Martin Gerhardy)
Volker Grabsch <vog@notjusthosting.com>
parents:
diff
changeset
|
46 } |
9fb37f10b037
test program for package gtkglext (by Martin Gerhardy)
Volker Grabsch <vog@notjusthosting.com>
parents:
diff
changeset
|
47 |
9fb37f10b037
test program for package gtkglext (by Martin Gerhardy)
Volker Grabsch <vog@notjusthosting.com>
parents:
diff
changeset
|
48 int main(int argc, char *argv[]) |
9fb37f10b037
test program for package gtkglext (by Martin Gerhardy)
Volker Grabsch <vog@notjusthosting.com>
parents:
diff
changeset
|
49 { |
9fb37f10b037
test program for package gtkglext (by Martin Gerhardy)
Volker Grabsch <vog@notjusthosting.com>
parents:
diff
changeset
|
50 GtkWidget* window; |
9fb37f10b037
test program for package gtkglext (by Martin Gerhardy)
Volker Grabsch <vog@notjusthosting.com>
parents:
diff
changeset
|
51 GtkWidget* gl; |
9fb37f10b037
test program for package gtkglext (by Martin Gerhardy)
Volker Grabsch <vog@notjusthosting.com>
parents:
diff
changeset
|
52 GdkGLConfig* glConfig; |
9fb37f10b037
test program for package gtkglext (by Martin Gerhardy)
Volker Grabsch <vog@notjusthosting.com>
parents:
diff
changeset
|
53 |
9fb37f10b037
test program for package gtkglext (by Martin Gerhardy)
Volker Grabsch <vog@notjusthosting.com>
parents:
diff
changeset
|
54 gtk_init(&argc, &argv); |
9fb37f10b037
test program for package gtkglext (by Martin Gerhardy)
Volker Grabsch <vog@notjusthosting.com>
parents:
diff
changeset
|
55 gtk_gl_init(&argc, &argv); |
9fb37f10b037
test program for package gtkglext (by Martin Gerhardy)
Volker Grabsch <vog@notjusthosting.com>
parents:
diff
changeset
|
56 |
9fb37f10b037
test program for package gtkglext (by Martin Gerhardy)
Volker Grabsch <vog@notjusthosting.com>
parents:
diff
changeset
|
57 window = gtk_window_new(GTK_WINDOW_TOPLEVEL); |
9fb37f10b037
test program for package gtkglext (by Martin Gerhardy)
Volker Grabsch <vog@notjusthosting.com>
parents:
diff
changeset
|
58 gl = gtk_drawing_area_new(); |
9fb37f10b037
test program for package gtkglext (by Martin Gerhardy)
Volker Grabsch <vog@notjusthosting.com>
parents:
diff
changeset
|
59 gtk_container_add(GTK_CONTAINER(window), gl); |
9fb37f10b037
test program for package gtkglext (by Martin Gerhardy)
Volker Grabsch <vog@notjusthosting.com>
parents:
diff
changeset
|
60 |
9fb37f10b037
test program for package gtkglext (by Martin Gerhardy)
Volker Grabsch <vog@notjusthosting.com>
parents:
diff
changeset
|
61 gtk_widget_set_events(gl, GDK_EXPOSURE_MASK); |
9fb37f10b037
test program for package gtkglext (by Martin Gerhardy)
Volker Grabsch <vog@notjusthosting.com>
parents:
diff
changeset
|
62 |
9fb37f10b037
test program for package gtkglext (by Martin Gerhardy)
Volker Grabsch <vog@notjusthosting.com>
parents:
diff
changeset
|
63 glConfig = gdk_gl_config_new_by_mode( |
9fb37f10b037
test program for package gtkglext (by Martin Gerhardy)
Volker Grabsch <vog@notjusthosting.com>
parents:
diff
changeset
|
64 GDK_GL_MODE_RGB | |
9fb37f10b037
test program for package gtkglext (by Martin Gerhardy)
Volker Grabsch <vog@notjusthosting.com>
parents:
diff
changeset
|
65 GDK_GL_MODE_ALPHA | |
9fb37f10b037
test program for package gtkglext (by Martin Gerhardy)
Volker Grabsch <vog@notjusthosting.com>
parents:
diff
changeset
|
66 GDK_GL_MODE_DEPTH | |
9fb37f10b037
test program for package gtkglext (by Martin Gerhardy)
Volker Grabsch <vog@notjusthosting.com>
parents:
diff
changeset
|
67 GDK_GL_MODE_DOUBLE); |
9fb37f10b037
test program for package gtkglext (by Martin Gerhardy)
Volker Grabsch <vog@notjusthosting.com>
parents:
diff
changeset
|
68 |
9fb37f10b037
test program for package gtkglext (by Martin Gerhardy)
Volker Grabsch <vog@notjusthosting.com>
parents:
diff
changeset
|
69 gtk_widget_set_gl_capability(gl, glConfig, |
9fb37f10b037
test program for package gtkglext (by Martin Gerhardy)
Volker Grabsch <vog@notjusthosting.com>
parents:
diff
changeset
|
70 NULL, TRUE, GDK_GL_RGBA_TYPE); |
9fb37f10b037
test program for package gtkglext (by Martin Gerhardy)
Volker Grabsch <vog@notjusthosting.com>
parents:
diff
changeset
|
71 |
9fb37f10b037
test program for package gtkglext (by Martin Gerhardy)
Volker Grabsch <vog@notjusthosting.com>
parents:
diff
changeset
|
72 g_signal_connect_swapped( |
9fb37f10b037
test program for package gtkglext (by Martin Gerhardy)
Volker Grabsch <vog@notjusthosting.com>
parents:
diff
changeset
|
73 G_OBJECT(window), "destroy", |
9fb37f10b037
test program for package gtkglext (by Martin Gerhardy)
Volker Grabsch <vog@notjusthosting.com>
parents:
diff
changeset
|
74 G_CALLBACK(gtk_main_quit), G_OBJECT(window)); |
9fb37f10b037
test program for package gtkglext (by Martin Gerhardy)
Volker Grabsch <vog@notjusthosting.com>
parents:
diff
changeset
|
75 |
9fb37f10b037
test program for package gtkglext (by Martin Gerhardy)
Volker Grabsch <vog@notjusthosting.com>
parents:
diff
changeset
|
76 g_signal_connect( |
9fb37f10b037
test program for package gtkglext (by Martin Gerhardy)
Volker Grabsch <vog@notjusthosting.com>
parents:
diff
changeset
|
77 G_OBJECT(window), "destroy", |
9fb37f10b037
test program for package gtkglext (by Martin Gerhardy)
Volker Grabsch <vog@notjusthosting.com>
parents:
diff
changeset
|
78 G_CALLBACK(gtk_main_quit), NULL); |
9fb37f10b037
test program for package gtkglext (by Martin Gerhardy)
Volker Grabsch <vog@notjusthosting.com>
parents:
diff
changeset
|
79 |
9fb37f10b037
test program for package gtkglext (by Martin Gerhardy)
Volker Grabsch <vog@notjusthosting.com>
parents:
diff
changeset
|
80 g_signal_connect(gl, "configure-event", |
9fb37f10b037
test program for package gtkglext (by Martin Gerhardy)
Volker Grabsch <vog@notjusthosting.com>
parents:
diff
changeset
|
81 G_CALLBACK(eventConfigure), NULL); |
9fb37f10b037
test program for package gtkglext (by Martin Gerhardy)
Volker Grabsch <vog@notjusthosting.com>
parents:
diff
changeset
|
82 |
9fb37f10b037
test program for package gtkglext (by Martin Gerhardy)
Volker Grabsch <vog@notjusthosting.com>
parents:
diff
changeset
|
83 g_signal_connect(gl, "expose-event", |
9fb37f10b037
test program for package gtkglext (by Martin Gerhardy)
Volker Grabsch <vog@notjusthosting.com>
parents:
diff
changeset
|
84 G_CALLBACK(eventExpose), NULL); |
9fb37f10b037
test program for package gtkglext (by Martin Gerhardy)
Volker Grabsch <vog@notjusthosting.com>
parents:
diff
changeset
|
85 |
9fb37f10b037
test program for package gtkglext (by Martin Gerhardy)
Volker Grabsch <vog@notjusthosting.com>
parents:
diff
changeset
|
86 gtk_widget_show_all(window); |
9fb37f10b037
test program for package gtkglext (by Martin Gerhardy)
Volker Grabsch <vog@notjusthosting.com>
parents:
diff
changeset
|
87 |
9fb37f10b037
test program for package gtkglext (by Martin Gerhardy)
Volker Grabsch <vog@notjusthosting.com>
parents:
diff
changeset
|
88 gtk_main(); |
9fb37f10b037
test program for package gtkglext (by Martin Gerhardy)
Volker Grabsch <vog@notjusthosting.com>
parents:
diff
changeset
|
89 return 0; |
9fb37f10b037
test program for package gtkglext (by Martin Gerhardy)
Volker Grabsch <vog@notjusthosting.com>
parents:
diff
changeset
|
90 } |