Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / DrawSprite() equivelent for Text

Author
Message
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 21st Dec 2017 04:08 Edited at: 21st Dec 2017 08:07
Question #1 : I'm trying to render some text (font) to an image. Is there a similar function to DrawSprite() only for text or do i need to do something else?

Question #2: I am using render to image in my example. I setvirtualesolution to 512x256, draw a 512x256 red box. I expect to end up with a red box but it is shrunk vertically and has borders. What am i doing wrong?
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 21st Dec 2017 10:04 Edited at: 21st Dec 2017 10:05
When you renderToImage, the image always uses the ratio of the screen.
You can fix this with some simple mathematics, but to unravel the confusion I always use a render image the same size as the screen, then extract the portion that I want to keep. This method only works if you are rendering images prior to gameplay. It is too slow for realtime image rendering.

Simply positioning the text is enough to grab the text in your render image.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 21st Dec 2017 12:33
i made some test and i think its a bug, it also not work with correct SetDisplayAspect
AGK (Steam) V2017.12.12 : Windows 10 Pro 64 Bit : AMD (17.12.1) Radeon R7 265 : Mac mini OS High Sierra (10.13)
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 21st Dec 2017 19:16
Quote: "When you renderToImage, the image always uses the ratio of the screen."

I'm sure i read somewhere that it didn't matter what the screen resolution was. I have a search for the quote

Quote: "This method only works if you are rendering images prior to gameplay. It is too slow for realtime image rendering."

What i am trying to do is render a high score to an image and then use it as a texture on a plane. This will need to happen every frame.
Any suggestions on how i should go about that?
Mobiius
Valued Member
21
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 22nd Dec 2017 08:48
Quote: "render a high score to an image and then use it as a texture on a plane. This will need to happen every frame"

No, you only need to create the image once.
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 22nd Dec 2017 09:47
Quote: "No, you only need to create the image once."

But the high score value changes EVERY frame. Do you have some same cade maybe so i can understand how it's done?
Scraggle
Moderator
21
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 22nd Dec 2017 11:19
If it's changing every frame then I presume you mean the current score rather than the high score?
Either way, why do you need to capture an image with the text on it?
Just use a background image (created once before the game starts) and apply the text over the top of it.
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 22nd Dec 2017 12:27
Quote: "I'm sure i read somewhere that it didn't matter what the screen resolution was. I have a search for the quote"


The screen resolution can be any size, but render image calculations must take account of this size.

Attached is code from an unpublished tutorial. It is a score display system that counts up rather than immediately showing the new score.



- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt

Attachments

Login to view attachments
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 22nd Dec 2017 23:40 Edited at: 22nd Dec 2017 23:43
Thanks BatVink i will check it out. Will i still have the issues of having to do it every frame though?


Quote: "Just use a background image (created once before the game starts) and apply the text over the top of it."


I want it to sit In the 3D scene so it is more readable. In 2D space it would be to small and look crappy

Attachments

Login to view attachments
smallg
Valued Member
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location: steam
Posted: 22nd Dec 2017 23:49 Edited at: 22nd Dec 2017 23:49
maybe create a bunch of 3d numbers from 0 - 9 and then break the score down into its individual units and display those instead?
i.e. 293 becomes 3 objects.
life's one big game
spec= 4ghz, 16gb ram, AMD R9 2700 gpu
puzzler2018
User Banned
Posted: 23rd Dec 2017 00:02
What we trying to achieve?

an Hiscore count that is in 3D space.

- could use setobjectimage to an 3d object and use the old frightful memblocks to appy each frame and grab an image every frame

im doing a magnifying glass at the moment which recreates images every frame (no fps lost).

once ive got it down to a tee, ill post
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 23rd Dec 2017 00:03 Edited at: 23rd Dec 2017 00:04
Quote: "maybe create a bunch of 3d numbers from 0 - 9 and then break the score down into its individual units and display those instead?"

That's a great idea! Maybe just squares with the number as a texture. that would only be a total of 120 tris

Thanks puzzler. Looking forward to that
Scraggle
Moderator
21
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 23rd Dec 2017 10:02 Edited at: 23rd Dec 2017 10:11
Now that we know what it is you're trying to achieve I would agree with the 3D text object approach.
And since it's for a pinball game you probably want something like an LED display, so I would model the crystals of the display and then turn then on/off depending on what letter/number you want to display.
I've already written code to do that in the AGK Coding Challenge thread.
Although that is for sprites not 3D objects but the principle is identcial.

[Edit]There is the same code further down the page but fully commented, here:
Fully Commented Version
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 23rd Dec 2017 19:07
Thanks scraggle! I will check it out

Login to post a reply

Server time is: 2024-11-24 05:45:10
Your offset time is: 2024-11-24 05:45:10