Handmade Hero»Forums»Code
Anders
20 posts
Professional (non-game)developer living in Stockholm, Sweden. Born '84. Gamer since five years of age, computer nerd since six.
DEBUGOverlay & DEBUGTextLine (day 180) and Windows 10
Edited by Anders on
Hello, I've just finished with day 180, but my debug cycle count texts aren't rendered like they are in Casey's video. I've verified it's not a code error, because I built it once with Casey's source code to verify I hadn't messed something up, and I get the exact same results then.

Basically, it's the formatting of text into columns that's different, and the font itself looks a bit weird too.

Which leaves the underlying platform. Is this perhaps because I run on Win 10 now and the video was made on Win 7? If anyone can shed some light on this issue I'd be very grateful. I'd like to understand it. :)

This is what it looks like:

Simon Anciaux
1337 posts
DEBUGOverlay & DEBUGTextLine (day 180) and Windows 10
I ran day 180 from Casey and it works on Windows 7 and Windows 10 (text is aligned properly). I used the hhas from "handmade_hero_legacy_art.zip" v0_hhas. Have you tried using those hhas ?

Otherwise it's most likely that you've got a bug in the text layout function. It looks like you're not advancing properly after each character, or that you're not using the right size to advance (e.g. if you scaled the font you need to scaled the advance too).

Your font doesn't look like the one Casey is using. That might also be a problem if you are using graphics from one font with metrics from another one (or there is a problem with how handmade hero handle the metrics, that just work with certain fonts ?).
Anders
20 posts
Professional (non-game)developer living in Stockholm, Sweden. Born '84. Gamer since five years of age, computer nerd since six.
DEBUGOverlay & DEBUGTextLine (day 180) and Windows 10
Edited by Anders on
Hm, interesting. Thanks for letting me know.

The weird part though is that I compiled Casey's code as well and got the same thing. Now that I think about it however, I never re-ran the test_asset_builder using Casey's compiled code, I only used his handmade.exe with MY hha's. So it could indeed be a bug in my version of the test_asset_builder...

I'll try that, and if that doesn't change anything I'll try with those hha's you mentioned.

Cheers


UPDATE

Ok, so, this is somewhat interesting. First I reran the test_asset_builder.exe on my machine, compiled using Casey's source code. Using win32_handmade.exe compiled using Casey's source code. And I got the same problem as before.

But when I dropped those hha's you linked into the directory instead, it worked! Everything looked ok with those.

So now the question is: why does the test_asset_builder.exe (both mine and Casey's version) create weird hha's when run on my machine?
Anders
20 posts
Professional (non-game)developer living in Stockholm, Sweden. Born '84. Gamer since five years of age, computer nerd since six.
DEBUGOverlay & DEBUGTextLine (day 180) and Windows 10
Edited by Anders on
Alright, I found out why this happened.

I did not have liberation mono in my Fonts folder. *facepalm*

I guess CreateFontA grabs the closest thing, or some default Font, instead.
Mārtiņš Možeiko
2559 posts / 2 projects
DEBUGOverlay & DEBUGTextLine (day 180) and Windows 10
Edited by Mārtiņš Možeiko on
No need to guess. CreateFont documentation clearly states:

Because available fonts can vary from system to system, do not assume that the selected font is always the same as the requested font. For example, if you request a font named Palatino, but no such font is available on the system, the font mapper will substitute a font that has similar attributes but a different name.


Also here: Font Substitution

If font looks wrong on screen that means there are some bugs in HH code that does not do measurements generic enough. They seem to work for font Casey chose, but they calculations are not universal enough for other fonts.
Anders
20 posts
Professional (non-game)developer living in Stockholm, Sweden. Born '84. Gamer since five years of age, computer nerd since six.
DEBUGOverlay & DEBUGTextLine (day 180) and Windows 10
Very true mmozeiko!

Thanks for the information :)