summaryrefslogtreecommitdiffstats
Side-by-side diff
-rw-r--r--src/model/exp004base.sqc49
1 files changed, 30 insertions, 19 deletions
diff --git a/src/model/exp004base.sqc b/src/model/exp004base.sqc
index 6189b72..cbf2291 100644
--- a/src/model/exp004base.sqc
+++ b/src/model/exp004base.sqc
@@ -38,12 +38,6 @@ exp004base (void)
EXEC SQL OPEN c2;
- /*
- FILE* coords =
- fopen ("/home/don/exp004/test/run20090514/run20090514.coords", "r");
- int i = 0;
- */
-
/*
* Initialize the bounding box of the points.
*/
@@ -52,18 +46,9 @@ exp004base (void)
S.bb.min_y = 0.0;
S.bb.max_y = 0.0;
- // for (i = 0; i < ROWS; i++)
-
EXEC SQL FETCH c2 INTO :coordinates;
while (sqlca.sqlcode != 100)
{
- /*
- fscanf (coords, "%s %f %f\n",
- S.gi_data[i],
- &S.base_vertices_data[i][0],
- &S.base_vertices_data[i][1]);
- */
-
int i = coordinates.coord_id;
strncpy(S.gi_data[i],
@@ -90,15 +75,14 @@ exp004base (void)
S.base_colors_data[i][0] = DEFAULT_COLOR_R;
S.base_colors_data[i][1] = DEFAULT_COLOR_G;
S.base_colors_data[i][2] = DEFAULT_COLOR_B;
+ S.base_colors_data[i][3] = DEFAULT_COLOR_A;
EXEC SQL FETCH c2 INTO :coordinates;
}
EXEC SQL CLOSE c2;
- /*
- fclose (coords);
- */
+ EXEC SQL COMMIT;
/*
* Find the largest axis and use it to setup the projection. This
@@ -126,6 +110,33 @@ exp004base (void)
S.base_vertices_data[i][1] =
S.ortho_max - S.base_vertices_data[i][1];
+ // Move the origin (0,0) to the center of the data.
+ S.ortho_min = 0.0;
+ S.ortho_max = 0.0;
+
+ for (int i = 0; i < ROWS; i++)
+ {
+ S.base_vertices_data[i][0] =
+ S.base_vertices_data[i][0] -
+ (0.5 * (S.bb.max_x - S.bb.min_x));
+
+ if (S.ortho_min > S.base_vertices_data[i][0])
+ S.ortho_min = S.base_vertices_data[i][0];
+
+ if (S.ortho_max < S.base_vertices_data[i][0])
+ S.ortho_max = S.base_vertices_data[i][0];
+
+ S.base_vertices_data[i][1] =
+ S.base_vertices_data[i][1] -
+ (0.5 * (S.bb.max_y - S.bb.min_y));
+
+ if (S.ortho_min > S.base_vertices_data[i][1])
+ S.ortho_min = S.base_vertices_data[i][1];
+
+ if (S.ortho_max < S.base_vertices_data[i][1])
+ S.ortho_max = S.base_vertices_data[i][1];
+ }
+
glGenBuffers (2, S.buffers);
glBindBuffer (GL_ARRAY_BUFFER, S.buffers[BASE_VERTICES]);
@@ -135,7 +146,7 @@ exp004base (void)
GL_STATIC_DRAW);
glBindBuffer (GL_ARRAY_BUFFER, S.buffers[BASE_COLORS]);
- glColorPointer (3, GL_FLOAT, 0, 0);
+ glColorPointer (4, GL_FLOAT, 0, 0);
glBufferData (GL_ARRAY_BUFFER,
sizeof (S.base_colors_data), S.base_colors_data,
GL_STATIC_DRAW);

Valid XHTML 1.0 Strict

Copyright © 2009 Don Pellegrino All Rights Reserved.