Reputation: 22
ok so I have determined that if I change my orthographic matrix coordinate system to
GL11.glOrtho(0, Strings.DISPLAY_WIDTH, Strings.DISPLAY_HEIGHT, 0, -1, 1);
instead of this
GL11.glOrtho(0, Strings.DISPLAY_WIDTH, 0, Strings.DISPLAY_HEIGHT, -1, 1);
I can draw strings with slick right side up however the game im building uses this system
GL11.glOrtho(0, Strings.DISPLAY_WIDTH, 0, Strings.DISPLAY_HEIGHT, -1, 1);
and slick draws things with the top of the matrix being 0 and the bottom being the height of the display is there anyway I can rotate or draw the strings differently without having to change my games coordinate system?
here is my string drawing class
private Font javaFont;
private UnicodeFont uniFont;
public TextHandler(int letterSize) {
this.initHandler(letterSize);
}
private void initHandler(int size) {
this.javaFont = new Font("Times New Roman", Font.BOLD, size);
this.uniFont = new UnicodeFont(this.javaFont);
this.uniFont.getEffects().add(new ColorEffect(java.awt.Color.white));
this.uniFont.addAsciiGlyphs();
try {
this.uniFont.loadGlyphs();
} catch (SlickException e) {
e.printStackTrace();
}
}
public void drawString(String string, float x, float y) {
this.uniFont.drawString(x, y, string, Color.white);
}
and my openGl initialization code if it helps
GL11.glMatrixMode(GL11.GL_PROJECTION);
GL11.glLoadIdentity();
GL11.glOrtho(0, Strings.DISPLAY_WIDTH, 0, Strings.DISPLAY_HEIGHT, -1, 1);
GL11.glMatrixMode(GL11.GL_MODELVIEW);
GL11.glEnable(GL11.GL_TEXTURE_2D);
GL11.glClearColor(0, 0, 1, 0);
GL11.glDisable(GL11.GL_DEPTH_TEST);
Upvotes: 0
Views: 501
Reputation:
Yes, you could set up a rendering system where the first glOrtho
call sets up the Slick rendering, and then you render the strings. Then you call glOrtho
again, but render the rest of your game. glOrtho
simply tells OpenGL to setup an orthographic projection, and what corner of the screen to start rendering from. Slick uses the top left hand corner whereas you are using the bottom left hand corner. OpenGL is a state based machine, so you must render the Slick stuff, switch to the new projection, and then render the rest of your game.
You also don't need that call to glDisable(GL_DEPTH_TEST);
. Depth testing is turned off by default.
Upvotes: 1