It would be useful (for me at least) to have a flag that would allow drawing on a surface outside of it's bourdaries, and not have the drawing rolled to the other side.
For example, a surface 64x64. I would like to draw a bitmap of 32x32 at 48,0 on the surface, and the part that is outside of the 64x64 surface would simply get clipped.
In some tests I did, using the "DONOTVERIFY" option, the bitmap would be rolled to the other side.
I don't remember how DirectX handles this, but it would be nice.
Thanks!
Hi,
In your example, you could just alter the width of the surface to be copied to (64-48)=16 pixels (Source Rectangle) to avoid the blit to fail. But I guess this is not what you want.
What you want is probably a surface clipper. Since GapiDraw is modeled after the DirectDraw standard, I have hesitated on adding clippers. The rationale for this is that clippers (in DirectDraw) are mostly used on primary (windowed) surfaces (where the primary surface is the Windows desktop, and the clipper is set to a specific window frame).
There are several issues associated with using a clipper. Since GapiDraw (similar to DirectX) does not use signed coordinates (+/-), you would only be able to clip on two walls (right and bottom). So you would be forced to do manual clipping on the top and left wall anyway. Using more advanced drawing primitives such as antialiased lines and circles, it is also not a simple task to implement a clipper while still maintaining acceptable performance.
If GapiDraw was NOT designed to be DirectDraw compatible I could have used signed integers for all operations. But since I wanted the operations to be as identical as possible this is currently not the case.
In most of the games I have encountered the coordinate systems used for the sprites differ from the screen cordinates anyways, and are translated prior to blitting the sprite to the screen. In this same translation process, I would suggest you implemented a simple clip function as well.
Best regards,
Johan
Thanks for answering. I understand now why that doesn't really fit in GapiDraw.
Here is yet another question... I am creating a tile base game, and I need to render to an area that has around 64 pixels left, right, top and bottom of the screen.
What I do is create a larger surface, draw what needs to be drawn, then copy the viewable part to the backbuffer and flip it.
Is this the best way? Is there another way that would be better?
Thanks!
instead of drawing what needs to be drawn on another surface and then copying to the back buffer, unless you're supporting multiple layered effects it'd be better to just draw directly to the back buffer.
So you'd do something like:
1.) load all graphics to surfaces
2.) Each Frame do the following
2.a) Copy appropriate graphics from surfaces to back buffer
2.b) Flip back buffer
This ofcourse is just one of many possible rendering loops, but should be faster then doing as you said:
1.) Each Frame do the following
1.a) Copy graphics onto a surface
1.b) Copy surface to back-buffer
1.c) Flip back buffer