Halo, sobat coding :)
Mengenai mata kuliah Grafika Komputer, kita akan belajar bagaimana cara membuat gambar pada komputer. Berikut ini adalah sebuah contoh 2D sederhana yaitu membentuk robot. Dalam membuat sebuah gambar kita membutuhkan library OpenGL
Untuk materi pengenalan Grafika Komputer dan dasar-dasar OpenGL, dapat Anda unduh di Pengenalan sistem grafika dan dasar-dasar penggunaan OpenGL pada dasar - dasar OpenGL
Screenshoot Program
Mengenai mata kuliah Grafika Komputer, kita akan belajar bagaimana cara membuat gambar pada komputer. Berikut ini adalah sebuah contoh 2D sederhana yaitu membentuk robot. Dalam membuat sebuah gambar kita membutuhkan library OpenGL
Untuk materi pengenalan Grafika Komputer dan dasar-dasar OpenGL, dapat Anda unduh di Pengenalan sistem grafika dan dasar-dasar penggunaan OpenGL pada dasar - dasar OpenGL
Screenshoot Program
#include<GL/glut.h> void init() { glClearColor(0.69, 0.89, 1.0, 1.0); glColor3f(1.0, 1.0, 1.0); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0); } void mydisplay() { glClear(GL_COLOR_BUFFER_BIT); //head glBegin(GL_POLYGON); glColor3f(1.0, 0.92, 0.80); //make the color Blanced Almond glVertex2f(-0.2, 0.9); glVertex2f(-0.2, 0.6); glVertex2f(0.2, 0.6); glVertex2f(0.2, 0.9); glEnd(); //eye left glBegin(GL_POLYGON); glColor3f(0.0, 0.0, 0.0); //make the color Black glVertex2f(-0.15, 0.82); glVertex2f(-0.15, 0.75); glVertex2f(-0.05, 0.75); glVertex2f(-0.05, 0.82); glEnd(); //eye right glBegin(GL_POLYGON); glColor3f(0.0, 0.0, 0.0); //make the color Black glVertex2f(0.15, 0.82); glVertex2f(0.15, 0.75); glVertex2f(0.05, 0.75); glVertex2f(0.05, 0.82); glEnd(); //alis kanan glBegin(GL_POLYGON); glColor3f(0.0, 0.0, 0.0); //make the color Black glVertex2f(0.15, 0.85); glVertex2f(0.15, 0.87); glVertex2f(0.05, 0.87); glVertex2f(0.05, 0.85); glEnd(); //alis kiri glBegin(GL_POLYGON); glColor3f(0.0, 0.0, 0.0); //make the color Black glVertex2f(-0.15, 0.85); glVertex2f(-0.15, 0.87); glVertex2f(-0.05, 0.87); glVertex2f(-0.05, 0.85); glEnd(); //bibir senyum glBegin(GL_POLYGON); glColor3f(0.69, 0.19, 0.38); //make the color Maroon glVertex2f(-0.05, 0.65); glVertex2f(-0.05, 0.67); glVertex2f(0.05, 0.67); glVertex2f(0.05, 0.65); glEnd(); glBegin(GL_POLYGON); glColor3f(0.69, 0.19, 0.38); //make the color Maroon glVertex2f(-0.05, 0.65); glVertex2f(-0.05, 0.70); glVertex2f(-0.04, 0.70); glVertex2f(-0.04, 0.65); glEnd(); glBegin(GL_POLYGON); glColor3f(0.69, 0.19, 0.38); //make the color Maroon glVertex2f(0.05, 0.65); glVertex2f(0.05, 0.70); glVertex2f(0.06, 0.70); glVertex2f(0.06, 0.65); glEnd(); //telinga kanan glBegin(GL_POLYGON); glColor3f(0.55, 0.55, 0.51); //make the color Azure glVertex2f(0.20, 0.80); glVertex2f(0.20, 0.70); glVertex2f(0.23, 0.70); glVertex2f(0.23, 0.80); glEnd(); //telinga kiri glBegin(GL_POLYGON); glColor3f(0.55, 0.55, 0.51); //make the color Azure glVertex2f(-0.20, 0.80); glVertex2f(-0.20, 0.70); glVertex2f(-0.23, 0.70); glVertex2f(-0.23, 0.80); glEnd(); //leher glBegin(GL_POLYGON); glColor3f(0.55, 0.55, 0.51); //make the color Azure glVertex2f(-0.07, 0.60); glVertex2f(-0.07, 0.55); glVertex2f(0.07, 0.55); glVertex2f(0.07, 0.60); glEnd(); //badan glBegin(GL_POLYGON); glColor3f(0.00, 0.00, 0.55); //make the color Dark Blue glVertex2f(-0.20, 0.10); glVertex2f(-0.20, 0.55); glVertex2f(0.20, 0.55); glVertex2f(0.20, 0.10); glEnd(); //sendi kiri glBegin(GL_POLYGON); glColor3f(0.55, 0.55, 0.51); //make the color Azure /*glVertex2f(-0.30, 0.55); glVertex2f(-0.30, 0.50); glVertex2f(-0.20, 0.50); glVertex2f(-0.20, 0.55);*/ glVertex2f(-0.30, 0.55); glVertex2f(-0.30, 0.42); glVertex2f(-0.20, 0.42); glVertex2f(-0.20, 0.55); glEnd(); //sendi kanan glBegin(GL_POLYGON); glColor3f(0.55, 0.55, 0.51); //make the color Azure /*glVertex2f(0.30, 0.55); glVertex2f(0.30, 0.50); glVertex2f(0.20, 0.50); glVertex2f(0.20, 0.55);*/ glVertex2f(0.30, 0.55); glVertex2f(0.30, 0.42); glVertex2f(0.20, 0.42); glVertex2f(0.20, 0.55); glEnd(); //lengan kiri glBegin(GL_POLYGON); glColor3f(0.55, 0.00, 0.00); //make the color Dark red /*glVertex2f(-0.30, 0.50); glVertex2f(-0.40, 0.30); glVertex2f(-0.30, 0.30); glVertex2f(-0.20, 0.45); glVertex2f(-0.20, 0.50);*/ glVertex2f(-0.30, 0.55); glVertex2f(-0.30, 0.45); glVertex2f(-0.50, 0.45); glVertex2f(-0.50, 0.55); glEnd(); glBegin(GL_POLYGON); glColor3f(0.55, 0.00, 0.00); //make the color Dark red glVertex2f(-0.50, 0.70); glVertex2f(-0.50, 0.55); glVertex2f(-0.40, 0.55); glVertex2f(-0.40, 0.70); glEnd(); //lengan kanan glBegin(GL_POLYGON); glColor3f(0.55, 0.00, 0.00); //make the color Dark red /*glVertex2f(0.30, 0.50); glVertex2f(0.40, 0.30); glVertex2f(0.30, 0.30); glVertex2f(0.20, 0.45); glVertex2f(0.20, 0.50);*/ glVertex2f(0.30, 0.55); glVertex2f(0.30, 0.45); glVertex2f(0.50, 0.45); glVertex2f(0.50, 0.55); glEnd(); glBegin(GL_POLYGON); glColor3f(0.55, 0.00, 0.00); //make the color Dark red glVertex2f(0.50, 0.45); glVertex2f(0.50, 0.20); glVertex2f(0.40, 0.20); glVertex2f(0.40, 0.45); glEnd(); //telapak kiri glBegin(GL_POLYGON); glColor3f(0.00, 0.55, 0.55); //make the color Dark cyan glVertex2f(-0.50, 0.70); glVertex2f(-0.50, 0.77); glVertex2f(-0.40, 0.77); glVertex2f(-0.40, 0.70); glEnd(); //telapak kanan glBegin(GL_POLYGON); glColor3f(0.00, 0.55, 0.55); //make the color Royal blue glVertex2f(0.50, 0.20); glVertex2f(0.50, 0.27); glVertex2f(0.40, 0.27); glVertex2f(0.40, 0.20); glEnd(); //sabuk glBegin(GL_POLYGON); glColor3f(0.20, 0.20, 0.20); //make the color Grey 20 glVertex2f(-0.22, 0.10); glVertex2f(-0.22, 0.00); glVertex2f(0.22, 0.00); glVertex2f(0.22, 0.10); glEnd(); //paha kiri glBegin(GL_POLYGON); glColor3f(0.00, 0.00, 0.55); //make the color Dark Blue glVertex2f(-0.20, 0.00); glVertex2f(-0.20, -0.20); glVertex2f(-0.02, -0.20); glVertex2f(-0.02, 0.00); glEnd(); //paha kanan glBegin(GL_POLYGON); glColor3f(0.00, 0.00, 0.55); //make the color Dark Blue glVertex2f(0.20, 0.00); glVertex2f(0.20, -0.20); glVertex2f(0.02, -0.20); glVertex2f(0.02, 0.00); glEnd(); //kaki kanan glBegin(GL_POLYGON); glColor3f(0.20, 0.20, 0.20); //make the color Grey 20 glVertex2f(0.18, -0.20); glVertex2f(0.18, -0.40); glVertex2f(0.05, -0.40); glVertex2f(0.05, -0.20); glEnd(); //kaki kiri glBegin(GL_POLYGON); glColor3f(0.20, 0.20, 0.20); //make the color Grey 20 glVertex2f(-0.18, -0.20); glVertex2f(-0.18, -0.40); glVertex2f(-0.05, -0.40); glVertex2f(-0.05, -0.20); glEnd(); //spatu kiri glBegin(GL_POLYGON); glColor3f(0.55, 0.00, 0.00); //make the color Dark red glVertex2f(-0.18, -0.40); glVertex2f(-0.25, -0.43); glVertex2f(-0.25, -0.50); glVertex2f(-0.05, -0.50); glVertex2f(-0.05, -0.40); glEnd(); //spatu kanan glBegin(GL_POLYGON); glColor3f(0.55, 0.00, 0.00); //make the color Dark red glVertex2f(0.18, -0.40); glVertex2f(0.25, -0.43); glVertex2f(0.25, -0.50); glVertex2f(0.05, -0.50); glVertex2f(0.05, -0.40); glEnd(); glFlush(); } int main(int argc, char** argv) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB); glutInitWindowSize(500,500); glutInitWindowPosition(0,0); glutCreateWindow("simpleRobot_5111100201_IkaAyuRahmania"); glutDisplayFunc(mydisplay); init(); glutMainLoop(); }
2 comments:
Ijin berbagi ke rekan-rekan yang punya hobi bikin game
http://heriadyblog.blogspot.com/2015/05/belajar-c-game-programming.html
Ijin berbagi ke rekan-rekan yang punya hobi bikin game
http://heriadyblog.blogspot.com/2015/05/belajar-c-game-programming.html
Post a Comment