PocketMatrix forums

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

Display question

Hi everybody

I have the feeling that once ProcessNextFrame is called and I fill the backbuffer, the whole backbuffer is blitted into the pocket pc screen despite I only need to refresh a certain part of the screen.
Does anybody knows this for sure? Is there any way to say gapidraw to refresh only a certain region of the screen? (I suppose the the backbuffer is not the "real" pocket pc video memory, otherwise it wouldn't be named backbuffer :) )

also, is GetBuffer the best way to deal with 3D? Is there any problem with 12 bits color displays?

lots of thanks! :)
Kak
ProcessNextFrame automatically does a 'flip' upon exit. You can handle all the flips on your own by not using ProcessNextFrame. A dirty rectangle method is certainly doable with GapiDraw.

12bit displays are handled properly, with a loss of 4 bits of color info (I forget which color off hand - you can find it in this forum though).
ppcStudios wrote:
ProcessNextFrame automatically does a 'flip' upon exit. You can handle all the flips on your own by not using ProcessNextFrame. A dirty rectangle method is certainly doable with GapiDraw.

however, do you know if the flip is a real page flip (I mean, pocket pc having 2 visible screens, selectable) or it's just a bitmap copy into the real screen buffer?
If it's a flip there's no point in bothering about dirty rectangles as we're writing right in the (next) visible screen, however if it's a copy the speed would increase considerably, isn't it?

ppcStudios wrote:
12bit displays are handled properly, with a loss of 4 bits of color info (I forget which color off hand - you can find it in this forum though).


I see, however I have another question relating buffers: If I do a getBuffer and I write directly to that buffer, can I expect to work exactly on all devices or I have to use the xPitch & yPitch values to know how the screen is sorted? ( I have only 1 pocket pc and I can't test this kind of things )
I have the feeling that having to work with xPitch & yPitch for all polygon operations must be slow as hell :(
It can depend on the device. See the 2.01b documentation for CGapiDisplay::GetBackBuffer.

Concerning doing direct pixel writes, GapiDraw handles the surface translations internally. Write to the logical pixel location and it will be placed in the physical location appropriately.
Kak: The current hardware interface on Pocket PCs makes it virtually impossible to use dirty rectangles on newer hardware (since the back buffer provided by the device is stored in RAM and copied in full by the system to the display). It's doable on older devices (such as the ipaq 36xx, 38xx, and 39xx series) since one can access the display directly.

With all the different Pocket PC hardware implementations I would really recommend not to use dirty rectangles in your application.
sbl wrote:
Kak: The current hardware interface on Pocket PCs makes it virtually impossible to use dirty rectangles on newer hardware (since the back buffer provided by the device is stored in RAM and copied in full by the system to the display). It's doable on older devices (such as the ipaq 36xx, 38xx, and 39xx series) since one can access the display directly.

With all the different Pocket PC hardware implementations I would really recommend not to use dirty rectangles in your application.


thanks for clarification, in fact the problem was that I was using a 36xx device and seemed factible to do so, however if it's not working with older models I won't be using that :)

thanks! :)
Kak
ppcStudios wrote:
Concerning doing direct pixel writes, GapiDraw handles the surface translations internally. Write to the logical pixel location and it will be placed in the physical location appropriately.


Hi again :)

I was playing again with GetBuffer & co last night, but I'm even more
puzzled than before :)
The operation is easy if you're using xPitch & yPitch, however my idea
would be having a buffer accessible, where the first pixel is 0,0 , and next
ones being 1,0 , 2,0 , and so on

With some formats (in my 3650 at least), the xPitch is negative (-2):
If I understand this correctly, this means that if pixel 0 is (in example)
0x10000 , the 1,0 will be 0x10000 - 2 (of course 0x10000 is not a fixed
value, but the pBuffer pointer received in the GetBuffer call). So the
triangle filling function (in example) should be done going "backwards" in
memory (which is not hard, but maybe a bit confusing)
Also, if the xPitch (or yPitch) is negative, the pointer being returned
from GetBuffer is not "the start of the screen", as you have to substract
some values from the original pointer. So, i.e., if the xPitch is -2 and
yPitch 640, receiving a pBuffer value of 0x10000 wouldn't mean the frame
buffer

In my 3650, the ROTATE90CCW is "perfect" : xPitch is 2 and yPitch is 640
(so the buffer is "really" linear from my point of view). So the real
question in fact is... is the ROTATE90CCW xPitch/yPitch (and other display
orientations) exactly the same for all devices, or it depends on the
screen structure of the device? -> Gapidraw has the same buffer for all devices and we can write what we want in it, and gapidraw does all the converting job to pocket pc video screen format, or we have to look which format (xPitch,yPitch) is being used in the surface and do the drawing functions acording them?

Also, if not possible, is there any function which returns a display orientation where xPitch==2 && yPitch==640 (or width*2)

sorry for such a confusing mail, my bad english doesn't help my lack of
communication skills :) as you can see I'm really lost with this issue ;)

btw, are the gapidraw dll sources freely available? I think it'd help me
a bit to see how it's internally working.

lots of thanks! :)
Kak
Hi Kak,

is the ROTATE90CCW xPitch/yPitch (and other display
orientations) exactly the same for all devices?

No, xPitch and yPitch will differ between devices.

Also, if not possible, is there any function which returns a display orientation where xPitch==2 && yPitch==640 (or width*2)

There was a function in previous versions of GapiDraw (1.04), but it was removed. What it did was essentially rotate the entire surface so that it matches xPitch==2, yPitch==width*2. It was removed since it was commonly misused.

btw, are the gapidraw dll sources freely available? I think it'd help me
a bit to see how it's internally working.

The GapiDraw DLL is not freely available, but it is available for licensing. It will cost you some money though.

//Johan
Hi sbl
sbl wrote:
is the ROTATE90CCW xPitch/yPitch (and other display
orientations) exactly the same for all devices?

No, xPitch and yPitch will differ between devices.

Also, if not possible, is there any function which returns a display orientation where xPitch==2 && yPitch==640 (or width*2)

There was a function in previous versions of GapiDraw (1.04), but it was removed. What it did was essentially rotate the entire surface so that it matches xPitch==2, yPitch==width*2. It was removed since it was commonly misused.



so despite using that 1.04 gapidraw version, some users would probably have to play with normal position, some would have to play with ccw90, some with 180, ....

weird :)
at least some of the combinations (i.e. 180 which seems the most uncomfortable) could be easily changed just making every vertex y height-y :)

I'll have a look at the gapidraw 1.04 to see it's just what I'm searching (I suppose it is) to see if it's good enough to make a backwards step from 2.01b to 1.04 :)

lots of thanks! :)
Kak
kak: What GapiDraw 1.04 did was simply:

(1) malloc (surface width * 2 * surface height)
(2) rotate the surface contents to this new memory area

The memory area will then contain this "rotated" surface where xPitch will always be 2, and yPitch width*2. This could be implemented in a few minutes. No need to go back to GapiDraw 1.04.
sbl wrote:
kak: What GapiDraw 1.04 did was simply:

(1) malloc (surface width * 2 * surface height)
(2) rotate the surface contents to this new memory area

The memory area will then contain this "rotated" surface where xPitch will always be 2, and yPitch width*2. This could be implemented in a few minutes. No need to go back to GapiDraw 1.04.


Hi sbl

I was thinking & coding last night (the only time I can code) and I got the same conclusion: no need to get back to 1.04 as it could be done easily. Also sometimes the 1.04 halted my computer for a long time (in the Flip screen function).

Anyway I've taken a different approach:

first I calculate the "real start" of the drawing buffer, using the xPitch, yPitch, dwWidth & dwHeight. I get the same real buffer start in all 4 directions, (that's how the display memory is sorted, but it doesn't really matter at all)

once having it, I calculate some constants for "vertex flipping".

i.e. , if yPitch is negative, (supposing I use a 240x160 viewport) all y coords of every vertex are changed by 160-y, and 240-x for negative x coords.

however if abs (xPitch) > abs (yPitch) this means the screen is tilted, so x coords and y coords are swapped (with some negative values depending on the xPitch & yPitch value)

I haven't tested it but it should work and shouldn't give too much work to the engine, as it can be probably inserted inside the 3d to 2d projection

I hope it'll work :) (or at least it can be useful for somebody else who improves the system ;) )
Kak wrote:
once having it, I calculate some constants for "vertex flipping".

i.e. , if yPitch is negative, (supposing I use a 240x160 viewport) all y coords of every vertex are changed by 160-y, and 240-x for negative x coords.

however if abs (xPitch) > abs (yPitch) this means the screen is tilted, so x coords and y coords are swapped (with some negative values depending on the xPitch & yPitch value)


You just have described how PocketFrog works =) Great minds think alike =)

You just have described how PocketFrog works =) Great minds think alike =)

This is also how GapiDraw works internally in all operations.