Sign in to follow this  
BoxyCraft

[SlimDX] Clipping font

Recommended Posts

Hi I'm trying to figure out how to draw text that is cut in half horizontally. (eg: I want to draw only the bottom half of the letters, as if the top half has been cut off) I am making a GUI, and I need to trim the text at the top and bottom of a listbox while it is being scrolled . Thanks you!

Share this post


Link to post
Share on other sites
May I suggest to use listbox with height is integer multiplier of the font height?
Most lisboxes are like that, and you don't have to clip the text.
Other than that, I guess there is some kind of scissor test in directx too.

Yup: http://msdn.microsoft.com/en-us/library/bb147354%28VS.85%29.aspx

Save the scissor test to clip text in edit-boxes, there you can't avoid using clipping (if the text size can exceed the box size).

Share this post


Link to post
Share on other sites
Thanks for the reply!

My listboxes look so smooth at the moment that I would hate to ruin them by making them scroll a whole line at a time! [cool]

I just discovered Scissor Rects a few hours ago, but I haven't tried them out yet. It seems that they are dependant on the graphics card though, could someone please confirm this? I'd rather have a universal solution if I can.

I have a pretty good Bitmap Font class that I have written which uses fonts from this generator: http://www.angelcode.com/products/bmfont/
At the moment though you can use either method (system or bitmap fonts) and I was hoping to keep that setup.

I might also try using vector fonts. The Nuclex Framework has a nice vector font class. I'll have to see if they're worth the speed sacrifice over bitmap fonts.

Share this post


Link to post
Share on other sites
That might work! I've tried that before, but in a different situation, and it was noticeably slower, which is why I hadn't tried it yet. Now that you've got me thinking though, it just might work in this situation! Thanks!

It'll definitely have a performance hit, but it mightn't be that bad, and it'll be good to have both bitmap and system fonts working with the same functionality.

I usually speed test everything, so once I've tried them all I'll post back with what was fastest and worked best.

Thanks!

Share this post


Link to post
Share on other sites
Speed doesn't seem to be an issue to me, since you only have to update the texture when you roll the listbox, or select an item. otherwise you just throw the textured quad into the listbox.

Share this post


Link to post
Share on other sites
You could even apply this to the whole GUI:
Render the whole stuff to a texture, and only update it, when something changes.
Even better: only update the that portion of the texture, which is changing.
This way you can have a GUI with no noticeable performance hit.

Share this post


Link to post
Share on other sites
That's a good idea, especially if I've got a portion of the GUI that stays the same most the whole game. I'll try it!

I've just tried your minesweaper game, and the GUI is really smooth and functional. Good job! Do you use the same, or a similar method with it?

Share this post


Link to post
Share on other sites
No, because the game is event based, so redrawing only occurs, when a windows message is sent. (I can't express myself: so there is no constant updates, just when something happens).
But the field itself is rendered that way. Only updated, when something changes.

On the other hand, the GUI in the signature works like that, but the full stuff is refreshed, not just the changing portion. It is enough for me, and I didn't want to have an extra variable to keep track of the old item.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this