modelviewer: fix some incorrect gl usage, add error logging

This commit is contained in:
Adam
2018-08-04 16:16:24 -04:00
parent 46c2745374
commit 90c962accf
3 changed files with 16 additions and 6 deletions

View File

@@ -51,8 +51,6 @@ public class Camera
glRotatef(rotation.y, 0, 1, 0);
glRotatef(rotation.z, 0, 0, 1);
glTranslatef(-pos.x, -pos.y, -pos.z);
GL11.glPopMatrix();
}
public void acceptInput(float delta)

View File

@@ -60,8 +60,16 @@ public class ModelManager
public ModelDefinition getModel(int id, ObjectDefinition object, Location location)
{
int type = location.getType();
int rot = location.getOrientation();
final int type, rot;
if (location != null)
{
type = location.getType();
rot = location.getOrientation();
}
else
{
type = rot = 0;
}
return this.getModel(new ModelKey(id, object.getId(), type, rot), md ->
{
// this logic is from method3697 in 140

View File

@@ -89,6 +89,9 @@ import static org.lwjgl.opengl.GL11.GL_TEXTURE_WRAP_S;
import static org.lwjgl.opengl.GL11.GL_TEXTURE_WRAP_T;
import static org.lwjgl.opengl.GL11.glTexParameteri;
import static org.lwjgl.opengl.GL12.GL_CLAMP_TO_EDGE;
import static org.lwjgl.opengl.GL43.GL_DEBUG_OUTPUT;
import static org.lwjgl.opengl.GL43.glDebugMessageCallback;
import org.lwjgl.opengl.KHRDebugCallback;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -279,7 +282,9 @@ public class ModelViewer
double far = 10000;
double fov = 1; // 1 gives you a 90° field of view. It's tan(fov_angle)/2.
GL11.glFrustum(-aspect * near * fov, aspect * near * fov, -fov, fov, near, far);
GL11.glPopMatrix();
GL11.glEnable(GL_DEBUG_OUTPUT);
glDebugMessageCallback(new KHRDebugCallback());
GL11.glEnable(GL11.GL_DEPTH_TEST);
@@ -783,7 +788,6 @@ public class ModelViewer
-height,
(regionY * TILE_SCALE) + ((length * TILE_SCALE) / 2)
);
GL11.glPopMatrix();
}
}