PocketMatrix forums

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

Using GAPI to draw only visible region?

Does anyone know how to use GAPI to draw only the clipped region of the screen, i.e. the area which isn't covered by other windows like the SIP menu and the keyboard and other windows like that?

I just end up drawing over the top.

In DirectDraw there is something called a DirectDrawClipper which has HRGN object. This can be parsed to find out regions of the screen.

I've tried lots of promising looking functions like GetRandomRgn GetUpdateRgn BeginPaint GetClipRgn GetWindowRgn, etc and all seem to return the full area of the window no matter what is in front...

I'm desperate here, so any ideas would be welcome... I notice PocketSNES subtle avoids this by redrawing the screen in a Bitmap when the menu may appear, which doesn't look promising
That would be device specific, depending on what GXIsDisplayDRAMBuffer returns. For displays that are not backbuffered, you should be able to blit only to the area you want to write to and not affect the rest. For others that require a call to GXEndDraw each frame you're probably out of luck (as far as finding a simple solution).

Dan East
Hi Dan,

I don't want to hijack this thread, but do you know of any PocketPC device, besides older device like the E-125, that returns GXIsDisplayDRAMBuffer as true? I would like to get one of these for testing.

Thanks!

--Eric
The only other one I know of is the iPAQ 3800. But you don't want to use it's GAPI implementation. People usually work around it by directly accessing it's framebuffer memory.
Thanks Thierry. Since I already do that, I guess I'm in the clear (for the moment!).

--Eric
See my post in this threadin the GapiDraw forum.
Dan East wrote:That would be device specific, depending on what GXIsDisplayDRAMBuffer returns. For displays that are not backbuffered, you should be able to blit only to the area you want to write to and not affect the rest. For others that require a call to GXEndDraw each frame you're probably out of luck (as far as finding a simple solution).

Dan East



I don't understand - isn't this problem related more to the GDI rather than GAPI?

What I mean is, GAPI will allow you to write to any pixel, all that needs to be determined is which pixels are covered up by windows in the GDI.

Is there no way to do this in Windows CE? There are several ways in Windows 9X/NT/2000...
Sorry, I misunderstood your question.

What you are wanting to do will probably require some experimentation.

The dirty method would be to just GetClientRect and blit that area. That should work properly so you don't overwrite toolbars and the SIP, however you will overwrite any windows higher in the z order than your window.

You could try catching WM_PAINT, then GetClipRgn the paint DC. If you're lucky that region will account for all windows closer in the Z-order than yours. I don't know - I've never used it in that way.

If that doesn't work then you could always GetTopWindow and GetNextWindow to iterate all the way down to your window. You'll want to use GetWindowRgn, because windows may not necessarily be rectangular. Just add all the regions of all the parents together, then use GetRegionData to get a list of rectangle / trapezoid primitives that make up the region.

If you want a less precise (and probably faster implementation) then just add the Window rects of each parent window instead of the regions. However I know PPC 2002 uses non-rectangular windows quite a bit, so there would be rendering issues.

Dan East
The only non-rectangular box I'm aware of offhand is the notification ones. What else is there?
sponge wrote:The only non-rectangular box I'm aware of offhand is the notification ones. What else is there?


Start Menu, Application menus, taskbar plugins, ...
I must be missing something here, my start menu is definitely rectangular.
sponge wrote:I must be missing something here, my start menu is definitely rectangular.


It is, but when it appears, the visible portion of your window isn't rectangular anymore.