1
0
Fork 0

First stab at using GL_TRIANGLE_STRIP's instead of GL_POLYGONS (to conserve

memory)
This commit is contained in:
curt 1997-05-23 20:05:24 +00:00
parent f08257175f
commit c5ffbe243f

View file

@ -53,7 +53,6 @@ static void mat3_cross_product(float result_vec[3], register float vec1[3],
/* walk through mesh and make ogl calls */
GLint mesh2GL(struct mesh *m) {
GLint mesh;
/* static GLfloat color[4] = { 0.3, 0.7, 0.2, 1.0 }; */
float x1, y1, x2, y2, z11, z12, z21, z22;
float v1[3], v2[3], normal[3];
@ -64,7 +63,6 @@ GLint mesh2GL(struct mesh *m) {
mesh = glGenLists(1);
glNewList(mesh, GL_COMPILE);
/* glMaterialfv( GL_FRONT, GL_AMBIENT_AND_DIFFUSE, color ); */
iend = m->cols - 1;
jend = m->rows - 1;
@ -75,48 +73,43 @@ GLint mesh2GL(struct mesh *m) {
for ( i = 0; i < iend; i += istep ) {
x1 = m->originx;
x2 = x1 + (m->row_step * jstep);
glBegin(GL_TRIANGLE_STRIP);
for ( j = 0; j < jend; j += jstep ) {
z11 = 0.03 * m->mesh_data[j * m->rows + i ];
z12 = 0.03 * m->mesh_data[j * m->rows + (i+istep)];
z21 = 0.03 * m->mesh_data[(j+jstep) * m->rows + i ];
z22 = 0.03 * m->mesh_data[(j+jstep) * m->rows + (i+istep)];
/* printf("x1 = %f y1 = %f\n", x1, y1);
printf("x2 = %f y2 = %f\n", x2, y2);
printf("z11 = %f z12 = %f z21 = %f z22 = %f\n",
z11, z12, z21, z22); */
v1[0] = x2 - x1; v1[1] = 0; v1[2] = z21 - z11;
v2[0] = x2 - x1; v2[1] = y2 - y1; v2[2] = z22 - z11;
mat3_cross_product(normal, v1, v2);
MAT3_NORMALIZE_VEC(normal,temp);
glBegin(GL_POLYGON);
glNormal3fv(normal);
glVertex3f(x1, y1, z11);
if ( j == 0 ) {
/* first time through */
glNormal3fv(normal);
glVertex3f(x1, y1, z11);
glVertex3f(x1, y2, z12);
} else {
glNormal3fv(normal);
}
glVertex3f(x2, y1, z21);
glVertex3f(x2, y2, z22);
/* printf("(%f, %f, %f)\n", x1, y1, z11);
printf("(%f, %f, %f)\n", x2, y1, z21);
printf("(%f, %f, %f)\n", x2, y2, z22); */
glEnd();
v1[0] = x2 - x1; v1[1] = y2 - y1; v1[2] = z22 - z11;
v2[0] = 0; v2[1] = y2 - y1; v2[2] = z12 - z11;
mat3_cross_product(normal, v1, v2);
MAT3_NORMALIZE_VEC(normal,temp);
glBegin(GL_POLYGON);
glNormal3fv(normal);
glVertex3f(x1, y1, z11);
glVertex3f(x2, y2, z22);
glVertex3f(x1, y2, z12);
/* printf("(%f, %f, %f)\n", x1, y1, z11);
printf("(%f, %f, %f)\n", x2, y2, z22);
printf("(%f, %f, %f)\n", x1, y2, z12); */
glEnd();
x1 = x2;
x2 = x1 + (m->row_step * jstep);
}
glEnd();
y1 = y2;
y2 = y1 + (m->col_step * istep);
}
@ -128,10 +121,14 @@ GLint mesh2GL(struct mesh *m) {
/* $Log$
/* Revision 1.3 1997/05/23 15:40:26 curt
/* Added GNU copyright headers.
/* Fog now works!
/* Revision 1.4 1997/05/23 20:05:24 curt
/* First stab at using GL_TRIANGLE_STRIP's instead of GL_POLYGONS (to conserve
/* memory)
/*
* Revision 1.3 1997/05/23 15:40:26 curt
* Added GNU copyright headers.
* Fog now works!
*
* Revision 1.2 1997/05/23 00:35:13 curt
* Trying to get fog to work ...
*