ENIGMA Forums

Outsourcing saves money => Issues Help Desk => Topic started by: Grundoko on October 21, 2008, 06:23:01 PM

Title: A replacement for draw_text
Post by: Grundoko on October 21, 2008, 06:23:01 PM
I need any way to draw text. I can't believe thats not there. Text is very basic -_-
Even if I could have a sprite for each character, could I make some kind of system so I could use that?
Title: Re: A replacement for draw_text
Post by: Rusky on October 22, 2008, 07:23:58 PM
Text really isn't all that simple.
As for a replacement, use cpp tags and figure out how to draw text in OpenGL, check out the engine source code and see if you can get something working.
Title: Re: A replacement for draw_text
Post by: Josh @ Dreamland on November 16, 2008, 09:05:35 AM
It's there in R3, assuming it functions. Does it...?

Check if it's on my list of corrected bugs in R3b
Title: Re: A replacement for draw_text
Post by: Grundoko on February 16, 2010, 02:37:19 PM
So, my old topic is old, over a year old in fact. But anyway, is there any alternative for draw_text at this point?
I'm using R3b, it's listed as not started in the functions list, and does not do anything when I use it.

Anyone have a C++ alternative?

I'd really like to get into Enigma, because I'm being limited by Game Maker's slow execution of code, and something as simple as draw_text would be very helpful to me. Thanks.
Title: Re: A replacement for draw_text
Post by: serprex on February 16, 2010, 09:39:53 PM
Stop calling text simple. If you want a replacement, you could put together a sprite based implementation. Preferably, an implementation would make use of 1bit images embedded in the binary of the font for portability. Therefore, the compiler has to be updated thusly. Doing so in the R3 compiler would raise snark from Josh. Once that's done, one would have to add a facility to EnigmaSys to process the embedded fonts into textures or some other such form which would appeal to the actual rendering functions
Title: Re: A replacement for draw_text
Post by: Josh @ Dreamland on February 17, 2010, 10:14:35 AM
Draw_text has been my least favorite function to implement due to deciding how to handle newlines. Presently, ENIGMA (R3) uses GL lists to hold the instructions for drawing individual glyphs. When you call draw_text, the string you pass is iterated by the card (ideally) with a single GL call. This is quite efficient, but it creates ugly glyphs and makes newlines impossible. The reason for that is simple; GL lists can't interface with variables on the RAM. Each time a glyph is drawn, the drawing window is translated in the viewport, and the list for that glyph is called. There is no way to preserve the starting location. That leaves me with the option of making my own pass, or just drawing the glyphs in myself, both of which are unattractive choices.

When you call draw_text in Game Maker, it doesn't do any of those things. It iterates the string itself, yes, but then it draws a sprite corresponding to the desired glyph, as serp suggested. This leaves a bad taste in my mouth for a number of reasons, but seems to be the best way to mimmic Game Maker.

Perhaps the other, more efficient technique can be implemented as a backup feature.
Title: Re: A replacement for draw_text
Post by: luiscubal on February 17, 2010, 04:22:05 PM
How about checking how existent open-source engines do it currently? I think reusing an existent library is way better than doing your own in a field as complex as text rendering(and, yes, it is complex - just think of ASCII vs Unicode, multiple fonts, curved paths, etc.)
Title: Re: A replacement for draw_text
Post by: Grundoko on February 17, 2010, 07:12:46 PM
Sorry, I didn't realise how complicated text could be. I don't know much about more difficult languages, though I'm trying to learn C++, I only know as much as C++ for Dummies teaches so far, which is very little (Command Prompt Only).

Can someone provide me with a C++ code I could use to replace draw_text?
Title: Re: A replacement for draw_text
Post by: Josh @ Dreamland on February 17, 2010, 08:26:05 PM
Luis:
That would definitely be a consideration if GM was unicode-friendly, but since we know exactly how GM does it, I don't think that's a good idea here. Perhaps for future extensions of draw_text (Listen to us talking about drawing text like we're some sort of connoisseurs. Hmph).

Grundoko:
No worries; our job is to make it look harmlessly simple. I pretty much failed at that in R3, but hey, "if at first you don't succeed, call it the beta."
I don't think anyone can just throw together some code to do so... Perhaps the stuff in R4 has been fixed since. Serp would probably know.
Title: Re: A replacement for draw_text
Post by: RetroX on February 17, 2010, 10:16:35 PM
Luis:
That would definitely be a consideration if GM was unicode-friendly, but since we know exactly how GM does it, I don't think that's a good idea here. Perhaps for future extensions of draw_text (Listen to us talking about drawing text like we're some sort of connoisseurs. Hmph).
You could probably just check how SFML does it because while it is Unicode-friendly, it probably won't be too far-off.

Also, it makes sense to support both Unicode and ASCII, because there's no point in limiting it to how GM does it.
Title: Re: A replacement for draw_text
Post by: Josh @ Dreamland on February 18, 2010, 07:09:43 AM
The GM way is nicer-looking, but completely incompatible with the unicode way (unless, as I assume, SFML went to the trouble of anti-aliasing their gylphs).
I can't store a sprite for each of two byte's worth of glyphs.
Title: Re: A replacement for draw_text
Post by: Grundoko on February 18, 2010, 02:24:31 PM
Are you sure they convert each character to a sprite? You can use any font in Game Maker, so they'd have to convert it upon building the exe.
And for R4, even if you do it a different way that Game Maker, it would be better. A weak but functional text script, is better than none, as for me, and I'm assuming many other people, text is something that is used very often.
Title: Re: A replacement for draw_text
Post by: luiscubal on February 18, 2010, 04:58:02 PM
Does GM really store a sprite per char on the exe?
I'd say it would be much more likely to just generate that sprite on runtime, considering that both the font name and the text can be variable, and that generating whole lines at once would be much more efficient, in my opinion.
Title: Re: A replacement for draw_text
Post by: Josh @ Dreamland on February 18, 2010, 06:51:21 PM
Both:
GM can use any sprite the *creator* has installed (it can import any sprite the end user has installed at runtime). Being able to render custom fonts is proof *something* is stored in the EXE. Transforming text causes pixelation. That means it's being stored as a bitmap before draw; whether before load time is unknown at this point. We can't prove it doesn't store the actual font file in the exe with what we know here; you'll just have to take my word for it that it is in fact part of the GM exe format. (And I know this for a fact, so unless I've been miserably mistaken for a long time...)
Title: Re: A replacement for draw_text
Post by: RetroX on February 18, 2010, 10:09:43 PM
It's probably converted during the massive "LOADING" part of the game.
Title: Re: A replacement for draw_text
Post by: notachair on February 19, 2010, 12:55:58 AM
Being able to render custom fonts is proof *something* is stored in the EXE.

And the fact that the font smoothing isn't anything like Windows'
Title: Re: A replacement for draw_text
Post by: Josh @ Dreamland on February 19, 2010, 11:11:46 AM
Retro:
That's when decryption is done and trees are generated.

a2h:
I'm not sure why that's the case. Maybe he does the smoothing himself. O_o
Title: Re: A replacement for draw_text
Post by: RetroX on February 19, 2010, 12:31:26 PM
Retro:
That's when decryption is done and trees are generated.
It still could be done during the loading screen.
Title: Re: A replacement for draw_text
Post by: Grundoko on February 19, 2010, 12:32:21 PM
I have to put my vote towards doing it in the loading screen, or when draw_text is called, not upon building the .exe, because if the font is not on your computer, Game Maker uses the default font.
Title: Re: A replacement for draw_text
Post by: RetroX on February 19, 2010, 06:54:28 PM
I have to put my vote towards doing it in the loading screen, or when draw_text is called, not upon building the .exe, because if the font is not on your computer, Game Maker uses the default font.
...are you suggesting that this should be done in ENIGMA?  ENIGMA won't have a loading screen; it's compiled, and will start instantly.

Unless you mean that you think that GM does it that way.
Title: Re: A replacement for draw_text
Post by: Grundoko on February 19, 2010, 08:53:44 PM
No, GM's way is horrible. I'm just saying, that's how I think GM does it.
Title: Re: A replacement for draw_text
Post by: Rusky on February 20, 2010, 12:18:34 PM
GM's loading screen cannot be eliminated by compilation. What on earth gave you that idea?
Title: Re: A replacement for draw_text
Post by: Josh @ Dreamland on February 20, 2010, 12:53:20 PM
Quote
GM's loading screen cannot be eliminated by compilation. What on earth gave you that idea?
The fact that at present, ENIGMA doesn't have one. Most things that compile in ENIGMA have presently not been big enough to have a noticeable load time, so no one has really missed a loading bar. That will likely change in the future, so I'll have to install one that's on by default. Click the Clown should never require a loading bar. <_<"

And no, Game Maker uses the font the game was compiled with, whether it exists on the new computer or not.
Title: Re: A replacement for draw_text
Post by: Grundoko on February 20, 2010, 01:36:55 PM
Are you sure about that? I've made programs with Game Maker, and when testing on my Laptop, it would use Arial instead of Bauhaus'93 (Which comes with Microsoft Office, and is not on my Laptop) But on my desktop it shows up fine.
Title: Re: A replacement for draw_text
Post by: Micah on February 20, 2010, 02:53:53 PM
When testing on your laptop, did you run from an executable or an editable?
Title: Re: A replacement for draw_text
Post by: Josh @ Dreamland on February 20, 2010, 11:09:09 PM
The GM6 doesn't store font glyphs as bitmap, they store it by font name. EXE stores the bitmaps.
Title: Re: A replacement for draw_text
Post by: Grundoko on February 21, 2010, 12:04:26 PM
So your right, I was testing with the .gmk