Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (781)
Games in Android Showcase (233)
games submitted by our members
Games in WIP (857)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Why was it so hard to get font rendering working with lwjgl?  (Read 2501 times)
0 Members and 1 Guest are viewing this topic.
Offline LiquidNitrogen
« Posted 2014-02-03 08:52:38 »

I had to mess around with so many different things to render some simple TTF text to the screen. The text displayed as a solid block of color... and the only way i managed to fix that was to pick a texture at random to bind just before rendering the text, which doesnt make any sense at all since at all since I have been binding various textures all through the map rendering code. spent several hours trawling google.

Is there any definitive info on the subject for people to get basic text working quickly and correctly?
Offline princec

« JGO Spiffy Duke »

Medals: 1064
Projects: 3
Exp: 20 years

Eh? Who? What? ... Me?

« Reply #1 - Posted 2014-02-03 09:43:56 »

LWJGL doesn't have anything to do with font rendering, is probably why. It's just pure OpenGL. You probably want to use some code somewhere from someone else rather than get bogged down rolling your own.

Cas Smiley

Offline Roquen

JGO Kernel

Medals: 518

« Reply #2 - Posted 2014-02-03 13:23:56 »

Yeah don't roll your own....there's no margin in it.  I have zero clue about java libraries, but if you answer a few questions somebody might be able to point you in the right direction.

1) Fixed and/or variable width fonts?
2) If variable do you want kerning?
3) Fixed size(s)?  And if so production or runtime?
4) Are any of these going to smoothly scale at runtime? (signed distance field)

Those are the main ones that come to mind.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline xsvenson
« Reply #3 - Posted 2014-02-03 15:24:07 »

Without really knowing Your needs, You might also find help from alternative approaches.
For example quite a few games pre-render the need fonts as bitmap fonts and then use the bitmap fonts in game/app.
Hiero with libgdx

Then there is also this alternative:

“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
Offline LiquidNitrogen
« Reply #4 - Posted 2014-02-03 20:13:05 »

I was trying to get a quick font to render so that i could observe a few variable values onscreen in real time.

perhaps an alternative would have been to open up a new window to the side of the screen and use plain java stuff to display values to that?
Offline Opiop
« Reply #5 - Posted 2014-02-03 20:15:02 »

No, don't do that. Use Slick-Util. Its just a few lines of code to implement font rendering, and its relatively painless. Using Java2D to draw strings in a LWJGL based program is more complex than you think, and it's pointless.
Offline LiquidNitrogen
« Reply #6 - Posted 2014-02-03 20:18:01 »

i am using slick-util in my project. i ended up having to bind a texture just before rendering the TTF, I dont understand why that would make any difference.
Offline Opiop
« Reply #7 - Posted 2014-02-03 20:19:50 »

You have to bind the font texture I believe. It makes sense because OpenGL is a state based machine.
Pages: [1]
  ignore  |  Print  

hadezbladez (1165 views)
2018-11-16 13:46:03

hadezbladez (525 views)
2018-11-16 13:41:33

hadezbladez (1187 views)
2018-11-16 13:35:35

hadezbladez (272 views)
2018-11-16 13:32:03

EgonOlsen (2567 views)
2018-06-10 19:43:48

EgonOlsen (2786 views)
2018-06-10 19:43:44

EgonOlsen (1564 views)
2018-06-10 19:43:20

DesertCoockie (2269 views)
2018-05-13 18:23:11

nelsongames (2121 views)
2018-04-24 18:15:36

nelsongames (2815 views)
2018-04-24 18:14:32
Deployment and Packaging
by philfrei
2019-02-17 20:25:53

Deployment and Packaging
by mudlee
2018-08-22 18:09:50

Java Gaming Resources
by gouessej
2018-08-22 08:19:41

Deployment and Packaging
by gouessej
2018-08-22 08:04:08

Deployment and Packaging
by gouessej
2018-08-22 08:03:45

Deployment and Packaging
by philfrei
2018-08-20 02:33:38

Deployment and Packaging
by philfrei
2018-08-20 02:29:55

Deployment and Packaging
by philfrei
2018-08-19 23:56:20 is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!