bagi teman2 yang ingin belajar komputer, khususnya komputer grafik dengan bahasa C++ ini ada sedikit contoh program.
bila ingin mempelajari lebih lanjut silahkan googleing diri ya...

#include
#include
#include
GLint circle_points = 100;
void MyCircle2f(GLfloat centerx, GLfloat centery, GLfloat radius)
{
GLint i;
GLdouble angle;
glBegin(GL_POLYGON);
for (i = 0; i
{
angle = 2*PI*i/circle_points;// angle in radians
glVertex2f(centerx+radius*cos(angle),
centery + radius*sin(angle));
}
glEnd();
}
GLfloat RadiusOfBall=15.;
//draw the ball, centered at the original
void draw_ball()
{
glColor3f(0.6,0.3,0.2);
MyCircle2f(50.,100.,RadiusOfBall);
}
void reshape (int w, int h)
{
glViewport(0,0,(GLsizei)w,(GLsizei)h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0.0,320.0,0.0,300.0);
}

void init()
{
glClearColor(1.0,0.0,0.0,1.0);
glPointSize(5.0);
}

void Display(void)
{
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.1,1.1,1.1);
MyCircle2f(160.,160.,35.);
draw_ball();
glFlush();
}

int main(int args,char*argy[])
{
glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB);
glutInitWindowSize(320,300);
glutCreateWindow("pertemuan ke 6");
init();
glutDisplayFunc(Display);
glutReshapeFunc(reshape);
glutMainLoop();
}

0 komentar:

Posting Komentar

Pengikut

Kamus....