use of io.xol.chunkstories.client.util.IconLoader in project chunkstories by Hugobros3.
the class GLFWGameWindow method run.
public void run() {
try {
// Client.onStart();
new IconLoader(this);
// Resize window logic
glfwSetFramebufferSizeCallback(glfwWindowHandle, (framebufferSizeCallback = new GLFWFramebufferSizeCallback() {
@Override
public void invoke(long window, int width, int height) {
windowWidth = width;
windowHeight = height;
glViewport(0, 0, width, height);
Layer layer = GLFWGameWindow.this.layer;
while (layer != null) {
layer.onResize(width, height);
layer = layer.getParentLayer();
}
}
}));
while (glfwWindowShouldClose(glfwWindowHandle) == false && !closeRequest) {
// Update pending actions
vramUsageVerticesObjects = VertexBufferGL.updateVerticesObjects();
Texture2DGL.updateTextureObjects();
FrameBufferObjectGL.updateFrameBufferObjects();
// Clear windows
renderingContext.getRenderTargetManager().clearBoundRenderTargetAll();
// Do scene changes etc
Iterator<SynchronousTask> is = mainThreadQueue.iterator();
while (is.hasNext()) {
SynchronousTask st = is.next();
st.run.run();
st.signal();
is.remove();
}
/*for (Runnable r : mainThreadQueue)
r.run();
mainThreadQueue.clear();*/
// Update audio
soundManager.update();
// update inputs first
client.getInputsManager().pollLWJGLInputs();
// Run scene content
if (layer != null) {
// then do the game logic
try {
layer.render(renderingContext);
}// Fucking tired of handling npes everywhere
catch (NullPointerException npe) {
npe.printStackTrace();
}
}
renderingContext.getGuiRenderer().drawBuffer();
tick();
// Clamp fps
int targetFPS = this.client.getConfiguration().getIntOption("client.video.framerateCap");
if (targetFPS != -1) {
// long time = System.currentTimeMillis();
sync(targetFPS);
// glFinish();
// long timeTook = System.currentTimeMillis() - time;
// timeTookLastTime = timeTook;
}
// Draw graph
if (client.getConfiguration().getBooleanOption("client.debug.frametimeGraph")) {
FrametimeRenderer.draw(renderingContext);
MemUsageRenderer.draw(renderingContext);
WorldLogicTimeRenderer.draw(renderingContext);
}
// Update the screen
// Display.update();
glfwSwapBuffers(glfwWindowHandle);
// Reset counters
GLCalls.nextFrame();
}
// Sane way of ending the game.
client.logger().info("Game exitting cleanly.");
soundManager.destroy();
client.onClose();
glfwDestroyWindow(glfwWindowHandle);
System.exit(0);
} catch (Throwable e) {
logger().error("A fatal error occured ! If you see the dev, show him this message !", e);
// e.printStackTrace();
// e.printStackTrace(logger().getPrintWriter());
}
}
Aggregations