Hello everyone!
I'm really new to the OpenGL/LWJGL world therefore my problem might be really easy to solve. My problem here is when I try to render some text onto the screen. I've read many different posts in many different places on how this can be done. I'm currently using the Slick2D library to try achieving it. I'm using the UnicodeFont class. Let me show you some relevant code:
UnicodeFont font = new UnicodeFont(new Font("Times New Roman", Font.PLAIN, 24));
font.addAsciiGlyphs();
try{
font.loadGlyphs();
}catch(SlickException e){
e.printStackTrace();
}
font.drawString(100, 100, "test");
I do this after the setup:
public void setup(){
int glfwResult = glfwInit();
if(glfwResult == GL_FALSE){ //In case the initialization fails
throw new IllegalStateException("GLFW Initialization failed");
}
glfwDefaultWindowHints(); // Loads GLFW's default window settings
glfwWindowHint(GLFW_VISIBLE, GL_TRUE); // Sets window to be visible
Constants.windowID = glfwCreateWindow(Constants.width, Constants.height, "Fractal", MemoryUtil.NULL, MemoryUtil.NULL);
if(Constants.windowID == MemoryUtil.NULL){ //In case the initialization fails
throw new IllegalStateException("Window creation failed");
}
glfwMakeContextCurrent(Constants.windowID); //Needs to be here
glfwSwapInterval(1); //Caps the fps to 60 with VSync
glfwShowWindow(Constants.windowID);
GLContext.createFromCurrent(); //Binds the OpenGL context to the current thread, the GLFW one
glEnable(GL_TEXTURE_2D);
glShadeModel(GL_SMOOTH);
glDisable(GL_DEPTH_TEST);
glDisable(GL_LIGHTING);
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glClearDepth(1);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
MouseInput.registerMouseInput(); //Registering the mouse inputs
glClearColor(0F, 0F, 0F, 0F);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
{//For normal use
glViewport(0, 0, Constants.width,Constants. height);
glMatrixMode(GL_MODELVIEW);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0, Constants.width, Constants.height, 0, 1, - 1);
glMatrixMode(GL_MODELVIEW);
}
screen = GUIs.mainScreen;
screen.render();
UnicodeFont font = new UnicodeFont(new Font("Times New Roman", Font.PLAIN, 24));
font.addAsciiGlyphs();
try{
font.loadGlyphs();
}catch(SlickException e){
e.printStackTrace();
}
font.drawString(0, 0, "test");
lastFPS = getTime(); //Sets for the first time the FPS
}
My problem here is that the application becomes unresponsive to all inputs but mouse ones. The FPS are not shown anymore in the console. The game loop looks like dead even before it actually started.
If you need any additional code I'll be more than happy to give it to you. Last additional note, I'm on MacOSX
I hope that someone can help me. I've been stuck on this for 5 days now.