can anybody help me i have the code below and basically i need to be able to change the 2nd veiwport window so it “zooms in” on the first. i try to use the glortho command and it just leaves the screen blank. any help??
/* map.c - world map - display map of the world */
#include <windows.h>
#include <stdio.h>
#include <GL/gl.h>
#include <GL/glut.h>
long int points[170000] ;
void myinit(void)
{
glColor3f(1.0, 1.0, 1.0) ;
/* set up background colour */
glClearColor(0.0, 0.0, 1.0, 1.0);
glClear(GL_COLOR_BUFFER_BIT);
return;
}
void readdata(void){
/* read data points from a binary file into memory. Values are stored in an array points
*/
unsigned long i;
FILE *world;
if ((world=fopen(“world.dat”, “rb”)) == NULL){
printf("Cannot open file.
");
return;
}
i = 0;
while ( ! feof(world)){
unsigned char b1,b2,b3,b4;
fread(&b1,1,1,world);
fread(&b2,1,1,world);
fread(&b3,1,1,world);
fread(&b4,1,1,world);
points[i]=(long int)(((unsigned long)b1<<24) | ((unsigned long)b2<<16) | ((unsigned long)b3<<8) | ((unsigned long)b4));
// if ((fread(&points[i], sizeof(int), 1, world) !=1) && (! feof(world))){
// printf("error reading file.
");
// break;
// }
i++;
}
fclose(world);
return;
}
void drawmap(void){
int npts;
int k = 0;
long base = 0;
/* cycle through the list of points sequentially using them to define vertices. Vertices are joined with a line-strip */
do{
npts = points[base];
glBegin(GL_LINE_STRIP);
for (k=1 ; k <= (npts2) ; k = k+2)
glVertex2s(points[base + k],points[base + k+1]);
glEnd();
base = base + (npts2+ 1);
glFlush();
}
while (npts != 0);
return;
}
void display(void){
/* clear background */
myinit();
/* set up a clip window and a viewport for the map data */
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-33000.0, 33000.0, -33000.0, 33000.0, -1.0, 1.0);
glViewport(00, 00, 500, 250);
/* Draw border just inside the edges of the clip window */
glBegin(GL_LINE_LOOP);
glVertex2i(-32995, -32995);
glVertex2i(32995, -32995);
glVertex2i(32995, 32995);
glVertex2i(-32995, 32995);
glEnd();
/* Draw the interior map */
drawmap();
============================> here is where i need to change the viewport below.
glViewport(00, 250, 500, 250);
/* Draw border just inside the edges of the clip window */
glBegin(GL_LINE_LOOP);
glVertex2i(-32995, -32995);
glVertex2i(32995, -32995);
glVertex2i(32995, 32995);
glVertex2i(-32995, 32995);
glEnd();
/* Draw the interior map */
drawmap();
return;
}
int main(int argc, char** argv){
/* set up window and call-back procedures */
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize(500,500);
glutInitWindowPosition(100, 100);
glutCreateWindow(“World Map”);
readdata();
glutDisplayFunc(display);
glutMainLoop();
return 0;
}