OPEN GL DEV C++ LOGO MARBORO

Postingan kali ini kita akan belajar menggunakan OPEN GL Dec C++ menggunakan Glut dengan gaya bahasa pemograman yang hampir kemirip miripan dengan C++, kita akan membuat logo Marboro, ada yang tau roko marboro, dan siap yang suka meroko, salah satunya roko marboro 3 Dimensi akan hadir di abad 21, semoga bermanfaat.




Codingan Logo Marboro :
#include<GL/glut.h>
GLfloat xRotated, yRotated, zRotated;
void Display(void)
{
glClear(GL_COLOR_BUFFER_BIT);
glLoadIdentity();
glTranslatef(0.0,0.0,-4.0);
glRotatef(xRotated,1.0,0.0,0.0);
glRotatef(yRotated,0.0,1.0,0.0);
glRotatef(zRotated,0.0,0.0,1.0);
glScalef(2.0,1.0,1.0);
//Depan
glBegin(GL_POLYGON);
//Merah
glColor3f(1.0,0.0,0.0);
glVertex3f(-0.50,0.50,0.0);
glVertex3f(0.50,0.50,0.0);
glVertex3f(0.50,-0.70,0.0);
glVertex3f(0.0,0.0,0.0);
glVertex3f(-0.50,-0.70,0.0);
glEnd();
//belakang
glBegin(GL_POLYGON);
//Merah
glColor3f(1.0,0.0,0.0);
glVertex3f(-0.50,0.50,0.40);
glVertex3f(0.50,0.50,0.40);
glVertex3f(0.50,-0.70,0.40);
glVertex3f(0.0,0.0,0.40);
glVertex3f(-0.50,-0.70,0.40);
glEnd();
//sisi
glBegin(GL_POLYGON);
//Merah
glColor3f(1.0,0.0,0.0);
glVertex3f(-0.50,0.50,0.0);
glVertex3f(-0.50,0.50,0.40);
glVertex3f(0.50,0.50,0.40);
glVertex3f(0.50,0.50,0.0);
glEnd();
//sisi
glBegin(GL_POLYGON);
//Merah
glColor3f(1.0,0.0,0.0);
glVertex3f(0.50,0.50,0.0);
glVertex3f(0.50,0.50,0.40);
glVertex3f(0.50,-0.70,0.40);
glVertex3f(0.50,-0.70,0.0);
glEnd();
//sisi
glBegin(GL_POLYGON);
//Merah
glColor3f(1.0,0.0,0.0);
glVertex3f(0.50,-0.70,0.0);
glVertex3f(0.50,-0.70,0.40);
glVertex3f(0.0,0.0,0.40);
glVertex3f(0.0,0.0,0.0);
glEnd();
//sisi
glBegin(GL_POLYGON);
//Merah
glColor3f(1.0,0.0,0.0);
glVertex3f(0.0,0.0,0.0);
glVertex3f(0.0,0.0,0.40);
glVertex3f(-0.50,-0.70,0.40);
glVertex3f(-0.50,-0.70,0.0);
glEnd();
//sisi
glBegin(GL_POLYGON);
//Merah
glColor3f(1.0,0.0,0.0);
glVertex3f(-0.50,-0.70,0.0);
glVertex3f(-0.50,-0.70,0.40);
glVertex3f(-0.50,0.50,0.0);
glVertex3f(-0.50,0.50,0.40);
glEnd();
glFlush();
glutSwapBuffers();
}
void Reshape(int x, int y)
{
if (y==0||x==0)return;
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(40.0,(GLdouble)x/(GLdouble)y,0.5,20.0);
glMatrixMode(GL_MODELVIEW);
glViewport(0,0,x,y);
}
void Idle(void)
{
xRotated +=0.01;//mengatur kecepatan rotasi bergerak
yRotated +=0.01;
zRotated +=0.01;
Display();
}
int main (int argc, char**argv){
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGB);
glutInitWindowSize(460,460);
glutCreateWindow("UAS");
xRotated= yRotated= zRotated= 0.0;
glutDisplayFunc(Display);
glutReshapeFunc(Reshape);
glutIdleFunc(Idle);
glutMainLoop();
return 0;
}

Komentar

Postingan populer dari blog ini

OPEN GL DEV C++ LOGO PERTAMINA

MEMBUAT WEBSITE INTERFACE RUMAH SAKIT PART 2