Escolar Documentos
Profissional Documentos
Cultura Documentos
Malaysia, 2007
class screenPoint
{
private:
GLint x,y;
public:
/* Defult constructor: initializes coordinates position to (0,0) */
screenPoint()
{
x = 0;
y = 0;
}
//Methods
void setCoordinates(GLint xCoordinateValue, GLint yCoordinateValue)
{
x = xCoordinateValue;
y = yCoordinateValue;
}
void incrementx ()
{
x++;
}
Computer Graphics with OpenGL By: Salha Alzahrani University of Technology
Malaysia, 2007
void decrementy ()
{
y--;
}
};
//function prototype
void circlePlotPoints(GLint, GLint, screenPoint);
//Initialize OpenGL
void init(void)
{
glClearColor(0.0,0.0,0.0,0.0); //set display-window color to black
glMatrixMode(GL_PROJECTION); //set projection parameters
gluOrtho2D(0.0,300.0,0.0,300.0);
void drawMyCircle(void)
{
glClear(GL_COLOR_BUFFER_BIT); //clear display-window
glColor3f(1.0,0.0,0.0); //set pixel color to red
glPointSize(3.0);
GLint xCenter=150;
GLint yCenter=150;
GLint raduis=50;
/* --------------------------------------------------------------
A program to draw a circle using Circle Mid Point Algorithm
Programmed By: Salha Alzahrani
Computer Graphics with OpenGL By: Salha Alzahrani University of Technology
Malaysia, 2007
Date: 28-7-2007
Using: C++, OpenGL, GLUT
-------------------------------------------------------------- */
#include<GL/glut.h>
class screenPoint
{
private:
GLint x,y;
public:
/* Defult constructor: initializes coordinates position to (0,0) */
screenPoint()
{
x = 0;
y = 0;
}
//Methods
void setCoordinates(GLint xCoordinateValue, GLint yCoordinateValue)
{
x = xCoordinateValue;
y = yCoordinateValue;
}
void incrementx ()
{
x++;
}
void decrementy ()
{
y--;
}
};
glBegin(GL_POINTS);
glVertex2i(xCoordinate, yCoordinate);
glEnd();
//function prototype
void circlePlotPoints(GLint, GLint, screenPoint);
//Initialize OpenGL
void init(void)
{
glClearColor(0.0,0.0,0.0,0.0); //set display-window color to black
glMatrixMode(GL_PROJECTION); //set projection parameters
gluOrtho2D(0.0,300.0,0.0,300.0);
void drawMyCircle(void)
{
glClear(GL_COLOR_BUFFER_BIT); //clear display-window
glColor3f(1.0,0.0,0.0); //set pixel color to red
glPointSize(3.0);
GLint xCenter = 150;
GLint yCenter = 150;
GLint raduis = 100;
circleMidPoint(xCenter, yCenter, raduis);
}