I have a native Delphi TFrame that emulates Roy Tanck's Cumulus Tag Cloud viewer, a WordPress Flash plug-in. What that plug-in does is create a 3D sphere of words that spin around on the surface of a "virtual" sphere. You can see it in action here:
http://www.roytanck.com/2008/03/06/wordpress-plugin-wp-cumulus-flash-based-tag-cloud/
In my appli开发者_如何学编程cation structure each word has its own TBitmap and to render the sphere I print all the word's bitmaps to a temporary TBitmap and then BitBlt() that temporary TBitmap on to the Canvas of a visible TPaintBox. The render operation occurs on a TTimer timer event that happens every 50 milliseconds.
However, no matter how hard I try there is a noticeable "jitter" to the movement of the words, especially in comparison to the silky smooth movement of the Flash player. I thought increasing the frame rate might help and I even tried using a Multimedia timer that updated every 10 milliseconds with proper locking and unlocking of all the Canvases due to the multithreaded nature of the MM timer. Still jittery. The only thing I can figure is that the calculations I do result in discrete pixel locations for each word to render at and that causes jitter. In contrast, and this is supposition, perhaps Flash potentially does dithering to facilitate "between pixel" rendering or maybe does anti-aliasing in real-time and that's why it doesn't jitter?
In any case, is it possible to get the silky smooth motion I am looking for using native Delphi code? Or is the only way to do it is to go all the way to something like a Direct3D or OpenGL solution? I don't want to waste time tweaking this thing to death if it's a losing battle. On the other hand, if you have any tips I'd love to hear them. My guess is that if I do have to go the Direct3D/OpenGL route it's a big job and learning curve so if I could find a way to get this done in native Delphi code I'd love that.
FOLLOW-UP EDIT: Would printing to a much larger "virtual" bitmap and then using a resampling method like that given here help to print "down" to the actual visible Canvas?:
Scale an image nicely in Delphi?
I have written a number of games in Delphi. It is certainly doable. There are a number of things to watch for.
Not only do you have to trigger an event regularly but also check the time when it arrives and move based upon the polled time rather than assuming the time based upon the expected wait period.
If subpixel accuracy without GPU dependency is needed I would recommend Antigrain Geometry or it's Pascal cousin AGGPAS for Delphi.
Animating Fonts can have an additional issue in that font rendering often contains logic to ensure that thin strokes appear on pixel boundries. Moving text rendered in that manner can change appearance as different strokes can jump from being aligned with one pixel to the next.
If the font is rendered to be pixel aligned, it would perhaps manage better if you quantized rendering to integers. It will still align to pixels but by moving a pixel at a time should make it do so consistently each time.
IMHO the right way to go is Direct3D (or OpenGL, but given Delphi is Windows only maybe Direct3D is better). It was introduced exactly because the GDI is not good at such tasks. Flash supports both vector and raster graphic, and thereby can handle such kind of applicaitons better than old plain GDI.
精彩评论