Konsep Texture mapping Texture Mapping

87 Pembuatan kode program untuk texture terhadapa objek 3 dimensi dirancang dengan melibatkan beberapa file java untuk memudahkan dalam pengaturan dan operasi transformasi geometri. Beberapa file pendukung akan disertakan dalam lampiran. Kegiatan Praktikum 6.1 Keluaran Program Perancangan class diagram

D. Aktivitas Pembelajaran

88 Texture.java import static org.lwjgl.opengl.GL11.; import static org.lwjgl.util.glu.GLU.; import java.awt.Font; import org.lwjgl.LWJGLException; import org.lwjgl.Sys; import org.lwjgl.input.Keyboard; import org.lwjgl.opengl.Display; import org.lwjgl.opengl.DisplayMode; public abstract class CGApplication { protected long lastFrame; protected int fps; protected long last; protected String windowTitle = ; protected int width; protected int height; protected boolean fullscreen; protected boolean vsync; public final int DEFAULT_FONT_SIZE = 14; protected boolean showFPS; protected int oldfps; protected int activeFontTextureId; public void startint width, int height, boolean fullscreen, boolean vsync, boolean showFPS, String windowTitle { this.windowTitle = windowTitle; this.height = height; this.width = width; this.fullscreen = fullscreen; this.vsync = vsync; this.showFPS = showFPS; try { 89 createWindow; init; while Display.isCloseRequested Keyboard.isKeyDownKeyboard.KEY_ESCAPE { render; Display.update; } deinit; Display.destroy; } catch Exception e { e.printStackTrace; System.exit0; } } public abstract void render; public abstract void deinit; private void createWindow throws LWJGLException { Display.setTitlewindowTitle; Display.setFullscreenfullscreen; Display.setVSyncEnabledvsync; DisplayMode displayMode = null; DisplayMode d[] = Display.getAvailableDisplayModes; for int i = 0; i d.length; i++ { if d[i].getWidth == width d[i].getHeight == height d[i].getBitsPerPixel == 32 { displayMode = d[i]; break; } } Display.setDisplayModedisplayMode; Display.create; } private void setOrthoMode { glViewport0, 0, width, height; glMatrixModeGL_PROJECTION; glPushMatrix; glLoadIdentity; gluOrtho2D0, width, height, 0; glMatrixModeGL_MODELVIEW; glPushMatrix; glLoadIdentity; } private void unsetOrthoMode { glPopMatrix; glMatrixModeGL_PROJECTION; glPopMatrix; glMatrixModeGL_MODELVIEW; } public abstract void init; } GCApplication.java import java.awt.Color; import java.awt.Graphics;