PocketMatrix forums

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

How do I increase response rate after clicks?

Hi,

I seem to have a second delay (approx) between key presses or stylus clicks and something happening on the screen...
Code Sniplet:

virtual HRESULT StylusDown(POINT p)
{
cursor.set_point(p,CSR_STYLUS_DOWN);
return S_OK;
};

The cursor object simple implements a cursor display on the screen so that I see a cursor when I click on any point on the screen.

Also, I have minimal code in this function as you can see so that I push most of the hard work into ProcessNextFrame.

Question: Is there any parameter I can change to affect this response rate? I played around with config.dwTargetFPS but it didnt really make a differnece?

Thanks,
Joe
Hi Joe,

I assume you use CGapiApplication.

The only way you should be able to get a delay of 1 second between the actual stylus down event and the next ProcessNextFrame(), is if each frame actually takes more than one second to render. If not, do you have anything extra going on in the background? Music playback or similar? If not, try resetting your device and see if the error still occurs. Do you experience similar issues with the sample applications (the "Simple" demo should be a good reference).

Are you using an emulator or a device? If emulator, what emulator? If device, what device?

/Johan
joe · 30 Jul 2002, 18:31 UTC — RE:
hi Johan,

Yes I use CGapiApplication.

I found out that a background image I am loading everytime I call ProcessNextFrame is the reason for the delay :(

The image is a png about 8K.
<snip snip>
CGapiSurface myscene_surface;
RECT myscene_rect;
myscene_surface.CreateSurface(TEXT("Scene.png"));
::SetRect(&myscene;_rect,0,0,myscene_surface.GetWidth(),myscene_surface.GetHeight());

backbuffer.BltFast(0,0,&myscene;_surface,&myscene;_rect,0,NULL);
<snip snip>

Is there anyway to load this without causing the noticeable delay? When I took out this code, there is no obvious delay at all..


any help will be apprecited.

thanks
joe
I am wondering why you load the same surface every frame? Once it is loaded onto a surface, there is no need to reload it, unless your doing something that I am not aware of such as making a sort of movie out of them.
sorry, I am new at this.

How do I maintain the background scene in the backbuffer? Is it not overwritten everytime processnextframe is called when I render/blit other surfaces on to it?

thanks
joe
is something like this what you mean?
Inside processnextframe:
<snipsnip>
if (first) {
CGapiSurface myscene_surface;
RECT myscene_rect;
myscene_surface.CreateSurface(TEXT("Scene.jpg"));
::SetRect(&myscene;_rect,0,0,
myscene_surface.GetWidth(),myscene_surface.GetHeight());
backbuffer.BltFast(0,0,&myscene;_surface,&myscene;_rect,0,NULL);
}
else first=0;

joe
<snip snip>
Hi Joe,

I would recommend spending some time browsing through the sample applications before building your own game. I would also recommend reading through the entire documentation on CGapiApplication.

Basically, you should create all surfaces in CGapiApplication::CreateSurfaces. You store the surfaces as member variables (if you are unsure what this is I would recommend reading through some C++ books as well). The contents of a surface is never changed unless you manually change it. This applies to all surfaces, including the backbuffer.

Also. If you want to use the entire surface in a blit operation, you can simply supply NULL as RECT. So.. Your code would look something like:

// Add the following as a member variable
CGapiSurface m_myscene_surface;

CMyApplication::CreateSurfaces(CGapiDisplay& display, HINSTANCE hInstance)
{
m_myscene_surface.CreateSurface(TEXT("Scene.jpg"));
}

CMyApplication::ProcessNextFrame(CGapiSurface& backbuffer, DWORD dwFlags)
{
backbuffer.BltFast(0,0,&m_myscene_surface,NULL,0,NULL);
}

You should always create all your surfaces in CreateSurfaces. The reason for this is that if you rotate the display with SetDisplayMode the surfaces will automatically be recreated to match the new display orientation.

Hope this does the trick.

/Johan