TUGAS GRAFKOM Q 6

Friday, 7 December 2012



KOTAK BERGARIS

keterangan : 

pakek openGL microsoft visual c++ 2010 express.

source code


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

void dispaly(){
glColor3f(1.0,1.0,1.0); //warna putih
glBegin(GL_QUADS); //buat kotak
glVertex2f(100,100);
glVertex2f(100,300);
glVertex2f(400,300);
glVertex2f(400,100);
glEnd();

glColor3f(0.0,0.0,0.0);
glBegin(GL_LINES);
glVertex2f(100,100);
glVertex2f(100,300);

glVertex2f(100,300);
glVertex2f(400,300);

glVertex2f(400,300);
glVertex2f(400,100);

glVertex2f(100,100);
glVertex2f(400,100);

glVertex2f(125,100);
glVertex2f(125,300);

glVertex2f(225,100);
glVertex2f(225,300);

glVertex2f(275,100);
glVertex2f(275,300);

glVertex2f(150,100);
glVertex2f(150,300);

glVertex2f(175,100);
glVertex2f(175,300);

glVertex2f(200,100);
glVertex2f(200,300);

glVertex2f(250,100);
glVertex2f(250,300);

glVertex2f(300,100);
glVertex2f(300,300);

glVertex2f(325,100);
glVertex2f(325,300);

glVertex2f(350,100);
glVertex2f(350,300);

glVertex2f(375,100);
glVertex2f(375,300);
glEnd();

glFlush();
}

void init (){
GLfloat w=500, h=400;
glClearColor(0,0,0,0);
glClear(GL_COLOR_BUFFER_BIT);
glViewport(0,0,(GLsizei) w, (GLsizei) h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
//gluOrtho2D(w,0,h,0);
gluOrtho2D(0,w,0,h);
glMatrixMode(GL_MODELVIEW);
}

void FnKey (unsigned char key, int x, int y) {
if (key==27)
{
//glutLeaveGmeMode(); set the revolution how it was
exit(1); //quit the program
}
}

int main(int argc, char** argv){
FreeConsole();
glutInit(&argc, argv);
glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);

//to full screen
/*glutGameModeString( "1024x768:32@75");
glutEnterGameMode();*/

glutInitWindowSize (600,500);
glutInitWindowPosition (100,100);
//glutCreateWindow (argv[0]);
glutCreateWindow ("Create Point");

init();
glutKeyboardFunc(FnKey);
glutDisplayFunc(dispaly);
//glutReshapeFunc(reshape);
glutMainLoop();
return 0;
}



No comments:

Post a Comment

Cara Refund Google Ads

  Non Aktifkan Akun gogle dulu. Baru semua saldo yang berada di dalamnya, akan otomatis di kembalikan, lengkap dengan tgl berapa akan di kem...

 
FREE BLOGGER TEMPLATE BY DESIGNER BLOGS