-rw-r--r-- | src/controller/selection_from_db.sqc | 44 |
1 files changed, 43 insertions, 1 deletions
diff --git a/src/controller/selection_from_db.sqc b/src/controller/selection_from_db.sqc index 20d277e..9467ab3 100644 --- a/src/controller/selection_from_db.sqc +++ b/src/controller/selection_from_db.sqc @@ -1,5 +1,7 @@ +#define GL_GLEXT_PROTOTYPES #include "selection_from_db.h" #include "../view/exp004state0.h" +#include <GL/glut.h> EXEC SQL INCLUDE sqlca; @@ -11,11 +13,51 @@ EXEC SQL INCLUDE sqlca; void selection_from_db (void) { + /* + * db2dclgn -d exp004 -t vis_sel_set + */ EXEC SQL BEGIN DECLARE SECTION; - + EXEC SQL INCLUDE 'controller/vis_sel_set.h'; EXEC SQL END DECLARE SECTION; + EXEC SQL DECLARE c3 CURSOR FOR + SELECT * FROM vis_sel_set + ORDER BY title, id DESC; + + EXEC SQL OPEN c3; + /* + * This loop currently assumes only one set in the table and does + * not use the title assigned to that set. This should be improved + * to allow the user to manage multiple sets by name. + */ + EXEC SQL FETCH c3 INTO :vis_sel_set; + while (sqlca.sqlcode != 100) + { + S.selection[vis_sel_set.id] = true; + S.base_colors_data[vis_sel_set.id][0] = vis_sel_set.r; + S.base_colors_data[vis_sel_set.id][1] = vis_sel_set.g; + S.base_colors_data[vis_sel_set.id][2] = vis_sel_set.b; + S.base_colors_data[vis_sel_set.id][3] = 0.6; + + EXEC SQL FETCH c3 INTO :vis_sel_set; + } + + EXEC SQL CLOSE c3; + + EXEC SQL COMMIT; + + /* + * Update the graphics memory. + */ + + glBindBuffer (GL_ARRAY_BUFFER, S.buffers[BASE_COLORS]); + glColorPointer (4, GL_FLOAT, 0, 0); + glBufferData (GL_ARRAY_BUFFER, + sizeof (S.base_colors_data), S.base_colors_data, + GL_STATIC_DRAW); + + glutPostRedisplay (); return; } |