exakt so aber warum mit debuggen bin ich auch nicht weiter gekommen weil ich keine ahnung habe wonach b.z wo ich suche
display manager klasse siet so aus:
Java:
package renderEngine;
import java.nio.IntBuffer;
import org.lwjgl.BufferUtils;
import org.lwjgl.glfw.GLFW;
import org.lwjgl.glfw.GLFWErrorCallback;
import org.lwjgl.opengl.GL;
import org.lwjgl.opengl.GL11;
import org.lwjgl.system.MemoryUtil;
public class DisplayManager {
private static final int WIDTH = 1280;
private static final int HEIGHT = 720;
private static long lastFrameTime;
private static float delta;
private static long window;
public static void createDisplay(){
GLFW.glfwSetErrorCallback((error, description) -> {
System.err.println("GLFW error[" + Integer.toHexString(error) + "]: " + GLFWErrorCallback.getDescription(description));
});
boolean isInit = GLFW.glfwInit();
if(isInit == false) {
throw new IllegalStateException("GLFW Init failed");
}
window = GLFW.glfwCreateWindow(WIDTH, HEIGHT, "title", MemoryUtil.NULL, MemoryUtil.NULL);
if(window == MemoryUtil.NULL) {
throw new IllegalStateException("GLFW window creation failed");
}
GLFW.glfwMakeContextCurrent(window);
GLFW.glfwSwapInterval(1);
GLFW.glfwShowWindow(window);
GL.createCapabilities();
GL11.glViewport(0,0, WIDTH, HEIGHT);
lastFrameTime = getCurrentTime();
}
public static void updateDisplay(){
GLFW.glfwSwapBuffers(window);
GLFW.glfwPollEvents();
long currentFrameTime = getCurrentTime();
delta = (currentFrameTime - lastFrameTime) / 1000f;
lastFrameTime = currentFrameTime;
}
public static long getWindow() {
return window;
}
public static int getWidth() {
IntBuffer w = BufferUtils.createIntBuffer(1);
IntBuffer h = BufferUtils.createIntBuffer(1);
GLFW.glfwGetWindowSize(window, w, h);
int width = w.get(0);
return width;
}
public static int getHeight() {
IntBuffer w = BufferUtils.createIntBuffer(1);
IntBuffer h = BufferUtils.createIntBuffer(1);
GLFW.glfwGetWindowSize(window, w, h);
int height = h.get(0);
return height;
}
public static float getFrameTimeSeconds() {
return delta;
}
public static void closeDisplay(){
GLFW.glfwSetErrorCallback(null).free();
GLFW.glfwDestroyWindow(window);
GLFW.glfwTerminate();
}
private static long getCurrentTime() {
return (long) (GLFW.glfwGetTime() * 1000 / GLFW.glfwGetTimerFrequency());
}
}
als erstes wird das hier aufgerufen in der main:
Java:
DisplayManager.createDisplay();
Java:
while(!GLFW.glfwWindowShouldClose(DisplayManager.getWindow())){
camera.move();
player.move(terrain);
renderer.processTerrain(terrain);
renderer.processEntity(player);
for(Entity entity:entities) {
renderer.processEntity(entity);
}
renderer.render(light, camera);
DisplayManager.updateDisplay();
}
Java:
public void prepare() {
GL11.glEnable(GL11.GL_DEPTH_TEST);
GL11.glClear(GL11.GL_COLOR_BUFFER_BIT|GL11.GL_DEPTH_BUFFER_BIT);
GL11.glClearColor(RED, GREEN, BLUE, 1);
}
//im master renderer diese funktion ruft prepare() auf:
public void render(Light sun, Camera camera) {
prepare();
shader.start();
shader.loadSkyColour(RED, GREEN, BLUE);
shader.loadLight(sun);
shader.loadViewMatrix(camera);
renderer.render(entities);
shader.stop();
terrainShader.start();
terrainShader.loadSkyColour(RED, GREEN, BLUE);
terrainShader.loadLight(sun);
terrainShader.loadViewMatrix(camera);
terrainRenderer.render(terrains);
terrainShader.stop();
terrains.clear();
entities.clear();
}
//welche auch im master renderer ist
hoffe ihr könnt mir helfen irgendwie