PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

GapiDraw 2.02 coming tomorrow...

I removed some of the new features under development to be able to release 2.02 quickly. The current issues with AlphaBlt are constantly on my mind and I don't want you guys struggling with issues that have already been resolved.

Clipping is there in 2.02 and works perfectly on lines, rectangles, blits, cursors and even fonts. :) Yep, it's finally possible to draw text anywhere (x=-10, y=-10) and all letters will clip nicely as needed.

The implementation for clipping is:
CGapiSurface::SetViewPort(RECT* pRect);
and
CGapiSurface::GetViewPort(RECT* pRect);

Clipping is by default disabled on all surfaces and will have to be enabled on a surface-by-surface basis.

(1) Setting a clipping viewport to clip near the surface boundaries

surface.SetViewPort(NULL);

The entire surface will be used for clipping. Drawing outside the surface will clip automatically.

(2) Setting a clipping viewport to a rectangle on the surface

CRect myrect;
myrect.SetRect(10, 10, surface.GetWidth() - 10, surface.GetHeight() - 10);
surface.SetViewPort(&myrect);

The above will clip all blits, lines, rectangles, fonts, etc to the viewport. The class CRect is almost identical to the MFC class CRect and resides in CGapiDrawExtension.h.

(3) Removing a clipping viewport
CRect myrect(0, 0, 0, 0);
surface.SetViewPort(&myrect);
Set the viewport to an empty rectangle to remove viewport clipping on the surface.

Currently there are some rounding issues with Blt, AlphaBlt and clipping. This is because DirectDraw does not support clipping in hardware (coords are unsigned DWORDS) and the scaling may cause some rendering issues (should not be visible under normal circumstances).
Um. I might rename the function to SetClipper when I'm at it to comply more with the DirectDraw specification. We'll see tomorrow...
Johan, Isn't the setClipper function in Direct X a rudimentary clipper for windowed objects so it doesn’t draw out of the window? I didn’t think Direct X had a real clipper built in.

-DillRye
Excellent! I’m glad you made clipping a part of GD2.02, you saved me from a serious headache, but almost gave me mild heart attack announcing the release of GD2.02 is coming real soon! I’m already wearing out my mouse button clicking the refresh button icon on my browser…

What are the chances of GD2.02 being released before Siggraph 2003? Ok, seriously speaking though, after axing out the new features under development that was planned for GD2.02, can you give us more or less an idea of when to expect the release of GD2.02 (Month/Week/Day)?

For some unexplained reason I sense that we might be left in suspense?... :wink:
Johan, if you can include a sample program/code that uses the new clipping routines for gapidraw, we'd very much appreciate it. Thanks. :)
Yeah! There has been a long standing bug in pocket war where a unit near the edge of the map does draw right when rotated because my simple clipper couldn't handle it. This will finally be fixed.
Thanks Johan. It's amazing that you can clip even when DrawText is used. Until now there has not been a real decent solution to do so. I can't wait for the release...
DillRye: Actually DirectDraw supports clipping on any surface (the clipper has two modes - window clipping and surface clipping). Since DirectDraw only supports unsigned coordinates however it's not that useful in most cases however.

8bit: GD 2.02 will be out today. Some of the features under development was removed and will be in future releases. Unfortunately I cannot give an estimate of when these future releases will be out, but since the features were unannounced I doubt no-one will go and wait that much for them.

egarayblas: I'll see what I can do..
Ok, so the “tomorrow” bit wasn't a metaphor… :lol: and now, I shall jump with joy! :D
What does this mean:

>>Since DirectDraw only supports unsigned coordinates however it's not that useful in most cases however.



You can certainly blit surfaces to destinations which are referenced by signed coordinate values. The RECT structure has members which are typed as LONG.

Where the DDraw clipper does come in handy is when you're running in a window and your window is partially obscured by another window or a pop-up menu. DDraw does the right thing in this instance and will turn your full-window-sized Blt into a series of multiple blits which keeps the blitter from stomping over the occluded regions. GAPIDraw will never be able to do something like this on Pocket PC because it doesn't have hooks into GWES to know when and where the occluded areas are of the destination window.
Digby: Ok, I wasn't aware of that Blt accepted negative coordinates. I was referring to the simple BltFast that uses unsigned coordinates (which means clipping to the top/left sides cannot be done).

While I was thinking of integrating a more advanced clipper in GapiDraw, the current solution with a rectangle for viewport works ok for most purposes I guess.
BltFast doesn't support clipping, so there's no point in being able to specify a destination with negative coordinates. It was designed to offer a fast path for apps that know their blits won't require clipping or stretching. If you need clipping, stretching, mirroring, etc. you'll need to use IDirectDrawSurface*::Blt instead.
Just FYI: GapiDraw 2.02 is finished and is being tested by tedson, ppcstudios and gersen (thanks a lot guys!). As soon as I get thumbs up it will be out on the web...
I've tested GD202 on the current Warlords build and everything works wonderfully! The only code changes required were for the new CGapiBitmapFont->GetStringWidth method (GDDRAWTEXT_CALCWIDTH has been removed from the CGapiSurface->DrawText method), and those changes were minor - it took longer to find the new method in the docs than it did to actually change the code.

The new GDBLTFAST_MULTIPLY and GDBLTFAST_MULTIPLYOPACITY work fantastic! The opacity value is a bit touchy, but a value of 242 worked perfectly for my needs. My animated cursors now colorize (err multiply) the way I intended them too.

I'll try GD202 on my finished products as well to make sure framerate isn't affected. Warlords is pretty much asynchronous when it comes to drawing - I'm only updating the screen as needed, allowing the saved CPU cycles for the AI.

Overall this looks like another great update by Johan!