Ok, this is probably has a really simple solution, so apologies in advance, but I can't get the sample code to work alongside my current OGL initialization. Here's the code my project uses currently:
// Enable textures since we're going to use these for our sprites
GL11.glEnable(GL11.GL_TEXTURE_2D);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
// Go into orthographic projection mode
GL11.glMatrixMode(GL11.GL_PROJECTION);
GL11.glLoadIdentity();
GLU.gluOrtho2D(0, Display.getDisplayMode().getWidth(), Display.getDisplayMode().getHeight(), 0);
GL11.glMatrixMode(GL11.GL_MODELVIEW);
GL11.glLoadIdentity();
GL11.glViewport(0, 0, Display.getDisplayMode().getWidth(), Display.getDisplayMode().getHeight());
// Set clear color to black
GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
// Sync frame (only works on windows)
Display.setVSyncEnabled(true);
And this is the text tutorial's init code:
GL11.glShadeModel(GL11.GL_SMOOTH); // Enable Smooth Shading
GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
// Black Background
GL11.glClearDepth(1.0); // Depth Buffer Setup
GL11.glDepthFunc(GL11.GL_LEQUAL);
GL11.glEnable(GL11.GL_DEPTH_TEST); // Enables Depth Testing
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GL11.glEnable(GL11.GL_BLEND);
GL11.glEnable(GL11.GL_TEXTURE_2D); // Enable Texture Mapping
//GL11.glEnable(GL11.GL_CULL_FACE);
// The Type Of Depth Testing To Do
GL11.glMatrixMode(GL11.GL_PROJECTION);
// Select The Projection Matrix
GL11.glLoadIdentity(); // Reset The Projection Matrix
// Calculate The Aspect Ratio Of The Window
GLU.gluPerspective(45.0f,
(float) displayMode.getWidth() / (float) displayMode.getHeight(),
0.1f,100.0f);
GL11.glMatrixMode(GL11.GL_MODELVIEW);
// Select The Modelview Matrix
// Really Nice Perspective Calculations
GL11.glHint(GL11.GL_PERSPECTIVE_CORRECTION_HINT, GL11.GL_NICEST);
And then the text is drawn with the following lines:
GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); // Clear Screen And Depth Buffer
GL11.glLoadIdentity(); // Reset The Current Modelview Matrix
// Position The Text On The Screen
GL11.glTranslatef(-0.9f + 0.05f * ((float)Math.cos(cnt1)), 0.32f * ((float)Math.sin(cnt2)), -2.0f); // Move One Unit Into The Screen
glPrint("Active OpenGL Text With NeHe - " + numberFormat.format(cnt1)); // Print GL Text To The Screen
...
public void glPrint(String msg) { // Custom GL "Print" Routine
if(msg != null) {
GL11.glBindTexture(GL11.GL_TEXTURE_2D, texture);
for(int i=0;i<msg.length();i++) {
GL11.glCallList(base + msg.charAt(i));
GL11.glTranslatef(0.05f, 0.0f, 0.0f);
}
}
}
So I've tried using the functions 'GL11.glClear', 'GL11.glLoadIdentity', 'GL11.glTranslatef' and 'glPrint' shown above in various combinations alongside my own drawing code. The result is that either the text doesn't draw or I get a black screen. Now I don't really know what half of what the static GL11 methods do, so I'm kind of lost. Does the order of the initialization code matter? Or do I need to change glPrint? If it helps, the app that I want to use the text in uses a different DisplayMode (with a larger resolution). Thanks.