I have made a simple LWJGL program where it makes a display and renders text to the screen. I render text with Slick-util btw.
So my question is why does it take a couple seconds of a black screen(or whatever the clear color is) before it loads up. Is there a way to fix this? Can I hide the Display until it all renders? Well those are my questions. Here is my code:
package com.survivalpixel.kopis;
import static org.lwjgl.opengl.GL11.GL_MODELVIEW;
import static org.lwjgl.opengl.GL11.GL_PROJECTION;
import static org.lwjgl.opengl.GL11.GL_TEXTURE_2D;
import static org.lwjgl.opengl.GL11.glEnable;
import static org.lwjgl.opengl.GL11.glMatrixMode;
import static org.lwjgl.opengl.GL11.*;
import static org.lwjgl.opengl.GL11.glPopMatrix;
import static org.lwjgl.opengl.GL11.glPushMatrix;
import java.awt.Font;
import org.lwjgl.LWJGLException;
import org.lwjgl.opengl.Display;
import org.lwjgl.opengl.DisplayMode;
import org.lwjgl.opengl.GL11;
import org.newdawn.slick.TrueTypeFont;
public class Menu {
private int WIDTH = 1080,HEIGHT = 720;
Font font;
TrueTypeFont gamefont;
public static void main(String args[]){
new Menu();
}
public Menu(){
try {
Display.setDisplayMode(new DisplayMode(WIDTH,HEIGHT));
Display.setResizable(false);
Display.setTitle("Kopis V.01");
Display.create();
} catch (LWJGLException e) {
}
initGL();
init();
while(!Display.isCloseRequested()){
glPopMatrix();
glClear(GL11.GL_COLOR_BUFFER_BIT);
drawString("This is a test",100,100);
Display.update();
Display.sync(100);
glPushMatrix();
}
Display.destroy();
System.exit(0);
}
private void initGL() {
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0, 1080, 720, 0, -1, 1);
glMatrixMode(GL_MODELVIEW);
glClearColor(0, 0, 0, 0);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}
private void init() {
font = new Font("times new roman", Font.BOLD,12);
gamefont = new TrueTypeFont(font, false);
}
public void drawString(String s,int x, int y){
gamefont.drawString(x, y, s);
}
}