Slick Forums

Discuss the Slick 2D Library
It is currently Tue May 21, 2013 1:42 pm

All times are UTC




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Using upside down fonts
PostPosted: Thu Aug 09, 2012 9:11 pm 
Offline

Joined: Thu Aug 09, 2012 8:42 pm
Posts: 3
If you call glOrtho to put the screen origin in the lower-left, then text displayed with fonts such as UnicodeFont and SpriteSheetFont will appear upside down. This is easy to fix if you use a screen origin in the upper-left, which seems to be the convention within the Slick library. My problem is I don't want to use an upper-left origin. Is there a graceful way to reflect text letters vertically (or horizontally)? I only know of these options:

1) With SpriteSheetFont at least, you could vertically flip the letters in the source image file. It's not enough to call Image.getFlippedCopy() before you pass it to the SpriteSheet used for the SpriteSheetFont, as that will also cause the wrong letters to be displayed.

2) Through OpenGL matrix magic, you could probably scale and transform your way into reflected text. I think this would require calculations based on the size of the GL viewport, and it would certainly require pushing and popping the matrix any time you needed to display text.

Does the Slick API provide an easier way to do this which I've overlooked? If it's not present, would there be interest in having simple reflections like this in the Font interface?


Top
 Profile  
 
PostPosted: Thu Aug 09, 2012 9:23 pm 
Offline
Slick Zombie

Joined: Sat Jan 27, 2007 7:10 pm
Posts: 1467
Why do you want to use y-up? Slick assumes y-down for everything (sub images, input, rendering, render to texture, copyArea, etc). To save yourself a lot of heartache, I'd suggest just sticking with y-down (origin at top left). The reason we use y-down is (a) because it resembles Java2D more closely and (b) most 2D frameworks assume y-down (for e.g. any GUI framework), so most 2D programmers will be more familiar with it.

If you want a 2D framework that uses a different projection matrix, LibGDX might be a better choice. You have to specify the matrices yourself, and whether you want it y-up or y-down. :)


Top
 Profile  
 
PostPosted: Thu Aug 09, 2012 9:36 pm 
Offline

Joined: Thu Aug 09, 2012 8:42 pm
Posts: 3
If I were using more of the library, I'd definitely switch to upper-left origin, but I prefer lower-left since it makes more sense to me mathematically, and converting my existing lower-left-origin program would be kind of a pain.

At this point, I'm just using Slick for the fonts and asset loading. I was using Slick-Util instead, but it only includes the deprecated TrueTypeFont. I'd also be interested in including the newer Font classes in Slick-Util, and I guess adding such a feature would probably only be useful to that end. ;) I'll check out LibGDX and see if its font support is as nice as Slick's, and if not, I'll probably just hack a local copy for personal use.


Top
 Profile  
 
PostPosted: Thu Aug 09, 2012 9:44 pm 
Offline
Slick Zombie

Joined: Sat Jan 27, 2007 7:10 pm
Posts: 1467
It would be pretty easy to use AngelCodeFont and some custom rendering (see FontTest in the dev repo).

If you really need Unicode support or font generation on the fly, you'll probably end up needing to hack around a little with UnicodeFont's drawString method. (Alternatively, I could expose methods like getGlyph so users can handle rendering from outside UnicodeFont.)

If you're writing your own LWJGL game you'll probably want to use sprite batching (i.e. GLSL instead of immediate mode and display lists), so you will want to rewrite the drawString method anyways. :)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group