Professional Documents
Culture Documents
UAS Grafika Komputer - Kelomok 7 - A PAGI
UAS Grafika Komputer - Kelomok 7 - A PAGI
KELOMPOK 7 :
1. M. Fachrur rozi 220602005
2. Qomaruzzaman 220602006
3. M. Ikfani Difangga 220602011
Source Code :
#include <Windows.h>
#ifdef __APPLE__
#include <GLUT/glut.h>
#else
#include <GL/glut.h>
#endif
#include <stdlib.h>
void init(){
GLfloat LightPosition[] = {10.0f, 10.0f, 20.0f, 0.0f};
GLfloat LightAmbient[] = {0.0f, 1.0f, 0.0f, 1.0f};
GLfloat LightDiffuse[] = {0.7f, 0.7f, 0.7f, 1.0f};
GLfloat LightSpecular[] = {0.5f, 0.5f, 0.5f, 1.0f};
GLfloat Shine[] = { 80 };
glShadeModel(GL_SMOOTH);
glClearColor(0.0f,0.0f,0.0f,0.5f);
glClearDepth(1.0f);
glEnable(GL_DEPTH_TEST);
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
return;
void pagar(){
//pagar
glPushMatrix();
glEnable(GL_COLOR_MATERIAL);
glTranslatef(3,-1,1);
glColor3f(0.6, 0.6, 0.6);
glPushMatrix();
glTranslatef(-1,0.2,0);
glScalef(5.4,0.2,0.1);
glutSolidCube(1);
glPopMatrix();
glPushMatrix();
glTranslatef(-1,-0.2,0);
glScalef(5.4,0.2,0.1);
glutSolidCube(1);
glPopMatrix();
glScalef(0.2,1,0.1);
//glutSolidCube(1);
glTranslatef(2,0,0);
glutSolidCube(1);
glTranslatef(2,0,0);
glutSolidCube(1);
glTranslatef(2,0,0);
glutSolidCube(1);
glTranslatef(2,0,0);
//glutSolidCube(1);
glTranslatef(2,0,0);
//glutSolidCube(1);
glTranslatef(2,0,0);
//glutSolidCube(1);
glTranslatef(2,0,0);
//glutSolidCube(1);
glTranslatef(-12,0,0);
glutSolidCube(1);
glTranslatef(-2,0,0);
glutSolidCube(1);
glTranslatef(-2,0,0);
glutSolidCube(1);
glTranslatef(-2,0,0);
glutSolidCube(1);
glTranslatef(-2,0,0);
glutSolidCube(1);
glTranslatef(-2,0,0);
glutSolidCube(1);
glTranslatef(-2,0,0);
glutSolidCube(1);
glTranslatef(-2,0,0);
glutSolidCube(1);
glTranslatef(-2,0,0);
glutSolidCube(1);
glTranslatef(-2,0,0);
glutSolidCube(1);
glDisable(GL_COLOR_MATERIAL);
glPopMatrix();
}
void renderScene(void){
GLfloat LightPosition[] = {10.0f, 10.0f, 20.0f, 0.0f};
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glClearColor(1,1,1,1);
LightPosition[0] = cx;
LightPosition[1] = cy;
glLoadIdentity();
glTranslatef(0,0,z);
glRotatef(sudut,x1,y1,z1);
glScalef(skalaX, skalaY, skalaZ);
//tembok
glPushMatrix();
glEnable(GL_COLOR_MATERIAL);
glColor3f(1.0, 0.8, 0.6);
glRotatef(50,0,1,0);
glutSolidCube(3);
glDisable(GL_COLOR_MATERIAL);
//pagar
glPushMatrix();
glTranslatef(0,0,1.5);
pagar();
glPopMatrix();
glPushMatrix();
glTranslatef(-2,0,-3.5);
pagar();
glPopMatrix();
glPushMatrix();
glRotatef(-90,0,1,0);
glTranslatef(-2,0,1.5);
pagar();
glPopMatrix();
glPushMatrix();
glRotatef(-90,0,1,0);
glTranslatef(-2,0,-3.5);
pagar();
glPopMatrix();
//pintu
glPushMatrix();
glEnable(GL_COLOR_MATERIAL);
glColor3f(0.7, 0.0, 0.1);
glTranslatef(-0.6,-0.5,1.46);
glScalef(8,17,1.3);
glutSolidCube(0.1);
glDisable(GL_COLOR_MATERIAL);
glPopMatrix();
glPushMatrix();
glEnable(GL_COLOR_MATERIAL);
glColor3f(1.0, 0.8, 0.2);
glTranslatef(-0.7, -0.45, 1.51);
glutSolidSphere(0.02, 10, 10);
glDisable(GL_COLOR_MATERIAL);
glPopMatrix();
//jendela
glPushMatrix();
glEnable(GL_COLOR_MATERIAL);
glColor3f(0.0, 0.5, 0.5);
glTranslatef(0.5,0.1,1.46);
glScalef(3,3,1);
glutSolidCube(0.1);
glDisable(GL_COLOR_MATERIAL);
glPopMatrix();
glPushMatrix();
glEnable(GL_COLOR_MATERIAL);
glColor3f(0.0, 0.5, 0.5);
glTranslatef(0.9,0.1,1.46);
glScalef(3,3,1);
glutSolidCube(0.1);
glDisable(GL_COLOR_MATERIAL);
glPopMatrix();
glPushMatrix();
glEnable(GL_COLOR_MATERIAL);
glColor3f(0.0, 0.5, 0.5);
glTranslatef(0.9,-0.3,1.46);
glScalef(3,3,1);
glutSolidCube(0.1);
glDisable(GL_COLOR_MATERIAL);
glPopMatrix();
glPushMatrix();
glEnable(GL_COLOR_MATERIAL);
glColor3f(0.0, 0.5, 0.5);
glTranslatef(0.5,-0.3,1.46);
glScalef(3,3,1);
glutSolidCube(0.1);
glDisable(GL_COLOR_MATERIAL);
glPopMatrix();
glPopMatrix();
//atap
glPushMatrix();
glEnable(GL_COLOR_MATERIAL);
glColor3f(0.7, 0.4, 0.2);
glRotatef(5,0,1,0);
glTranslatef(0,1.5,0);
glScalef(3,1.3,3);
glutSolidOctahedron();
glDisable(GL_COLOR_MATERIAL);
glPopMatrix();
glPushMatrix();
glTranslatef(-2.5, -1.0, 1.5);
glPopMatrix();
glutSwapBuffers();
}