Hello friends! I’m gonna show you what I’ve done from my first activity in Graphics. Our professor instructed us to create a smiley face (which she drew it on the board) with the proper shapes to be used.
First instruction was to create your draft on your graphing paper before encoding your codes in Visual Basic, so that you will not be confused of what you are doing. Especially in labeling of your x & y.
Expected Output:
Tadah! HAHAHAHA *looks scary joke. 🙂
#include <GL/glew.h> #include <GL/freeglut.h> #include <iostream> void event_display(void) { glClearColor(0, 0, 0, 0); glClear(GL_COLOR_BUFFER_BIT); glColor3f(1.0, 0.0, 0.0); glPointSize(30.0); glBegin(GL_POLYGON); //right eye glVertex3f(0.60, 0.70, 0.0); glVertex3f(0.80, 0.50, 0.0); glVertex3f(0.60, 0.30, 0.0); glVertex3f(0.40, 0.50, 0.0); glEnd(); glBegin(GL_POLYGON); //left eye glVertex3f(-0.60, 0.70, 0.0); glVertex3f(-0.80, 0.50, 0.0); glVertex3f(-0.60, 0.30, 0.0); glVertex3f(-0.40, 0.50, 0.0); glEnd(); glBegin(GL_POLYGON); //nose glVertex3f(-0.20, 0.10, 0.0); glVertex3f(-0.20, -0.10, 0.0); glVertex3f(0, -0.20, 0.0); glVertex3f(0.20, -0.10, 0.0); glVertex3f(0.20, 0.10, 0.0); glEnd(); glBegin(GL_TRIANGLES); //mouth glVertex3f(-0.60, -0.40, 0.0); glVertex3f(0.60, -0.40, 0.0); glVertex3f(0.0, -0.70, 0.0); glEnd(); glBegin(GL_LINE_STRIP); //face glVertex3f(-0.90, 0.80, 0.0); glVertex3f(-0.90, -0.80, 0.0); glVertex3f(0.0, -1.0, 0.0); glVertex3f(0.90, -0.80, 0.0); glVertex3f(0.90, 0.80, 0.0); glEnd(); glBegin(GL_LINES); //hair 1 glVertex3f(-0.80, 0.80, 0.0); glVertex3f(-0.60, 1.0, 0.0); glEnd(); glBegin(GL_LINES); //hair 2 glVertex3f(-0.50, 0.80, 0.0); glVertex3f(-0.30, 1.0, 0.0); glEnd(); glBegin(GL_LINES); //hair 3 glVertex3f(-0.20, 0.80, 0.0); glVertex3f(0.0, 1.0, 0.0); glEnd(); glBegin(GL_LINES); //hair 4 glVertex3f(0.10, 0.80, 0.0); glVertex3f(0.30, 1.0, 0.0); glEnd(); glBegin(GL_LINES); //hair 5 glVertex3f(0.40, 0.80, 0.0); glVertex3f(0.60, 1.0, 0.0); glEnd(); glBegin(GL_LINES); //hair 6 glVertex3f(0.70, 0.80, 0.0); glVertex3f(0.90, 1.0, 0.0); glEnd(); glFlush(); } void main(int argc, char** argv) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); glutInitWindowSize(300, 300); glutInitWindowPosition(30, 30); glutCreateWindow(argv[0]); glutDisplayFunc(event_display); glutMainLoop(); }
You can also change the colors if you wished, at the same time the windows size. 🙂
That’s all for now.. :*
-Tinay
No Comments