Latihan Tugas Modul TIK SMK REKAYASA PERANGKAT LUNAK kelompok kompetensi G
97
import org.lwjgl.util.glu.GLU; public class TeksturGedung extends CGApplication {
public static final int DISPLAY_HEIGHT = 480; public static final int DISPLAY_WIDTH = 640;
private final int[] m_texID = new int[14]; public final static int NO_WRAP = -1;
private Texture m_texture;
public static void mainString[] args { TODO code application logic here
TeksturGedung main = new TeksturGedung; main.start800,600,false,false,true,Tekstur Gedung;
} public void render {
glViewport0, 0, width, height; glMatrixModeGL_PROJECTION;
glLoadIdentity; gluPerspective45.0f,widthheight, 1.0f, 700.0f;
glMatrixModeGL_MODELVIEW; glLoadIdentity;
glClearGL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT; glClearColor0.0f, 0.0f, 0.0f, 0.0f;
glEnableGL_DEPTH_TEST; glEnableGL_ALPHA_TEST;
glAlphaFuncGL_GREATER, 0.1f; glEnableGL_BLEND;
glBlendFuncGL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; glEnableGL_TEXTURE_2D;
glPushMatrix; glTranslatef-50, 0, 25;
for int row = 0; row 2; row++ {
glPushMatrix; for int col = 0; col 6; col++ {
drawBuilding4, 6, 10; glTranslatef6, 0, 0;
drawBuilding4, 12, 11; glTranslatef6, 0, 0;
drawBuilding4, 10, 10; glTranslatef4, 0, 0;
} glPopMatrix;
glTranslatef0, 0, 12; }
glPopMatrix; glPushMatrix;
glTranslatef-50, 0, -50; for int row = 0; row 2; row++ {
glPushMatrix; for int col = 0; col 6; col++ {
drawBuilding4, 6, 10; glTranslatef6, 0, 0;
drawBuilding4, 12, 11; glTranslatef6, 0, 0;
98
drawBuilding4, 10, 10; glTranslatef4, 0, 0;
} glPopMatrix;
glTranslatef0, 0, 12; }
glDisableGL_DEPTH_TEST; glDisableGL_ALPHA_TEST;
glDisableGL_TEXTURE_2D; glDisableGL_BLEND;
} private void update {
} public void destroy {
Mouse.destroy; Keyboard.destroy;
Display.destroy; }
public void deinit { }
public void init {
IntBuffer textureIDBuffer = BufferUtils.createIntBuffer14;
glGenTexturestextureIDBuffer; m_texID[0] = textureIDBuffer.get0;
m_texID[1] = textureIDBuffer.get1; m_texID[2] = textureIDBuffer.get2;
m_texID[3] = textureIDBuffer.get3; m_texID[4] = textureIDBuffer.get4;
m_texID[5] = textureIDBuffer.get5; m_texID[6] = textureIDBuffer.get6;
m_texID[7] = textureIDBuffer.get7; m_texID[8] = textureIDBuffer.get8;
m_texID[9] = textureIDBuffer.get9; m_texID[10] = textureIDBuffer.get10;
m_texID[11] = textureIDBuffer.get11; m_texID[12] = textureIDBuffer.get12;
m_texID[12] = textureIDBuffer.get12; loadTexturem_texID[10], picgedungA.png, false,
GL_LINEAR, NO_WRAP; loadTexturem_texID[11], picgedungB.png, false,
GL_LINEAR, NO_WRAP;
} private void drawBuildingfloat width, float height, int
texID { width = width 2;
glBindTextureGL_TEXTURE_2D, m_texID[texID]; glBeginGL_QUADS;
front side glTexCoord2d0, 0;
glVertex3f-width, 0, width; glTexCoord2d1, 0;
glVertex3fwidth, 0, width; glTexCoord2d1, 1;
glVertex3fwidth, height, width;