Redid lighting and made it asyncronous
This commit is contained in:
parent
d24f9296a5
commit
3c9b7a23e9
|
|
@ -15,16 +15,19 @@ public class DisplayRenderUI
|
|||
{
|
||||
public static boolean showFPS = false;
|
||||
public static boolean showPos = false;
|
||||
public static int guiScale = 2;
|
||||
|
||||
public static void render()
|
||||
{
|
||||
double s = GlHelpers.getScale() / 10.0;
|
||||
|
||||
// Get some text settings
|
||||
Vec2d text_size = new Vec2d(0.5, 0.5);
|
||||
|
||||
// Render the fps
|
||||
if(showFPS) {
|
||||
GlHelpers.pushMatrix();
|
||||
GlHelpers.translate2(-9.5, 9.5);
|
||||
GlHelpers.translate2(-10*s + 0.5, 10*s - 0.5);
|
||||
GlHelpers.color3(1, 1, 0);
|
||||
Text.render("FPS: " + DisplayStatsEventHandler.fps, text_size);
|
||||
GlHelpers.popMatrix();
|
||||
|
|
@ -47,7 +50,7 @@ public class DisplayRenderUI
|
|||
// Render the position
|
||||
if(showPos) {
|
||||
GlHelpers.pushMatrix();
|
||||
GlHelpers.translate2(-9.5, 9);
|
||||
GlHelpers.translate2(-10*s + 0.5, 10*s - 1);
|
||||
GlHelpers.color3(1, 1, 0);
|
||||
Text.render("x: " + (int) player.pos.x + ", y: " + (int) player.pos.y, text_size);
|
||||
GlHelpers.color3(1, 1, 1);
|
||||
|
|
@ -61,7 +64,7 @@ public class DisplayRenderUI
|
|||
TextureReference health_bg = Textures.UI_HEALTH_BG;
|
||||
|
||||
GlHelpers.pushMatrix();
|
||||
GlHelpers.translate2(-2, -9);
|
||||
GlHelpers.translate2(-2*s, -9*s);
|
||||
GlHelpers.begin();
|
||||
|
||||
health_bg.texCoord(0, 1); GlHelpers.vertex2(-8, 1);
|
||||
|
|
@ -83,7 +86,7 @@ public class DisplayRenderUI
|
|||
TextureReference gunlevel_tex = Textures.UI_GUN_LEVEL;
|
||||
TextureReference deflevel_tex = Textures.UI_DEFENCE_LEVEL;
|
||||
|
||||
GlHelpers.translate2(-9.5, -9);
|
||||
GlHelpers.translate2(-9.5*s, -9*s);
|
||||
GlHelpers.begin();
|
||||
ammo_tex.texCoord(0, 1); GlHelpers.vertex2(0, 0);
|
||||
ammo_tex.texCoord(0, 0); GlHelpers.vertex2(0, 2);
|
||||
|
|
@ -109,7 +112,7 @@ public class DisplayRenderUI
|
|||
|
||||
GlHelpers.popMatrix();
|
||||
GlHelpers.pushMatrix();
|
||||
GlHelpers.translate2(-8.5, -9.25);
|
||||
GlHelpers.translate2(-8.5*s, -9.25*s);
|
||||
Text.render(Integer.toString(player.ammo), text_size);
|
||||
GlHelpers.translate2(0, 3);
|
||||
Text.render(Integer.toString(player.gun_level), text_size);
|
||||
|
|
@ -121,7 +124,7 @@ public class DisplayRenderUI
|
|||
TextureReference slots_tex = Textures.UI_ITEM_SLOTS;
|
||||
|
||||
GlHelpers.pushMatrix();
|
||||
GlHelpers.translate2(3, -9.5);
|
||||
GlHelpers.translate2(3*s, -9.5*s);
|
||||
|
||||
GlHelpers.begin();
|
||||
slots_tex.texCoord(0, 1); GlHelpers.vertex2(12, 2);
|
||||
|
|
@ -147,7 +150,7 @@ public class DisplayRenderUI
|
|||
Inventory player_inv = player.getInventory();
|
||||
|
||||
GlHelpers.pushMatrix();
|
||||
GlHelpers.translate2(3.12, -9.5);
|
||||
GlHelpers.translate2(3.12*s, -9.5*s);
|
||||
|
||||
// Render the players inventory
|
||||
for(int i=0;i<6;i++)
|
||||
|
|
@ -172,7 +175,8 @@ public class DisplayRenderUI
|
|||
if(!item_active.isEmpty())
|
||||
{
|
||||
GlHelpers.pushMatrix();
|
||||
GlHelpers.translate2(3.2, -7.25);
|
||||
GlHelpers.translate2(3.12*s, -9.5*s);
|
||||
GlHelpers.translate2(-0.08, 2.24);
|
||||
Text.render(item_active.item.getName(item_active.meta), text_size);
|
||||
GlHelpers.popMatrix();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,8 +9,10 @@ import projectzombie.util.math.vec.Vec2d;
|
|||
public class CursorPosCallback implements GLFWCursorPosCallbackI
|
||||
{
|
||||
@Override
|
||||
public void invoke(long window, double x, double y) {
|
||||
public void invoke(long window, double x, double y)
|
||||
{
|
||||
Main.menu.input.mousePos(new Vec2d(x, y));
|
||||
|
||||
Main.window.setMouseVisibility(!Main.menu.keepMouse);
|
||||
InputMode.Controller = false;
|
||||
|
||||
|
|
@ -20,8 +22,10 @@ public class CursorPosCallback implements GLFWCursorPosCallbackI
|
|||
|
||||
int wx = Main.window.getWidth();
|
||||
int wy = Main.window.getHeight();
|
||||
x = x / wx - 0.5;
|
||||
y = y / wy - 0.5;
|
||||
|
||||
x = (x / wx - 0.5);
|
||||
y = (y / wy - 0.5);
|
||||
|
||||
Main.menu.input.camera(true, x * 60);
|
||||
GLFW.glfwSetCursorPos(window, wx / 2, wy / 2);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,5 @@
|
|||
package projectzombie.mainloop;
|
||||
|
||||
public interface MainloopEnd {
|
||||
public void end();
|
||||
}
|
||||
|
|
@ -52,6 +52,14 @@ public class MenuSettings extends Menu
|
|||
button.setText("Render Distance: "+Chunk.RENDER_DISTANCE);
|
||||
}));
|
||||
|
||||
group.add(new ButtonSetting("GUI Scale: " + DisplayRenderUI.guiScale, button -> {
|
||||
DisplayRenderUI.guiScale += 1;
|
||||
if(DisplayRenderUI.guiScale > 4) {
|
||||
DisplayRenderUI.guiScale = 1;
|
||||
}
|
||||
button.setText("GUI Scale: " + DisplayRenderUI.guiScale);
|
||||
}));
|
||||
|
||||
/*group.add(new ButtonSetting("Dynamic Lighting: " + (LightingManager.lightingMode == 0 ? "Fast" : "Fancy"),
|
||||
button ->
|
||||
{
|
||||
|
|
|
|||
|
|
@ -102,6 +102,9 @@ public class Button implements GUIComponent, GUISelectable
|
|||
double mx = pos.x / Main.window.getWidth() * 20 - 10;
|
||||
double my = pos.y / Main.window.getHeight() * 20 - 10;
|
||||
|
||||
mx = mx * GlHelpers.getScale() / 10;
|
||||
my = my * GlHelpers.getScale() / 10;
|
||||
|
||||
double m = 3;
|
||||
double w = textSize.x * m * 8 / GlHelpers.getAspectRatio();
|
||||
double h = textSize.x * m / 2;
|
||||
|
|
|
|||
|
|
@ -19,13 +19,14 @@ public class Overlay implements GUIComponent
|
|||
|
||||
@Override
|
||||
public void render(Vec2d mousePos) {
|
||||
int s = GlHelpers.getScale();
|
||||
GlHelpers.disableTexture2d();
|
||||
GlHelpers.color4(color.x, color.y, color.z, color.m);
|
||||
GlHelpers.begin();
|
||||
GlHelpers.vertex3(-10, -10, 0);
|
||||
GlHelpers.vertex3(-10, 10, 0);
|
||||
GlHelpers.vertex3(10, 10, 0);
|
||||
GlHelpers.vertex3(10, -10, 0);
|
||||
GlHelpers.vertex3(-s, -s, 0);
|
||||
GlHelpers.vertex3(-s, s, 0);
|
||||
GlHelpers.vertex3(s, s, 0);
|
||||
GlHelpers.vertex3(s, -s, 0);
|
||||
GlHelpers.end();
|
||||
GlHelpers.color4(1, 1, 1, 1);
|
||||
GlHelpers.enableTexture2d();
|
||||
|
|
|
|||
|
|
@ -35,6 +35,12 @@ public class Settings implements IBdfClassManager
|
|||
} else {
|
||||
DisplayRenderUI.showPos = false;
|
||||
}
|
||||
|
||||
if(nl.get("gui_scale").getType() == BdfTypes.INTEGER) {
|
||||
DisplayRenderUI.guiScale = nl.get("gui_scale").getInteger();
|
||||
} else {
|
||||
DisplayRenderUI.guiScale = 2;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -43,6 +49,7 @@ public class Settings implements IBdfClassManager
|
|||
nl.set("render_distance", BdfObject.withInteger(Chunk.RENDER_DISTANCE));
|
||||
nl.set("show_fps", BdfObject.withBoolean(DisplayRenderUI.showFPS));
|
||||
nl.set("show_pos", BdfObject.withBoolean(DisplayRenderUI.showPos));
|
||||
nl.set("gui_scale", BdfObject.withInteger(DisplayRenderUI.guiScale));
|
||||
}
|
||||
|
||||
public static void init() {
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ public class TileLadder extends TileVertical
|
|||
this.tileHitbox = 0.3;
|
||||
this.unbreakable = true;
|
||||
this.emitsLight = true;
|
||||
this.passNaturalLight = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ public class TileRock extends TileVertical
|
|||
|
||||
@Override
|
||||
public double getLightDissipation(TileState state) {
|
||||
return 1/2.0;
|
||||
return 1/8.0;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ public class TileTree extends TileVertical
|
|||
|
||||
@Override
|
||||
public double getLightDissipation(TileState state) {
|
||||
return 1/2.0;
|
||||
return 1/8.0;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ import static org.lwjgl.opengl.GL11.glVertex2d;
|
|||
import static org.lwjgl.opengl.GL11.glVertex3d;
|
||||
|
||||
import projectzombie.Main;
|
||||
import projectzombie.display.DisplayRenderUI;
|
||||
|
||||
public class GlHelpers
|
||||
{
|
||||
|
|
@ -47,13 +48,23 @@ public class GlHelpers
|
|||
glEnd();
|
||||
}
|
||||
|
||||
public static int getScale() {
|
||||
if(DisplayRenderUI.guiScale == 1) return 6;
|
||||
if(DisplayRenderUI.guiScale == 2) return 10;
|
||||
if(DisplayRenderUI.guiScale == 3) return 14;
|
||||
if(DisplayRenderUI.guiScale == 4) return 18;
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static void vertex3(double x, double y, double z) {
|
||||
glVertex3d(x/10, y/10, z/10);
|
||||
int s = getScale();
|
||||
glVertex3d(x/s, y/s, z/s);
|
||||
}
|
||||
|
||||
public static void vertex2(double x, double y) {
|
||||
double aspect_ratio = getAspectRatio();
|
||||
glVertex2d(x/10/aspect_ratio, y/10);
|
||||
int s = getScale();
|
||||
glVertex2d(x/s/aspect_ratio, y/s);
|
||||
}
|
||||
|
||||
public static void color3(double r, double g, double b) {
|
||||
|
|
@ -69,11 +80,13 @@ public class GlHelpers
|
|||
}
|
||||
|
||||
public static void translate3(double x, double y, double z) {
|
||||
glTranslated(x/10, y/10, z/10);
|
||||
int s = getScale();
|
||||
glTranslated(x/s, y/s, z/s);
|
||||
}
|
||||
|
||||
public static void translate2(double x, double y) {
|
||||
glTranslated(x/10, y/10, 0);
|
||||
int s = getScale();
|
||||
glTranslated(x/s, y/s, 0);
|
||||
}
|
||||
|
||||
public static void disableCullFace() {
|
||||
|
|
|
|||
|
|
@ -10,4 +10,8 @@ public class Range2i
|
|||
this.mx = mx;
|
||||
this.my = my;
|
||||
}
|
||||
|
||||
public int maxValue() {
|
||||
return mx * my;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,4 +12,8 @@ public class Range3i
|
|||
this.my = my;
|
||||
this.mz = mz;
|
||||
}
|
||||
|
||||
public int maxValue() {
|
||||
return mx * my * mz;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,4 +14,8 @@ public class Range4i
|
|||
this.mz = mz;
|
||||
this.mm = mm;
|
||||
}
|
||||
|
||||
public int maxValue() {
|
||||
return mx * my * mz * mm;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue