package projectzombie.display; import static org.lwjgl.opengl.GL11.GL_COLOR_BUFFER_BIT; import static org.lwjgl.opengl.GL11.GL_DEPTH_BUFFER_BIT; import static org.lwjgl.opengl.GL11.glClear; import static org.lwjgl.opengl.GL11.glViewport; import org.lwjgl.opengl.GL33; import gl_engine.matrix.Matrix4; import projectzombie.Main; import projectzombie.entity.player.EntityPlayer; import projectzombie.model.Model; import projectzombie.world.chunk.ChunkEventHandler; public class DisplayRender { public static void render(int w, int h) { // Setup GL and clear the colour glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glViewport(0, 0, w, h); GL33.glEnable(GL33.GL_DEPTH_TEST); GL33.glUniform4f(Main.window.glsl_color, 1, 1, 1, 1); GL33.glUniform2f(Main.window.glsl_tex_cut, 0, 0); if(Main.menu.doGameRender) { if(ChunkEventHandler.loaded) { EntityPlayer player = Main.player; Camera camera = new Camera(); Camera.camera = camera; // Create the projection matrix Matrix4 projection = Matrix4.projection((double)w / (double)h, 45, 0.1, 1000); Matrix4 rotated = Matrix4.rotate(-camera.angle, 0, 1, 0); // Process all the light sources //DynamicLighting.update(); Main.window.environmentRenderer.use(); GL33.glUniformMatrix4fv(Main.window.glsl_camera, true, camera.getMatrix().getArray()); GL33.glUniformMatrix4fv(Main.window.glsl_projection, true, projection.getArray()); GL33.glUniformMatrix4fv(Main.window.glsl_rotated, true, rotated.getArray()); GL33.glUniform1i(Main.window.glsl_time, (int)((System.currentTimeMillis() / 10) % 1000)); // Render the world and the player Main.world.render(camera); player.chunk = Main.world.getLayer().getChunk(player.pos); if(!Main.player.dead) { Model model = player.getModel(); model.setModel(Matrix4.translate(player.pos.x - 0.5, player.getHeight(), player.pos.y - 0.5)); model.render(); } } } // Render the user interface DisplayRenderUI.render(); } }