Game Development Community

How to write vertical text?

by Cosmic Logic · in Torque X 2D · 10/23/2010 (7:05 am) · 5 replies

Hey,


I'm getting in to optimization for the first time in my game-making career and, needless to say, I'm learning a lot.

One thing I'm trying to do is merely write the player's name vertically down the side. It works and all, except it's taking 29-42% (60-70% on my PC) of my total processing time on the xbox.

All I've done is taken the gamer tag string, broken it down and added a newline after every letter. I've then put this new string in to a GUIMLText.

The problem with how GUIMLText works is that it calls a draw command on every newline, or in this case every letter. That's 8 individual draw calls per frame with my gamertag (including the space...).

Is there a better way to do this? I'm not particularly familiar with basic XNA draw commands. I started with Torque X. But, if there's a way to manually write out these strings that would be awesome.

#1
10/23/2010 (1:35 pm)
Best approach is to render the text to a texture once and then re-use it. You will have to use XNA drawing to do that though. On the other hand, once you've assigned the texture to an instance of SimpleMaterial and put the texture on an object then you can move, rotate, etc, just as you normally would.
#2
10/23/2010 (5:54 pm)
Awesome. I'll hit up the Creator's club website to find out how to do that. I was thinking something like that must be possible.

Thanks.
#3
10/27/2010 (2:52 am)
I am going to be working on a "text to image" component in the next few days that will allow one to display text or numbers from a string form into a rendered graphical text. The component will use a sprite sheet that contains pre-rendered numbers and letters and then will be able to transform any text into the graphical format.

It should be "Light Weight" and will have the ability to rotate it.

#4
10/27/2010 (1:15 pm)
A better option would be to use XNA text rendering to render using a spritefont instead of using a spritesheet (a spritefont being essentially a spritesheet for text).

NOTE: spritefonts can be provided to XNA as a simple bitmap, so you can pre-render or modify the font in anyway you like before adding it to your game.
#5
10/28/2010 (3:23 am)
Rendering it to a texture and then making a material out of it was super lightweight. I can toss you the code if you want it. It's pretty simple. From there you can just set that material on a sceneobject and then you can rotate it all you like.