4 #include <gdk/gdkkeysyms.h>
10 guint load_texture(char *filename)
13 GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file(filename, NULL);
14 guchar *pixels = gdk_pixbuf_get_pixels(pixbuf);
15 int width = gdk_pixbuf_get_width(pixbuf);
16 int height = gdk_pixbuf_get_height(pixbuf);
20 glGenTextures(1, &id);
21 glBindTexture(GL_TEXTURE_2D, id); // 2d texture (x and y size)
23 glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
24 glTexImage2D(GL_TEXTURE_2D, 0, 3, width, height, 0,
25 GL_RGB, GL_UNSIGNED_BYTE, pixels);
26 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
27 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
29 g_message("loaded %s: w=%d h=%d", filename, width, height);
33 static gboolean expose(GtkWidget *da, GdkEventExpose *event, gpointer user_data)
35 //g_message("ridge:expose");
37 glScaled(500*1000, 500*1000, 0);
39 glBindTexture(GL_TEXTURE_2D, topo_tex);
40 glEnable(GL_TEXTURE_2D);
43 glTexCoord2f(0.0, 0.0); glVertex3f(-1.0, 1.0, 0.1);
44 glTexCoord2f(0.0, 1.0); glVertex3f(-1.0, -1.0, 0.1);
45 glTexCoord2f(1.0, 1.0); glVertex3f( 1.0, -1.0, 0.1);
46 glTexCoord2f(1.0, 0.0); glVertex3f( 1.0, 1.0, 0.1);
53 static gboolean configure(GtkWidget *da, GdkEventConfigure *event, gpointer user_data)
55 topo_tex = load_texture("../data/topo.jpg");
59 gboolean ridge_init(GtkDrawingArea *drawing, GtkNotebook *config)
61 /* Set up OpenGL Stuff */
62 g_signal_connect(drawing, "expose-event", G_CALLBACK(expose), NULL);
63 g_signal_connect(drawing, "configure-event", G_CALLBACK(configure), NULL);