ENIGMA Development Environment
Website is in read-only mode due to a recent attack.

Pages: 1 2 »
  Print  
Author Topic: A replacement for draw_text  (Read 5879 times)
Offline (Unknown gender) Grundoko
Posted on: October 21, 2008, 06:23:01 PM
Member
Joined: Sep 2008
Posts: 22

View Profile Email
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?
Logged
Offline (Male) Rusky
Reply #1 Posted on: October 22, 2008, 07:23:58 PM

Resident Troll
Joined: Feb 2008
Posts: 954
MSN Messenger - rpjohnst@gmail.com
View Profile WWW Email
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.
Logged
Offline (Male) Josh @ Dreamland
Reply #2 Posted on: November 16, 2008, 09:05:35 AM

Prince of all Goldfish
Developer
Location: Pittsburgh, PA, USA
Joined: Feb 2008
Posts: 2951

View Profile Email
It's there in R3, assuming it functions. Does it...?

Check if it's on my list of corrected bugs in R3b
Logged
"That is the single most cryptic piece of code I have ever seen." -Master PobbleWobble
"I disapprove of what you say, but I will defend to the death your right to say it." -Evelyn Beatrice Hall, Friends of Voltaire
Offline (Unknown gender) Grundoko
Reply #3 Posted on: February 16, 2010, 02:37:19 PM
Member
Joined: Sep 2008
Posts: 22

View Profile Email
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.
Logged
Offline (Female) serprex
Reply #4 Posted on: February 16, 2010, 09:39:53 PM
Smooth ER
Developer
Joined: Apr 2008
Posts: 106

View Profile WWW
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
Logged
Offline (Male) Josh @ Dreamland
Reply #5 Posted on: February 17, 2010, 10:14:35 AM

Prince of all Goldfish
Developer
Location: Pittsburgh, PA, USA
Joined: Feb 2008
Posts: 2951

View Profile Email
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.
Logged
"That is the single most cryptic piece of code I have ever seen." -Master PobbleWobble
"I disapprove of what you say, but I will defend to the death your right to say it." -Evelyn Beatrice Hall, Friends of Voltaire
Offline (Unknown gender) luiscubal
Reply #6 Posted on: February 17, 2010, 04:22:05 PM
Member
Joined: Jun 2009
Posts: 452

View Profile Email
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.)
Logged
Offline (Unknown gender) Grundoko
Reply #7 Posted on: February 17, 2010, 07:12:46 PM
Member
Joined: Sep 2008
Posts: 22

View Profile Email
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?
Logged
Offline (Male) Josh @ Dreamland
Reply #8 Posted on: February 17, 2010, 08:26:05 PM

Prince of all Goldfish
Developer
Location: Pittsburgh, PA, USA
Joined: Feb 2008
Posts: 2951

View Profile Email
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.
Logged
"That is the single most cryptic piece of code I have ever seen." -Master PobbleWobble
"I disapprove of what you say, but I will defend to the death your right to say it." -Evelyn Beatrice Hall, Friends of Voltaire
Offline (Male) RetroX
Reply #9 Posted on: February 17, 2010, 10:16:35 PM

Master of all things Linux
Contributor
Location: US
Joined: Apr 2008
Posts: 1055
MSN Messenger - classixretrox@gmail.com
View Profile Email
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.
« Last Edit: February 17, 2010, 10:19:24 PM by RetroX » Logged
My Box: Phenom II 3.4GHz X4 | ASUS ATI RadeonHD 5770, 1GB GDDR5 RAM | 1x4GB DDR3 SRAM | Arch Linux, x86_64 (Cube) / Windows 7 x64 (Blob)
Quote from: Fede-lasse
Why do all the pro-Microsoft people have troll avatars? :(
Offline (Male) Josh @ Dreamland
Reply #10 Posted on: February 18, 2010, 07:09:43 AM

Prince of all Goldfish
Developer
Location: Pittsburgh, PA, USA
Joined: Feb 2008
Posts: 2951

View Profile Email
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.
Logged
"That is the single most cryptic piece of code I have ever seen." -Master PobbleWobble
"I disapprove of what you say, but I will defend to the death your right to say it." -Evelyn Beatrice Hall, Friends of Voltaire
Offline (Unknown gender) Grundoko
Reply #11 Posted on: February 18, 2010, 02:24:31 PM
Member
Joined: Sep 2008
Posts: 22

View Profile Email
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.
Logged
Offline (Unknown gender) luiscubal
Reply #12 Posted on: February 18, 2010, 04:58:02 PM
Member
Joined: Jun 2009
Posts: 452

View Profile Email
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.
Logged
Offline (Male) Josh @ Dreamland
Reply #13 Posted on: February 18, 2010, 06:51:21 PM

Prince of all Goldfish
Developer
Location: Pittsburgh, PA, USA
Joined: Feb 2008
Posts: 2951

View Profile Email
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...)
Logged
"That is the single most cryptic piece of code I have ever seen." -Master PobbleWobble
"I disapprove of what you say, but I will defend to the death your right to say it." -Evelyn Beatrice Hall, Friends of Voltaire
Offline (Male) RetroX
Reply #14 Posted on: February 18, 2010, 10:09:43 PM

Master of all things Linux
Contributor
Location: US
Joined: Apr 2008
Posts: 1055
MSN Messenger - classixretrox@gmail.com
View Profile Email
It's probably converted during the massive "LOADING" part of the game.
Logged
My Box: Phenom II 3.4GHz X4 | ASUS ATI RadeonHD 5770, 1GB GDDR5 RAM | 1x4GB DDR3 SRAM | Arch Linux, x86_64 (Cube) / Windows 7 x64 (Blob)
Quote from: Fede-lasse
Why do all the pro-Microsoft people have troll avatars? :(
Pages: 1 2 »
  Print