[SlimDX] Clipping font

Started by
7 comments, last by szecs 14 years, 1 month ago
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!
Advertisement
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).
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.
Can you render the whole text to a texture, then display it as a list-box sized quad with appropriate texture coordinates (so you don't have to use clipping)?
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!
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.
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.
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?
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.

This topic is closed to new replies.

Advertisement