Welcome! Log In Create A New Profile

Advanced

Text display using Wii DevKitPro libraries

Posted by csanii 
Text display using Wii DevKitPro libraries
January 29, 2011 10:52PM
I am coding a game and after getting part way through decided to use Dolphin to speed up the code/debug/test process. Initially I was just using "printf" console output to get scores and text to appear but on Dolphin that doesn't seem to work. So my question is are there any built in functions for displaying text on a graphics screen using the DevKitPro libraries or do I have to use an external library and/or code my own? I looked into the DevKitPro files and examples but could not find any info. I suspect to code my own I load a graphic file with all the characters in it and then just increment the top-left and bottom-right pointers to display the character in question. Is there a better/simpler way to do this?
Re: Text display using Wii DevKitPro libraries
January 30, 2011 03:31PM
Dolphin hooks the printf() function and redirects the output to its log window. If you want it to show console output in the regular display window go to the graphics config->advanced tab, tick the XFB "Enable" box and set it to "Real". Note that this will slow down the emulation considerably at the cost of making it act more like a real console.
Re: Text display using Wii DevKitPro libraries
January 30, 2011 03:43PM
Quote
tueidj
Dolphin hooks the printf() function and redirects the output to its log window. If you want it to show console output in the regular display window go to the graphics config->advanced tab, tick the XFB "Enable" box and set it to "Real". Note that this will slow down the emulation considerably at the cost of making it act more like a real console.

Great! That will help me with my debugging.
Do you know if there is also a "built in" print text on a graphics screen function ?
Re: Text display using Wii DevKitPro libraries
January 30, 2011 04:07PM
Nothing simple. There are probably a few graphics libraries that can make it easier but I've only ever done it manually (loading a font into a texture, load the texture into the graphics hardware, render the appropriate portion of the texture for each letter at the target location as a quad or triangle fan primitive...)
Re: Text display using Wii DevKitPro libraries
January 31, 2011 01:02AM
There is a simple way, the "console_init" function sets up a simple text console on the screen. Most starting tutorials and templates use it.
Re: Text display using Wii DevKitPro libraries
January 31, 2011 01:39AM
I assumed he meant overlaying text on graphics rather than a text console.
Re: Text display using Wii DevKitPro libraries
January 31, 2011 10:41AM
You can use this very simple font engine to draw characters using the internal Wii FONT.
[code.google.com]

Usage is to call FONT_Init once after having initialized Video then call FONT_write functions to render text on screen in different ways (centered, aligned, etc). The DrawChar function is the basis of character drawing using GX rendering.

It's probably not usable "out of the box" as you need to configure Video and GX in libogc first and you also need to refresh the screen (EFB->XFB copy) as in any application using GX but I'm assuming you know how to do that already.

Here's the GX config I use for menu rendering so I can render text over images with transparency support:

GX_ClearVtxDesc();

 GX_SetBlendMode(GX_BM_BLEND,GX_BL_SRCALPHA,GX_BL_INVSRCALPHA,GX_LO_CLEAR);
 GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XY, GX_S16, 0);
 GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_CLR0, GX_CLR_RGBA, GX_RGBA8, 0);
 GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX0, GX_TEX_ST, GX_F32, 0);
 GX_SetVtxDesc(GX_VA_POS, GX_DIRECT);
 GX_SetVtxDesc(GX_VA_TEX0, GX_DIRECT);
 GX_SetVtxDesc (GX_VA_CLR0, GX_DIRECT);
 /* 
       Color.out = Color.rasterized*Color.texture
       Alpha.out = Alpha.rasterized*Alpha.texture 
 */
 GX_SetTevOp (GX_TEVSTAGE0, GX_MODULATE);
 GX_SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR0A0);
 GX_SetNumTexGens(1);
 GX_SetNumChans(1);
 GX_Flush();
Re: Text display using Wii DevKitPro libraries
February 01, 2011 02:24AM
Thanks ekeeke, your GX code config is almost identical to what I have in my code already.
The difference I think is that I have GX_F32 and you have GX_S16 and I don't have a line of code with GX_VA_CLR0.

I'll have to go through the google code to see how I can make that work me.
Sorry, only registered users may post in this forum.

Click here to login