Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi,

I've downloaded some samples for directdraw, but only in directx7 (SpaceBreakout) or I've found some for dx9 in C or C++ on this pages here.

I want to move some small bitmaps (50 times 50 Pixs) with black as transparent color over a map (400 times 400 Pixs visible, 1000 times 1000 virtual). All in mode "display.SetCooperativeLevel(this, CooperativeLevelFlags.Normal);" . FullScreen maybe later...

 

Are here some good hints in csharp for directx9 here or has someone an example?

 

Here is, what I have tried so far (the "knight" has still a black Border...):

 

private void Draw()

....

primary.Draw(destination, offscreen, new Rectangle(i,j,300,300), Microsoft.DirectX.DirectDraw.DrawFlags.Wait, new DrawEffects() ) ;

primary.Draw(destination1, knight, DrawFlags.Wait);

 

private void CreateSurfaces()

{

display = new Device();

display.SetCooperativeLevel(this, CooperativeLevelFlags.Normal);

SurfaceDescription description = new SurfaceDescription();

description.SurfaceCaps.PrimarySurface = true;

primary = new Surface(description, display);

description.Clear();

clip = new Clipper(display);

clip.Window = this;

primary.Clipper = clip;

description.Clear();

offscreen = new Surface("card.bmp", description, display);

description.Clear();

ColorKey CC = new ColorKey();

CC.ColorSpaceHighValue = 0;

CC.ColorSpaceLowValue = 0;

knight = new Surface("knight.bmp", description, display);

knight.SetColorKey(Microsoft.DirectX.DirectDraw.ColorKeyFlags.SourceDraw, CC);

}

 

Maybe, I have forgotten something :(

 

Best regards

Roman

Posted (edited)
The Error is on this line
primary.Draw(destination1, knight, DrawFlags.Wait);

It should be:

primary.Draw(destination1, knight, DrawFlags.Wait | DrawFlags.KeySource);

You need to tell DirectDraw to use the color key, because it wants to know whether to use it on a case-by-case basis.

Edited by AndreRyan
.Net allows software to be written for any version of Windows and not break like Unmanaged applications unless using Unmanaged procedures like APIs. If your program uses large amounts of memory but releases it when something else needs it, then what's the problem?
Posted

Thanx alot!

 

Thanx for the help!

Is there a way to bring bitmaps faster to the screen using directX9 / c#? When I move/scroll the map and the knight in windowed mode.. it seams to fl[ai]cker...

Regards,

Roman

:rolleyes:

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...