Rotating DirectDraw surfaces

Started by
11 comments, last by David M. 23 years, 10 months ago
Hello, I''m David, I''m 15 years old, and I''m slowly losing my sanity. Here''s why. When I try to use IDirectDrawSurface_Blt to rotate a surface and blit it to the back buffer, it tells me that there is "no rotation hardware" (DDERR_NOROTATIONHW or some such constant). So the question is, did I make a mistake, or what? Do I really need special hardware? I don''t feel like buying any, and I certainly don''t want to make everyone else buy it. I''ll post the code (which is in C) if you need it.
Advertisement
Unfortunately, DirectDraw cannot emulate sprite rotation in software. If the video card running your app doesn''t have hardware sprite rotation built in, the function will return DDERR_NOROTATIONHW and you won''t see anything onscreen. If you absolutely need it, then you could make hardware rotation a system requirement, but I think a LOT of cards don''t support it. You''d be better off writing your own software sprite rotation function. Don''t ask me how to do that though! I''ve never tried! :-)

Another solution to consider would be to render your sprites using D3D Immediate mode as a 4 TLVERTEX quad. Then you''d only have to worry about rotating the 4 points of the square and you''d get the 3D card''s good pixel fill rate to boot! There are a lot of articles popping up nowadays about using D3D for 2D rendering. Give one of those a read.
*sigh* That''s what I was afraid of. Geez. I needed no such hardware to rotate an Allegro bitmap.... AAAAAAAAAAARRRRRRGH!

Anyway, thanks for your help. Will I be able to use Direct3D for the rotation without a 3D card? ''Cause I don''t want to make that a requirement, either. (I don''t have a 3D card, and I don''t know anyone who does.)
You must not know very many people!! =) I can''t name anybody I know that DOESN''T have a 3D card.
I can name about six people who don't have a 3d accelerator. Long live software rendering!

What you could do is use the rotation formula to rotate the sprite's four corners and use a modified Bresenham's algorithm to fill in the different coloured pixels from the sprite's data. You could use assembly if you know it to make it faster, or you could keep it as it is, which might be a bit slower.

Edited by - furby100 on June 15, 2000 2:05:47 PM
Hmmm...well, since I probably wouldn''t be using Direct3D for anything else, I''ll just skip that hassle and write my own code to do the rotation.
Allegro does it in software just use that code. OR look at CDX or NukeDX they both have software rotation code in them and you are free to use it.

hebertjo
hebertjo
For my game I had do bitmap rotation (http://arkia.tripod.com). What I did was I took some of my old code for a modified rasterizer for 3d stuff that I never finished, and used it. It is actually faster at doing 3d stuff than direct3d is. It takes 3 points and draws a parallelagram between them. So for rotations I just needed to use cos and sin to get those points.

The problem is that I really optimized it. It uses only integer arithmetic. I was even able to change a multiply into an add. Then I found little glitches from rounding errors. I had to put in lots of if statements before doing each row to make sure it wasn''t out of bounds. So its still really optimized, but it could use some work.
For a good time hit Alt-F4! Go ahead try it, all the cool people are doing it.
Hmmm, that''s strange...I looked at CDX, and all calls to the nonexistent rotating functions were commented out...I looked at NukeDX, and the sprite class was empty. They''ve changed some things since then, evidently.
It''s not the sprite class in NukeDX that does rotation, it''s the NDX_Surface class.

NDXSurface.RotoZoom I believe.

Clay
Clay LarabieLead DeveloperTacendia.com

This topic is closed to new replies.

Advertisement