#include void init() { // set matrix mode to PROJECTION mode glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluOrtho2D(0,200,0,200); } void drawPoint(int x, int y) { glBegin(GL_POINTS); glColor3f( 1.0f, 1.0f, 1.0f ); glVertex2i(x,y); glVertex2i(y,x); glVertex2i(-x,y); glVertex2i(x,-y); glVertex2i(-x,-y); glVertex2i(-y,-x); glVertex2i(-y,x); glVertex2i(y,-x); glEnd(); } void midpoint( int R, float cx, float cy ) { int x, y, h; glPushMatrix(); /* eltaroljuk az eredeti koordinatarendszert */ glTranslatef(cx,cy,0); /* eltoljuk a koordinatarendszert, hogy a megfelelo helyre rajzoljuk a kort */ x = 0; y = R; h = 1-R; drawPoint(x,y); while( y >= x ) { if ( h < 0 ) { x++; h += 2*x+3; } else { x++; y--; h += 2*(x-y)+5; } drawPoint(x,y); } glPopMatrix(); /* Visszakerjuk az eredeti matrixot */ } void drawCircle() { //delete buffers glClear(GL_COLOR_BUFFER_BIT); midpoint(40,60.0f,60.0f); } void keyboard(unsigned char key, int x, int y) { switch(key) { case 27: exit(0); break; } } // Called to draw scene void RenderScene(void) { // Clear the window with current clearing color glClear(GL_COLOR_BUFFER_BIT); drawCircle(); // Flush drawing commands glFlush(); } // Setup the rendering state void SetupRC(void) { // Set clear color to black glClearColor(0.0f, 0.0f, 0.0f, 1.0f); } // Main program entry point int main(int argc, char* argv[]) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); glutInitWindowSize(100,100); glutInitWindowPosition(20,20); glutCreateWindow("Points"); SetupRC(); init(); glutDisplayFunc(RenderScene); glutKeyboardFunc(keyboard); glutMainLoop(); return 0; }