VDP_drawText - palette index colour
Moderator: Stef
VDP_drawText - palette index colour
I've not looked at this in great depth but is it possible to assign a different colour from a palette to text or is the function hardwired to use colour 0 in the palette you assign to it?
I'd like to make full use of a single palette for text colours
I'd like to make full use of a single palette for text colours
-
- Very interested
- Posts: 117
- Joined: Sun Jan 02, 2011 9:14 pm
- Contact:
Re: VDP_drawText - palette index colour
Font is just usual tiles. Call VDP_setTextPalette() to use another palette. Also you can change the color/s used by the font with VDP_setPaletteColor() or similar functions
-
- Very interested
- Posts: 3131
- Joined: Thu Nov 30, 2006 9:46 pm
- Location: France - Sevres
- Contact:
Re: VDP_drawText - palette index colour
If you define your own font with characters using several color then it will display in several colors, that is what you mean ?
And as said Moon-Watcher you can change the palette currently used to display text
And as said Moon-Watcher you can change the palette currently used to display text
Re: VDP_drawText - palette index colour
I gather the default uses positions 0 for forecolour and 15 for back colour. I want to use PAL0 and have it so different colours can be used for different sections of text: 0 15, 1 15, 2 15, etc
I can't swap palettes as my APLAN uses PAL0 for the text, PAL1 for the layout, PAL2 for the background scene on BPLAN and PAL3 for the sprites.
I can't swap palettes as my APLAN uses PAL0 for the text, PAL1 for the layout, PAL2 for the background scene on BPLAN and PAL3 for the sprites.
-
- Very interested
- Posts: 3131
- Joined: Thu Nov 30, 2006 9:46 pm
- Location: France - Sevres
- Contact:
Re: VDP_drawText - palette index colour
Oh in this case no, you cannot do that unfortunately... at least 0 is always the "transparent" color and the font tiles are hardwired in SGDK so you cannot use severals font at same time. At best you can change font at some point but that is not what you want.matteus wrote:I gather the default uses positions 0 for forecolour and 15 for back colour. I want to use PAL0 and have it so different colours can be used for different sections of text: 0 15, 1 15, 2 15, etc
I can't swap palettes as my APLAN uses PAL0 for the text, PAL1 for the layout, PAL2 for the background scene on BPLAN and PAL3 for the sprites.
Re: VDP_drawText - palette index colour
Stef how do I go about changing the font?
-
- Very interested
- Posts: 3131
- Joined: Thu Nov 30, 2006 9:46 pm
- Location: France - Sevres
- Contact:
Re: VDP_drawText - palette index colour
You just need to replace the standard font by your own with :
where font is a TileSet, you can look into SGDK about how to declare it :
https://github.com/Stephane-D/SGDK/blob ... libres.res
Code: Select all
u16 VDP_loadFont(const TileSet *font, u8 use_dma)
https://github.com/Stephane-D/SGDK/blob ... libres.res
Re: VDP_drawText - palette index colour
Ohhhh so I declare the image as a palette as well!!!
Re: VDP_drawText - palette index colour
How do I set the font's palette?
-
- Very interested
- Posts: 3131
- Joined: Thu Nov 30, 2006 9:46 pm
- Location: France - Sevres
- Contact:
Re: VDP_drawText - palette index colour
If you declare your font as an image then you can use its TileSet to set the font with the method i introduced before.
For the palette you can change it as you want by using the VDP_setPalette(..) method so you can use the specific font palette (declared in the IMAGE resource) but you can also use any other you prefer.
By default drawText(..) method use palette 0 but you can change the palette index to use with VDP_setTextPalette(...) (as already mentioned by Moon-Watcher)
For the palette you can change it as you want by using the VDP_setPalette(..) method so you can use the specific font palette (declared in the IMAGE resource) but you can also use any other you prefer.
By default drawText(..) method use palette 0 but you can change the palette index to use with VDP_setTextPalette(...) (as already mentioned by Moon-Watcher)
Re: VDP_drawText - palette index colour
I can't get this to work!
VDP_loadFont(&font_lib, TRUE);
VDP_loadFont(&font_lib, TRUE);
Re: VDP_drawText - palette index colour
I think I've got a problem do I need to set the palette of a PLAN before loading an image?
VDP_drawImageEx(BPLAN, image, TILE_ATTR_FULL(PAL2, FALSE, FALSE, FALSE, ind), STAGE_POSITION_X, STAGE_POSITION_Y, FALSE, TRUE);
This statement should load the image into BPLAN and load its palette into PAL2? Yes? or do I also have to set the PAL2 to the palette data of the image?
VDP_drawImageEx(BPLAN, image, TILE_ATTR_FULL(PAL2, FALSE, FALSE, FALSE, ind), STAGE_POSITION_X, STAGE_POSITION_Y, FALSE, TRUE);
This statement should load the image into BPLAN and load its palette into PAL2? Yes? or do I also have to set the PAL2 to the palette data of the image?
-
- Very interested
- Posts: 3131
- Joined: Thu Nov 30, 2006 9:46 pm
- Location: France - Sevres
- Contact:
Re: VDP_drawText - palette index colour
Just look into the SGDK source, i'm using :
and it does work. Use emulator debugger to understand why your font is not loaded.
Just to be sure, did you named your variable 'font_lib' ? In which case it could conflict with the internal 'font_lib' variable
Code: Select all
if (!VDP_loadFont(&font_lib, FALSE))
...
Just to be sure, did you named your variable 'font_lib' ? In which case it could conflict with the internal 'font_lib' variable
Re: VDP_drawText - palette index colour
Okay forgot the FLAG lol but seem to still have a problem! lol
It's this line that's the problem! VDP_fadeIn(32, 47, palette, 30, FALSE);
I thought this would only fade in 32 to 47 (pal2?) but it seems to clear all colours in palette 0 to black too?
It's this line that's the problem! VDP_fadeIn(32, 47, palette, 30, FALSE);
I thought this would only fade in 32 to 47 (pal2?) but it seems to clear all colours in palette 0 to black too?
Code: Select all
VDP_setPaletteColors(32, BlackPalette, 47);
VDP_drawImageEx(BPLAN, image, TILE_ATTR_FULL(PAL2, FALSE, FALSE, FALSE, ind), STAGE_POSITION_X, STAGE_POSITION_Y, FALSE, TRUE);
VDP_fadeIn(32, 47, palette, 30, FALSE);
Re: VDP_drawText - palette index colour
Code: Select all
VDP_setPaletteColors(32, BlackPalette, 16);