C# - DirectX.DirectDraw question about off-borders

EFileTahi-A

Contributor
Joined
Aug 8, 2004
Messages
623
Location
Portugal / Barreiro
Yesterday (16-5-2005 (Sunday)) I started to learn DirectX's DirectDraw, I thought it would be harder, but, like the book's author (from which am learning DirectX) stated, "it's simpler then you imagine".

Anyway I noticed some HEAVY (at least for my needs) limitation on DirectDraw. I can't draw pictures off borders. That is, DirectDraw only draws inside the actual screen size. If I have an 800x600 screen it means I cannot draw with values less then x0, y0 or bigger then x800, y600...

Since am now porting my 2D Tiled Game Editor to DirectX which draws images (in some ocasions) off-border am pretty stucked right row as I have no ideia how walk around this.

In theory, how can I make a picture apearing from left to right (like a slide show) or scrolling text from bottom to top of the screen like a movie ending credits in DirectX.DirecDraw? This too examples are easly acomplish using GDI+ as you can draw off-borders...

Extremely thankfull for any possible help as my progress is alted until this issue is solved...
 
Last edited:
I believe that you are referring to "clipping," i.e. you draw an image that overlaps the edge of a surface, and what goes over the border is clipped off. When you create a DirectDraw surface, you can provide it with a Clipper that specifies the region to clip, either taking a form from which it can find the bounds, or explicitly providing a rectangle.

The following code (from codeproject.com) is used to set the clipper of the primary surface to the region of the application's form
Visual Basic:
display = DirectDraw Device
using(Imports) namespace Microsoft.DirectX
using(Imports) namespace Microsoft.DirectX.DirectDraw
 
C#
	Clipper clip;
	// Create the Clipper
	clip = new Clipper(display);
	// Set the region to this form
	clip.Window = this;
	// Set the clipper for the front Surface
	front.Clipper = clip;
	
VB
	Dim clip As Clipper
	'Create the Clipper
	clip = New Clipper(display)
	'Set the region to this form
	clip.Window = Me
	'Set the clipper for the front Surface
	front.Clipper = clip

Since you will probably be rendering to a backbuffer, rather than to the primary surface, you will probably want to set a clipper for your backbuffer. I don't believe that DrawFast() uses the clipper. In this case, whatever you need to be drawn using clipping will need to be drawn using the plain old Draw() function. On my computer there is no noticable speed difference. This may not be the case with lower end graphics cards.
 
Not that this helps your question a great deal but you might want to consider skipping DirectDraw altogether and just go straight to Direct3D. Although it might sound odd advice - using Direct3D you can 'simulate' 2D surfaces using textured quads (thing sprites) fairly easily.
 
PlausiblyDamp said:
Not that this helps your question a great deal but you might want to consider skipping DirectDraw altogether and just go straight to Direct3D. Although it might sound odd advice - using Direct3D you can 'simulate' 2D surfaces using textured quads (thing sprites) fairly easily.
What PlausiblyDamp said and, especially since DirectDraw is depracated and soon you probably won't have a chance to use it with newer releases of the SDK.
 
Thank you all, I was still deciding which path would I choose... but in this case, if there is a chance of directdraw might get "banned", well am going to Direct3D then...

Thank you once more for your feedback, realy apreciated...
 
Well, Direct3D can do everything that DirectDraw could, and can do it better. It is really no surprise that it is depracated now since Direct3D is now so programmer-friendly (at least it seems that way to me), and this brings out the fact the DirectDraw is no longer really needed.
 
I want to know How can I do this like using DirectDraw?
m_lpSurface->Blt(&destRect, m_lpDestDDS, &srcRect, .....);

I can't using Texture or Sprite to bitblt another texture ,please help me
 
Back
Top