Pewarnaan di Pemrograman OpenGL

Posted on Updated on


#include <windows.h>
#include <gl/glut.h>

void Display(void)
{
    glClear(GL_COLOR_BUFFER_BIT);
    glBegin(GL_POINTS);
        glColor3f(0.0,1.0,0.0);
        glVertex2f(10.,10.);
        glColor3f(1.0,1.0,0.0);
        glVertex2f(10.,110.);
        glColor3f(0.0,0.0,1.0);
        glVertex2f(150.,110.0);
        glColor3f(1.0,1.0,1.0);
        glVertex2f(150.,10);
    glEnd();
    glFlush();
}

void reshape(int w,int h)
{
    glViewport(0,0,(GLsizei)w,(GLsizei)h);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    gluOrtho2D(0.0,160.0,0.0,120);

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

void main(int argc,char* argv[])
{
    glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
    glutInitWindowSize(320,240);
    glutCreateWindow("ProgramPertama");
    init();
    glutDisplayFunc(Display);
    glutReshapeFunc(reshape);
    glutMainLoop();
}

Program di atas bila dikompel hasilnya :

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s