summaryrefslogtreecommitdiffstats
authorDon Pellegrino <don@drexel.edu>2009-07-01 22:07:46 (GMT)
committer Don Pellegrino <don@drexel.edu>2009-07-01 22:07:46 (GMT)
commitae129719e6ff1cb0691638e9483b4e21a93aa7f5 (patch) (unidiff)
treea0b1aac7ecdad44e8b1c5dadb196dc77de3e8a73
parent106a2d9c8782be085eafe632b187366cee7f862c (diff)
downloadexp005-ae129719e6ff1cb0691638e9483b4e21a93aa7f5.zip
exp005-ae129719e6ff1cb0691638e9483b4e21a93aa7f5.tar.gz
exp005-ae129719e6ff1cb0691638e9483b4e21a93aa7f5.tar.bz2
Modified to use a display list to render the proteins rather than just
points. This feels much slower but looks much better.
-rw-r--r--src/Makefile.am3
-rw-r--r--src/model/display_list_index.h6
-rw-r--r--src/model/exp004state.h6
-rw-r--r--src/model/protein_geometry.c21
-rw-r--r--src/model/protein_geometry.h9
-rw-r--r--src/view/exp004geometry.c21
-rw-r--r--src/view/exp004init.c3
-rw-r--r--src/view/exp004view.c2
8 files changed, 61 insertions, 10 deletions
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 = \
13 db/dbconnect.c \13 db/dbconnect.c \
14 exp004viz.c \14 exp004viz.c \
15 model/exp004base.c \15 model/exp004base.c \
16 model/protein_geometry.c \
16 model/selection_info_init.c \17 model/selection_info_init.c \
17 model/zoom_info_init.c \18 model/zoom_info_init.c \
18 util/check_error.c \19 util/check_error.c \
@@ -35,8 +36,10 @@ noinst_HEADERS = \
35 controller/selsave.h \36 controller/selsave.h \
36 controller/set_ortho.h \37 controller/set_ortho.h \
37 db/dbconnect.h \38 db/dbconnect.h \
39 model/display_list_index.h \
38 model/exp004base.h \40 model/exp004base.h \
39 model/exp004state.h \41 model/exp004state.h \
42 model/protein_geometry.h \
40 model/selection_info.h \43 model/selection_info.h \
41 model/selection_info_init.h \44 model/selection_info_init.h \
42 model/selection_purposes.h \45 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 @@
1#ifndef DISPLAY_LIST_INDEX
2#define DISPLAY_LIST_INDEX
3
4#define PROTEIN_GEOMETRY 0
5
6#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 @@
23#define SELECT_COLOR_B 0.0023#define SELECT_COLOR_B 0.00
24#define SELECT_COLOR_A 0.7524#define SELECT_COLOR_A 0.75
2525
26typedef enum { PROTEIN_GEOMETRY } LISTS;
27
26/*28/*
27 * Maintain state of the model.29 * Maintain state of the model.
28 */30 */
29typedef struct31typedef struct
30{32{
33 /*
34 * Display lists.
35 */
36 unsigned int list_offset;
3137
32 /* 38 /*
33 * Track the bounding box of the points.39 * 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 @@
1#include "protein_geometry.h"
2#include "../view/exp004state0.h"
3#include <GL/glut.h>
4
5#define S exp004state0
6
7void
8protein_geometry (void)
9{
10 /*
11 * Create a sphere and put it in a display list.
12 */
13 GLUquadricObj *obj = gluNewQuadric ();
14 gluQuadricDrawStyle (obj, GLU_FILL);
15 glNewList (S.list_offset + PROTEIN_GEOMETRY, GL_COMPILE);
16 gluSphere (obj, 0.05, 20, 20);
17 glEndList ();
18 gluDeleteQuadric (obj);
19
20 return;
21}
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 @@
1#ifndef PROTEIN_GEOMETRY_H
2#define PROTEIN_GEOMETRY_H
3
4/*
5 * Define the geometry to render for a protein.
6 */
7void protein_geometry (void);
8
9#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 @@
6#include "exp004state0.h"6#include "exp004state0.h"
7#include <GL/glut.h>7#include <GL/glut.h>
88
9#define S exp004state0
10
9void11void
10exp004geometry (GLenum mode)12exp004geometry (GLenum mode)
11{13{
@@ -15,17 +17,16 @@ exp004geometry (GLenum mode)
15 glPointSize (0.1);17 glPointSize (0.1);
16 glColor3f (0.2, 0.2, 0.2);18 glColor3f (0.2, 0.2, 0.2);
1719
18 if (mode == GL_SELECT)20 for (int i = 0; i < ROWS; i++)
19 {
20 for (int i = 0; i < ROWS; i++)
21 {
22 glLoadName (i);
23 glDrawArrays (GL_POINTS, i, 1);
24 }
25 }
26 else
27 {21 {
28 glDrawArrays (GL_POINTS, 0, ROWS);22 glLoadName (i);
23 glPushMatrix ();
24 glTranslatef (S.base_vertices_data[i][0],
25 S.base_vertices_data[i][1],
26 0.0);
27 glColor4fv (S.base_colors_data[i]);
28 glCallList (S.list_offset + PROTEIN_GEOMETRY);
29 glPopMatrix ();
29 }30 }
3031
31 return;32 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 @@
2#include "exp004state0.h"2#include "exp004state0.h"
3#include "../model/selection_info_init.h"3#include "../model/selection_info_init.h"
4#include "../model/zoom_info_init.h"4#include "../model/zoom_info_init.h"
5#include <GL/glut.h>
56
6#define S exp004state07#define S exp004state0
78
@@ -11,5 +12,7 @@ exp004init (void)
11 selection_info_init (&S.selection);12 selection_info_init (&S.selection);
12 zoom_info_init (&S.zoom);13 zoom_info_init (&S.zoom);
1314
15 S.list_offset = glGenLists (1);
16
14 return;17 return;
15}18}
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 @@
4#include "../controller/keyboard.h"4#include "../controller/keyboard.h"
5#include "../db/dbconnect.h"5#include "../db/dbconnect.h"
6#include "../model/exp004base.h"6#include "../model/exp004base.h"
7#include "../model/protein_geometry.h"
7#include "exp004init.h"8#include "exp004init.h"
8#include "exp004state0.h"9#include "exp004state0.h"
9#include "exp004view.h"10#include "exp004view.h"
@@ -42,6 +43,7 @@ exp004view (void)
42 // Initialize the model.43 // Initialize the model.
43 exp004base ();44 exp004base ();
44 exp004init ();45 exp004init ();
46 protein_geometry ();
4547
46 // Callbacks (Controllers)48 // Callbacks (Controllers)
47 glutDisplayFunc (exp004display);49 glutDisplayFunc (exp004display);

Valid XHTML 1.0 Strict

Copyright © 2009 Don Pellegrino All Rights Reserved.