티스토리 뷰
#include<glut.h>
#include<gl.h>
#include<glu.h>
#include<math.h>
void plot_2(int x, int y)
{
glVertex2i(x,y);
glVertex2i(x,-y);
}
void display()
{
float radius=100, y,i;
glClear( GL_COLOR_BUFFER_BIT );
glBegin( GL_LINE_LOOP);
for(i=-100;i<=100 ;i+=1)
{
y=sqrt((radius*radius)-(i*i));
plot_2(i,y);
}
glEnd();
glFlush();
}
void main( int argc, char **argv ){
glutInit( &argc, argv );
glutInitDisplayMode( GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH );
glutInitWindowPosition( 500, 500);
glutInitWindowSize( 300,300 );
glutCreateWindow( "원그리기" );
glClearColor( 0.0f, 0.0f, 0.0f, 0.0f );
glMatrixMode( GL_PROJECTION );
glLoadIdentity();
glOrtho( -150.0, 150.0, -150.0, 150.0, -1.0, 1.0 );
glutDisplayFunc( display );
glutMainLoop();
}