diff options
Diffstat (limited to 'src/ru/olamedia/game/GameManager.java')
-rw-r--r-- | src/ru/olamedia/game/GameManager.java | 51 |
1 files changed, 43 insertions, 8 deletions
diff --git a/src/ru/olamedia/game/GameManager.java b/src/ru/olamedia/game/GameManager.java index f8c05d9..d9efdfb 100644 --- a/src/ru/olamedia/game/GameManager.java +++ b/src/ru/olamedia/game/GameManager.java @@ -2,8 +2,6 @@ package ru.olamedia.game; import java.util.Set; -import javax.media.nativewindow.WindowClosingProtocol.WindowClosingMode; -import javax.media.opengl.DebugGL2ES2; import javax.media.opengl.GL; import javax.media.opengl.GL2ES2; import javax.media.opengl.GLAutoDrawable; @@ -13,9 +11,10 @@ import ru.olamedia.olacraft.game.Game; import ru.olamedia.olacraft.network.discovery.DiscoveryThread; import ru.olamedia.olacraft.render.jogl.DefaultRenderer; import ru.olamedia.olacraft.render.jogl.IRenderer; +import ru.olamedia.olacraft.world.chunk.ChunkMeshBulder; +import ru.olamedia.olacraft.world.location.BlockLocation; import ru.olamedia.tasks.TaskManager; - import com.jogamp.opengl.JoglVersion; public class GameManager implements GLEventListener { @@ -28,6 +27,37 @@ public class GameManager implements GLEventListener { public GameManager() { instance = this; + tests(); + } + + private void tests() { + BlockLocation b; + b = new BlockLocation(0, 0, 0); + assert b.getChunkLocation().x == 0; + assert b.getChunkLocation().getBlockLocation().x == 0; + b = new BlockLocation(14, 0, 0); + assert b.getChunkLocation().x == 0; + assert b.getChunkLocation().getBlockLocation().x == 0; + b = new BlockLocation(15, 0, 0); + assert b.getChunkLocation().x == 0; + assert b.getChunkLocation().getBlockLocation().x == 0; + b = new BlockLocation(16, 0, 0); + assert b.getChunkLocation().x == 1; + assert b.getChunkLocation().getBlockLocation().x == 0; + b = new BlockLocation(-1, 0, 0); + assert b.getChunkLocation().x == -1; + assert b.getChunkLocation().getBlockLocation().x == -1; + b = new BlockLocation(-14, 0, 0); + assert b.getChunkLocation().x == -1; + b = new BlockLocation(-15, 0, 0); + assert b.getChunkLocation().x == -1; + assert b.getChunkLocation().getBlockLocation().x == -1; + b = new BlockLocation(-16, 0, 0); + assert b.getChunkLocation().x == -1; + assert b.getChunkLocation().getBlockLocation().x == -1; + b = new BlockLocation(-17, 0, 0); + assert b.getChunkLocation().x == -2; + assert b.getChunkLocation().getBlockLocation().x == -17; } private void createServerGame() { @@ -107,12 +137,18 @@ public class GameManager implements GLEventListener { } } frame.dispose(); + if (ChunkMeshBulder.instance.isAlive()) { + ChunkMeshBulder.instance.interrupt(); + } // Get all threads Set<Thread> threadSet = Thread.getAllStackTraces().keySet(); for (Thread t : threadSet) { if (t instanceof DiscoveryThread) { t.interrupt(); } + if (t instanceof ChunkMeshBulder) { + t.interrupt(); + } } } @@ -120,10 +156,9 @@ public class GameManager implements GLEventListener { public void init(GLAutoDrawable drawable) { // GLContext.getContext().getGL() GL2ES2 gl = drawable.getGL().getGL2ES2(); - //drawable.setGL(new DebugGL2ES2(gl)); + // drawable.setGL(new DebugGL2ES2(gl)); System.err.println(JoglVersion.getGLInfo(drawable.getGL(), null)); - System.err.println(Thread.currentThread() + " Chosen GLCapabilities: " - + drawable.getChosenGLCapabilities()); + System.err.println(Thread.currentThread() + " Chosen GLCapabilities: " + drawable.getChosenGLCapabilities()); System.err.println(Thread.currentThread() + " INIT GL IS: " + gl.getClass().getName()); System.err.println(Thread.currentThread() + " GL_VENDOR: " + gl.glGetString(GL.GL_VENDOR)); System.err.println(Thread.currentThread() + " GL_RENDERER: " + gl.glGetString(GL.GL_RENDERER)); @@ -144,7 +179,7 @@ public class GameManager implements GLEventListener { public void display(GLAutoDrawable drawable) { GL2ES2 gl = drawable.getGL().getGL2ES2(); gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); - //gl.glClearColor(0.2f, 0.2f, 0.2f, 1); + // gl.glClearColor(0.2f, 0.2f, 0.2f, 1); renderer.render(drawable); } @@ -153,7 +188,7 @@ public class GameManager implements GLEventListener { GL gl = drawable.getGL().getGL2ES2(); gl.glViewport(0, 0, width, height); } - + public void showMainMenu() { menu.setVisible(true); } |