Jump to content
  • Advertisement
Sign in to follow this  
odyodyodys

Text marquee using ID3DXFont and Sprites

This topic is 3675 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey all, I'm trying to do a marquee for my d3d app. I want to have a rectangle that defines the area in which the text is going to be scrolling, but i'm failing.. What I do is the following:

// Initialize the font
D3DXCreateFont(device, 24 , 0, FW_DONTCARE, 0, false, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLEARTYPE_NATURAL_QUALITY, DEFAULT_PITCH | FF_DONTCARE, TEXT("Lucida Console"), &font);


// Draw the text
RECT sourceRect = {0};
sourceRect.Top = 0;
sourceRect.Bottom = 300;
sourceRect.Left = 0;
sourceRect.Right = 500;

font->DrawText(NULL, L"Hello World!", -1, &sourceRect, 0, D3DCOLOR_ARGB(255, 0, 0, 0) );


This allows me to draw on the monitor. But what I cannot do is move the text left or right inside the sourceRect. any ideas or where to look at??

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by odyodyodys
Does anybody have a clue on this subject?
I'm really desperate
Your best bet would probably be to use render to texture to render the string you want, then apply it to a quad which you can clip the texture coordinates of.

Alternatively, you might be able to do something with the state of the ID3DXSprite used to render to text to make it appear behind some other sprites (If there's a solid border around your text marquee).

Share this post


Link to post
Share on other sites
Just draw normal scrolling text and use a scissor rect to clip the edges.

http://msdn.microsoft.com/en-us/library/bb147354(VS.85).aspx

Share this post


Link to post
Share on other sites
Thanks for your replies,

I didn't knew anything about scissors. I am going to use it.

Any ideas on how to get a texture from a text?

no such method as font->GetTexture() exists...

I am working on it for more than 2 days and I am desperate!!

Share this post


Link to post
Share on other sites
Thanks for your replies,

I didn't knew anything about scissors. I am going to use it.

Any ideas on how to get a texture from a text?

no such method as font->GetTexture() exists...

I am working on it for more than 2 days and I am desperate!!

Share this post


Link to post
Share on other sites
Quote:
Original post by odyodyodys
Thanks for your replies,

I didn't knew anything about scissors. I am going to use it.

Any ideas on how to get a texture from a text?

no such method as font->GetTexture() exists...

I am working on it for more than 2 days and I am desperate!!
I completely forgot about scissors, they'd definitely be better.

There is no way to get a texture from text. What are you trying to do? If you're trying to do a render-to-texture, take a look on Google.

Share this post


Link to post
Share on other sites
I Just LOVE gamedev!!!

Scissors worked great!!

My actual code:

// On device initialization
device->SetRenderState(D3DRS_SCISSORTESTENABLE, true);

// while rendering inside the Begin-End Scene
RECT visibleAreaOld = {0};
hr = device->GetScissorRect( &visibleAreaOld);

// Change the rectangle as desired here...

RECT visibleAreaNew = {0};
hr = device->SetScissorRect( &visibleAreaNew );

RECT textRect = {0};
//Set textRect as desired. Eg. add a step on the textRect on each frame so it advances right or left.


font->DrawTextW(NULL, messageToDisplay.c_str(), -1, &textRect, DT_NOCLIP, D3DCOLOR_ARGB(255,0,0,0));

device->SetScissorRect(&visibleAreaOld);




Thank you guys...!!!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!