package projectzombie.display; import org.lwjgl.opengl.GL33; import gl_engine.MathHelpers; import gl_engine.matrix.Matrix4; import gl_engine.vec.Vec3d; import projectzombie.Main; import projectzombie.init.Models; import projectzombie.inventory.Inventory; import projectzombie.model.Model; import projectzombie.model.ModelGui; import projectzombie.text.Text; import projectzombie.util.gl.GlHelpers; import projectzombie.util.math.ItemStack; public class DisplayRenderUI { public static boolean showFPS = false; public static boolean showPos = false; public static int guiScale = 2; public static Matrix4 camera, projection; public static void renderGameGui() { { Matrix4 matrix = Matrix4.translate(-Models.UI_ITEM_SLOTS.getWidth() / 2, -9.5, 0); Inventory inventory = Main.player.getInventory(); int slot = Main.player.inventory_hand; double offset = Models.UI_ITEM_SLOTS.getWidth() / 10; Matrix4 matrix_slot = Matrix4.multiply(matrix, Matrix4.translate(offset * slot, 0, 0)); Models.UI_ITEM_SLOTS.setModel(matrix); Models.UI_ITEM_SLOTS.render(); Models.UI_ACTIVE_SLOT.setModel(matrix_slot); Models.UI_ACTIVE_SLOT.render(); for(int i = 0; i < inventory.getSlotCount(); i++) { ItemStack stack = inventory.getItem(i); if(stack.isEmpty()) { continue; } Model model_item = stack.item.getModel(stack.meta).getGuiModel(); double item_offset = (Models.UI_ACTIVE_SLOT.getHeight() - model_item.getHeight()) / 2; Matrix4 matrix_item = Matrix4.multiply(matrix, Matrix4.translate(i * offset + item_offset, item_offset, 0)); model_item.setModel(matrix_item); model_item.render(); if(stack.count > 1) { matrix_item = Matrix4.multiply(matrix, Matrix4.translate(i * offset + 0.25, 0.28125, 0)); matrix_item = Matrix4.multiply(Matrix4.scale(new Vec3d(0.4, 0.4, 0.4)), matrix_item); Text.render("" + stack.count, matrix_item); } } } { ModelGui model_health_f = Models.UI_HEALTH_FG; ModelGui model_health_b = Models.UI_HEALTH_BG; Matrix4 matrix = Matrix4.translate(-model_health_f.getWidth() / 2, -8, 0); model_health_b.setModel(matrix); model_health_b.render(); GL33.glUniform2f(Main.window.glsl_tex_cut, 1, (float)MathHelpers.map( Main.player.getHealth(), 0, Main.player.maxHealth(), 0, model_health_f.getWidth())); model_health_f.setModel(matrix); model_health_f.render(); GL33.glUniform2f(Main.window.glsl_tex_cut, 0, 0); } } public static void render() { camera = Matrix4.identity(); projection = Matrix4.scale(new Vec3d(0.1/GlHelpers.getAspectRatio(), 0.1, 1)); GL33.glUniform3f(Main.window.glsl_day_low, 1, 1, 1); GL33.glUniform3f(Main.window.glsl_day_high, 1, 1, 1); GL33.glUniformMatrix4fv(Main.window.glsl_projection, true, projection.getArray()); GL33.glDisable(GL33.GL_DEPTH_TEST); if(Main.menu.doGameRender && Main.menu.showIngameGUI) { renderGameGui(); } // Render the loaded menu Main.menu.render(); } }