From ae129719e6ff1cb0691638e9483b4e21a93aa7f5 Mon Sep 17 00:00:00 2001 From: Don Pellegrino Date: Wed, 01 Jul 2009 22:07:46 +0000 Subject: Modified to use a display list to render the proteins rather than just points. This feels much slower but looks much better. --- diff --git a/src/Makefile.am b/src/Makefile.am index 86c1dae..abedab7 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -13,6 +13,7 @@ exp004viz_SOURCES = \ db/dbconnect.c \ exp004viz.c \ model/exp004base.c \ + model/protein_geometry.c \ model/selection_info_init.c \ model/zoom_info_init.c \ util/check_error.c \ @@ -35,8 +36,10 @@ noinst_HEADERS = \ controller/selsave.h \ controller/set_ortho.h \ db/dbconnect.h \ + model/display_list_index.h \ model/exp004base.h \ model/exp004state.h \ + model/protein_geometry.h \ model/selection_info.h \ model/selection_info_init.h \ model/selection_purposes.h \ diff --git a/src/model/display_list_index.h b/src/model/display_list_index.h new file mode 100644 index 0000000..a68f8a7 --- a/dev/null +++ b/src/model/display_list_index.h @@ -0,0 +1,6 @@ +#ifndef DISPLAY_LIST_INDEX +#define DISPLAY_LIST_INDEX + +#define PROTEIN_GEOMETRY 0 + +#endif // DISPLAY_LIST_INDEX diff --git a/src/model/exp004state.h b/src/model/exp004state.h index d151966..1af8a5b 100644 --- a/src/model/exp004state.h +++ b/src/model/exp004state.h @@ -23,11 +23,17 @@ #define SELECT_COLOR_B 0.00 #define SELECT_COLOR_A 0.75 +typedef enum { PROTEIN_GEOMETRY } LISTS; + /* * Maintain state of the model. */ typedef struct { + /* + * Display lists. + */ + unsigned int list_offset; /* * Track the bounding box of the points. diff --git a/src/model/protein_geometry.c b/src/model/protein_geometry.c new file mode 100644 index 0000000..001b578 --- a/dev/null +++ b/src/model/protein_geometry.c @@ -0,0 +1,21 @@ +#include "protein_geometry.h" +#include "../view/exp004state0.h" +#include + +#define S exp004state0 + +void +protein_geometry (void) +{ + /* + * Create a sphere and put it in a display list. + */ + GLUquadricObj *obj = gluNewQuadric (); + gluQuadricDrawStyle (obj, GLU_FILL); + glNewList (S.list_offset + PROTEIN_GEOMETRY, GL_COMPILE); + gluSphere (obj, 0.05, 20, 20); + glEndList (); + gluDeleteQuadric (obj); + + return; +} diff --git a/src/model/protein_geometry.h b/src/model/protein_geometry.h new file mode 100644 index 0000000..e9ac0db --- a/dev/null +++ b/src/model/protein_geometry.h @@ -0,0 +1,9 @@ +#ifndef PROTEIN_GEOMETRY_H +#define PROTEIN_GEOMETRY_H + +/* + * Define the geometry to render for a protein. + */ +void protein_geometry (void); + +#endif // PROTEIN_GEOMETRY_H diff --git a/src/view/exp004geometry.c b/src/view/exp004geometry.c index b34d7f3..e7193fd 100644 --- a/src/view/exp004geometry.c +++ b/src/view/exp004geometry.c @@ -6,6 +6,8 @@ #include "exp004state0.h" #include +#define S exp004state0 + void exp004geometry (GLenum mode) { @@ -15,17 +17,16 @@ exp004geometry (GLenum mode) glPointSize (0.1); glColor3f (0.2, 0.2, 0.2); - if (mode == GL_SELECT) - { - for (int i = 0; i < ROWS; i++) - { - glLoadName (i); - glDrawArrays (GL_POINTS, i, 1); - } - } - else + for (int i = 0; i < ROWS; i++) { - glDrawArrays (GL_POINTS, 0, ROWS); + glLoadName (i); + glPushMatrix (); + glTranslatef (S.base_vertices_data[i][0], + S.base_vertices_data[i][1], + 0.0); + glColor4fv (S.base_colors_data[i]); + glCallList (S.list_offset + PROTEIN_GEOMETRY); + glPopMatrix (); } return; diff --git a/src/view/exp004init.c b/src/view/exp004init.c index 97bd779..e7da51d 100644 --- a/src/view/exp004init.c +++ b/src/view/exp004init.c @@ -2,6 +2,7 @@ #include "exp004state0.h" #include "../model/selection_info_init.h" #include "../model/zoom_info_init.h" +#include #define S exp004state0 @@ -11,5 +12,7 @@ exp004init (void) selection_info_init (&S.selection); zoom_info_init (&S.zoom); + S.list_offset = glGenLists (1); + return; } diff --git a/src/view/exp004view.c b/src/view/exp004view.c index b7e4367..68a4e79 100644 --- a/src/view/exp004view.c +++ b/src/view/exp004view.c @@ -4,6 +4,7 @@ #include "../controller/keyboard.h" #include "../db/dbconnect.h" #include "../model/exp004base.h" +#include "../model/protein_geometry.h" #include "exp004init.h" #include "exp004state0.h" #include "exp004view.h" @@ -42,6 +43,7 @@ exp004view (void) // Initialize the model. exp004base (); exp004init (); + protein_geometry (); // Callbacks (Controllers) glutDisplayFunc (exp004display); -- cgit v0.8.3.1-22-g547a