Dasar Meggambar Menggunakan OpenGL di C++

#include <GL/glut.h>

//=======================================================
void tampilan(){
glClear(GL_COLOR_BUFFER_BIT); // Menghapus layar
glBegin(GL_POLYGON);
glColor3f(255,255,255);
//for(int i=0; i<400; i++){
glVertex2f(-0.5, 0.5);
glVertex2f(0.5, 0.5);
glVertex2f(0.5, -0.5);
glVertex2f(-0.5, -0.5);
//}
glEnd();
glBegin(GL_POINTS);
glColor3f(255,0,0);
for(int i=0; i<400; i++){
glVertex2f(0, 1.0f*i/400);
glVertex2f(0, -1.0f*i/400);
glVertex2f(1.0f*i/400, 0);
glVertex2f(-1.0f*i/400, 0);

}
glEnd();
glFlush();
}
//=======================================================
int main(int argc, char** argv){
glutInit(&argc,argv);
glutInitWindowPosition(100,100);
glutInitWindowSize(400,400);
glutCreateWindow(“Dasar-dasar OpenGL dan glut “);
glutDisplayFunc(tampilan);
glutMainLoop();
return 0;
}
//=======================================================

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout /  Ubah )

Foto Google

You are commenting using your Google account. Logout /  Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout /  Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout /  Ubah )

Connecting to %s