Created example openGL triangle in window.
authorRafał Długołęcki <rafal@dlugolecki.net.pl>
Sun, 12 Jan 2014 00:30:07 +0000 (01:30 +0100)
committerRafał Długołęcki <rafal@dlugolecki.net.pl>
Sun, 12 Jan 2014 00:30:07 +0000 (01:30 +0100)
src/viewport/drawing_area.c

index 07e916609d20369bc860d8087173f9b96b866326..374c87cc724a2015758fd1fecbc4fcbeadd49ef8 100644 (file)
@@ -17,10 +17,16 @@ gboolean drawing_area_draw(GtkWidget *widget, cairo_t *cr, gpointer user_data)
                return FALSE;
        }
 
-       glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+//     glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
 
        glPushMatrix ();
+               glLoadIdentity ();
                glColor3f (1.0, 1.0, 1.0);
+               glBegin(GL_TRIANGLES);
+                       glVertex3f( 0.0f, 1.0f, 0.0f);    // Top
+                       glVertex3f(-1.0f,-1.0f, 0.0f);    // Bottom Left
+                       glVertex3f( 1.0f,-1.0f, 0.0f);    // Bottom Right
+               glEnd();
        glPopMatrix ();
 
        gtk_widget_end_gl (widget, TRUE);
@@ -49,8 +55,8 @@ gboolean drawing_area_configure_event (GtkWidget *widget,
        GLfloat width = 0;
        /* Current page height */
        GLfloat height = 0;
-       /* Current page */
-       struct order_page *page = NULL;
+       /* Aspect ratio */
+       GLfloat aspect = 0;
 
        gtk_widget_get_allocation (widget, &allocation);
        w = allocation.width;
@@ -65,7 +71,14 @@ gboolean drawing_area_configure_event (GtkWidget *widget,
        glMatrixMode (GL_PROJECTION);
        glLoadIdentity ();
 
-       /* Code was here */
+//     if (w > h) {
+               aspect = w / h;
+//             glFrustum (-aspect, aspect, -1.0, 1.0, 5.0, 60.0);
+//     }
+//     else {
+//             aspect = h / w;
+               glFrustum (-1.0, 1.0, -aspect, aspect, 5.0, 60.0);
+//     }
 
        glMatrixMode (GL_MODELVIEW);