// OPEN_GL_test.cpp : Defines the entry point for the console application. // // OPEN_GL_test.cpp : Defines the entry point for the console application. // #include "stdafx.h" #define GL_PI 3.1415f GLfloat xRot = 0.45f; GLfloat yRot = 0.35f; // Keep track of windows changing width and height GLfloat windowWidth; GLfloat windowHeight; /////////////////////////////////////////////////////////// // Called to draw scene void RenderScene(void) { GLfloat x,y,z,angle; // Storage for coordinates and angles // Clear the window with current clearing color glClear(GL_COLOR_BUFFER_BIT); // Save matrix state and do the rotation glPushMatrix(); glRotatef(xRot, 1.0f, 0.0f, 0.0f); glRotatef(yRot, 0.0f, 1.0f, 0.0f); // Call only once for all remaining points glBegin(GL_POINTS); angle = 0.0f; z = -50.0f; for(int i=2350; i<=2425; i++) //for(angle = 0.0f; angle <= (2.0f*GL_PI)*24.0f; angle += 0.2f) {angle = (float)i*0.2f; x = 190.0f*sin(angle); y = 190.0f*cos(angle); // Specify the point and move the Z value up a little glVertex3f(x, y, z); z = -50.0f+ (float)i*0.02f; } // Done drawing points glEnd(); // Restore transformations glPopMatrix(); // Flush drawing commands glFlush(); } // Called by GLUT library when idle (window not being // resized or moved) /////////////////////////////////////////////////////////// // Setup the rendering state void SetupRC() { // Black background glClearColor(0.0f, 0.0f, 0.0f, 1.0f ); // Set drawing color to green glColor3f(0.0f, 1.0f, 0.0f); } // Called by GLUT library when the window has changed size void ChangeSize(GLsizei w, GLsizei h) { GLfloat aspectRatio; // Prevent a divide by zero if(h == 0) h = 1; // Set Viewport to window dimensions glViewport(0, 0, w, h); // Reset coordinate system glMatrixMode(GL_PROJECTION); glLoadIdentity(); // Establish clipping volume (left, right, bottom, top, near, far) aspectRatio = (GLfloat)w / (GLfloat)h; if (w <= h) { windowWidth = 500; windowHeight = 500 / aspectRatio; gluLookAt (0.25, -0.25, -1.5, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0); glOrtho (-500.0, 500.0, -windowHeight, windowHeight, 1.0, -7.0); } else { windowWidth = 500 * aspectRatio; windowHeight = 500; gluLookAt (0.25, -0.25, -1.5, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0); glOrtho (-windowWidth, windowWidth, -500.0, 500.0, 1.0, -7.0); } /*glMatrixMode(GL_MODELVIEW); glLoadIdentity();*/ } /////////////////////////////////////////////////////////// int main(int argc, char** argv) { glutInit(&argc, argv); glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB); glutInitWindowSize (500, 500); glutInitWindowPosition (100, 100); glutCreateWindow (argv[0]); glutDisplayFunc(RenderScene); glutReshapeFunc(ChangeSize); /* glutTimerFunc(33, TimerFunction, 1);*/ SetupRC(); glutMainLoop(); return 0; }