 |

03-05-2002, 02:52 PM
|
|
Junior Contributor
|
|
Join Date: Jan 2002
Location: Ontario, Canada
Posts: 332
|
|
Changing Text Colour in Direct3D
|
I use the following line to display my text:
Code:
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
|
 |
Political Coder
Retired Moderator * Guru *
|
|
Join Date: Mar 2001
Location: London, England
Posts: 8,037
|
|
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:
Code:
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
|
|

03-05-2002, 03:23 PM
|
|
Junior Contributor
|
|
Join Date: Jan 2002
Location: Ontario, Canada
Posts: 332
|
|
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
|
 |
Political Coder
Retired Moderator * Guru *
|
|
Join Date: Mar 2001
Location: London, England
Posts: 8,037
|
|
Code:
&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:
Code:
&HFF000000 Or RGB(200, 100, 0)
to get blue-green text 
|
|

03-05-2002, 04:30 PM
|
|
Junior Contributor
|
|
Join Date: Jan 2002
Location: Ontario, Canada
Posts: 332
|
|
sweeeet
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
|
 |
Political Coder
Retired Moderator * Guru *
|
|
Join Date: Mar 2001
Location: London, England
Posts: 8,037
|
|
|
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.
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|
|