diff --git a/src/main/java/ru/windcorp/optica/client/graphics/Layer.java b/src/main/java/ru/windcorp/optica/client/graphics/Layer.java index bb04456..4b0a384 100644 --- a/src/main/java/ru/windcorp/optica/client/graphics/Layer.java +++ b/src/main/java/ru/windcorp/optica/client/graphics/Layer.java @@ -46,11 +46,11 @@ public abstract class Layer { protected abstract void doRender(); - protected float getWidth() { + protected int getWidth() { return GraphicsInterface.getFramebufferWidth(); } - protected float getHeight() { + protected int getHeight() { return GraphicsInterface.getFramebufferHeight(); } diff --git a/src/main/java/ru/windcorp/optica/client/graphics/flat/FlatRenderHelper.java b/src/main/java/ru/windcorp/optica/client/graphics/flat/FlatRenderHelper.java index f30cc4a..7d13157 100644 --- a/src/main/java/ru/windcorp/optica/client/graphics/flat/FlatRenderHelper.java +++ b/src/main/java/ru/windcorp/optica/client/graphics/flat/FlatRenderHelper.java @@ -5,6 +5,8 @@ import ru.windcorp.optica.client.graphics.model.ShapeRenderHelper; public class FlatRenderHelper extends ShapeRenderHelper { + private static final float MAX_DEPTH = 1 << 16; + private final Mask mask = new Mask(); { @@ -58,8 +60,9 @@ public class FlatRenderHelper extends ShapeRenderHelper { private void setupScreenTransform() { float width = GraphicsInterface.getFramebufferWidth(); float height = GraphicsInterface.getFramebufferHeight(); - - getTransform().translate(-1, +1, 0).scale(2 / width, -2 / height, 1); + + getTransform().translate(-1, +1, 0) + .scale(2 / width, -2 / height, 1 / MAX_DEPTH); } } diff --git a/src/main/java/ru/windcorp/optica/client/graphics/flat/LayerTestUI.java b/src/main/java/ru/windcorp/optica/client/graphics/flat/LayerTestUI.java index 5108330..fb7386b 100644 --- a/src/main/java/ru/windcorp/optica/client/graphics/flat/LayerTestUI.java +++ b/src/main/java/ru/windcorp/optica/client/graphics/flat/LayerTestUI.java @@ -25,16 +25,16 @@ public class LayerTestUI extends AssembledFlatLayer { @Override protected void assemble(RenderTarget target) { - final float width = 512 + 256; - final float height = 64; - final float border = 5; + final int width = 512 + 256; + final int height = 64; + final int border = 5; final int boxColor = flag ? 0xEE8888 : 0xEEEE88; final int borderColor = flag ? 0xAA4444 : 0xAAAA44; final int boxShadowColor = flag ? 0x440000 : 0x444400; - float x = (getWidth() - width) / 2; - float y = getHeight() - height; + int x = (getWidth() - width) / 2; + int y = getHeight() - height; y -= 2*border; @@ -43,13 +43,58 @@ public class LayerTestUI extends AssembledFlatLayer { target.fill(x, y, width, height, borderColor); target.fill(x + border, y + border, width - 2*border, height - 2*border, boxColor); - final float texShadow = 2; - final float texSize = height - 4*border; + final int texShadow = 2; + final int texSize = height - 4*border; target.fill(x + 2*border + texShadow, y + 2*border + texShadow, texSize, texSize, Colors.BLACK); target.drawTexture(x + 2*border, y + 2*border, texSize, texSize, qtex("compass")); + + drawCross(target); } + private void drawCross(RenderTarget target) { + int cx = getWidth() / 2; + int cy = getHeight() / 2; + + final int length = 15; + final int thickness = 5; + final int borderSize = 1; + final int borderColor = Colors.BLACK; + final int fillColor = Colors.WHITE; + + target.fill( + cx - length - thickness / 2, + cy - thickness / 2, + 2*length + thickness, + thickness, + borderColor + ); + + target.fill( + cx - thickness / 2, + cy - length - thickness / 2, + thickness, + 2*length + thickness, + borderColor + ); + + target.fill( + cx - length - thickness / 2 + borderSize, + cy - thickness / 2 + borderSize, + 2*length + thickness - 2*borderSize, + thickness - 2*borderSize, + fillColor + ); + + target.fill( + cx - thickness / 2 + borderSize, + cy - length - thickness / 2 + borderSize, + thickness - 2*borderSize, + 2*length + thickness - 2*borderSize, + fillColor + ); + } + @Subscribe public void onKeyEvent(KeyEvent event) { if (event.isRepeat() || event.getKey() != GLFW.GLFW_KEY_LEFT_CONTROL) { diff --git a/src/main/java/ru/windcorp/optica/client/graphics/flat/RenderTarget.java b/src/main/java/ru/windcorp/optica/client/graphics/flat/RenderTarget.java index 4a0ee3b..9869bfc 100644 --- a/src/main/java/ru/windcorp/optica/client/graphics/flat/RenderTarget.java +++ b/src/main/java/ru/windcorp/optica/client/graphics/flat/RenderTarget.java @@ -16,8 +16,6 @@ import ru.windcorp.optica.client.graphics.texture.Texture; public class RenderTarget { - private static final int MAX_DEPTH = 1 << 16; - private final List assembled = new ArrayList<>(); private final Deque maskStack = new LinkedList<>(); @@ -126,30 +124,30 @@ public class RenderTarget { } public void drawTexture( - float x, float y, float width, float height, + int x, int y, int width, int height, int color, Texture texture ) { - float depth = this.depth-- / (float) MAX_DEPTH; + float depth = this.depth--; addFaceToCurrentClip(Faces.createRectangle( FlatRenderProgram.getDefault(), texture, createVectorFromRGBInt(color), new Vec3(x, y + height, depth), // Flip - new Vec3(width, 0, depth), - new Vec3(0, -height, depth) + new Vec3(width, 0, 0), + new Vec3(0, -height, 0) )); } public void drawTexture( - float x, float y, float width, float height, + int x, int y, int width, int height, Texture texture ) { drawTexture(x, y, width, height, Colors.WHITE, texture); } public void fill( - float x, float y, float width, float height, + int x, int y, int width, int height, int color ) { drawTexture(x, y, width, height, color, null);