IAGSFontRenderer example

Started by Dualnames, Tue 26/03/2019 21:28:40

Previous topic - Next topic

Dualnames

So I've been reading about IAGSFontRenderer and it looks wonderful and perfect for what I wanna do.
I know how to get the part of what I wanna do (add an extra outline and a gradient effect) done, but my issue lies that I'm not able to make a plugin to work
Is there some sort of easy example,where I can replace the font renderer for font 1 let's say and use the RenderText() function so that I can 'edit' that bitmap?

I've tried looking at the agspritefont code, but there's parts of it that I'm not sure I get or need. So if anyone knows of a simple script to get me rolling that'd be nice.
Like a script that turns all the instances of a certain font to red, that'd be very useful and I could move on from there.
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

Dualnames

To elaborate, I don't want to change the width of a font or the height, I just want to read the bitmap it returns, edit the bitmap and push it back to the screen, which is what Render does, but my efforts so far have only managed to get me to print an empty font on the screen as if I'm printing a cleared bitmap.
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

Crimson Wizard

#2
Quote from: Dualnames on Tue 26/03/2019 22:43:54
To elaborate, I don't want to change the width of a font or the height, I just want to read the bitmap it returns, edit the bitmap and push it back to the screen, which is what Render does, but my efforts so far have only managed to get me to print an empty font on the screen as if I'm printing a cleared bitmap.

I don't think that's possible, the idea of IFontRenderer is that you supply your own data (bitmaps or else). The bitmap it gives to you in Render is destination, a clear bitmap where you need to draw the text.
You would have to read a bitmap font from disk probably if you want to adjust it before displaying on screen.

Dualnames

Alright better question, is there a way to pool/pull said bitmap from the engine, or does that heavily depend on renderer (software, d3d, opengl)?

What I'm also wondering is, is there an 'easy' way to render the font exactly as ags renders it and use render text then? I'm still trying to grasp the whole renderer thing, so apologies if I sound like bicilotti.
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

Crimson Wizard

#4
Quote from: Dualnames on Tue 26/03/2019 23:53:14
Alright better question, is there a way to pool/pull said bitmap from the engine, or does that heavily depend on renderer (software, d3d, opengl)?
If you mean - get bitmap with text just drawn on it, then answer is no. Plugin hooks only allow you to get "stage bitmap" which is a layer before room drawn / between room and gui / after gui.

Quote from: Dualnames on Tue 26/03/2019 23:53:14
What I'm also wondering is, is there an 'easy' way to render the font exactly as ags renders it and use render text then?

May I ask, what exactly are you trying to achieve?

If it is enough for you to draw some text in between rendering stages, e.g. over a room or over whole game, then you may use DrawText from plugin interface and then GetVirtualScreen to get screen bitmap with that text, which you may then edit further.

If you are drawing on some object, you could print it on Dynamic sprite in script and then work with that further (also in script).

But if you want to be able to adjust just any text in game no matter when and where it is drawn (GUI, speech, etc), then can't think of an easy way to do so. You may have to duplicate font drawing code from the engine in your IAGSFontRenderer implementation, and do necessary modifications to it.

Dualnames

I'm trying to apply a gradient effect on fonts, I've managed to do it in code, and it's great and all, just it creates a couple of issues as well, and i think if i could redraw my font and edit that, it'd be better and more certain.
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

Crimson Wizard

This may mean that plugin API is missing another type of hook: for getting intermediate bitmap with text before it gets drawn on screen.
On other hand, 1) text may be drawn on something else, like GUI bitmap; 2) someone suggested we switch to textures completely in the future. So that may not be a good idea to add.

Perhaps better alternative is to allow plugins to load in-game resources, which will let you use fonts from the main package, and draw them the way you like (assuming you copy font code from the engine).
Right now it will only work if you load fonts from game folder.

Kweepa

Quote from: Dualnames on Tue 26/03/2019 23:53:14
apologies if I sound like bicilotti.
Damn, harsh.
Also, what happened to that guy?  :~(
Still waiting for Purity of the Surf II

Dualnames

He's definitely around in irc!
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

Dualnames

Anyhoo, I've managed to clean up my ags code so it seems to be working fine so need to set up the plugin.
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

Dualnames

Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

SMF spam blocked by CleanTalk