Hmm, I dont think that this would really help me.
Here are selected pieces of code:
//Initialize GLUT
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
glutInitWindowSize(600, 600);
//Create the window
glutCreateWindow("2D map");
glutDisplayFunc(display);
//
/*------init panning-------------*/
zprInit();
zprSelectionFunc(drawScene); /* Selection mode draw function */
zprPickFunc(pickScene);
/*------end panning--------------*/
glutTimerFunc(100, update, 0); //Add a timer
void display(void)
{
/* Initialise OpenGL Lighting and material structure */
GLERROR;
glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambient);
glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse);
glLightfv(GL_LIGHT0, GL_SPECULAR, light_specular);
glLightfv(GL_LIGHT0, GL_POSITION, light_position);
glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient);
glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse);
glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular);
glMaterialfv(GL_FRONT, GL_SHININESS, high_shininess);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glDepthFunc(GL_LESS);
glEnable(GL_DEPTH_TEST);
glEnable(GL_NORMALIZE);
glEnable(GL_COLOR_MATERIAL);
GLERROR;
//glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glClear(GL_DEPTH_BUFFER_BIT);
drawScene();
glutSwapBuffers();
GLERROR;
}
void drawScene(void) {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
//glClear(GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW); //Switch to the drawing perspective
//glLoadIdentity(); //Reset the drawing perspective
glPushMatrix();
glTranslatef(0.0f, 0.0f, -5.0f); //Move forward 5 units into visible region
if((prevcoord[0]!=coordinates[0])&&(prevcoord[1]!=coordinates[1])){ //this if statement accounts for transmission lag
glPushMatrix(); //Save the current state of transformations
glPushName(1);
glColor3ub(255,255,255); //white
glBegin(GL_LINE_STRIP);
glVertex3f(prevcoord[0],prevcoord[1],prevcoord[2]);//initial line co-ordinate, needs to be updated to init GPSlocation
glVertex3f(coordinates[0],coordinates[1],coordinates[2]);
glEnd();
glPopName();
glPopMatrix();
//draws the red triangle with the current location of the igv
glPushMatrix(); //save previous translate and color
glPushName(2);
//glClear(GL_DEPTH_BUFFER_BIT);
glTranslatef(coordinates[0],coordinates[1],coordinates[2]);
glRotatef((360/(2*PI))*atan2(coordinates[1],coordinates[0]),coordinates[0],coordinates[1],coordinates[2]); //does rotation calc
//glRotatef((360/(2*PI))*atan2(coordinates[1],coordinates[0]),1,1,1); //does rotation calc
glColor3ub(255,0,0); //set to red
glBegin(GL_TRIANGLES);
glVertex2f(0,.05);
glVertex2f(0,-.05);
glVertex2f(.05,0);
glEnd();
glPopName();
glPopMatrix(); //restore previous translate and color
}
//this section erases the old triangle and overwrites it with a green dot
if((prevcoord[0]!=coordinates[0])&&(prevcoord[1]!=coordinates[1])){ //this if statement accounts for transmission lag
glPushMatrix(); //save previous translate and color
glPushName(3);
glTranslatef(prevcoord[0],prevcoord[1],prevcoord[2]);
glRotatef((360/(2*PI))*atan2(prevcoord[1],prevcoord[0]),prevcoord[0],prevcoord[1],prevcoord[2]);
//glRotatef((360/(2*PI))*atan2(prevcoord[1],prevcoord[0]),1,1,1);
glColor3ub(0,0,0); //set black
glBegin(GL_TRIANGLES);
glVertex2f(0,.05);
glVertex2f(0,-.05);
glVertex2f(.05,0);
glEnd();
glColor3ub(0,255,0); //set sphere to green
glutSolidSphere(.02,15,15); //radius, slices,stacks
glPopName();
glPopMatrix(); //restore previous translate and color
}
glPopMatrix();
glutSwapBuffers();
}
Any suggestions?