I am trying to create a gui with nifty on top of lwjgl. I've already had some problems during the Nifty setup, however now Nifty is set up and running correctly but for text rendering. Here is my xml file:
<?xml version="1.0" encoding="UTF-8"?>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<nifty xmlns="http://nifty-gui.sourceforge.net/nifty-1.4.xsd" xmlns:xsi="http://
www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://niftygui.
sourceforge.net/nifty-1.4.xsd http://nifty-gui.sourceforge.net/nifty-1.4.xsd">
<screen id="start">
<layer childLayout="center">
<panel id="panel" height="25%" width="35%" align="center" valign="center" backgroundColor="#f60f" childLayout="center" visibleToMouse="true">
<text id="text" font="aurulent-sans-16.fnt" color="#ffff" text="Hello World!"/>
</panel>
</layer>
</screen>
</nifty>
and here the respective java class:
package niftylwjgl;
import de.lessvoid.nifty.Nifty;
import de.lessvoid.nifty.nulldevice.NullSoundDevice;
import de.lessvoid.nifty.renderer.lwjgl.input.LwjglInputSystem;
import de.lessvoid.nifty.renderer.lwjgl.render.LwjglRenderDevice;
import de.lessvoid.nifty.tools.TimeProvider;
import org.lwjgl.LWJGLException;
import org.lwjgl.input.Keyboard;
import org.lwjgl.opengl.Display;
import org.lwjgl.opengl.GL11;
public class NiftyLwjgl {
private static Nifty nifty;
private static boolean close;
private static LwjglInputSystem inSys;
public static void main(String[] args) throws LWJGLException, Exception {
init();
initNifty();
while (!close) {
update();
preRender();
render();
postRender();
}
destroy();
}
private static void init() throws LWJGLException {
Display.setDisplayMode(Display.getDesktopDisplayMode());
Display.setFullscreen(true);
Display.create();
GL11.glOrtho(0, 1920, 0, 1080, 1, -1);
}
private static void initNifty() throws Exception {
inSys = new LwjglInputSystem();
inSys.startup();
nifty = new Nifty(new LwjglRenderDevice(),
new NullSoundDevice(),
inSys,
new TimeProvider());
nifty.fromXml("xml/main.xml", "start");
nifty.loadStyleFile("nifty-default-styles.xml");
nifty.loadControlFile("nifty-default-controls.xml");
}
private static void preRender() {
GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT | GL11.GL_STENCIL_BUFFER_BIT);
GL11.glMatrixMode(GL11.GL_PROJECTION);
GL11.glLoadIdentity();
GL11.glMatrixMode(GL11.GL_MODELVIEW);
GL11.glEnable(GL11.GL_TEXTURE_2D);
}
private static void postRender() {
GL11.glDisable(GL11.GL_TEXTURE_2D);
}
private static void update() {
if (Display.isCloseRequested()
|| Keyboard.isKeyDown(Keyboard.KEY_ESCAPE)
|| nifty.update()) {
close = true;
}
}
private static void render() {
nifty.render(false);
Display.update();
}
private static void destroy() {
inSys.shutdown();
Display.destroy();
}
}
Here is a screenshot of the application running: I somehow feel like I'm missing something incredible simple but important, like an glXXXXX call. Any help/suggestions are appreciated.