Ad 468 X 60

Selasa, 21 Oktober 2014

Widgets

Membuat Kapal dengan OpenGl C++

Coding :

#include <windows.h>
#include <GL/gl.h>
#include <GL/glut.h>
void mydisplay()
{
glClear(GL_COLOR_BUFFER_BIT);
//bacground
glBegin(GL_POLYGON);
glColor3f(248.0/255,153.0/255,59.0/255);//make the color Dark Blue
glVertex2f(-1, 1);
glVertex2f(-1, -99);
glVertex2f(1, -99);
glVertex2f(1, 1);
glEnd();

//laut
glBegin(GL_POLYGON);
glColor3f(59.0/255,206.0/255,248.0/255); //make the color Dark Blue
glVertex2f(-1, -1);
glVertex2f(-1, -0.5);
glVertex2f(1, -0.5);
glVertex2f(1,-1);
glEnd();
//bagian bawah kapal
glBegin(GL_POLYGON);
glColor3f(1,1,1); //make the color Dark Blue
glVertex2f(-0.7, -0.5);
glVertex2f(-0.98, -0.134);
glVertex2f(0.98, -0.134);
glVertex2f(0.7, -0.5);
glEnd();
//bagian kapal 1
glBegin(GL_POLYGON);
glColor3f(251.0/255.0, 238.0/255.0, 195.0/255.0);//make the color Dark Blue
glVertex2f(-0.55, -0.135);
glVertex2f(-0.42, -0.015);
glVertex2f(0.42, -0.015);
glVertex2f(0.55, -0.135);
glEnd();
//bagian kapal 2
glBegin(GL_POLYGON);
glColor3f(249.0/255.0, 228.0/255.0, 157.0/255.0); //make the color Dark Blue
glVertex2f(-0.36, -0.015);
glVertex2f(-0.32, 0.075);
glVertex2f(0.32, 0.075);
glVertex2f(0.36, -0.015);
glEnd();
//bagian kapal 3
glBegin(GL_POLYGON);
glColor3f(250.0/255.0, 218.0/255.0, 109.0/255.0); //make the color Dark Blue
glVertex2f(-0.20, 0.075);
glVertex2f(-0.20, 0.17);
glVertex2f(0.20, 0.17);
glVertex2f(0.20, 0.075);
glEnd();
//tiang bendera
glBegin(GL_POLYGON);
glColor3f(200.0/255.0, 195.0/255.0, 145.0/255.0); //make the color Dark Blue
glVertex2f(0.15, 0.17);
glVertex2f(0.15, 0.6);
glVertex2f(0.10, 0.6);
glVertex2f(0.10, 0.17);
glEnd();
//bendera Merah
glBegin(GL_POLYGON);
glColor3f(1.0,0.0,0.0); //make the color Dark Blue
glVertex2f(0.15, 0.55);
glVertex2f(0.15, 0.60);
glVertex2f(0.40, 0.60);
glVertex2f(0.40, 0.55);
glEnd();
//bendera Putih
glBegin(GL_POLYGON);
glColor3f(1.0,1.0,1.0); //make the color Dark Blue
glVertex2f(0.15, 0.50);
glVertex2f(0.15, 0.55);
glVertex2f(0.40, 0.55);
glVertex2f(0.40, 0.50);
glEnd();
}
int main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB);
glutInitWindowSize(700,700);
glutInitWindowPosition(0,0);
glutCreateWindow("kapal");
glutDisplayFunc(mydisplay);
glutMainLoop();
}


Output :

SHARE THIS POST   

  • Facebook
  • Twitter
  • Myspace
  • Google Buzz
  • Reddit
  • Stumnleupon
  • Delicious
  • Digg
  • Technorati
Author: Mohammad
Mohammad is the founder of STC Network which offers Web Services and Online Business Solutions to clients around the globe. Read More →

0 komentar: