PocketMatrix forums

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

Odd behaviour (probably my fault)

Hi,

I am hacking around with PocketHAL and stumbled upon an interesting issue.

If I run my small program with orientation NORMAL or 180, everything works out fine. On the other hand, if I use ROTATE90CW or ROTATE90CCW, the area that's covered by the SIP and taskbar seems to be painted over by a delayed write after the display object has been deleted.

I don't get this issue with the PocketHAL Minimal sample application (I tried both backbuffer flags - discardable and copy), so I could probably find the cause by trial-and-error... The strange thing however is that it works perfectly with the normal/180 rotations. I've tested this on my 2210 and the 4150.

Thierry: Is there anything special about the code in Display when the display is rotated?
Attachments:
phal2.jpg
phal1.jpg
Just thought I should add. I have removed all calls to SHSipPreference, SHFullScreen etc to see if it made any difference, but it did not...
In addition to this, I am also experiencing issues when the display object is deleted and then immediatly re-created (to allow rotation of the display while the application is running).

The following code results in the SIP input button becoming visible and placed on top of the application window:
Code:

// Destroy the display object
Display* pDisplay = (Display*) g_pHelper->m_pPHALDisplay;
if (pDisplay)
{
pDisplay->Swap();
SAFE_DELETE(pDisplay);
g_pHelper->m_pPHALDisplay = NULL;
}

// Re-create the display object
DisplayParameters params;
params.m_width = 0;
params.m_height = 0;
params.m_orientation = gddisplay::PHALDispMode(dwMode);
dwMode = GDDISPMODE_NORMAL;

// Discardable back buffer
params.m_swapEffect = ((m_surface.dwFlags & GDDISPLAY_DISCARDBACKBUFFER) == GDDISPLAY_DISCARDBACKBUFFER) ? SWAP_DISCARD : SWAP_COPY;

// Create Display
pDisplay = Display::Create(g_pHelper->m_hWnd, params);
if (!pDisplay)
{
CloseDisplay();
return GDERR_INVALIDMODE;
}


After the above code I call BeginScene + GetBackBuffer as usual...
This is quite weird. There is nothing special about 90CW or 90CCW.

You say that the samples don't cause the problem. Perhaps there is something different in the way you create your app's window? What are the style and extended style flags you use? Compare them with what the minimal sample uses.
Ok, I'll continue the investigation. The issue is most probably on my part. I checked the window styles and they're the same... Thanks! I'll let you know how I progress...
Found it.

It appears that if the window is moved right after it has been created, odd things happen when Display is destroyed and the display is rotated... Commenting out this row that's exactly after GetBackBuffer() solved the issue (in fact, it solved the issue when the Display object was deleted and re-created as well, so now I have on-the-fly display rotations)...

::MoveWindow(hWnd, 0, 0, params.m_width, params.m_height, TRUE);

//Johan
Awesome. Why did you need that MoveWindow() anyways?

I will investigate what can be done, I have the feeling that the MoveWindow() shouldn't cause problems.
It was just some old code lying around from back when GapiDraw didn't ship with an application framework.. It really shouldn't be there in the first place...

Thanks, I'm off to do some PHAL benchmarks... I'll post them here later...