#include <glut.h>
using namespace std;
void Start_Line( );
void Set_Graphics( int, int );
//void Line_Algo( int, int, int, int );
int main( int argc, char** argv )
{
glutInit( &argc, argv );
glutInitWindowSize( 600,600);
glutInitWindowPosition( 100, 150 );
glutInitDisplayMode( GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH );
glutCreateWindow( " Circle Drawing" );
glutDisplayFunc( Start_Line );
Set_Graphics( 100, 100 /*window_width, window_height*/ );
glutMainLoop( );
return 0;
}
void drawDot (GLint x, GLint y, GLfloat r, GLfloat g, GLfloat b)
{ glColor3f(r,g,b);
glBegin (GL_POINTS);
glVertex2i (x,y);
glEnd();
}
void circlePoints (int x, int y, float r, float g, float b)
{
drawDot (x,y,r,g,b);
drawDot (-x,y,r,g,b);
drawDot (x,-y,r,g,b);
drawDot (-x,-y,r,g,b);
drawDot (y,x,r,g,b);
drawDot (-y,x,r,g,b);
drawDot (y,-x,r,g,b);
drawDot (-y,-x,r,g,b);
}
void Circle (int rad, float r, float g, float b)
{ int x,y,d;
x = 0;
y = rad;
circlePoints (x,y,r,g,b);
d = 1 - rad;
while (y>x)
{
if (d < 0)
{ d += 2*x +3;
x++;}
else{
d += 2*(x-y) + 5;
x++;y--;}
circlePoints (x,y,r,g,b);
}
}
void Set_Graphics( int width, int height )
{
glClearColor( 1.0, 1.0, 1.0, 0.0 );
glColor3f( 0.0f, 0.0f, 0.0f );
glViewport( 0, 0, width, height );
glMatrixMode( GL_PROJECTION );
glLoadIdentity( );
glEnable( GL_DEPTH_TEST );
gluPerspective( 45, ( float ) width / height, 1.0, 0 );
glMatrixMode( GL_MODELVIEW );
glTranslatef( 0, 0, 5 * ( -height) );
}
void Start_Line( )
{
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
// Line_Algo( 5, 8, 29,32 );
Circle (100,0,0,1);
glRotatef(1.0, 1.0, 0.0, 0.0);
glutSwapBuffers( );
}
using namespace std;
void Start_Line( );
void Set_Graphics( int, int );
//void Line_Algo( int, int, int, int );
int main( int argc, char** argv )
{
glutInit( &argc, argv );
glutInitWindowSize( 600,600);
glutInitWindowPosition( 100, 150 );
glutInitDisplayMode( GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH );
glutCreateWindow( " Circle Drawing" );
glutDisplayFunc( Start_Line );
Set_Graphics( 100, 100 /*window_width, window_height*/ );
glutMainLoop( );
return 0;
}
void drawDot (GLint x, GLint y, GLfloat r, GLfloat g, GLfloat b)
{ glColor3f(r,g,b);
glBegin (GL_POINTS);
glVertex2i (x,y);
glEnd();
}
void circlePoints (int x, int y, float r, float g, float b)
{
drawDot (x,y,r,g,b);
drawDot (-x,y,r,g,b);
drawDot (x,-y,r,g,b);
drawDot (-x,-y,r,g,b);
drawDot (y,x,r,g,b);
drawDot (-y,x,r,g,b);
drawDot (y,-x,r,g,b);
drawDot (-y,-x,r,g,b);
}
void Circle (int rad, float r, float g, float b)
{ int x,y,d;
x = 0;
y = rad;
circlePoints (x,y,r,g,b);
d = 1 - rad;
while (y>x)
{
if (d < 0)
{ d += 2*x +3;
x++;}
else{
d += 2*(x-y) + 5;
x++;y--;}
circlePoints (x,y,r,g,b);
}
}
void Set_Graphics( int width, int height )
{
glClearColor( 1.0, 1.0, 1.0, 0.0 );
glColor3f( 0.0f, 0.0f, 0.0f );
glViewport( 0, 0, width, height );
glMatrixMode( GL_PROJECTION );
glLoadIdentity( );
glEnable( GL_DEPTH_TEST );
gluPerspective( 45, ( float ) width / height, 1.0, 0 );
glMatrixMode( GL_MODELVIEW );
glTranslatef( 0, 0, 5 * ( -height) );
}
void Start_Line( )
{
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
// Line_Algo( 5, 8, 29,32 );
Circle (100,0,0,1);
glRotatef(1.0, 1.0, 0.0, 0.0);
glutSwapBuffers( );
}