mulaiOpenGL();
//
// mulai looping utama program
float kaki = 1.0f;
float atbw = 0.0f;
while( mRunning )
{
//
// bersihkan layar dan depth buffer
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
glLoadIdentity();
//
// lakukan penggambaran di sini
//------------------------------------------------------------------------------------
glTranslatef(-7,-15,-80);
glRotatef(kaki,0,1,0);
glRotatef(atbw,1,0,0);
glBegin(GL_QUADS);
//bawah bngun1
glColor3f(0.0f,1.0f,0.0f);
glVertex3f(0,0,0); glVertex3f(10,0,0);
glColor3f(0.0f,1.0f,1.0f);
glVertex3f(10,0,-10); glVertex3f(0,0,-10);
//atas bngun1
glColor3f(0.0f,1.0f,0.0f);
glVertex3f(-5,5,5); glVertex3f(15,5,5);
glColor3f(0.0f,1.0f,1.0f);
glVertex3f(15,5,-15); glVertex3f(-5,5,-15);
//depan bngun1
glColor3f(0.0f,1.0f,0.0f);
glVertex3f(0,0,0); glVertex3f(10,0,0);
glColor3f(0.0f,1.0f,1.0f);
glVertex3f(15,5,5); glVertex3f(-5,5,5);
//blakang bngun1
glColor3f(0.0f,1.0f,0.0f);
glVertex3f(0,0,-10); glVertex3f(10,0,-10);
glColor3f(0.0f,1.0f,1.0f);
glVertex3f(15,5,-15); glVertex3f(-5,5,-15);
//kanan bngun1
glColor3f(0.0f,1.0f,0.0f);
glVertex3f(10,0,0); glVertex3f(10,0,-10);
glColor3f(0.0f,1.0f,1.0f);
glVertex3f(15,5,-15); glVertex3f(15,5,5);
//kiri bngun1
glColor3f(0.0f,1.0f,0.0f);
glVertex3f(0,0,0); glVertex3f(0,0,-10);
glColor3f(0.0f,1.0f,1.0f);
glVertex3f(-5,5,-15); glVertex3f(-5,5,5);
//bawah bngun2
glColor3f(1.0f,1.0f,0.0f);
glVertex3f(0,5,0); glVertex3f(10,5,0);
glColor3f(1.0f,1.0f,1.0f);
glVertex3f(10,5,-10); glVertex3f(0,5,-10);
//atas bngun2
glColor3f(1.0f,1.0f,0.0f);
glVertex3f(3,25,-3); glVertex3f(7,25,-3);
glColor3f(1.0f,1.0f,1.0f);
glVertex3f(7,25,-7); glVertex3f(3,25,-7);
//depan bngun2
glColor3f(1.0f,1.0f,0.0f);
glVertex3f(0,5,0); glVertex3f(10,5,0);
glColor3f(1.0f,1.0f,1.0f);
glVertex3f(7,25,-3); glVertex3f(3,25,-3);
//blakng bngun2
glColor3f(1.0f,1.0f,0.0f);
glVertex3f(0,5,-10); glVertex3f(10,5,-10);
glColor3f(1.0f,1.0f,1.0f);
glVertex3f(7,25,-7); glVertex3f(3,25,-7);
//kanan bangun2
glColor3f(1.0f,1.0f,0.0f);
glVertex3f(10,5,0); glVertex3f(10,5,-10);
glColor3f(1.0f,1.0f,1.0f);
glVertex3f(7,25,-7); glVertex3f(7,25,-3);
//kiri bangun2
glColor3f(1.0f,1.0f,0.0f);
glVertex3f(0,5,0); glVertex3f(0,5,-10);
glColor3f(1.0f,1.0f,1.0f);
glVertex3f(3,25,-7); glVertex3f(3,25,-3);
//bawah bngun3
glColor3f(1.0f,0.0f,1.0f);
glVertex3f(3,25,-3); glVertex3f(7,25,-3);
glColor3f(0.0f,1.0f,1.0f);
glVertex3f(7,25,-7); glVertex3f(3,25,-7);
//atas bngun3
glColor3f(1.0f,0.0f,1.0f);
glVertex3f(1.5,27,-1.5); glVertex3f(8.5,27,-1.5);
glColor3f(0.0f,1.0f,1.0f);
glVertex3f(8.5,27,-8.5); glVertex3f(1.5,27,-8.5);
//depan bngun3
glColor3f(1.0f,0.0f,1.0f);
glVertex3f(3,25,-3); glVertex3f(7,25,-3);
glColor3f(0.0f,1.0f,1.0f);
glVertex3f(8.5,27,-1.5); glVertex3f(1.5,27,-1.5);
//belakang bngun3
glColor3f(1.0f,0.0f,1.0f);
glVertex3f(3,25,-7); glVertex3f(7,25,-7);
glColor3f(0.0f,1.0f,1.0f);
glVertex3f(8.5,27,-8.5); glVertex3f(1.5,27,-8.5);
//kanan bngun3
glColor3f(1.0f,0.0f,1.0f);
glVertex3f(7,25,-3); glVertex3f(7,25,-7);
glColor3f(0.0f,1.0f,1.0f);
glVertex3f(8.5,27,-8.5); glVertex3f(8.5,27,-1.5);
//kiri bngun3
glColor3f(1.0f,0.0f,1.0f);
glVertex3f(3,25,-3); glVertex3f(3,25,-7);
glColor3f(0.0f,1.0f,1.0f);
glVertex3f(1.5,27,-8.5); glVertex3f(1.5,27,-1.5);
glEnd();
glBegin(GL_QUADS);
//bawah bngun4
glColor3f(0.0f,0.0f,1.0f);
glVertex3f(3,25,-3); glVertex3f(7,25,-3);
glColor3f(1.0f,0.0f,1.0f);
glVertex3f(7,25,-7); glVertex3f(3,25,-7);
glEnd();
glBegin(GL_TRIANGLES);
//bagian depan
glColor3f(0.0f,0.0f,1.0f);
glVertex3f(3,27,-3); glVertex3f(7,27,-3);
glColor3f(1.0f,0.0f,1.0f);
glVertex3f(5,32,-5);
//bagian belakang
glColor3f(0.0f,0.0f,1.0f);
glVertex3f(7,27,-7); glVertex3f(3,27,-7);
glColor3f(1.0f,0.0f,1.0f);
glVertex3f(5,32,-5);
//bagian kanan
glColor3f(0.0f,0.0f,1.0f);
glVertex3f(7,27,-7); glVertex3f(7,27,-3);
glColor3f(1.0f,0.0f,1.0f);
glVertex3f(5,32,-5);
//bagian belakang
glColor3f(0.0f,0.0f,1.0f);
glVertex3f(3,27,-7); glVertex3f(3,27,-3);
glColor3f(1.0f,0.0f,1.0f);
glVertex3f(5,32,-5);
glEnd();
//tuk Alas monas
glBegin(GL_QUADS);
//atas kotak1
glColor3f(1.0f,0.0f,0.0f);
glVertex3f(-15,0,15); glVertex3f(25,0,15);
glColor3f(1.0f,1.0f,0.0f);
glVertex3f(25,0,-25); glVertex3f(-15,0,-25);
//alas kotak1
glColor3f(1.0f,0.0f,0.0f);
glVertex3f(-15,-1,15); glVertex3f(25,-1,15);
glColor3f(1.0f,1.0f,0.0f);
glVertex3f(25,-1,-25); glVertex3f(-15,-1,-25);
//kanan kotak1
glColor3f(1.0f,0.0f,0.0f);
glVertex3f(25,0,15); glVertex3f(25,-1,15);
glColor3f(1.0f,1.0f,0.0f);
glVertex3f(25,0,-25); glVertex3f(25,-1,-25);
//kiri kotak1
glColor3f(1.0f,0.0f,0.0f);
glVertex3f(-15,0,15); glVertex3f(-15,-1,15);
glColor3f(1.0f,1.0f,0.0f);
glVertex3f(-15,0,-25); glVertex3f(-15,-1,-25);
//depan kotak1
glColor3f(1.0f,0.0f,0.0f);
glVertex3f(-15,0,15); glVertex3f(25,0,15);
glColor3f(1.0f,1.0f,0.0f);
glVertex3f(-15,-1,15); glVertex3f(25,-1,15);
//belakang kotak1
glColor3f(1.0f,0.0f,0.0f);
glVertex3f(-15,0,-25); glVertex3f(25,0,-25);
glColor3f(1.0f,1.0f,0.0f);
glVertex3f(-15,-1,-25);glVertex3f(25,-1,-25);
//atas kotak2
glColor3f(0.0f,1.0f,0.0f);
glVertex3f(-18,-1,18); glVertex3f(28,-1,18);
glColor3f(1.0f,1.0f,0.0f);
glVertex3f(28,-1,-28); glVertex3f(-18,-1,-28);
//alas kotak2
glColor3f(0.0f,1.0f,0.0f);
glVertex3f(-18,-2,18); glVertex3f(28,-2,18);
glColor3f(1.0f,1.0f,0.0f);
glVertex3f(28,-2,-28); glVertex3f(-18,-2,-28);
//kanan kotak2
glColor3f(0.0f,1.0f,0.0f);
glVertex3f(28,-1,18); glVertex3f(28,-2,18);
glColor3f(1.0f,1.0f,0.0f);
glVertex3f(28,-1,-28); glVertex3f(28,-2,-28);
//kiri kotak2
glColor3f(0.0f,1.0f,0.0f);
glVertex3f(-18,-1,18); glVertex3f(-18,-2,18);
glColor3f(1.0f,1.0f,0.0f);
glVertex3f(-18,-1,-28);glVertex3f(-18,-2,-28);
//depan kotak2
glColor3f(0.0f,1.0f,0.0f);
glVertex3f(-18,-1,18); glVertex3f(28,-1,18);
glColor3f(1.0f,1.0f,0.0f);
glVertex3f(-18,-2,18); glVertex3f(28,-2,18);
//belakang kotak2
glColor3f(0.0f,1.0f,0.0f);
glVertex3f(-18,-1,-28); glVertex3f(28,-1,-28);
glColor3f(1.0f,1.0f,0.0f);
glVertex3f(-18,-2,-28); glVertex3f(28,-2,-28);
glEnd();
if(glfwGetKey(GLFW_KEY_UP)) atbw -= 1.1f;
if(glfwGetKey(GLFW_KEY_DOWN)) atbw += 1.1f;
if(glfwGetKey(GLFW_KEY_LEFT)) kaki -= 1.1f;
if(glfwGetKey(GLFW_KEY_RIGHT)) kaki += 1.1f;
//------------------------------------------------------------------------------------
//
// mulai looping utama program
float kaki = 1.0f;
float atbw = 0.0f;
while( mRunning )
{
//
// bersihkan layar dan depth buffer
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
glLoadIdentity();
//
// lakukan penggambaran di sini
//------------------------------------------------------------------------------------
glTranslatef(-7,-15,-80);
glRotatef(kaki,0,1,0);
glRotatef(atbw,1,0,0);
glBegin(GL_QUADS);
//bawah bngun1
glColor3f(0.0f,1.0f,0.0f);
glVertex3f(0,0,0); glVertex3f(10,0,0);
glColor3f(0.0f,1.0f,1.0f);
glVertex3f(10,0,-10); glVertex3f(0,0,-10);
//atas bngun1
glColor3f(0.0f,1.0f,0.0f);
glVertex3f(-5,5,5); glVertex3f(15,5,5);
glColor3f(0.0f,1.0f,1.0f);
glVertex3f(15,5,-15); glVertex3f(-5,5,-15);
//depan bngun1
glColor3f(0.0f,1.0f,0.0f);
glVertex3f(0,0,0); glVertex3f(10,0,0);
glColor3f(0.0f,1.0f,1.0f);
glVertex3f(15,5,5); glVertex3f(-5,5,5);
//blakang bngun1
glColor3f(0.0f,1.0f,0.0f);
glVertex3f(0,0,-10); glVertex3f(10,0,-10);
glColor3f(0.0f,1.0f,1.0f);
glVertex3f(15,5,-15); glVertex3f(-5,5,-15);
//kanan bngun1
glColor3f(0.0f,1.0f,0.0f);
glVertex3f(10,0,0); glVertex3f(10,0,-10);
glColor3f(0.0f,1.0f,1.0f);
glVertex3f(15,5,-15); glVertex3f(15,5,5);
//kiri bngun1
glColor3f(0.0f,1.0f,0.0f);
glVertex3f(0,0,0); glVertex3f(0,0,-10);
glColor3f(0.0f,1.0f,1.0f);
glVertex3f(-5,5,-15); glVertex3f(-5,5,5);
//bawah bngun2
glColor3f(1.0f,1.0f,0.0f);
glVertex3f(0,5,0); glVertex3f(10,5,0);
glColor3f(1.0f,1.0f,1.0f);
glVertex3f(10,5,-10); glVertex3f(0,5,-10);
//atas bngun2
glColor3f(1.0f,1.0f,0.0f);
glVertex3f(3,25,-3); glVertex3f(7,25,-3);
glColor3f(1.0f,1.0f,1.0f);
glVertex3f(7,25,-7); glVertex3f(3,25,-7);
//depan bngun2
glColor3f(1.0f,1.0f,0.0f);
glVertex3f(0,5,0); glVertex3f(10,5,0);
glColor3f(1.0f,1.0f,1.0f);
glVertex3f(7,25,-3); glVertex3f(3,25,-3);
//blakng bngun2
glColor3f(1.0f,1.0f,0.0f);
glVertex3f(0,5,-10); glVertex3f(10,5,-10);
glColor3f(1.0f,1.0f,1.0f);
glVertex3f(7,25,-7); glVertex3f(3,25,-7);
//kanan bangun2
glColor3f(1.0f,1.0f,0.0f);
glVertex3f(10,5,0); glVertex3f(10,5,-10);
glColor3f(1.0f,1.0f,1.0f);
glVertex3f(7,25,-7); glVertex3f(7,25,-3);
//kiri bangun2
glColor3f(1.0f,1.0f,0.0f);
glVertex3f(0,5,0); glVertex3f(0,5,-10);
glColor3f(1.0f,1.0f,1.0f);
glVertex3f(3,25,-7); glVertex3f(3,25,-3);
//bawah bngun3
glColor3f(1.0f,0.0f,1.0f);
glVertex3f(3,25,-3); glVertex3f(7,25,-3);
glColor3f(0.0f,1.0f,1.0f);
glVertex3f(7,25,-7); glVertex3f(3,25,-7);
//atas bngun3
glColor3f(1.0f,0.0f,1.0f);
glVertex3f(1.5,27,-1.5); glVertex3f(8.5,27,-1.5);
glColor3f(0.0f,1.0f,1.0f);
glVertex3f(8.5,27,-8.5); glVertex3f(1.5,27,-8.5);
//depan bngun3
glColor3f(1.0f,0.0f,1.0f);
glVertex3f(3,25,-3); glVertex3f(7,25,-3);
glColor3f(0.0f,1.0f,1.0f);
glVertex3f(8.5,27,-1.5); glVertex3f(1.5,27,-1.5);
//belakang bngun3
glColor3f(1.0f,0.0f,1.0f);
glVertex3f(3,25,-7); glVertex3f(7,25,-7);
glColor3f(0.0f,1.0f,1.0f);
glVertex3f(8.5,27,-8.5); glVertex3f(1.5,27,-8.5);
//kanan bngun3
glColor3f(1.0f,0.0f,1.0f);
glVertex3f(7,25,-3); glVertex3f(7,25,-7);
glColor3f(0.0f,1.0f,1.0f);
glVertex3f(8.5,27,-8.5); glVertex3f(8.5,27,-1.5);
//kiri bngun3
glColor3f(1.0f,0.0f,1.0f);
glVertex3f(3,25,-3); glVertex3f(3,25,-7);
glColor3f(0.0f,1.0f,1.0f);
glVertex3f(1.5,27,-8.5); glVertex3f(1.5,27,-1.5);
glEnd();
glBegin(GL_QUADS);
//bawah bngun4
glColor3f(0.0f,0.0f,1.0f);
glVertex3f(3,25,-3); glVertex3f(7,25,-3);
glColor3f(1.0f,0.0f,1.0f);
glVertex3f(7,25,-7); glVertex3f(3,25,-7);
glEnd();
glBegin(GL_TRIANGLES);
//bagian depan
glColor3f(0.0f,0.0f,1.0f);
glVertex3f(3,27,-3); glVertex3f(7,27,-3);
glColor3f(1.0f,0.0f,1.0f);
glVertex3f(5,32,-5);
//bagian belakang
glColor3f(0.0f,0.0f,1.0f);
glVertex3f(7,27,-7); glVertex3f(3,27,-7);
glColor3f(1.0f,0.0f,1.0f);
glVertex3f(5,32,-5);
//bagian kanan
glColor3f(0.0f,0.0f,1.0f);
glVertex3f(7,27,-7); glVertex3f(7,27,-3);
glColor3f(1.0f,0.0f,1.0f);
glVertex3f(5,32,-5);
//bagian belakang
glColor3f(0.0f,0.0f,1.0f);
glVertex3f(3,27,-7); glVertex3f(3,27,-3);
glColor3f(1.0f,0.0f,1.0f);
glVertex3f(5,32,-5);
glEnd();
//tuk Alas monas
glBegin(GL_QUADS);
//atas kotak1
glColor3f(1.0f,0.0f,0.0f);
glVertex3f(-15,0,15); glVertex3f(25,0,15);
glColor3f(1.0f,1.0f,0.0f);
glVertex3f(25,0,-25); glVertex3f(-15,0,-25);
//alas kotak1
glColor3f(1.0f,0.0f,0.0f);
glVertex3f(-15,-1,15); glVertex3f(25,-1,15);
glColor3f(1.0f,1.0f,0.0f);
glVertex3f(25,-1,-25); glVertex3f(-15,-1,-25);
//kanan kotak1
glColor3f(1.0f,0.0f,0.0f);
glVertex3f(25,0,15); glVertex3f(25,-1,15);
glColor3f(1.0f,1.0f,0.0f);
glVertex3f(25,0,-25); glVertex3f(25,-1,-25);
//kiri kotak1
glColor3f(1.0f,0.0f,0.0f);
glVertex3f(-15,0,15); glVertex3f(-15,-1,15);
glColor3f(1.0f,1.0f,0.0f);
glVertex3f(-15,0,-25); glVertex3f(-15,-1,-25);
//depan kotak1
glColor3f(1.0f,0.0f,0.0f);
glVertex3f(-15,0,15); glVertex3f(25,0,15);
glColor3f(1.0f,1.0f,0.0f);
glVertex3f(-15,-1,15); glVertex3f(25,-1,15);
//belakang kotak1
glColor3f(1.0f,0.0f,0.0f);
glVertex3f(-15,0,-25); glVertex3f(25,0,-25);
glColor3f(1.0f,1.0f,0.0f);
glVertex3f(-15,-1,-25);glVertex3f(25,-1,-25);
//atas kotak2
glColor3f(0.0f,1.0f,0.0f);
glVertex3f(-18,-1,18); glVertex3f(28,-1,18);
glColor3f(1.0f,1.0f,0.0f);
glVertex3f(28,-1,-28); glVertex3f(-18,-1,-28);
//alas kotak2
glColor3f(0.0f,1.0f,0.0f);
glVertex3f(-18,-2,18); glVertex3f(28,-2,18);
glColor3f(1.0f,1.0f,0.0f);
glVertex3f(28,-2,-28); glVertex3f(-18,-2,-28);
//kanan kotak2
glColor3f(0.0f,1.0f,0.0f);
glVertex3f(28,-1,18); glVertex3f(28,-2,18);
glColor3f(1.0f,1.0f,0.0f);
glVertex3f(28,-1,-28); glVertex3f(28,-2,-28);
//kiri kotak2
glColor3f(0.0f,1.0f,0.0f);
glVertex3f(-18,-1,18); glVertex3f(-18,-2,18);
glColor3f(1.0f,1.0f,0.0f);
glVertex3f(-18,-1,-28);glVertex3f(-18,-2,-28);
//depan kotak2
glColor3f(0.0f,1.0f,0.0f);
glVertex3f(-18,-1,18); glVertex3f(28,-1,18);
glColor3f(1.0f,1.0f,0.0f);
glVertex3f(-18,-2,18); glVertex3f(28,-2,18);
//belakang kotak2
glColor3f(0.0f,1.0f,0.0f);
glVertex3f(-18,-1,-28); glVertex3f(28,-1,-28);
glColor3f(1.0f,1.0f,0.0f);
glVertex3f(-18,-2,-28); glVertex3f(28,-2,-28);
glEnd();
if(glfwGetKey(GLFW_KEY_UP)) atbw -= 1.1f;
if(glfwGetKey(GLFW_KEY_DOWN)) atbw += 1.1f;
if(glfwGetKey(GLFW_KEY_LEFT)) kaki -= 1.1f;
if(glfwGetKey(GLFW_KEY_RIGHT)) kaki += 1.1f;
//------------------------------------------------------------------------------------
Tidak ada komentar:
Posting Komentar