Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifdef WIN32
- #include <windows.h>
- #endif
- #include <stdlib.h>
- #include <iostream>
- #include <fstream>
- #ifdef __APPLE__
- #include <GLUT/glut.h>
- #include <OpenGL/gl.h>
- #include <OpenGL/glu.h>
- #else
- #include <GL/glut.h>
- #include <GL/glu.h>
- #include <GL/gl.h>
- #endif
- char flag;
- void display(void)
- {
- /* bersihkan layar dari titik pixel yang masih ada */
- glClear (GL_COLOR_BUFFER_BIT);
- glColor3f (0.5, 1.0, 0.0);
- /* gambar 5 titik di layar */
- //glBegin(GL_POINTS);
- //glBegin(GL_LINE_STRIP);
- //glBegin(GL_LINE_LOOP);
- //glBegin(GL_LINES);
- //glBegin(GL_TRIANGLES);
- //glBegin(GL_TRIANGLE_FAN);
- //glBegin(GL_TRIANGLE_STRIP);
- //glBegin(GL_QUADS);
- //glBegin(GL_QUAD_STRIP);
- //glBegin(GL_POLYGON);
- //kotak2x2
- glColor3f (0.3, 0.3, 0.3);
- glBegin(GL_POLYGON);
- glVertex3f (0.0, 0.0, 0.0);
- glVertex3f (0.0, 0.8, 0.0);
- glVertex3f (-0.8, 0.8, 0.0);
- glVertex3f (-0.8, 0, 0.0);
- glEnd();
- glBegin(GL_POLYGON);
- glVertex3f (0.0, 0.0, 0.0);
- glVertex3f (0.0, -0.8, 0.0);
- glVertex3f (0.8, -0.8, 0.0);
- glVertex3f (0.8, 0, 0.0);
- glEnd();
- glColor3f (0.7, 0.7, 0.7);
- glBegin(GL_POLYGON);
- glVertex3f (0.0, 0.0, 0.0);
- glVertex3f (0.0, 0.8, 0.0);
- glVertex3f (0.8, 0.8, 0.0);
- glVertex3f (0.8, 0, 0.0);
- glEnd();
- glBegin(GL_POLYGON);
- glVertex3f (0.0, 0.0, 0.0);
- glVertex3f (0.0, -0.8, 0.0);
- glVertex3f (-0.8, -0.8, 0.0);
- glVertex3f (-0.8, 0, 0.0);
- glEnd();
- glLineWidth(500);
- //mulai huruf A
- if(flag=='a'){
- glColor3f (1, 1, 1);
- glBegin(GL_LINE_STRIP);
- glVertex3f (0.0, 0.7, 0.0);
- glVertex3f (-0.4, -0.1, 0.0);
- glVertex3f (0.4, -0.1, 0.0);
- glVertex3f (0.0, 0.7, 0.0);
- glEnd();
- glBegin(GL_LINE_STRIP);
- glVertex3f (-0.4, -0.1, 0.0);
- glVertex3f (-0.7, -0.7, 0.0);
- glEnd();
- glBegin(GL_LINE_STRIP);
- glVertex3f (0.4, -0.1, 0.0);
- glVertex3f (0.7, -0.7, 0.0);
- glEnd();
- }
- //mulai huruf I
- else if(flag=='i'){
- glColor3f (1, 1, 1);
- glBegin(GL_LINE_STRIP);
- glVertex3f (-0.2, 0.7, 0.0);
- glVertex3f (0,0.7,0);
- glVertex3f (0.2,0.7,0);
- glEnd();
- glBegin(GL_LINE_STRIP);
- glVertex3f (0, 0.7, 0.0);
- glVertex3f (0, -0.7, 0.0);
- glEnd();
- glBegin(GL_LINE_STRIP);
- glVertex3f (-0.2, -0.7, 0.0);
- glVertex3f (0,-0.7,0);
- glVertex3f (0.2,-0.7,0);
- glEnd();
- }
- //mulai huruf E
- else if(flag=='e'){
- glColor3f (1, 1, 1);
- glBegin(GL_LINE_STRIP);
- glVertex3f (0.3, 0.7, 0.0);
- glVertex3f (0,0.7,0);
- glVertex3f (-0.3,0.7,0);
- glEnd();
- glBegin(GL_LINE_STRIP);
- glVertex3f (0.3, 0, 0.0);
- glVertex3f (0,0,0);
- glVertex3f (-0.3,0,0);
- glEnd();
- glBegin(GL_LINE_STRIP);
- glVertex3f (0.3, -0.7, 0.0);
- glVertex3f (0,-0.7,0);
- glVertex3f (-0.3,-0.7,0);
- glEnd();
- glBegin(GL_LINE_STRIP);
- glVertex3f (-0.3, 0.7, 0.0);
- glVertex3f (-0.3,-0.7,0);
- glEnd();
- }
- //mulai huruf O
- else if(flag=='o'){
- glLineWidth(1000);
- glColor3f (1, 1, 1);
- glBegin(GL_LINE_STRIP);
- glVertex3f (-0.3, 0.6, 0.0);
- glVertex3f (0.3,0.6, 0);
- glVertex3f (0.3,-0.6,0);
- glVertex3f (-0.3,-0.6,0);
- glVertex3f (-0.3, 0.6, 0.0);
- glEnd();
- }
- //mulai huruf U
- else if(flag=='u'){
- glColor3f (1, 1, 1);
- glBegin(GL_LINE_STRIP);
- glVertex3f (-0.4, 0.6, 0.0);
- glVertex3f (-0.4,-0.6, 0);
- glVertex3f(0.4,-0.6,0);
- glVertex3f(0.4,0.6,0);
- glEnd();
- }
- glFlush ();
- }
- void kunci(unsigned char key, int x, int y)
- {
- switch (key)
- {
- /* aplikasi berhenti ketika tombol q ditekan */
- case 27 :
- case 'q':
- exit(0);
- break;
- case 'a':
- flag='a';
- break;
- case 'e':
- flag='e';
- break;
- case 'i':
- flag='i';
- break;
- case 'u':
- flag='u';
- break;
- case 'o':
- flag='o';
- break;
- }
- glutPostRedisplay();
- }
- int main(int argc, char *argv[])
- {
- glutInit(&argc, argv);
- glutInitWindowSize(400,400);
- glutInitWindowPosition(100,100);
- glutInitDisplayMode(GLUT_RGB | GLUT_SINGLE);
- glutCreateWindow("Primitif");
- glutKeyboardFunc(kunci);
- glutDisplayFunc(display);
- glutMainLoop();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement