Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > Game Programming > DirectX > Changing Text Colour in Direct3D


Reply
 
Thread Tools Display Modes
  #1  
Old 03-05-2002, 02:52 PM
Epo Epo is offline
Junior Contributor
 
Join Date: Jan 2002
Location: Ontario, Canada
Posts: 332
Default 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?
Reply With Quote
  #2  
Old 03-05-2002, 03:17 PM
Squirm's Avatar
Squirm Squirm is offline
Political Coder

Retired Moderator
* Guru *
 
Join Date: Mar 2001
Location: London, England
Posts: 8,037
Default

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
__________________
Search the forums | Use [vb][/vb] tags | Still IRCing
Reply With Quote
  #3  
Old 03-05-2002, 03:23 PM
Epo Epo is offline
Junior Contributor
 
Join Date: Jan 2002
Location: Ontario, Canada
Posts: 332
Default

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.....
Reply With Quote
  #4  
Old 03-05-2002, 03:28 PM
Squirm's Avatar
Squirm Squirm is offline
Political Coder

Retired Moderator
* Guru *
 
Join Date: Mar 2001
Location: London, England
Posts: 8,037
Default

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
__________________
Search the forums | Use [vb][/vb] tags | Still IRCing
Reply With Quote
  #5  
Old 03-05-2002, 04:30 PM
Epo Epo is offline
Junior Contributor
 
Join Date: Jan 2002
Location: Ontario, Canada
Posts: 332
Default

sweeeet

thanks alot

by the way...what IS the &HFF000000 there for if the RGB value is what sets the font colour ?
Reply With Quote
  #6  
Old 03-06-2002, 06:26 AM
Squirm's Avatar
Squirm Squirm is offline
Political Coder

Retired Moderator
* Guru *
 
Join Date: Mar 2001
Location: London, England
Posts: 8,037
Default

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.
__________________
Search the forums | Use [vb][/vb] tags | Still IRCing
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->