package speiger.src.coreengine.rendering.gui.helper; import org.lwjgl.opengl.GL11; import speiger.src.coreengine.math.misc.Facing; import speiger.src.coreengine.rendering.gui.renderer.UIRenderer; import speiger.src.coreengine.rendering.gui.renderer.buffer.RenderBuffer; import speiger.src.coreengine.rendering.tesselation.Tesselator; import speiger.src.coreengine.rendering.tesselation.VertexType; public class UIShapes { public static void createCross(RenderBuffer buffer, float width, float height, float paddingA, float paddingB, int color) { createCross(buffer.start(GL11.GL_TRIANGLES, VertexType.UI), width, height, paddingA, paddingB, color); buffer.finishShape(0); } public static void createCross(Tesselator tes, float width, float height, float paddingA, float paddingB, int color) { tes.setOffset(-(width * 0.5F), -(height * 0.5F), 0F); tes.pos(paddingB, paddingA, 0F).tex(0F, 0F).color4f(color).endVertex(); tes.pos(paddingA, paddingB, 0F).tex(0F, 0F).color4f(color).endVertex(); tes.pos(width - paddingB, height - paddingA, 0F).tex(0F, 0F).color4f(color).endVertex(); tes.pos(width - paddingA, height - paddingB, 0F).tex(0F, 0F).color4f(color).endVertex(); tes.pos(paddingB, paddingA, 0F).tex(0F, 0F).color4f(color).endVertex(); tes.pos(width - paddingB, height - paddingA, 0F).tex(0F, 0F).color4f(color).endVertex(); tes.pos(width - paddingB, paddingA, 0F).tex(0F, 0F).color4f(color).endVertex(); tes.pos(width - paddingA, paddingB, 0F).tex(0F, 0F).color4f(color).endVertex(); tes.pos(paddingB, height - paddingA, 0F).tex(0F, 0F).color4f(color).endVertex(); tes.pos(paddingA, height - paddingB, 0F).tex(0F, 0F).color4f(color).endVertex(); tes.pos(width - paddingB, paddingA, 0F).tex(0F, 0F).color4f(color).endVertex(); tes.pos(paddingB, height - paddingA, 0F).tex(0F, 0F).color4f(color).endVertex(); tes.setOffset(0F, 0F, 0F); } public static void createCross(UIRenderer renderer, float width, float height, float paddingA, float paddingB, int color) { renderer.translate(-(width * 0.5F), -(height * 0.5F)); renderer.startCustomShape(GL11.GL_TRIANGLES, false); renderer.pos(paddingB, paddingA, 0F).tex(0F, 0F).color(color).endVertex(); renderer.pos(paddingA, paddingB, 0F).tex(0F, 0F).color(color).endVertex(); renderer.pos(width - paddingB, height - paddingA, 0F).tex(0F, 0F).color(color).endVertex(); renderer.pos(width - paddingA, height - paddingB, 0F).tex(0F, 0F).color(color).endVertex(); renderer.pos(paddingB, paddingA, 0F).tex(0F, 0F).color(color).endVertex(); renderer.pos(width - paddingB, height - paddingA, 0F).tex(0F, 0F).color(color).endVertex(); renderer.pos(width - paddingB, paddingA, 0F).tex(0F, 0F).color(color).endVertex(); renderer.pos(width - paddingA, paddingB, 0F).tex(0F, 0F).color(color).endVertex(); renderer.pos(paddingB, height - paddingA, 0F).tex(0F, 0F).color(color).endVertex(); renderer.pos(paddingA, height - paddingB, 0F).tex(0F, 0F).color(color).endVertex(); renderer.pos(width - paddingB, paddingA, 0F).tex(0F, 0F).color(color).endVertex(); renderer.pos(paddingB, height - paddingA, 0F).tex(0F, 0F).color(color).endVertex(); renderer.translate((width * 0.5F), (height * 0.5F)); } public static void createArrow(RenderBuffer buffer, float width, float height, int color, Facing dir) { createArrow(buffer.start(GL11.GL_TRIANGLES, VertexType.UI), width, height, color, dir); buffer.finishShape(0); } public static void createArrow(Tesselator tes, float width, float height, int color, Facing dir) { float halfWidth = width * 0.5F; float halfHeight = height * 0.5F; tes.setOffset(-halfWidth, -halfHeight, 0F); switch(dir) { case NORTH: tes.pos(0F, halfHeight, 0F).tex(0F, 0F).color4f(color).endVertex(); tes.pos(width, halfHeight, 0F).tex(0F, 0F).color4f(color).endVertex(); tes.pos(halfWidth, 0F, 0F).tex(0F, 0F).color4f(color).endVertex(); tes.pos(0F, halfHeight, 0F).tex(0F, 0F).color4f(color).endVertex(); tes.pos(0F, height, 0F).tex(0F, 0F).color4f(color).endVertex(); tes.pos(width, halfHeight, 0F).tex(0F, 0F).color4f(color).endVertex(); tes.pos(width, halfHeight, 0F).tex(0F, 0F).color4f(color).endVertex(); tes.pos(0F, height, 0F).tex(0F, 0F).color4f(color).endVertex(); tes.pos(width, height, 0F).tex(0F, 0F).color4f(color).endVertex(); break; case SOUTH: tes.pos(0F, 0F, 0F).tex(0F, 0F).color4f(color).endVertex(); tes.pos(0F, halfHeight, 0F).tex(0F, 0F).color4f(color).endVertex(); tes.pos(width, 0F, 0F).tex(0F, 0F).color4f(color).endVertex(); tes.pos(width, 0F, 0F).tex(0F, 0F).color4f(color).endVertex(); tes.pos(0F, halfHeight, 0F).tex(0F, 0F).color4f(color).endVertex(); tes.pos(width, halfHeight, 0F).tex(0F, 0F).color4f(color).endVertex(); tes.pos(0F, halfHeight, 0F).tex(0F, 0F).color4f(color).endVertex(); tes.pos(width, halfHeight, 0F).tex(0F, 0F).color4f(color).endVertex(); tes.pos(halfWidth, height, 0F).tex(0F, 0F).color4f(color).endVertex(); break; case EAST: tes.pos(0F, 0F, 0F).tex(0F, 0F).color4f(color).endVertex(); tes.pos(halfWidth, 0F, 0F).tex(0F, 0F).color4f(color).endVertex(); tes.pos(0F, height, 0F).tex(0F, 0F).color4f(color).endVertex(); tes.pos(0F, height, 0F).tex(0F, 0F).color4f(color).endVertex(); tes.pos(halfWidth, 0F, 0F).tex(0F, 0F).color4f(color).endVertex(); tes.pos(halfWidth, height, 0F).tex(0F, 0F).color4f(color).endVertex(); tes.pos(halfWidth, 0F, 0F).tex(0F, 0F).color4f(color).endVertex(); tes.pos(halfWidth, height, 0F).tex(0F, 0F).color4f(color).endVertex(); tes.pos(width, halfHeight, 0F).tex(0F, 0F).color4f(color).endVertex(); break; case WEST: tes.pos(halfWidth, 0F, 0F).tex(0F, 0F).color4f(color).endVertex(); tes.pos(width, 0F, 0F).tex(0F, 0F).color4f(color).endVertex(); tes.pos(halfWidth, height, 0F).tex(0F, 0F).color4f(color).endVertex(); tes.pos(halfWidth, height, 0F).tex(0F, 0F).color4f(color).endVertex(); tes.pos(width, 0F, 0F).tex(0F, 0F).color4f(color).endVertex(); tes.pos(width, height, 0F).tex(0F, 0F).color4f(color).endVertex(); tes.pos(halfWidth, 0F, 0F).tex(0F, 0F).color4f(color).endVertex(); tes.pos(halfWidth, height, 0F).tex(0F, 0F).color4f(color).endVertex(); tes.pos(0F, halfHeight, 0F).tex(0F, 0F).color4f(color).endVertex(); break; } tes.setOffset(0F, 0F, 0F); } public static void createArrow(UIRenderer renderer, float width, float height, int color, Facing dir) { float halfWidth = width * 0.5F; float halfHeight = height * 0.5F; renderer.translate(-halfWidth, -halfHeight, 0F); renderer.startCustomShape(GL11.GL_TRIANGLES, false); switch(dir) { case NORTH: renderer.pos(0F, halfHeight, 0F).tex(0F, 0F).color(color).endVertex(); renderer.pos(width, halfHeight, 0F).tex(0F, 0F).color(color).endVertex(); renderer.pos(halfWidth, 0F, 0F).tex(0F, 0F).color(color).endVertex(); renderer.pos(0F, halfHeight, 0F).tex(0F, 0F).color(color).endVertex(); renderer.pos(0F, height, 0F).tex(0F, 0F).color(color).endVertex(); renderer.pos(width, halfHeight, 0F).tex(0F, 0F).color(color).endVertex(); renderer.pos(width, halfHeight, 0F).tex(0F, 0F).color(color).endVertex(); renderer.pos(0F, height, 0F).tex(0F, 0F).color(color).endVertex(); renderer.pos(width, height, 0F).tex(0F, 0F).color(color).endVertex(); break; case SOUTH: renderer.pos(0F, 0F, 0F).tex(0F, 0F).color(color).endVertex(); renderer.pos(0F, halfHeight, 0F).tex(0F, 0F).color(color).endVertex(); renderer.pos(width, 0F, 0F).tex(0F, 0F).color(color).endVertex(); renderer.pos(width, 0F, 0F).tex(0F, 0F).color(color).endVertex(); renderer.pos(0F, halfHeight, 0F).tex(0F, 0F).color(color).endVertex(); renderer.pos(width, halfHeight, 0F).tex(0F, 0F).color(color).endVertex(); renderer.pos(0F, halfHeight, 0F).tex(0F, 0F).color(color).endVertex(); renderer.pos(width, halfHeight, 0F).tex(0F, 0F).color(color).endVertex(); renderer.pos(halfWidth, height, 0F).tex(0F, 0F).color(color).endVertex(); break; case EAST: renderer.pos(0F, 0F, 0F).tex(0F, 0F).color(color).endVertex(); renderer.pos(halfWidth, 0F, 0F).tex(0F, 0F).color(color).endVertex(); renderer.pos(0F, height, 0F).tex(0F, 0F).color(color).endVertex(); renderer.pos(0F, height, 0F).tex(0F, 0F).color(color).endVertex(); renderer.pos(halfWidth, 0F, 0F).tex(0F, 0F).color(color).endVertex(); renderer.pos(halfWidth, height, 0F).tex(0F, 0F).color(color).endVertex(); renderer.pos(halfWidth, 0F, 0F).tex(0F, 0F).color(color).endVertex(); renderer.pos(halfWidth, height, 0F).tex(0F, 0F).color(color).endVertex(); renderer.pos(width, halfHeight, 0F).tex(0F, 0F).color(color).endVertex(); break; case WEST: renderer.pos(halfWidth, 0F, 0F).tex(0F, 0F).color(color).endVertex(); renderer.pos(width, 0F, 0F).tex(0F, 0F).color(color).endVertex(); renderer.pos(halfWidth, height, 0F).tex(0F, 0F).color(color).endVertex(); renderer.pos(halfWidth, height, 0F).tex(0F, 0F).color(color).endVertex(); renderer.pos(width, 0F, 0F).tex(0F, 0F).color(color).endVertex(); renderer.pos(width, height, 0F).tex(0F, 0F).color(color).endVertex(); renderer.pos(halfWidth, 0F, 0F).tex(0F, 0F).color(color).endVertex(); renderer.pos(halfWidth, height, 0F).tex(0F, 0F).color(color).endVertex(); renderer.pos(0F, halfHeight, 0F).tex(0F, 0F).color(color).endVertex(); break; } renderer.translate(halfWidth, halfHeight, 0F); } }