I use the following line to display my text:
D3DX.DrawText MainFont, &HFFCCCCFF, TextToDraw, TextRect, DT_TOP Or DT_CENTER
i read that there is a way to use a texture to display custom fonts....but the code for that is so huge for what i want to do....i just want to change the colour of my text :)......will i need to make a texture or is there something simpler? thanks :)
also...what does the &HFFCCCCFF do in my line of code above?
03-05-2002, 03:17 PM
The &HFFCCCCFF is the colour value, in the Hex format : AARRGGBB.
Lets say you have the amount of R, G, and B stored in byte variables called bR bG bB, in the range 0 to 255. The code then becomes:
D3DX.DrawText MainFont, &HFF000000 Or RGB(bB, bG, bR), TextToDraw, TextRect, DT_TOP Or DT_CENTER
You have to reverse the RGB order because VB and DX do things differently.
&HFF0000FF would be deep blue
&HFF00FF00 would be bright green
&HFFFF0000 would be red
&HFFFFFFFF would be white
&HFF000000 would be black
I replaced the &HFFCCCCFF in my code with RGB(0, 100, 200) in hopes to get a blue green mix, but all i got was nothing :( .....the entire text disappeared.....
03-05-2002, 03:28 PM
&HFF000000 Or RGB(0, 100, 200)
The Or there wasnt a statement, its actually supposed to be in the code. :)
Plus, as I said, you need to put the numbers in backward. The above call would produce red-orange text. You probably want:
&HFF000000 Or RGB(200, 100, 0)
to get blue-green text :)
thanks alot :)
by the way...what IS the &HFF000000 there for if the RGB value is what sets the font colour ?
03-06-2002, 06:26 AM
The &HFF000000 specifies that the text be at full opacity. A value of &H99000000 would make the text partially transparent, so the background shows up behind. A value of &H44000000 would make the text barely visible on the background. A value of &H00000000 makes the text totally transparent, so it is invisible.
In DirectX 7 there was a .CreateColorRGBA which did this for you. Unfortunately not in DX 8.