Archived

This topic is now archived and is closed to further replies.

Rotating DirectDraw surfaces

This topic is 6386 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

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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
*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.)

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites