#include <GL/glut.h>
void printer(void)
{
glClearColor(1.0,1.0,1.0,0.0); //putih
}
void renderScene(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
//segitiga merah bagian bawah
glColor3f(1,0,0);
glBegin(GL_TRIANGLES);
glVertex2f(-0.5f, -0.5f);
glVertex2f(0.5f, -0.5f);
glVertex2f(0.5f, 0.5f);
glEnd();
//segitiga biru bagian atas
glColor3f(0,0,1);
glBegin(GL_TRIANGLES);
glVertex2f(-0.5f, -0.5f);
glVertex2f(0.5f, 0.5f);
glVertex2f(-0.5f, 0.5f);
glEnd();
glutSwapBuffers();
}
int main(int argc, char *argv[])
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA);
glutInitWindowPosition(100, 100);
glutInitWindowSize(320, 320);
glutCreateWindow("GLUT 1st program");
printer();
glutDisplayFunc(renderScene);
glutMainLoop();
return 0;
}
Berikut tampilan persegi bila program itu berjalan :
Tidak ada komentar:
Posting Komentar