1
0
Fork 0

imrove debug logging

This commit is contained in:
Sen 2025-09-02 14:34:47 +02:00
parent 0be3f218e5
commit 324332c242
Signed by: sen
GPG key ID: 3AC50A6F47D1B722
10 changed files with 37 additions and 27 deletions

View file

@ -853,8 +853,6 @@ public class Client implements IThreadListener {
GL15.glMatrixMode(GL15.GL_MODELVIEW); GL15.glMatrixMode(GL15.GL_MODELVIEW);
this.textureMap = new TextureMap(); this.textureMap = new TextureMap();
this.textureManager.loadTexture(TextureMap.BLOCKS, this.textureMap); this.textureManager.loadTexture(TextureMap.BLOCKS, this.textureMap);
this.textureManager.bindTexture(TextureMap.BLOCKS);
TextureUtil.setParams();
this.modelManager = new ModelManager(this.textureMap); this.modelManager = new ModelManager(this.textureMap);
this.modelManager.onReload(); this.modelManager.onReload();
this.renderItem = new RenderItem(this.textureManager, this.modelManager); this.renderItem = new RenderItem(this.textureManager, this.modelManager);

View file

@ -96,13 +96,13 @@ public enum Font implements Identifyable, Displayable {
img = TextureUtil.readImage(FileUtils.getResource("textures/font_" + font.name + ".png")); img = TextureUtil.readImage(FileUtils.getResource("textures/font_" + font.name + ".png"));
} }
catch(FileNotFoundException e) { catch(FileNotFoundException e) {
Log.IO.error("Konnte Font-Textur nicht laden: Datei nicht vorhanden"); Log.IO.error("Konnte Font-Textur '%s' nicht laden: Datei nicht vorhanden", font.name);
} }
catch(IOException e) { catch(IOException e) {
Log.IO.error(e, "Konnte Font-Textur nicht laden"); Log.IO.error(e, "Konnte Font-Textur '%s' nicht laden", font.name);
} }
if(img != null && (img.getWidth() != width * 16 || img.getHeight() != height * 16)) { if(img != null && (img.getWidth() != width * 16 || img.getHeight() != height * 16)) {
Log.IO.error("Konnte Font-Textur nicht laden: Größe ist nicht %dx%d", width * 16, height * 16); Log.IO.error("Konnte Font-Textur '%s' nicht laden: Größe ist nicht %dx%d", font.name, width * 16, height * 16);
img = null; img = null;
} }
if(img == null) if(img == null)
@ -112,7 +112,7 @@ public enum Font implements Identifyable, Displayable {
calculate(data, font.sizes, width, height, 0); calculate(data, font.sizes, width, height, 0);
font.texture = GL15.glGenTextures(); font.texture = GL15.glGenTextures();
TextureUtil.uploadImage(font.texture, img); TextureUtil.uploadImage(font.texture, img);
Log.RENDER.debug("Font-Textur wurde mit ID #%d geladen", font.texture); Log.RENDER.debug("Font-Textur '%s' wurde mit ID #%d geladen", font.name, font.texture);
} }
} }
@ -141,8 +141,8 @@ public enum Font implements Identifyable, Displayable {
public static void unloadFonts() { public static void unloadFonts() {
for(Font font : values()) { for(Font font : values()) {
if(font.texture != 0) { if(font.texture != 0) {
GL15.glDeleteTextures(font.texture); GlState.deleteTexture(font.texture);
Log.RENDER.debug("Font-Textur mit ID #%d wurde gelöscht", font.texture); Log.RENDER.debug("Font-Textur '%s' mit ID #%d wurde gelöscht", font.name, font.texture);
font.texture = 0; font.texture = 0;
} }
} }

View file

@ -12,6 +12,7 @@ public class VertexBuffer {
public VertexBuffer(VertexFormat format) { public VertexBuffer(VertexFormat format) {
this.format = format; this.format = format;
this.id = GL15.glGenBuffers(); this.id = GL15.glGenBuffers();
// Log.SYSTEM.debug("Puffer mit Größe %d (%dE) wurde mit ID #%d geladen", this.format.getNextOffset(), this.format.getElementCount(), this.id);
} }
public void bindBuffer() { public void bindBuffer() {
@ -36,6 +37,7 @@ public class VertexBuffer {
public void deleteGlBuffers() { public void deleteGlBuffers() {
if(this.id >= 0) { if(this.id >= 0) {
GL15.glDeleteBuffers(this.id); GL15.glDeleteBuffers(this.id);
// Log.SYSTEM.debug("Puffer mit Größe %d (%dE) / ID #%d wurde gelöscht", this.format.getNextOffset(), this.format.getElementCount(), this.id);
this.id = -1; this.id = -1;
} }
} }

View file

@ -15,18 +15,6 @@ public class VertexFormat
private List<Integer> uvOffsetsById; private List<Integer> uvOffsetsById;
private int normalElementOffset; private int normalElementOffset;
public VertexFormat(VertexFormat vertexFormatIn)
{
this();
for (int i = 0; i < vertexFormatIn.getElementCount(); ++i)
{
this.addElement(vertexFormatIn.getElement(i));
}
this.nextOffset = vertexFormatIn.getNextOffset();
}
public VertexFormat() public VertexFormat()
{ {
this.elements = Lists.<VertexFormatElement>newArrayList(); this.elements = Lists.<VertexFormatElement>newArrayList();

View file

@ -4,6 +4,7 @@ import java.awt.image.BufferedImage;
import java.io.IOException; import java.io.IOException;
import client.renderer.GlState; import client.renderer.GlState;
import common.log.Log;
public class DynamicTexture extends Texture { public class DynamicTexture extends Texture {
private final int[] data; private final int[] data;
@ -21,6 +22,7 @@ public class DynamicTexture extends Texture {
this.height = height; this.height = height;
this.data = new int[width * height]; this.data = new int[width * height];
TextureUtil.allocateTexture(this.getGlTextureId(), width, height); TextureUtil.allocateTexture(this.getGlTextureId(), width, height);
Log.RENDER.debug("Dynamische Textur in Größe %dx%d wurde mit ID #%d erstellt", width, height, this.getGlTextureId());
} }
public void loadTexture() throws IOException { public void loadTexture() throws IOException {

View file

@ -9,6 +9,7 @@ import java.util.List;
import client.util.FileUtils; import client.util.FileUtils;
import common.collect.Lists; import common.collect.Lists;
import common.log.Log; import common.log.Log;
import common.util.Util;
public class LayeredTexture extends Texture public class LayeredTexture extends Texture
{ {
@ -21,7 +22,10 @@ public class LayeredTexture extends Texture
public void loadTexture() throws IOException public void loadTexture() throws IOException
{ {
this.deleteGlTexture(); int id = this.deleteGlTexture();
if(id != -1)
Log.RENDER.debug("Textur '%s' mit ID #%d wurde gelöscht", Util.buildLines("|", this.layers), id);
BufferedImage bufferedimage = null; BufferedImage bufferedimage = null;
try try
@ -49,5 +53,6 @@ public class LayeredTexture extends Texture
} }
TextureUtil.uploadImage(this.getGlTextureId(), bufferedimage); TextureUtil.uploadImage(this.getGlTextureId(), bufferedimage);
Log.RENDER.debug("Textur '%s' wurde mit ID #%d geladen", Util.buildLines("|", this.layers), this.getGlTextureId());
} }
} }

View file

@ -5,6 +5,7 @@ import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import client.util.FileUtils; import client.util.FileUtils;
import common.log.Log;
public class SimpleTexture extends Texture { public class SimpleTexture extends Texture {
private final String texture; private final String texture;
@ -14,12 +15,15 @@ public class SimpleTexture extends Texture {
} }
public void loadTexture() throws IOException { public void loadTexture() throws IOException {
this.deleteGlTexture(); int id = this.deleteGlTexture();
if(id != -1)
Log.RENDER.debug("Textur '%s' mit ID #%d wurde gelöscht", this.texture, id);
InputStream in = null; InputStream in = null;
try { try {
in = FileUtils.getResource(this.texture); in = FileUtils.getResource(this.texture);
BufferedImage img = TextureUtil.readImage(in); BufferedImage img = TextureUtil.readImage(in);
TextureUtil.uploadImage(this.getGlTextureId(), img); TextureUtil.uploadImage(this.getGlTextureId(), img);
Log.RENDER.debug("Textur '%s' wurde mit ID #%d geladen", this.texture, this.getGlTextureId());
} }
finally { finally {
if(in != null) if(in != null)

View file

@ -15,11 +15,14 @@ public abstract class Texture {
return this.id; return this.id;
} }
public final void deleteGlTexture() { public final int deleteGlTexture() {
if(this.id != -1) { if(this.id != -1) {
GlState.deleteTexture(this.id); GlState.deleteTexture(this.id);
int id = this.id;
this.id = -1; this.id = -1;
return id;
} }
return -1;
} }
public abstract void loadTexture() throws IOException; public abstract void loadTexture() throws IOException;

View file

@ -45,8 +45,13 @@ public class TextureManager {
public void deleteTexture(String res) { public void deleteTexture(String res) {
Texture tex = this.getTexture(res); Texture tex = this.getTexture(res);
if(tex != null) if(tex != null) {
GlState.deleteTexture(tex.getGlTextureId()); int id = tex.getGlTextureId();
if(id != -1) {
GlState.deleteTexture(id);
Log.RENDER.debug("Textur '%s' mit ID #%d wurde gelöscht (Manager)", res, id);
}
}
this.textures.remove(res); this.textures.remove(res);
} }

View file

@ -92,7 +92,9 @@ public class TextureMap extends Texture
sprites.put(loc, sprite); sprites.put(loc, sprite);
} }
this.initMissingImage(); this.initMissingImage();
this.deleteGlTexture(); int id = this.deleteGlTexture();
if(id != -1)
Log.RENDER.debug("Textur-Atlas mit ID #%d wurde gelöscht", id);
this.loadTextureAtlas(); this.loadTextureAtlas();
} }
@ -154,7 +156,6 @@ public class TextureMap extends Texture
throw stitcherexception; throw stitcherexception;
} }
Log.RENDER.info("Textur-Atlas in Größe " + stitcher.getCurrentWidth() + "x" + stitcher.getCurrentHeight() + " erstellt");
TextureUtil.allocateTexture(this.getGlTextureId(), this.width = stitcher.getCurrentWidth(), this.height = stitcher.getCurrentHeight()); TextureUtil.allocateTexture(this.getGlTextureId(), this.width = stitcher.getCurrentWidth(), this.height = stitcher.getCurrentHeight());
Map<String, Sprite> map = Maps.<String, Sprite>newHashMap(this.mapRegisteredSprites); Map<String, Sprite> map = Maps.<String, Sprite>newHashMap(this.mapRegisteredSprites);
@ -176,6 +177,8 @@ public class TextureMap extends Texture
{ {
textureatlassprite3.copyFrom(this.missingImage); textureatlassprite3.copyFrom(this.missingImage);
} }
Log.RENDER.info("Textur-Atlas in Größe %dx%d wurde mit ID #%d erstellt", stitcher.getCurrentWidth(), + stitcher.getCurrentHeight(), this.getGlTextureId());
} }
public Sprite getAtlasSprite(String iconName) public Sprite getAtlasSprite(String iconName)