diff options
author | taw27 <taw27@bf6ca9ba-c028-0410-8290-897cf20841d1> | 2007-09-04 19:51:41 +0000 |
---|---|---|
committer | taw27 <taw27@bf6ca9ba-c028-0410-8290-897cf20841d1> | 2007-09-04 19:51:41 +0000 |
commit | 5bb6af0c8ec375ed557b5c4a2f9c6e54cc274036 (patch) | |
tree | 0b731b337057a56a7c9d961cacfcca6574127c98 /src | |
parent | 14dd96829ed69a7f9635ba4cbad91472b635dc3b (diff) |
"Basis" is a property of IPR, not rctx
OpenGL stuff belongs to DisplayWindow
git-svn-id: svn://cook.msm.cam.ac.uk:745/diff-tomo/dtr@114 bf6ca9ba-c028-0410-8290-897cf20841d1
Diffstat (limited to 'src')
-rw-r--r-- | src/control.h | 20 | ||||
-rw-r--r-- | src/displaywindow.c | 215 | ||||
-rw-r--r-- | src/imagedisplay.h | 2 | ||||
-rw-r--r-- | src/ipr.c | 12 | ||||
-rw-r--r-- | src/ipr.h | 16 | ||||
-rw-r--r-- | src/reflections.h | 18 |
6 files changed, 140 insertions, 143 deletions
diff --git a/src/control.h b/src/control.h index 46646a0..3dc030c 100644 --- a/src/control.h +++ b/src/control.h @@ -116,28 +116,12 @@ typedef struct cctx_struct { GtkWidget *combo_peaksearch; GtkWidget *checkbox_prealign; GtkWidget *checkbox_savecache; - - /* OpenGL bits */ - GLuint gl_list_id; /* Display list for "everything else" */ - int gl_use_buffers; /* 0=use vertex arrays only, otherwise use VBOs */ - GLuint gl_ref_vertex_buffer; /* "Measured reflection" stuff */ - GLfloat *gl_ref_vertex_array; - GLsizei gl_ref_num_vertices; - GLuint gl_marker_vertex_buffer; /* Marker "reflection" stuff */ - GLuint gl_marker_normal_buffer; - GLfloat *gl_marker_vertex_array; - GLfloat *gl_marker_normal_array; - GLsizei gl_marker_num_vertices; - GLuint gl_gen_vertex_buffer; /* Generated reflection stuff */ - GLuint gl_gen_normal_buffer; - GLfloat *gl_gen_vertex_array; - GLfloat *gl_gen_normal_array; - GLsizei gl_gen_num_vertices; /* IPR stuff */ int ipr_cur_image; - struct struct_imagedisplay *ipr_id; + struct imagedisplay_struct *ipr_id; struct rctx_struct *ipr_lat; + struct basis_struct *ipr_basis; } ControlContext; diff --git a/src/displaywindow.c b/src/displaywindow.c index 1d72f4f..39532b5 100644 --- a/src/displaywindow.c +++ b/src/displaywindow.c @@ -28,6 +28,7 @@ #include "trackball.h" #include "reflections.h" #include "main.h" +#include "ipr.h" enum { DW_ORTHO, @@ -54,6 +55,21 @@ typedef struct { float y_start; float view_quat[4]; int fog; + GLuint gl_list_id; /* Display list for "everything else" */ + int gl_use_buffers; /* 0=use vertex arrays only, otherwise use VBOs */ + GLuint gl_ref_vertex_buffer; /* "Measured reflection" stuff */ + GLfloat *gl_ref_vertex_array; + GLsizei gl_ref_num_vertices; + GLuint gl_marker_vertex_buffer; /* Marker "reflection" stuff */ + GLuint gl_marker_normal_buffer; + GLfloat *gl_marker_vertex_array; + GLfloat *gl_marker_normal_array; + GLsizei gl_marker_num_vertices; + GLuint gl_gen_vertex_buffer; /* Generated reflection stuff */ + GLuint gl_gen_normal_buffer; + GLfloat *gl_gen_vertex_array; + GLfloat *gl_gen_normal_array; + GLsizei gl_gen_num_vertices; } DisplayWindow; @@ -304,7 +320,7 @@ static gint displaywindow_gl_motion_notify(GtkWidget *widget, GdkEventMotion *ev } \ } -static void displaywindow_gl_create_list(ControlContext *ctx) { +static void displaywindow_gl_create_list(DisplayWindow *dw) { GLfloat blue[] = { 0.0, 0.0, 0.5, 1.0 }; GLfloat blue_spec[] = { 0.0, 0.0, 1.0, 1.0 }; @@ -315,12 +331,15 @@ static void displaywindow_gl_create_list(ControlContext *ctx) { Reflection *reflection; GLUquadricObj *quadric; int i; + ControlContext *ctx; GLfloat *vertices; GLfloat *normals; - + + ctx = dw->ctx; + /* "Measured" reflections */ - if ( ctx->gl_use_buffers ) { - glGenBuffersARB(1, &ctx->gl_ref_vertex_buffer); + if ( dw->gl_use_buffers ) { + glGenBuffersARB(1, &dw->gl_ref_vertex_buffer); } reflection = ctx->reflectionctx->reflections; i = 0; @@ -328,10 +347,10 @@ static void displaywindow_gl_create_list(ControlContext *ctx) { if ( reflection->type == REFLECTION_NORMAL ) i++; reflection = reflection->next; } while ( reflection != NULL ); - ctx->gl_ref_num_vertices = i; + dw->gl_ref_num_vertices = i; i = 0; reflection = ctx->reflectionctx->reflections; - vertices = malloc(3*ctx->gl_ref_num_vertices*sizeof(GLfloat)); + vertices = malloc(3*dw->gl_ref_num_vertices*sizeof(GLfloat)); do { if ( reflection->type == REFLECTION_NORMAL ) { vertices[3*i + 0] = reflection->x/1e9; @@ -341,19 +360,18 @@ static void displaywindow_gl_create_list(ControlContext *ctx) { } reflection = reflection->next; } while ( reflection != NULL ); - if ( ctx->gl_use_buffers ) { - glBindBufferARB(GL_ARRAY_BUFFER, ctx->gl_ref_vertex_buffer); - glBufferDataARB(GL_ARRAY_BUFFER, 3*ctx->gl_ref_num_vertices*sizeof(GLfloat), vertices, GL_STATIC_DRAW); + if ( dw->gl_use_buffers ) { + glBindBufferARB(GL_ARRAY_BUFFER, dw->gl_ref_vertex_buffer); + glBufferDataARB(GL_ARRAY_BUFFER, 3*dw->gl_ref_num_vertices*sizeof(GLfloat), vertices, GL_STATIC_DRAW); free(vertices); } else { - ctx->gl_ref_vertex_array = vertices; + dw->gl_ref_vertex_array = vertices; } - /* Marker "reflections" */ - if ( ctx->gl_use_buffers ) { - glGenBuffersARB(1, &ctx->gl_marker_vertex_buffer); - glGenBuffersARB(1, &ctx->gl_marker_normal_buffer); + if ( dw->gl_use_buffers ) { + glGenBuffersARB(1, &dw->gl_marker_vertex_buffer); + glGenBuffersARB(1, &dw->gl_marker_normal_buffer); } reflection = ctx->reflectionctx->reflections; i = 0; @@ -361,33 +379,33 @@ static void displaywindow_gl_create_list(ControlContext *ctx) { if ( reflection->type == REFLECTION_MARKER ) i++; reflection = reflection->next; } while ( reflection != NULL ); - ctx->gl_marker_num_vertices = i*VERTICES_IN_A_BLOB; + dw->gl_marker_num_vertices = i*VERTICES_IN_A_BLOB; i = 0; reflection = ctx->reflectionctx->reflections; - vertices = malloc(3*ctx->gl_marker_num_vertices*sizeof(GLfloat)); - normals = malloc(3*ctx->gl_marker_num_vertices*sizeof(GLfloat)); + vertices = malloc(3*dw->gl_marker_num_vertices*sizeof(GLfloat)); + normals = malloc(3*dw->gl_marker_num_vertices*sizeof(GLfloat)); do { if ( reflection->type == REFLECTION_MARKER ) { DRAW_BLOB } reflection = reflection->next; } while ( reflection != NULL ); - if ( ctx->gl_use_buffers ) { - glBindBufferARB(GL_ARRAY_BUFFER, ctx->gl_marker_vertex_buffer); - glBufferDataARB(GL_ARRAY_BUFFER, 3*ctx->gl_marker_num_vertices*sizeof(GLfloat), vertices, GL_STATIC_DRAW); + if ( dw->gl_use_buffers ) { + glBindBufferARB(GL_ARRAY_BUFFER, dw->gl_marker_vertex_buffer); + glBufferDataARB(GL_ARRAY_BUFFER, 3*dw->gl_marker_num_vertices*sizeof(GLfloat), vertices, GL_STATIC_DRAW); free(vertices); - glBindBufferARB(GL_ARRAY_BUFFER, ctx->gl_marker_normal_buffer); - glBufferDataARB(GL_ARRAY_BUFFER, 3*ctx->gl_marker_num_vertices*sizeof(GLfloat), normals, GL_STATIC_DRAW); + glBindBufferARB(GL_ARRAY_BUFFER, dw->gl_marker_normal_buffer); + glBufferDataARB(GL_ARRAY_BUFFER, 3*dw->gl_marker_num_vertices*sizeof(GLfloat), normals, GL_STATIC_DRAW); free(normals); } else { - ctx->gl_marker_vertex_array = vertices; - ctx->gl_marker_normal_array = normals; + dw->gl_marker_vertex_array = vertices; + dw->gl_marker_normal_array = normals; } /* Generated reflections */ - if ( ctx->gl_use_buffers ) { - glGenBuffersARB(1, &ctx->gl_gen_vertex_buffer); - glGenBuffersARB(1, &ctx->gl_gen_normal_buffer); + if ( dw->gl_use_buffers ) { + glGenBuffersARB(1, &dw->gl_gen_vertex_buffer); + glGenBuffersARB(1, &dw->gl_gen_normal_buffer); } reflection = ctx->reflectionctx->reflections; i = 0; @@ -395,31 +413,31 @@ static void displaywindow_gl_create_list(ControlContext *ctx) { if ( reflection->type == REFLECTION_GENERATED ) i++; reflection = reflection->next; } while ( reflection != NULL ); - ctx->gl_gen_num_vertices = i*VERTICES_IN_A_BLOB; + dw->gl_gen_num_vertices = i*VERTICES_IN_A_BLOB; i = 0; reflection = ctx->reflectionctx->reflections; - vertices = malloc(3*ctx->gl_gen_num_vertices*sizeof(GLfloat)); - normals = malloc(3*ctx->gl_gen_num_vertices*sizeof(GLfloat)); + vertices = malloc(3*dw->gl_gen_num_vertices*sizeof(GLfloat)); + normals = malloc(3*dw->gl_gen_num_vertices*sizeof(GLfloat)); do { if ( reflection->type == REFLECTION_GENERATED ) { DRAW_BLOB } reflection = reflection->next; } while ( reflection != NULL ); - if ( ctx->gl_use_buffers ) { - glBindBufferARB(GL_ARRAY_BUFFER, ctx->gl_gen_vertex_buffer); - glBufferDataARB(GL_ARRAY_BUFFER, 3*ctx->gl_gen_num_vertices*sizeof(GLfloat), vertices, GL_STATIC_DRAW); + if ( dw->gl_use_buffers ) { + glBindBufferARB(GL_ARRAY_BUFFER, dw->gl_gen_vertex_buffer); + glBufferDataARB(GL_ARRAY_BUFFER, 3*dw->gl_gen_num_vertices*sizeof(GLfloat), vertices, GL_STATIC_DRAW); free(vertices); - glBindBufferARB(GL_ARRAY_BUFFER, ctx->gl_gen_normal_buffer); - glBufferDataARB(GL_ARRAY_BUFFER, 3*ctx->gl_gen_num_vertices*sizeof(GLfloat), normals, GL_STATIC_DRAW); + glBindBufferARB(GL_ARRAY_BUFFER, dw->gl_gen_normal_buffer); + glBufferDataARB(GL_ARRAY_BUFFER, 3*dw->gl_gen_num_vertices*sizeof(GLfloat), normals, GL_STATIC_DRAW); free(normals); glBindBufferARB(GL_ARRAY_BUFFER, 0); /* ************* */ } else { - ctx->gl_gen_vertex_array = vertices; + dw->gl_gen_vertex_array = vertices; } - ctx->gl_list_id = glGenLists(1); - glNewList(ctx->gl_list_id, GL_COMPILE); + dw->gl_list_id = glGenLists(1); + glNewList(dw->gl_list_id, GL_COMPILE); /* Bounding cube: 100 nm^-1 side length */ glBegin(GL_LINE_LOOP); @@ -528,44 +546,44 @@ static void displaywindow_gl_create_list(ControlContext *ctx) { glBegin(GL_LINE_STRIP); glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, red); glVertex3f(0.0, 0.0, 0.0); - glVertex3f(ctx->reflectionctx->basis->a.x/1e9, ctx->reflectionctx->basis->a.y/1e9, ctx->reflectionctx->basis->a.z/1e9); - glVertex3f(ctx->reflectionctx->basis->a.x/1e9 + ctx->reflectionctx->basis->b.x/1e9, - ctx->reflectionctx->basis->a.y/1e9 + ctx->reflectionctx->basis->b.y/1e9, - ctx->reflectionctx->basis->a.z/1e9 + ctx->reflectionctx->basis->b.z/1e9); - glVertex3f(ctx->reflectionctx->basis->b.x/1e9, ctx->reflectionctx->basis->b.y/1e9, ctx->reflectionctx->basis->b.z/1e9); + glVertex3f(ctx->ipr_basis->a.x/1e9, ctx->ipr_basis->a.y/1e9, ctx->ipr_basis->a.z/1e9); + glVertex3f(ctx->ipr_basis->a.x/1e9 + ctx->ipr_basis->b.x/1e9, + ctx->ipr_basis->a.y/1e9 + ctx->ipr_basis->b.y/1e9, + ctx->ipr_basis->a.z/1e9 + ctx->ipr_basis->b.z/1e9); + glVertex3f(ctx->ipr_basis->b.x/1e9, ctx->ipr_basis->b.y/1e9, ctx->ipr_basis->b.z/1e9); glVertex3f(0.0, 0.0, 0.0); - glVertex3f(ctx->reflectionctx->basis->c.x/1e9, ctx->reflectionctx->basis->c.y/1e9, ctx->reflectionctx->basis->c.z/1e9); - glVertex3f(ctx->reflectionctx->basis->c.x/1e9 + ctx->reflectionctx->basis->a.x/1e9, - ctx->reflectionctx->basis->c.y/1e9 + ctx->reflectionctx->basis->a.y/1e9, - ctx->reflectionctx->basis->c.z/1e9 + ctx->reflectionctx->basis->a.z/1e9); - glVertex3f(ctx->reflectionctx->basis->c.x/1e9 + ctx->reflectionctx->basis->a.x/1e9 + ctx->reflectionctx->basis->b.x/1e9, - ctx->reflectionctx->basis->c.y/1e9 + ctx->reflectionctx->basis->a.y/1e9 + ctx->reflectionctx->basis->b.y/1e9, - ctx->reflectionctx->basis->c.z/1e9 + ctx->reflectionctx->basis->a.z/1e9 + ctx->reflectionctx->basis->b.z/1e9); - glVertex3f(ctx->reflectionctx->basis->c.x/1e9 + ctx->reflectionctx->basis->b.x/1e9, - ctx->reflectionctx->basis->c.y/1e9 + ctx->reflectionctx->basis->b.y/1e9, - ctx->reflectionctx->basis->c.z/1e9 + ctx->reflectionctx->basis->b.z/1e9); - glVertex3f(ctx->reflectionctx->basis->c.x/1e9, ctx->reflectionctx->basis->c.y/1e9, ctx->reflectionctx->basis->c.z/1e9); + glVertex3f(ctx->ipr_basis->c.x/1e9, ctx->ipr_basis->c.y/1e9, ctx->ipr_basis->c.z/1e9); + glVertex3f(ctx->ipr_basis->c.x/1e9 + ctx->ipr_basis->a.x/1e9, + ctx->ipr_basis->c.y/1e9 + ctx->ipr_basis->a.y/1e9, + ctx->ipr_basis->c.z/1e9 + ctx->ipr_basis->a.z/1e9); + glVertex3f(ctx->ipr_basis->c.x/1e9 + ctx->ipr_basis->a.x/1e9 + ctx->ipr_basis->b.x/1e9, + ctx->ipr_basis->c.y/1e9 + ctx->ipr_basis->a.y/1e9 + ctx->ipr_basis->b.y/1e9, + ctx->ipr_basis->c.z/1e9 + ctx->ipr_basis->a.z/1e9 + ctx->ipr_basis->b.z/1e9); + glVertex3f(ctx->ipr_basis->c.x/1e9 + ctx->ipr_basis->b.x/1e9, + ctx->ipr_basis->c.y/1e9 + ctx->ipr_basis->b.y/1e9, + ctx->ipr_basis->c.z/1e9 + ctx->ipr_basis->b.z/1e9); + glVertex3f(ctx->ipr_basis->c.x/1e9, ctx->ipr_basis->c.y/1e9, ctx->ipr_basis->c.z/1e9); - glVertex3f(ctx->reflectionctx->basis->c.x/1e9 + ctx->reflectionctx->basis->b.x/1e9, - ctx->reflectionctx->basis->c.y/1e9 + ctx->reflectionctx->basis->b.y/1e9, - ctx->reflectionctx->basis->c.z/1e9 + ctx->reflectionctx->basis->b.z/1e9); - glVertex3f(ctx->reflectionctx->basis->b.x/1e9, ctx->reflectionctx->basis->b.y/1e9, ctx->reflectionctx->basis->b.z/1e9); - glVertex3f(ctx->reflectionctx->basis->c.x/1e9 + ctx->reflectionctx->basis->b.x/1e9, - ctx->reflectionctx->basis->c.y/1e9 + ctx->reflectionctx->basis->b.y/1e9, - ctx->reflectionctx->basis->c.z/1e9 + ctx->reflectionctx->basis->b.z/1e9); - glVertex3f(ctx->reflectionctx->basis->c.x/1e9 + ctx->reflectionctx->basis->a.x/1e9 + ctx->reflectionctx->basis->b.x/1e9, - ctx->reflectionctx->basis->c.y/1e9 + ctx->reflectionctx->basis->a.y/1e9 + ctx->reflectionctx->basis->b.y/1e9, - ctx->reflectionctx->basis->c.z/1e9 + ctx->reflectionctx->basis->a.z/1e9 + ctx->reflectionctx->basis->b.z/1e9); - glVertex3f(ctx->reflectionctx->basis->a.x/1e9 + ctx->reflectionctx->basis->b.x/1e9, - ctx->reflectionctx->basis->a.y/1e9 + ctx->reflectionctx->basis->b.y/1e9, - ctx->reflectionctx->basis->a.z/1e9 + ctx->reflectionctx->basis->b.z/1e9); - glVertex3f(ctx->reflectionctx->basis->c.x/1e9 + ctx->reflectionctx->basis->a.x/1e9 + ctx->reflectionctx->basis->b.x/1e9, - ctx->reflectionctx->basis->c.y/1e9 + ctx->reflectionctx->basis->a.y/1e9 + ctx->reflectionctx->basis->b.y/1e9, - ctx->reflectionctx->basis->c.z/1e9 + ctx->reflectionctx->basis->a.z/1e9 + ctx->reflectionctx->basis->b.z/1e9); - glVertex3f(ctx->reflectionctx->basis->c.x/1e9 + ctx->reflectionctx->basis->a.x/1e9, - ctx->reflectionctx->basis->c.y/1e9 + ctx->reflectionctx->basis->a.y/1e9, - ctx->reflectionctx->basis->c.z/1e9 + ctx->reflectionctx->basis->a.z/1e9); - glVertex3f(ctx->reflectionctx->basis->a.x/1e9, ctx->reflectionctx->basis->a.y/1e9, ctx->reflectionctx->basis->a.z/1e9); + glVertex3f(ctx->ipr_basis->c.x/1e9 + ctx->ipr_basis->b.x/1e9, + ctx->ipr_basis->c.y/1e9 + ctx->ipr_basis->b.y/1e9, + ctx->ipr_basis->c.z/1e9 + ctx->ipr_basis->b.z/1e9); + glVertex3f(ctx->ipr_basis->b.x/1e9, ctx->ipr_basis->b.y/1e9, ctx->ipr_basis->b.z/1e9); + glVertex3f(ctx->ipr_basis->c.x/1e9 + ctx->ipr_basis->b.x/1e9, + ctx->ipr_basis->c.y/1e9 + ctx->ipr_basis->b.y/1e9, + ctx->ipr_basis->c.z/1e9 + ctx->ipr_basis->b.z/1e9); + glVertex3f(ctx->ipr_basis->c.x/1e9 + ctx->ipr_basis->a.x/1e9 + ctx->ipr_basis->b.x/1e9, + ctx->ipr_basis->c.y/1e9 + ctx->ipr_basis->a.y/1e9 + ctx->ipr_basis->b.y/1e9, + ctx->ipr_basis->c.z/1e9 + ctx->ipr_basis->a.z/1e9 + ctx->ipr_basis->b.z/1e9); + glVertex3f(ctx->ipr_basis->a.x/1e9 + ctx->ipr_basis->b.x/1e9, + ctx->ipr_basis->a.y/1e9 + ctx->ipr_basis->b.y/1e9, + ctx->ipr_basis->a.z/1e9 + ctx->ipr_basis->b.z/1e9); + glVertex3f(ctx->ipr_basis->c.x/1e9 + ctx->ipr_basis->a.x/1e9 + ctx->ipr_basis->b.x/1e9, + ctx->ipr_basis->c.y/1e9 + ctx->ipr_basis->a.y/1e9 + ctx->ipr_basis->b.y/1e9, + ctx->ipr_basis->c.z/1e9 + ctx->ipr_basis->a.z/1e9 + ctx->ipr_basis->b.z/1e9); + glVertex3f(ctx->ipr_basis->c.x/1e9 + ctx->ipr_basis->a.x/1e9, + ctx->ipr_basis->c.y/1e9 + ctx->ipr_basis->a.y/1e9, + ctx->ipr_basis->c.z/1e9 + ctx->ipr_basis->a.z/1e9); + glVertex3f(ctx->ipr_basis->a.x/1e9, ctx->ipr_basis->a.y/1e9, ctx->ipr_basis->a.z/1e9); glEnd(); } @@ -582,7 +600,7 @@ static void displaywindow_gl_create_list(ControlContext *ctx) { glEndList(); - printf("DW: Vertex counts: meas:%i, mark:%i, gen:%i\n", ctx->gl_ref_num_vertices, ctx->gl_marker_num_vertices, ctx->gl_gen_num_vertices); + printf("DW: Vertex counts: meas:%i, mark:%i, gen:%i\n", dw->gl_ref_num_vertices, dw->gl_marker_num_vertices, dw->gl_gen_num_vertices); } @@ -602,7 +620,6 @@ static gint displaywindow_gl_expose(GtkWidget *widget, GdkEventExpose *event, Di GLfloat light1_position[] = { 0.0, 0.0, -100.0, 0.0 }; GLfloat light1_diffuse[] = { 0.8, 0.8, 0.8, 1.0 }; GLfloat light1_specular[] = { 0.5, 0.5, 0.5, 1.0 }; - ControlContext *ctx = dw->ctx; if ( !gdk_gl_drawable_gl_begin(gldrawable, glcontext) ) { return 0; @@ -630,13 +647,13 @@ static gint displaywindow_gl_expose(GtkWidget *widget, GdkEventExpose *event, Di glPushClientAttrib(GL_CLIENT_VERTEX_ARRAY_BIT); glEnableClientState(GL_VERTEX_ARRAY); glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, green); - if ( ctx->gl_use_buffers ) { - glBindBufferARB(GL_ARRAY_BUFFER, ctx->gl_ref_vertex_buffer); + if ( dw->gl_use_buffers ) { + glBindBufferARB(GL_ARRAY_BUFFER, dw->gl_ref_vertex_buffer); glVertexPointer(3, GL_FLOAT, 0, NULL); - glDrawArrays(GL_POINTS, 0, ctx->gl_ref_num_vertices); + glDrawArrays(GL_POINTS, 0, dw->gl_ref_num_vertices); } else { - glVertexPointer(3, GL_FLOAT, 0, ctx->gl_ref_vertex_array); - glDrawArrays(GL_POINTS, 0, ctx->gl_ref_num_vertices); + glVertexPointer(3, GL_FLOAT, 0, dw->gl_ref_vertex_array); + glDrawArrays(GL_POINTS, 0, dw->gl_ref_num_vertices); } glPopClientAttrib(); @@ -649,16 +666,16 @@ static gint displaywindow_gl_expose(GtkWidget *widget, GdkEventExpose *event, Di glMaterialf(GL_FRONT, GL_SHININESS, 50.0); glPolygonOffset(1.0, 1.0); glEnable(GL_POLYGON_OFFSET_FILL); - if ( ctx->gl_use_buffers ) { - glBindBufferARB(GL_ARRAY_BUFFER, ctx->gl_marker_vertex_buffer); + if ( dw->gl_use_buffers ) { + glBindBufferARB(GL_ARRAY_BUFFER, dw->gl_marker_vertex_buffer); glVertexPointer(3, GL_FLOAT, 0, NULL); - glBindBufferARB(GL_ARRAY_BUFFER, ctx->gl_marker_normal_buffer); + glBindBufferARB(GL_ARRAY_BUFFER, dw->gl_marker_normal_buffer); glNormalPointer(GL_FLOAT, 0, NULL); - glDrawArrays(GL_QUADS, 0, ctx->gl_marker_num_vertices); + glDrawArrays(GL_QUADS, 0, dw->gl_marker_num_vertices); } else { - glVertexPointer(3, GL_FLOAT, 0, ctx->gl_marker_vertex_array); - glNormalPointer(GL_FLOAT, 0, ctx->gl_marker_normal_array); - glDrawArrays(GL_QUADS, 0, ctx->gl_marker_num_vertices); + glVertexPointer(3, GL_FLOAT, 0, dw->gl_marker_vertex_array); + glNormalPointer(GL_FLOAT, 0, dw->gl_marker_normal_array); + glDrawArrays(GL_QUADS, 0, dw->gl_marker_num_vertices); } glDisable(GL_POLYGON_OFFSET_FILL); glPopClientAttrib(); @@ -670,22 +687,22 @@ static gint displaywindow_gl_expose(GtkWidget *widget, GdkEventExpose *event, Di glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, gold); glMaterialfv(GL_FRONT, GL_SPECULAR, gold_spec); glMaterialf(GL_FRONT, GL_SHININESS, 70.0); - if ( ctx->gl_use_buffers ) { - glBindBufferARB(GL_ARRAY_BUFFER, ctx->gl_gen_vertex_buffer); + if ( dw->gl_use_buffers ) { + glBindBufferARB(GL_ARRAY_BUFFER, dw->gl_gen_vertex_buffer); glVertexPointer(3, GL_FLOAT, 0, NULL); - glBindBufferARB(GL_ARRAY_BUFFER, ctx->gl_gen_normal_buffer); + glBindBufferARB(GL_ARRAY_BUFFER, dw->gl_gen_normal_buffer); glNormalPointer(GL_FLOAT, 0, NULL); - glDrawArrays(GL_QUADS, 0, ctx->gl_gen_num_vertices); + glDrawArrays(GL_QUADS, 0, dw->gl_gen_num_vertices); glBindBufferARB(GL_ARRAY_BUFFER, 0); /* NOTE THIS PLZKTHX */ } else { - glVertexPointer(3, GL_FLOAT, 0, ctx->gl_gen_vertex_array); - glNormalPointer(GL_FLOAT, 0, ctx->gl_gen_normal_array); - glDrawArrays(GL_QUADS, 0, ctx->gl_gen_num_vertices); + glVertexPointer(3, GL_FLOAT, 0, dw->gl_gen_vertex_array); + glNormalPointer(GL_FLOAT, 0, dw->gl_gen_normal_array); + glDrawArrays(GL_QUADS, 0, dw->gl_gen_num_vertices); } glPopClientAttrib(); /* Draw everything else */ - glCallList(ctx->gl_list_id); + glCallList(dw->gl_list_id); if ( gdk_gl_drawable_is_double_buffered(gldrawable) ) { gdk_gl_drawable_swap_buffers(gldrawable); @@ -705,14 +722,13 @@ static gint displaywindow_gl_realise(GtkWidget *widget, DisplayWindow *dw) { GdkGLDrawable *gldrawable = gtk_widget_get_gl_drawable(widget); GLfloat w = widget->allocation.width; GLfloat h = widget->allocation.height; - ControlContext *ctx = dw->ctx; if ( !gdk_gl_drawable_gl_begin(gldrawable, glcontext) ) { return 0; } displaywindow_gl_set_ortho(dw, w, h); - displaywindow_gl_create_list(ctx); + displaywindow_gl_create_list(dw); gdk_gl_drawable_gl_end(gldrawable); @@ -773,8 +789,7 @@ DisplayWindow *displaywindow_open(ControlContext *ctx) { strcpy(title, filename); strcat(title, " - dtr"); - ctx->gl_use_buffers = 1; - + dw->gl_use_buffers = 1; dw->view = DW_ORTHO; dw->distance = 150; dw->x_pos = 0; diff --git a/src/imagedisplay.h b/src/imagedisplay.h index 72e2f63..f69c720 100644 --- a/src/imagedisplay.h +++ b/src/imagedisplay.h @@ -39,7 +39,7 @@ typedef struct struct_imagedisplaymark { struct struct_imagedisplaymark *next; } ImageDisplayMark; -typedef struct struct_imagedisplay { +typedef struct imagedisplay_struct { ImageRecord imagerecord; ImageDisplayFlags flags; @@ -23,6 +23,7 @@ #include "utils.h" #include "imagedisplay.h" #include "reproject.h" +#include "ipr.h" static int ipr_choose_max(Basis *basis) { @@ -205,9 +206,9 @@ static ReflectionContext *ipr_generate(ControlContext *ctx, Basis *basis) { } ordered = reflection_init(); -// basis->a.x = 1.842e9; basis->a.y = 0.0; basis->a.z = 0.0; -// basis->b.x = 0.0; basis->b.y = 1.842e9; basis->b.z = 0.0; -// basis->c.x = 0.0; basis->c.y = 0.0; basis->c.z = 1.842e9; + basis->a.x = 1.842e9; basis->a.y = 0.0; basis->a.z = 0.0; + basis->b.x = 0.0; basis->b.y = 1.842e9; basis->b.z = 0.0; + basis->c.x = 0.0; basis->c.y = 0.0; basis->c.z = 1.842e9; for ( h=-30; h<=30; h++ ) { for ( k=-30; k<=30; k++ ) { for ( l=-30; l<=30; l++ ) { @@ -267,13 +268,12 @@ int ipr_refine(ControlContext *ctx) { int finished; basis = ipr_choose_initial_basis(ctx); - ctx->reflectionctx->basis = basis; if ( !basis ) return -1; - srand(time(NULL)); + ctx->ipr_basis = basis; ctx->ipr_lat = ipr_generate(ctx, basis); - ctx->reflectionctx->basis = basis; + srand(time(NULL)); finished = 0; do { @@ -17,6 +17,22 @@ #ifndef IPR_H #define IPR_H +typedef struct { + + double x; + double y; + double z; + + double modulus; /* Convenience */ + +} Vector; + +typedef struct basis_struct { + Vector a; + Vector b; + Vector c; +} Basis; + #include "control.h" extern int ipr_refine(ControlContext *ctx); diff --git a/src/reflections.h b/src/reflections.h index 5c0a1d7..0eade3a 100644 --- a/src/reflections.h +++ b/src/reflections.h @@ -43,22 +43,6 @@ typedef struct reflection_struct { } Reflection; -typedef struct { - - double x; - double y; - double z; - - double modulus; /* Convenience */ - -} Vector; - -typedef struct { - Vector a; - Vector b; - Vector c; -} Basis; - typedef struct rctx_struct { Reflection *reflections; @@ -67,8 +51,6 @@ typedef struct rctx_struct { unsigned int n_reflections; unsigned int list_capped; - Basis *basis; - } ReflectionContext; extern ReflectionContext *reflection_init(void); |