From: Rafał Długołęcki Date: Sun, 12 Jan 2014 00:30:07 +0000 (+0100) Subject: Created example openGL triangle in window. X-Git-Url: https://git.dlugolecki.net.pl/?a=commitdiff_plain;h=4332a173c913ba3b3db75c5be52d9aca20b64aac;p=familia.git Created example openGL triangle in window. --- diff --git a/src/viewport/drawing_area.c b/src/viewport/drawing_area.c index 07e9166..374c87c 100644 --- a/src/viewport/drawing_area.c +++ b/src/viewport/drawing_area.c @@ -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);