Actually got some gui stuff rendering
This commit is contained in:
parent
b553923a3d
commit
b483234d9c
|
|
@ -1,5 +1,13 @@
|
||||||
package projectzombie.display;
|
package projectzombie.display;
|
||||||
|
|
||||||
|
import org.lwjgl.opengl.GL33;
|
||||||
|
|
||||||
|
import gl_engine.matrix.Matrix4;
|
||||||
|
import gl_engine.vec.Vec3d;
|
||||||
|
import projectzombie.Main;
|
||||||
|
import projectzombie.init.Models;
|
||||||
|
import projectzombie.util.gl.GlHelpers;
|
||||||
|
|
||||||
public class DisplayRenderUI
|
public class DisplayRenderUI
|
||||||
{
|
{
|
||||||
public static boolean showFPS = false;
|
public static boolean showFPS = false;
|
||||||
|
|
@ -8,7 +16,15 @@ public class DisplayRenderUI
|
||||||
|
|
||||||
public static void render()
|
public static void render()
|
||||||
{
|
{
|
||||||
|
Matrix4 matrix = Matrix4.identity();
|
||||||
|
Matrix4 projection = Matrix4.scale(new Vec3d(1/GlHelpers.getAspectRatio(), 1, 1));
|
||||||
|
|
||||||
|
GL33.glUniformMatrix4fv(Main.window.glsl_projection, true, projection.getArray());
|
||||||
|
GL33.glUniformMatrix4fv(Main.window.glsl_camera, true, matrix.getArray());
|
||||||
|
GL33.glUniformMatrix4fv(Main.window.glsl_model, true, matrix.getArray());
|
||||||
|
|
||||||
|
Models.UI_ITEM_SLOTS.bind();
|
||||||
|
Models.UI_ITEM_SLOTS.render();
|
||||||
|
|
||||||
// Render the loaded menu
|
// Render the loaded menu
|
||||||
//Main.menu.render();
|
//Main.menu.render();
|
||||||
|
|
|
||||||
|
|
@ -98,7 +98,7 @@ public class DisplayWindow implements IMainloopTask
|
||||||
//GLFW.glfwShowWindow(this.window);
|
//GLFW.glfwShowWindow(this.window);
|
||||||
|
|
||||||
GL33.glEnable(GL33.GL_DEPTH_TEST);
|
GL33.glEnable(GL33.GL_DEPTH_TEST);
|
||||||
GL33.glEnable(GL33.GL_BLEND);
|
//GL33.glEnable(GL33.GL_BLEND);
|
||||||
|
|
||||||
environmentRenderer = new GraphicsShader("/resources/shader/environmentRenderer");
|
environmentRenderer = new GraphicsShader("/resources/shader/environmentRenderer");
|
||||||
environmentRenderer.use();
|
environmentRenderer.use();
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,7 @@ public class Models
|
||||||
|
|
||||||
public static final Model UI_HEALTH_FG = new ModelGui(Resources.ATLAS.get("/gui/health_full.png"));
|
public static final Model UI_HEALTH_FG = new ModelGui(Resources.ATLAS.get("/gui/health_full.png"));
|
||||||
public static final Model UI_HEALTH_BG = new ModelGui(Resources.ATLAS.get("/gui/health_empty.png"));
|
public static final Model UI_HEALTH_BG = new ModelGui(Resources.ATLAS.get("/gui/health_empty.png"));
|
||||||
public static final Model UI_ITEM_SLOTS = new ModelGui(Resources.ATLAS.get("/gui/hotbar.png"));
|
public static final Model UI_ITEM_SLOTS = new ModelGui(Resources.ATLAS.get("/gui/hotbar.png"), new Vec2d(6, 1));
|
||||||
public static final Model UI_ACTIVE_SLOT = new ModelGui(Resources.ATLAS.get("/gui/hotbar_selected.png"));
|
public static final Model UI_ACTIVE_SLOT = new ModelGui(Resources.ATLAS.get("/gui/hotbar_selected.png"));
|
||||||
|
|
||||||
public static final Model UI_DEFENCE_LEVEL = new ModelGui(Resources.ATLAS.get("/gui/shield.png"));
|
public static final Model UI_DEFENCE_LEVEL = new ModelGui(Resources.ATLAS.get("/gui/shield.png"));
|
||||||
|
|
|
||||||
|
|
@ -28,17 +28,11 @@ public abstract class Model
|
||||||
public abstract double getHeight();
|
public abstract double getHeight();
|
||||||
public abstract int getSize();
|
public abstract int getSize();
|
||||||
|
|
||||||
private TextureRef3D tex;
|
|
||||||
|
|
||||||
private void generate()
|
private void generate()
|
||||||
{
|
{
|
||||||
float[] verticies = this.getVerticies();
|
float[] verticies = this.getVerticies();
|
||||||
TextureRef3D[] refs = this.getTextures();
|
TextureRef3D[] refs = this.getTextures();
|
||||||
|
|
||||||
if(refs.length != 0) {
|
|
||||||
tex = refs[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
if(verticies.length % SIZE != 0 || refs.length * 3 != verticies.length / SIZE) {
|
if(verticies.length % SIZE != 0 || refs.length * 3 != verticies.length / SIZE) {
|
||||||
System.err.println("Invalid model");
|
System.err.println("Invalid model");
|
||||||
System.exit(1);
|
System.exit(1);
|
||||||
|
|
@ -91,19 +85,6 @@ public abstract class Model
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void texCoord(double x, double y)
|
|
||||||
{
|
|
||||||
if(!loaded) {
|
|
||||||
generate();
|
|
||||||
}
|
|
||||||
|
|
||||||
double k = 0.001;
|
|
||||||
x = MathHelpers.map(x, 0, 1, tex.sx + k, tex.ex - k);
|
|
||||||
y = MathHelpers.map(y, 0, 1, tex.sy + k, tex.ey - k);
|
|
||||||
|
|
||||||
GL33.glTexCoord2d(x, y);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void render() {
|
public void render() {
|
||||||
GL33.glDrawArrays(GL33.GL_TRIANGLES, 0, getSize());
|
GL33.glDrawArrays(GL33.GL_TRIANGLES, 0, getSize());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -49,13 +49,13 @@ public class ModelGui extends Model
|
||||||
height = y;
|
height = y;
|
||||||
|
|
||||||
return new float[] {
|
return new float[] {
|
||||||
0, 0, 0, 0, 0, 0, ref.sy, ref.ey, 0, 0, 0, asi, asp, 0x11,
|
0, 0, 0, 0, 0, 0, ref.sy, ref.ey, 0, 0, 0, asi, asp, 0x10,
|
||||||
x, 0, 0, 1, 0, 0, ref.sy, ref.ey, 0, 0, 0, asi, asp, 0x11,
|
x, 0, 0, 1, 0, 0, ref.sy, ref.ey, 0, 0, 0, asi, asp, 0x10,
|
||||||
x, y, 0, 1, 1, 0, ref.sy, ref.ey, 0, 0, 0, asi, asp, 0x11,
|
x, y, 0, 1, 1, 0, ref.sy, ref.ey, 0, 0, 0, asi, asp, 0x10,
|
||||||
|
|
||||||
x, y, 0, 1, 1, 0, ref.sy, ref.ey, 0, 0, 0, asi, asp, 0x11,
|
x, y, 0, 1, 1, 0, ref.sy, ref.ey, 0, 0, 0, asi, asp, 0x10,
|
||||||
0, y, 0, 0, 1, 0, ref.sy, ref.ey, 0, 0, 0, asi, asp, 0x11,
|
0, y, 0, 0, 1, 0, ref.sy, ref.ey, 0, 0, 0, asi, asp, 0x10,
|
||||||
0, 0, 0, 0, 0, 0, ref.sy, ref.ey, 0, 0, 0, asi, asp, 0x11,
|
0, 0, 0, 0, 0, 0, ref.sy, ref.ey, 0, 0, 0, asi, asp, 0x10,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue