use of org.joml.Vector4f in project chunkstories-api by Hugobros3.
the class LargeButton method render.
@Override
public void render(RenderingInterface renderer) {
String localizedText = layer.getGameWindow().getClient().getContent().localization().localize(text);
Texture2D buttonTexture = renderer.textures().getTexture("./textures/gui/mainMenu.png");
if (isFocused() || isMouseOver())
buttonTexture = renderer.textures().getTexture("./textures/gui/mainMenuOver.png");
buttonTexture.setLinearFiltering(false);
renderer.getGuiRenderer().drawCorneredBoxTiled(xPosition, yPosition, getWidth(), getHeight(), 4 * scale(), buttonTexture, 32, scale());
Font font = layer.getGameWindow().getRenderingInterface().getFontRenderer().getFont("LiberationSansNarrow-Bold__aa", 16f * scale());
float a = 1f / scale();
float yPositionText = yPosition + 2.5f * scale();
float centering = getWidth() / 2 - font.getWidth(localizedText) * a * scale() / 2;
renderer.getFontRenderer().drawString(font, xPosition + centering + scale(), yPositionText - scale(), localizedText, a * scale(), new Vector4f(161 / 255f, 161 / 255f, 161 / 255f, 1));
renderer.getFontRenderer().drawString(font, xPosition + centering, yPositionText, localizedText, a * scale(), new Vector4f(38 / 255f, 38 / 255f, 38 / 255f, 1));
}
use of org.joml.Vector4f in project chunkstories by Hugobros3.
the class FrametimeRenderer method draw.
public static void draw(OpenGLRenderingContext renderingContext) {
lel++;
lel %= 1024;
long elapsedTime = (System.nanoTime() - lastTime);
lastTime = System.nanoTime();
dataBB.putFloat(lel * 4, elapsedTime / 1000000f);
renderingContext.setDepthTestMode(DepthTestMode.DISABLED);
renderingContext.setBlendMode(BlendMode.MIX);
renderingContext.setCullingMode(CullingMode.DISABLED);
Shader overlayProgram = renderingContext.useShader("fps_graph");
overlayProgram.setUniform1f("currentTiming", lel);
overlayProgram.setUniform2f("screenSize", renderingContext.getWindow().getWidth(), renderingContext.getWindow().getHeight());
overlayProgram.setUniform1f("sizeInPixels", 768);
overlayProgram.setUniform1f("heightInPixels", 192);
overlayProgram.setUniform1f("xPosition", 0);
overlayProgram.setUniform1f("yPosition", 0);
overlayProgram.setUniform3f("graphColour", 0, 1, 0);
overlayProgram.setUniform1f("shade", 0.0f);
dataBB.rewind();
texture.uploadTextureData(1024, dataBB);
texture.setLinearFiltering(false);
texture.setTextureWrapping(true);
renderingContext.bindTexture1D("frametimeData", texture);
renderingContext.drawFSQuad();
renderingContext.getFontRenderer().drawStringWithShadow(renderingContext.getFontRenderer().defaultFont(), 4, 192 - 30, "Frametime (ms)", 2, 2, new Vector4f(0.0f, 1.0f, 0.0f, 1.0f));
}
use of org.joml.Vector4f in project chunkstories by Hugobros3.
the class MemUsageRenderer method draw.
public static void draw(OpenGLRenderingContext renderingContext) {
lel++;
lel %= 1024;
// long elapsedTime = (System.nanoTime() - lastTime);
lastTime = System.nanoTime();
float totalMemoryMB = Runtime.getRuntime().totalMemory() / 1024 / 1024;
float freeMemoryMB = Runtime.getRuntime().freeMemory() / 1024 / 1024;
float usedMemoryMB = totalMemoryMB - freeMemoryMB;
dataBB.putFloat(lel * 4, usedMemoryMB / totalMemoryMB * 192f);
// System.out.println(usedMemoryMB + " / " + totalMemoryMB);
renderingContext.setDepthTestMode(DepthTestMode.DISABLED);
renderingContext.setBlendMode(BlendMode.MIX);
renderingContext.setCullingMode(CullingMode.DISABLED);
Shader overlayProgram = renderingContext.useShader("fps_graph");
overlayProgram.setUniform1f("currentTiming", lel);
overlayProgram.setUniform2f("screenSize", renderingContext.getWindow().getWidth(), renderingContext.getWindow().getHeight());
overlayProgram.setUniform1f("sizeInPixels", 768);
overlayProgram.setUniform1f("heightInPixels", 192);
overlayProgram.setUniform1f("xPosition", 0);
overlayProgram.setUniform1f("yPosition", 192 + 192);
overlayProgram.setUniform3f("graphColour", 1, 1, 0);
overlayProgram.setUniform1f("shade", 1.0f);
dataBB.rewind();
texture.uploadTextureData(1024, dataBB);
texture.setLinearFiltering(false);
texture.setTextureWrapping(true);
renderingContext.bindTexture1D("frametimeData", texture);
renderingContext.drawFSQuad();
renderingContext.getFontRenderer().drawStringWithShadow(renderingContext.getFontRenderer().defaultFont(), 4, 192 + 192 + 192 - 30, "Memory used (%" + Runtime.getRuntime().totalMemory() / 1024 / 1024 + "Mb)", 2, 2, new Vector4f(1.0f, 1.0f, 0.0f, 1.0f));
}
use of org.joml.Vector4f in project chunkstories by Hugobros3.
the class WorldLogicTimeRenderer method draw.
public static void draw(OpenGLRenderingContext renderingContext) {
renderingContext.setDepthTestMode(DepthTestMode.DISABLED);
renderingContext.setBlendMode(BlendMode.MIX);
renderingContext.setCullingMode(CullingMode.DISABLED);
Shader overlayProgram = renderingContext.useShader("fps_graph");
overlayProgram.setUniform1f("currentTiming", lel);
overlayProgram.setUniform2f("screenSize", renderingContext.getWindow().getWidth(), renderingContext.getWindow().getHeight());
overlayProgram.setUniform1f("sizeInPixels", 768);
overlayProgram.setUniform1f("heightInPixels", 192);
overlayProgram.setUniform1f("xPosition", 0);
overlayProgram.setUniform1f("yPosition", 192);
overlayProgram.setUniform3f("graphColour", 0, 1, 1);
overlayProgram.setUniform1f("shade", 0.0f);
dataBB.rewind();
texture.uploadTextureData(1024, dataBB);
texture.setLinearFiltering(false);
texture.setTextureWrapping(true);
renderingContext.bindTexture1D("frametimeData", texture);
renderingContext.drawFSQuad();
renderingContext.getFontRenderer().drawStringWithShadow(renderingContext.getFontRenderer().defaultFont(), 4, 192 + 192 - 30, "World logic timing (ms)", 2, 2, new Vector4f(0.0f, 1.0f, 1.0f, 1.0f));
}
use of org.joml.Vector4f in project chunkstories by Hugobros3.
the class TrianglesClipper method cullTop.
private static int cullTop(Vector4f vert1, Vector4f vert2, Vector4f vert3) {
Vector4f v1, v2, v3;
if (vert1.y() > vert2.y()) {
if (vert1.y() > vert3.y()) {
v3 = vert1;
if (vert2.y() > vert3.y()) {
v2 = vert2;
v1 = vert3;
} else {
v2 = vert3;
v1 = vert2;
}
} else {
v2 = vert1;
if (vert2.y() > vert3.y()) {
v3 = vert2;
v1 = vert3;
} else {
v3 = vert3;
v1 = vert2;
}
}
} else {
if (vert2.y() > vert3.y()) {
v3 = vert2;
if (vert1.y() > vert3.y()) {
v2 = vert1;
v1 = vert3;
} else {
v2 = vert3;
v1 = vert1;
}
} else {
v2 = vert2;
v3 = vert3;
v1 = vert1;
}
}
if (v1.y() <= v2.y() && v2.y() <= v3.y()) {
} else {
System.out.println("fuck Y" + v1 + v2 + v3);
return 0;
}
// Actual culling here
float border = 1.0f;
// One point is clipping
if (v1.y() < border && v2.y() < border && v3.y() > border) {
// System.out.println("clipping...");
// Continue the two segments up to the border
float d2t3 = v3.y() - v2.y();
float d2tb = border - v2.y();
Vector4f v2to3 = new Vector4f(v3).sub(v2);
v2to3.mul((d2tb) / d2t3);
v2to3.add(v2);
// System.out.println(v2to3+" is in of clip ("+v2to3.y+")");
// other one
float d1t3 = v3.y() - v1.y();
float d1tb = border - v1.y();
Vector4f v1to3 = new Vector4f(v3).sub(v1);
v1to3.mul((d1tb) / d1t3);
v1to3.add(v1);
return cullBot(v1, v2, v1to3) + cullBot(v2to3, v2, v1to3);
} else // Two points are
if (v1.y() < border && v2.y() > border && v3.y() > border) {
float d1t3 = v3.y() - v1.y();
float d1tb = border - v1.y();
Vector4f v1to3 = new Vector4f(v3).sub(v1);
v1to3.mul((d1tb) / d1t3);
v1to3.add(v1);
// other one
float d1t2 = v2.y() - v1.y();
// float d1tb = border - v1.y;
Vector4f v1to2 = new Vector4f(v2).sub(v1);
v1to2.mul((d1tb) / d1t2);
v1to2.add(v1);
return cullBot(v1, v1to2, v1to3);
} else if (v1.y() > border && v2.y() > border && v3.y() > border) {
// System.out.println("all out !");
return 0;
} else {
return cullBot(v1, v2, v3);
}
}
Aggregations