Need help with a basic 3d Mesh

Hi I tried looking searching for the information I was looking for and could not find any. I am trying to read information from a binary file with a set of Z coordinate points to generate the elevation of maps on my map. My program does not seem to want to display the Z values and give me any height. Also at some point I’ll need to apply the correct lighting and texture, will calculating the normalized cross products have any affect on GL_TRIANGLE_STRIP?

  • Lost EE in a CS world.

#include <iostream>
#include <fstream>
#include <stdlib.h>
#include <math.h>
#include <GL/glut.h>

using namespace std;
int i = 0;
int j = 0;
const int rows = 425;
const int columns = 542;
const float xllcorner = -84.540833330105;
const float yllcorner = 34.760833332277;
float elevation[rows][columns];
float maxElevation ;
float minElevation ;

void Readfile(char *Filename)
{
ifstream inFile (“ned_30392114.flt”, ios_base::binary);
if (!inFile.is_open())
{
cout << “Could not find file” << endl;
exit(1);
}
inFile.read((char *) elevation[0], sizeof(float) * columns * rows);
for (int i = 0; i < rows; i++)
{
for (int j = 0; j < columns - 1; j++)
{
if (elevation[i][j] > maxElevation)
maxElevation = elevation[i][j];
if (elevation[i][j] < minElevation)
minElevation = elevation[i][j];
}
}
}

void init (void)
{
/* select clearing color */
glClearColor (0.0, 0.0, 0.0, 0.0);
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
glEnable(GL_CULL_FACE);
//glEnable(GL_DEPTH_TEST);
}

void display(void)
{
glClear (GL_COLOR_BUFFER_BIT);
glLoadIdentity();

 gluLookAt(0, 0, 400, 
			200, 200, 0, 
	        0, 0, 1); 

for (int i = 0; i < rows; i++)
{
for (int j = 0; j < columns - 1; j++)
{

		glColor3f(0.0, 0.0, 1.0);	
		glBegin(GL_TRIANGLE_STRIP);
		glVertex3i(i,j,100*elevation[i][j]);
		glVertex3i(i+1,j,100*elevation[i+1][j]);
		glVertex3i(i,j+1,100*elevation[i][j+1]);
		glVertex3i(i+1,j+1,100*elevation[i+1][j+1]);
		glEnd();
		
	}
	
}	
glFlush();
glutSwapBuffers();

}

void reshape(int w, int h) // Reshapes the window when the window is being “stretched”
{
glViewport(0, 0, (GLsizei) w, (GLsizei) h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(60, (float) w / h, 0, 100);
glMatrixMode(GL_MODELVIEW);
}

int main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
glutInitWindowSize (500, 300);
glutInitWindowPosition (100, 100);
glutCreateWindow (“USGS Data”);
init ();
glutDisplayFunc(display);
glutReshapeFunc(reshape);
glutMainLoop();
return 0; /* ANSI C requires main to return int. */
}