aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/cc/polyfrost/oneconfig/lwjgl
diff options
context:
space:
mode:
authornextdaydelivery <79922345+nxtdaydelivery@users.noreply.github.com>2022-05-10 18:51:51 +0100
committernextdaydelivery <79922345+nxtdaydelivery@users.noreply.github.com>2022-05-10 18:51:51 +0100
commitb5a1aea2239b0beace4d4407d2ab75294c6eab12 (patch)
tree8bff04f17385dd348cbc73fdffe5462772d1412b /src/main/java/cc/polyfrost/oneconfig/lwjgl
parent20cf8146e88f3ca06399fdf163badef759f01d2c (diff)
downloadOneConfig-b5a1aea2239b0beace4d4407d2ab75294c6eab12.tar.gz
OneConfig-b5a1aea2239b0beace4d4407d2ab75294c6eab12.tar.bz2
OneConfig-b5a1aea2239b0beace4d4407d2ab75294c6eab12.zip
reduce dependency on minecraft
Diffstat (limited to 'src/main/java/cc/polyfrost/oneconfig/lwjgl')
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/lwjgl/OneColor.java9
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/lwjgl/RenderManager.java43
2 files changed, 32 insertions, 20 deletions
diff --git a/src/main/java/cc/polyfrost/oneconfig/lwjgl/OneColor.java b/src/main/java/cc/polyfrost/oneconfig/lwjgl/OneColor.java
index 423ecee..7a4ae1e 100644
--- a/src/main/java/cc/polyfrost/oneconfig/lwjgl/OneColor.java
+++ b/src/main/java/cc/polyfrost/oneconfig/lwjgl/OneColor.java
@@ -155,7 +155,7 @@ public class OneColor {
/**
* Get the RGBA color from the HSB color, and apply the alpha.
*/
- public int HSBAtoRGBA(float hue, float saturation, float brightness, int alpha) {
+ public static int HSBAtoRGBA(float hue, float saturation, float brightness, int alpha) {
int temp = Color.HSBtoRGB(hue / 360f, saturation / 100f, brightness / 100f);
return ((temp & 0x00ffffff) | (alpha << 24));
}
@@ -163,7 +163,7 @@ public class OneColor {
/**
* Get the HSBA color from the RGBA color.
*/
- public short[] RGBAtoHSBA(int rgba) {
+ public static short[] RGBAtoHSBA(int rgba) {
short[] hsb = new short[4];
float[] hsbArray = Color.RGBtoHSB((rgba >> 16 & 255), (rgba >> 8 & 255), (rgba & 255), null);
hsb[0] = (short) (hsbArray[0] * 360);
@@ -181,4 +181,9 @@ public class OneColor {
rgba = Integer.parseInt(hex, 16);
hsba = RGBAtoHSBA(rgba);
}
+
+ @Override
+ public String toString() {
+ return "OneColor{rgba=[r=" + getRed() + ", g=" + getGreen() + ", b=" + getBlue() + ", a=" + getAlpha() + "], hsba=[h=" + getHue() + ", s=" + getSaturation() + ", b=" + getBrightness() + ", a=" + getAlpha() + "], hex=" + getHex() + "}";
+ }
}
diff --git a/src/main/java/cc/polyfrost/oneconfig/lwjgl/RenderManager.java b/src/main/java/cc/polyfrost/oneconfig/lwjgl/RenderManager.java
index 979acde..297fcfc 100644
--- a/src/main/java/cc/polyfrost/oneconfig/lwjgl/RenderManager.java
+++ b/src/main/java/cc/polyfrost/oneconfig/lwjgl/RenderManager.java
@@ -1,15 +1,15 @@
package cc.polyfrost.oneconfig.lwjgl;
import cc.polyfrost.oneconfig.config.OneConfigConfig;
-import cc.polyfrost.oneconfig.lwjgl.font.Font;
import cc.polyfrost.oneconfig.lwjgl.font.FontManager;
import cc.polyfrost.oneconfig.lwjgl.font.Fonts;
import cc.polyfrost.oneconfig.lwjgl.image.Image;
import cc.polyfrost.oneconfig.lwjgl.image.ImageLoader;
import cc.polyfrost.oneconfig.lwjgl.image.Images;
import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.ScaledResolution;
-import net.minecraft.client.renderer.GlStateManager;
+import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.shader.Framebuffer;
import org.lwjgl.nanovg.NVGColor;
import org.lwjgl.nanovg.NVGPaint;
@@ -63,7 +63,7 @@ public final class RenderManager {
nvgEndFrame(vg);
- GlStateManager.popAttrib();
+ GL11.glPopAttrib();
}
public static void drawRectangle(long vg, float x, float y, float width, float height, int color) { // TODO make everything use this one day
@@ -314,10 +314,10 @@ public final class RenderManager {
}
public static void drawScaledString(String text, float x, float y, int color, boolean shadow, float scale) {
- GlStateManager.pushMatrix();
- GlStateManager.scale(scale, scale, 1);
+ GL11.glPushMatrix();
+ GL11.glScalef(scale, scale, 1);
Minecraft.getMinecraft().fontRendererObj.drawString(text, x * (1 / scale), y * (1 / scale), color, shadow);
- GlStateManager.popMatrix();
+ GL11.glPopMatrix();
}
public static void glColor(int color) {
@@ -325,29 +325,36 @@ public final class RenderManager {
float f1 = (float) (color >> 16 & 255) / 255.0F;
float f2 = (float) (color >> 8 & 255) / 255.0F;
float f3 = (float) (color & 255) / 255.0F;
- GlStateManager.color(f1, f2, f3, f);
+ GL11.glColor4f(f1, f2, f3, f);
}
public static void drawDottedLine(float sx, float sy, float ex, float ey, int width, int factor, int color) {
- GlStateManager.pushMatrix();
+ GL11.glPushMatrix();
GL11.glLineStipple(factor, (short) 0xAAAA);
GL11.glEnable(GL11.GL_LINE_STIPPLE);
- GlStateManager.pushMatrix();
- GlStateManager.disableTexture2D();
- GlStateManager.enableBlend();
- GlStateManager.disableAlpha();
- GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
+ GL11.glPushMatrix();
+ GL11.glDisable(GL11.GL_TEXTURE_2D);
+ GL11.glEnable(GL11.GL_BLEND);
+ GL11.glDisable(GL11.GL_ALPHA);
+ OpenGlHelper.glBlendFunc(770, 771, 1, 0);
glColor(color);
GL11.glLineWidth(width);
GL11.glBegin(GL11.GL_LINES);
GL11.glVertex2d(sx, sy);
GL11.glVertex2d(ex, ey);
GL11.glEnd();
- GlStateManager.disableBlend();
- GlStateManager.enableAlpha();
- GlStateManager.enableTexture2D();
- GlStateManager.popMatrix();
+ GL11.glDisable(GL11.GL_BLEND);
+ GL11.glEnable(GL11.GL_ALPHA);
+ GL11.glEnable(GL11.GL_TEXTURE_2D);
+ GL11.glPopMatrix();
GL11.glDisable(GL11.GL_LINE_STIPPLE);
- GlStateManager.popMatrix();
+ GL11.glPopMatrix();
+ }
+
+
+
+ // other minecraft functions
+ public static void displayGuiScreen(GuiScreen guiScreen) {
+ Minecraft.getMinecraft().displayGuiScreen(guiScreen);
}
}