diff options
author | taw27 <taw27@bf6ca9ba-c028-0410-8290-897cf20841d1> | 2007-09-05 12:48:17 +0000 |
---|---|---|
committer | taw27 <taw27@bf6ca9ba-c028-0410-8290-897cf20841d1> | 2007-09-05 12:48:17 +0000 |
commit | 9a696404c7473256598f1dd4253979feb95c9e83 (patch) | |
tree | fb8dfcf83b331cbfe8d7ba0ef5d91228f3bd7f5c /src | |
parent | 33812018c1584e0ccdea764ae971c1dd82e7a5d3 (diff) |
Move some things around
Specify normals for tilt axis pointer
git-svn-id: svn://cook.msm.cam.ac.uk:745/diff-tomo/dtr@117 bf6ca9ba-c028-0410-8290-897cf20841d1
Diffstat (limited to 'src')
-rw-r--r-- | src/displaywindow.c | 71 |
1 files changed, 43 insertions, 28 deletions
diff --git a/src/displaywindow.c b/src/displaywindow.c index 64a4c41..47d7ffd 100644 --- a/src/displaywindow.c +++ b/src/displaywindow.c @@ -431,6 +431,8 @@ static void displaywindow_gl_create_list(DisplayWindow *dw) { glEnd(); /* Tilt axis */ + glPushMatrix(); + glRotatef(-ctx->images[0].omega, 0.0, 0.0, 1.0); glPolygonOffset(1.0, 1.0); glEnable(GL_POLYGON_OFFSET_LINE); glBegin(GL_LINES); @@ -444,14 +446,21 @@ static void displaywindow_gl_create_list(DisplayWindow *dw) { glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, yellow); glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, black); glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 0.0); - glVertex3f(50, 0.0, 0.0); - glVertex3f(50-5, 1.0, 1.0); - glVertex3f(50-5, -1.0, 1.0); - glVertex3f(50-5, -1.0, -1.0); - glVertex3f(50-5, 1.0, -1.0); - glVertex3f(50-5, 1.0, 1.0); + glVertex3f(50.0, 0.0, 0.0); + glNormal3f(1.0, 0.0, 0.0); + glVertex3f(50.0-5.0, 1.0, 1.0); + glNormal3f(-2.5, 1.0, 1.0); + glVertex3f(50.0-5.0, -1.0, 1.0); + glNormal3f(-2.5, -1.0, 1.0); + glVertex3f(50.0-5.0, -1.0, -1.0); + glNormal3f(-2.5, -1.0, -1.0); + glVertex3f(50.0-5.0, 1.0, -1.0); + glNormal3f(-2.5, 1.0, -1.0); + glVertex3f(50.0-5.0, 1.0, 1.0); + glNormal3f(-2.5, 1.0, 1.0); glEnd(); glDisable(GL_POLYGON_OFFSET_LINE); + glPopMatrix(); /* Plot the other reflections */ reflection = ctx->reflectionctx->reflections; @@ -599,6 +608,11 @@ static gint displaywindow_gl_expose(GtkWidget *widget, GdkEventExpose *event, Di glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_ACCUM_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); + /* NB The virtual trackball works by rotating the objects, not the viewer. + * i.e. it operates on the ModelView matrix, not the Projection matrix. + * Therefore, multiply the current ModelView by whatever transformations + * are required, pushing/popping as appropriate. Don't do glLoadIdentity(). */ + glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glTranslatef(dw->x_pos, -dw->y_pos, -dw->distance); build_rotmatrix(m, dw->view_quat); @@ -743,10 +757,29 @@ static gboolean displaywindow_gl_configure(GtkWidget *widget, GdkEventConfigure } -static gint displaywindow_closedown(GtkWidget *widget, DisplayWindow *dw) { +static void displaywindow_gl_free_resources(DisplayWindow *dw) { - return 0; + if ( dw->gl_use_buffers ) { + glDeleteBuffersARB(1, &dw->gl_ref_vertex_buffer); + glDeleteBuffersARB(1, &dw->gl_marker_vertex_buffer); + glDeleteBuffersARB(1, &dw->gl_marker_normal_buffer); + glDeleteBuffersARB(1, &dw->gl_gen_vertex_buffer); + glDeleteBuffersARB(1, &dw->gl_gen_normal_buffer); + } else { + free(dw->gl_ref_vertex_array); + free(dw->gl_marker_vertex_array); + free(dw->gl_marker_normal_array); + free(dw->gl_gen_vertex_array); + free(dw->gl_gen_normal_array); + } + glDeleteLists(dw->gl_list_id, 1); + +} +static gint displaywindow_closedown(GtkWidget *widget, DisplayWindow *dw) { + displaywindow_gl_free_resources(dw); + gtk_exit(0); + return 0; } DisplayWindow *displaywindow_open(ControlContext *ctx) { @@ -786,8 +819,7 @@ DisplayWindow *displaywindow_open(ControlContext *ctx) { gtk_statusbar_set_has_resize_grip(GTK_STATUSBAR(dw->status_bar), FALSE); gtk_box_pack_end(GTK_BOX(dw->bigvbox), dw->status_bar, FALSE, FALSE, 0); - g_signal_connect(GTK_OBJECT(dw->window), "destroy", G_CALLBACK(displaywindow_closedown), NULL); - g_signal_connect_after(GTK_OBJECT(dw->window), "destroy", G_CALLBACK(gtk_main_quit), NULL); + g_signal_connect(GTK_OBJECT(dw->window), "destroy", G_CALLBACK(displaywindow_closedown), dw); /* GL stuff */ glconfig = gdk_gl_config_new_by_mode(GDK_GL_MODE_RGB | GDK_GL_MODE_DEPTH | GDK_GL_MODE_DOUBLE); @@ -814,25 +846,8 @@ DisplayWindow *displaywindow_open(ControlContext *ctx) { } void displaywindow_update(DisplayWindow *dw) { - - if ( dw->gl_use_buffers ) { - glDeleteBuffersARB(1, &dw->gl_ref_vertex_buffer); - glDeleteBuffersARB(1, &dw->gl_marker_vertex_buffer); - glDeleteBuffersARB(1, &dw->gl_marker_normal_buffer); - glDeleteBuffersARB(1, &dw->gl_gen_vertex_buffer); - glDeleteBuffersARB(1, &dw->gl_gen_normal_buffer); - } else { - free(dw->gl_ref_vertex_array); - free(dw->gl_marker_vertex_array); - free(dw->gl_marker_normal_array); - free(dw->gl_gen_vertex_array); - free(dw->gl_gen_normal_array); - } - glDeleteLists(dw->gl_list_id, 1); - + displaywindow_gl_free_resources(dw); displaywindow_gl_create_list(dw); - gdk_window_invalidate_rect(dw->drawing_area->window, &dw->drawing_area->allocation, FALSE); - } |