diff --git a/pom.xml b/pom.xml
index acf7184..93bb63c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -13,7 +13,7 @@
org.gotti.wurmunlimited
client-modlauncher
- 0.4
+ 0.5-beta1
org.lwjgl.lwjgl
diff --git a/src/main/java/com/wurmonline/client/renderer/gui/LiveMapButton.java b/src/main/java/com/wurmonline/client/renderer/gui/LiveMapButton.java
index f1ddf07..2ec96c2 100644
--- a/src/main/java/com/wurmonline/client/renderer/gui/LiveMapButton.java
+++ b/src/main/java/com/wurmonline/client/renderer/gui/LiveMapButton.java
@@ -1,7 +1,6 @@
package com.wurmonline.client.renderer.gui;
-import org.lwjgl.opengl.GL11;
-
+import com.wurmonline.client.renderer.backend.Queue;
import com.wurmonline.client.resources.textures.Texture;
public class LiveMapButton extends WButton {
@@ -22,13 +21,9 @@ public LiveMapButton(final String label, final String hoverString, int width, in
}
@Override
- protected void renderComponent(final float alpha) {
+ protected void renderComponent(Queue queue, final float alpha) {
if (!this.hoverMode || this.hovered) {
- GL11.glEnable(3553);
- GL11.glEnable(3042);
- GL11.glBlendFunc(770, 771);
-
float r2 = this.r;
float g2 = this.g;
float b2 = this.b;
@@ -39,40 +34,16 @@ protected void renderComponent(final float alpha) {
g2 /= 2.0f;
b2 /= 2.0f;
}
- GL11.glColor4f(r2, g2, b2, 1.0f);
if (this.texture != null) {
-
- this.texture.switchTo();
- GL11.glBegin(7);
-
- GL11.glTexCoord2f(0.0f, 0.0f);
- GL11.glVertex2f((float) (this.x + 0), (float) (this.y + 0));
-
- GL11.glTexCoord2f(0.0f, 1.0f);
- GL11.glVertex2f((float) (this.x + 0), (float) (this.y + this.height));
-
- GL11.glTexCoord2f(1.0f, 1.0f);
- GL11.glVertex2f((float) (this.x + this.width), (float) (this.y + this.height));
-
- GL11.glTexCoord2f(1.0f, 0.0f);
- GL11.glVertex2f((float) (this.x + this.width), (float) (this.y + 0));
-
- GL11.glEnd();
+ this.drawTexture(queue, (Texture)this.texture, r2, g2, b2, 1.0f, this.x, this.y, this.width, this.height, 0, 0, 256, 256);
}
- GL11.glDisable(3553);
- GL11.glDisable(3042);
-
}
+
final int yo2 = ((this.isCloseHovered || this.isDown) && this.isEnabled()) ? 1 : 0;
final float c = ((this.isCloseHovered || this.isDown) && this.isEnabled()) ? 0.8f : 1.0f;
- GL11.glColor4f(this.rText * c, this.gText * c, this.bText * c, 1.0f);
this.text.moveTo(this.x + 4 + 0, this.y + this.text.getHeight() + yo2 + 0);
- this.text.paint(this.label);
- if (c == 0.8f || this.rText != 1.0f || this.gText != 1.0f || this.bText != 1.0f) {
-
- GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
- }
+ this.text.paint(queue, this.label, this.rText * c, this.gText *c, this.bText * c, 1.0f);
}
}
diff --git a/src/main/java/com/wurmonline/client/renderer/gui/LiveMapView.java b/src/main/java/com/wurmonline/client/renderer/gui/LiveMapView.java
index 32c419d..6168cb8 100644
--- a/src/main/java/com/wurmonline/client/renderer/gui/LiveMapView.java
+++ b/src/main/java/com/wurmonline/client/renderer/gui/LiveMapView.java
@@ -1,7 +1,8 @@
package com.wurmonline.client.renderer.gui;
import org.gotti.wurmonline.clientmods.livehudmap.LiveMap;
-import org.lwjgl.opengl.GL11;
+
+import com.wurmonline.client.renderer.backend.Queue;
public class LiveMapView extends FlexComponent {
@@ -15,22 +16,12 @@ public class LiveMapView extends FlexComponent {
this.liveMap = liveMap;
}
- protected void renderComponent(float alpha) {
- super.renderComponent(alpha);
+ @Override
+ protected void renderComponent(Queue queue, float alpha) {
+ super.renderComponent(queue, alpha);
liveMap.update(x, y);
-
- GL11.glEnable(GL11.GL_TEXTURE_2D);
-
- GL11.glEnable(GL11.GL_BLEND);
- GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
- GL11.glColor4f(r, g, b, 1.0F);
-
- liveMap.render(0.0F, 0.0F, 1.0F);
-
- GL11.glDisable(GL11.GL_BLEND);
- GL11.glDisable(GL11.GL_TEXTURE_2D);
- GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
+ liveMap.render(queue, 0.0F, 0.0F, 1.0F);
}
diff --git a/src/main/java/com/wurmonline/client/renderer/gui/LiveMapWindow.java b/src/main/java/com/wurmonline/client/renderer/gui/LiveMapWindow.java
index faa8f7b..b389b07 100644
--- a/src/main/java/com/wurmonline/client/renderer/gui/LiveMapWindow.java
+++ b/src/main/java/com/wurmonline/client/renderer/gui/LiveMapWindow.java
@@ -142,7 +142,7 @@ private BufferedImage loadIconImage() {
private WButton createButton(String label, String tooltip, int textureIndex, ButtonListener listener) {
if (iconImage != null) {
BufferedImage image = iconImage.getSubimage(textureIndex * 32, 0, 32, 32);
- ImageTexture texture = ImageTextureLoader.loadNowrapNearestTexture(image);
+ ImageTexture texture = ImageTextureLoader.loadNowrapNearestTexture(image, false);
return new LiveMapButton("", tooltip, 32, 32, texture, listener);
} else {
final String themeName = Options.guiSkins.options[Options.guiSkins.value()].toLowerCase(Locale.ENGLISH).replace(" ", "");
diff --git a/src/main/java/org/gotti/wurmonline/clientmods/livehudmap/LiveMap.java b/src/main/java/org/gotti/wurmonline/clientmods/livehudmap/LiveMap.java
index 9d1883c..e2013ad 100644
--- a/src/main/java/org/gotti/wurmonline/clientmods/livehudmap/LiveMap.java
+++ b/src/main/java/org/gotti/wurmonline/clientmods/livehudmap/LiveMap.java
@@ -1,18 +1,23 @@
package org.gotti.wurmonline.clientmods.livehudmap;
import java.awt.image.BufferedImage;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
import org.gotti.wurmonline.clientmods.livehudmap.renderer.RenderType;
-import org.lwjgl.opengl.GL11;
+import org.gotti.wurmunlimited.modloader.ReflectionUtil;
import com.wurmonline.client.game.PlayerPosition;
import com.wurmonline.client.game.TerrainChangeListener;
import com.wurmonline.client.game.World;
import com.wurmonline.client.renderer.PickData;
+import com.wurmonline.client.renderer.backend.Queue;
import com.wurmonline.client.renderer.cave.CaveBufferChangeListener;
+import com.wurmonline.client.renderer.gui.Renderer;
import com.wurmonline.client.resources.textures.ImageTexture;
import com.wurmonline.client.resources.textures.ImageTextureLoader;
-import com.wurmonline.client.util.WurmGL;
+import com.wurmonline.client.resources.textures.PreProcessedTextureData;
+import com.wurmonline.client.resources.textures.TextureLoader;
public class LiveMap implements TerrainChangeListener, CaveBufferChangeListener {
@@ -26,11 +31,11 @@ public class LiveMap implements TerrainChangeListener, CaveBufferChangeListener
private BufferedImage image;
private ImageTexture texture;
- private float[] textureCoord = { 0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F, 1.0F, 0.0F };
private int x;
private int y;
private int px = 0, py = 0;
+ private final Method preprocessImage;
public LiveMap(World world, int size) {
this.size = size;
@@ -42,6 +47,12 @@ public LiveMap(World world, int size) {
this.surface = new MapLayerView(world, RenderType.FLAT);
this.cave = new MapLayerView(world, RenderType.CAVE);
+
+ try {
+ this.preprocessImage = ReflectionUtil.getMethod(TextureLoader.class, "preprocessImage", new Class[] { BufferedImage.class, boolean.class, boolean.class });
+ } catch (NoSuchMethodException e) {
+ throw new RuntimeException(e);
+ }
}
public void update(int windowX, int windowY) {
@@ -54,10 +65,16 @@ public void update(int windowX, int windowY) {
py = pos.getTileY();
image = getLayer().render(px, py);
- if (texture != null) {
- WurmGL.wglDeleteTexture(texture.getId());
+ if (texture == null) {
+ texture = ImageTextureLoader.loadNowrapNearestTexture(image, false);
+ } else {
+ try {
+ PreProcessedTextureData data = ReflectionUtil.callPrivateMethod(TextureLoader.class, preprocessImage, image, false, true);
+ texture.deferInit(data, TextureLoader.Filter.NEAREST, false, false, false);
+ } catch (InvocationTargetException | IllegalAccessException | IllegalArgumentException e) {
+ throw new RuntimeException(e);
+ }
}
- texture = ImageTextureLoader.loadNowrapNearestTexture(image);
dirty = false;
}
@@ -100,45 +117,14 @@ private boolean isSurface() {
return world.getPlayerLayer() >= 0;
}
- public void render(float textureX, float textureY, float textureScale) {
+ public void render(Queue queue, float textureX, float textureY, float textureScale) {
float resultX = textureX / this.size;
float resultY = textureY / this.size;
- textureCoord[0] = resultX;
- textureCoord[1] = resultY;
-
- textureCoord[2] = resultX;
- textureCoord[3] = (resultY + textureScale);
-
- textureCoord[4] = (resultX + textureScale);
- textureCoord[5] = (resultY + textureScale);
-
- textureCoord[6] = (resultX + textureScale);
- textureCoord[7] = resultY;
-
if (texture != null) {
- renderTexture(x, y, size, size, texture);
- }
- }
-
- protected void renderTexture(int xPosition, int yPosition, int width1, int height1, ImageTexture texture) {
- if (texture != null) {
- texture.switchTo();
- GL11.glBegin(7);
-
- GL11.glTexCoord2f(textureCoord[0], textureCoord[1]);
- GL11.glVertex2f(xPosition + 0, yPosition + 0);
-
- GL11.glTexCoord2f(textureCoord[2], textureCoord[3]);
- GL11.glVertex2f(xPosition + 0, yPosition + height1);
-
- GL11.glTexCoord2f(textureCoord[4], textureCoord[5]);
- GL11.glVertex2f(xPosition + width1, yPosition + height1);
-
- GL11.glTexCoord2f(textureCoord[6], textureCoord[7]);
- GL11.glVertex2f(xPosition + width1, yPosition + 0);
-
- GL11.glEnd();
+ Renderer.texturedQuadAlphaBlend(queue, texture, 1.0f, 1.0f, 1.0f, 1.0f, (float) this.x,
+ (float) this.y, (float) this.size, (float) this.size, resultX, resultY, textureScale,
+ textureScale);
}
}