Next: About this document ...
Up: SETI Visualizations: Development of
Previous: home.pov
// SETI Visualizations
// by Immanuel Buder
#include <stdlib.h>
#include <iostream.h>
#include <GL/glut.h>
double f,t;
int mainwindow; //window id numbers
GLint height, width; //window size
void display (); //main drawing function (prototype)
void outtext (double x, double y, double z, char *string, void *font); //not used
void initialize () {
height = width = 500; //set size
glutInitDisplayMode(GLUT_RGB); //OpenGl mode
glutInitWindowSize(width, height);
mainwindow = glutCreateWindow("SETI Visualizations"); //create main window
glutDisplayFunc(display); //set display function
glClearColor(.3,.3,.6,0); //background color
glMatrixMode(GL_PROJECTION); //create view
glLoadIdentity(); //
glOrtho(0,500,0,2500,-1,1); //drawspace size
// cwidth= 200; cheight = 200; //no longer used
glutInitDisplayMode(GLUT_DEPTH|GLUT_SINGLE|GLUT_RGB);
/* controlwindow = glutCreateWindow("Controls");
glutDisplayFunc(controldisplay); //no longer used
glClearColor (1,1,1,1);
glClear(GL_COLOR_BUFFER_BIT);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-1,1,-1,1,-1,1);
Twindow = glutCreateSubWindow(controlwindow, 10, 10, 40, 40);
glutDisplayFunc(Tdisplay);
glutMouseFunc(Tmouse);*/
}
void outtext (double x, double y, double z, char *string, void *font) {
glRasterPos3f(x,y,z); //locate position for output
int len = strlen (string); //find length of output
for (int i = 0; i < len; i++) {
glutBitmapCharacter(font,string[i]); //output by chars
}
}
void display () {
glClear(GL_DEPTH_BUFFER_BIT|GL_COLOR_BUFFER_BIT); //clear
glColor3f(.8,0,.6); //color
glBegin(GL_QUADS); //draw background square
glVertex3f(0,0,0);
glVertex3f(0,2500,0);
glVertex3f(500,2500,0);
glVertex3f(500,0,0);
glColor3f(.8,.8,0);
glVertex3f(0,0,0); //draw foreground rectangle
glVertex3f(0,f,0);
glVertex3f(t,f,0);
glVertex3f(t,0,0);
glEnd(); //done drawing quads
glColor3f(1,1,1);
outtext(200,50,0.1,"Time",GLUT_BITMAP_TIMES_ROMAN_24); //label axes
outtext(10,1250,.1,"Frequency",GLUT_BITMAP_TIMES_ROMAN_24);
glFlush(); //force drawing
cout<<"The current frequency width is "<<f<<" kHz"<<endl
<<"The current time width is "<<t<<" s"<<endl
<<"The current data size is "<<2*f*t<<" Kb"<<endl;
cout<<"Enter new (f,t) in (kHz,s)"<<endl;
cin>>f>>t;
glutPostRedisplay(); //redraw after input
// glutPostWindowRedisplay(Twindow);
}
int main (int argc, char ** argv) {
f = 10; //initialize values = SETI@home current
t=107;
initialize(); //OpenGL stuff
glutMainLoop(); //hand control to OpenGL
return 0;
}
Immanuel Buder
2003-06-03