Fixed rendering (multithreading issue)

This commit is contained in:
Sebastian Cabrera 2020-03-25 03:43:06 -04:00
parent 2105610921
commit 9428f42635
6 changed files with 12 additions and 20 deletions

Binary file not shown.

Binary file not shown.

View file

@ -15,8 +15,6 @@ public class Window {
private static float backgroundR, backgroundG, backgroundB;
private static boolean isInitialized;
public void setBackgroundColor(float r, float g, float b) {
backgroundR = r;
backgroundG = g;
@ -32,10 +30,8 @@ public class Window {
}
public static void update() {
if (isInitialized) {
GL11.glClearColor(backgroundR, backgroundG, backgroundB, 1.0f);
GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
}
GLFW.glfwPollEvents();
@ -84,8 +80,6 @@ public class Window {
GLFW.glfwSwapInterval(2);
Window.time = System.currentTimeMillis();
isInitialized = true;
}
public Window(int width, int height, String title) {

View file

@ -6,6 +6,11 @@ import bz.bronze.latte.engine.io.Input;
import bz.bronze.latte.engine.io.Window;
public class Game implements Runnable {
public static Window window;
public static final int width = 800, height = 600;
public static final String title = "latte | v0.01";
private void update() {
Window.update();
@ -17,6 +22,11 @@ public class Game implements Runnable {
}
public void run() {
window = new Window(width, height, title);
window.create();
window.setBackgroundColor(1.0f, 0, 0);
while (!Window.shouldClose()) {
update();
render();

View file

@ -1,23 +1,11 @@
package bz.bronze.latte.main;
import bz.bronze.latte.engine.io.Window;
public class Main {
public static Thread game;
public static Window window;
public static final int width = 800, height = 600;
public static final String title = "latte | v0.01";
public static void init() {
game = new Thread(new Game(), "game");
window = new Window(width, height, title);
game.start();
window.create();
window.setBackgroundColor(1.0f, 0, 0);
}
public static void main(String[] args) {