티스토리 뷰

#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();             
}

공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/12   »
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31
글 보관함