PocketMatrix forums

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

Strange case with GetDisplay

I've noticed stange GetDisplay behavior. Please see code below. This error I get only when I'm tracing from the beginning of entry point.

Entry Point:

Break here and trace->

CreateWindowEx
SetFocus
ShowWindow
UpdateWindow

HAL::DisplayParameters phal_display_params;
phal_display_params.m_width=240;
phal_display_params.m_height=320;
phal_display_params.m_orientation=PHAL::ORIENTATION_NORMAL;
phal_display_params.m_swapEffect=PHAL::SWAP_DISCARD;
phal_display=PHAL::Display::Create(hwnd,phal_display_params);

PHAL::GetKeyList(&phal;_keylist);

SetWindowText(hwnd,...);

phal_backbuffer=phal_display->GetBackBuffer();

phal_backbuffer is not null, but phal_backbuffer.m_pixels is null.
I've forgotten to notice that call of BeginScene before GetDisplay in the trace process returns FALSE. But documentation says that BeginScrene called in GetDisplay, and that GetDisplay must return 0 when it failed.

I used 0.6.5
I will double check the code and update the doc if there is a need. It seems I am returning a Surface with m_pixels = 0 instead of 0, which was the original intend (as per the doc).

To make sure you stay out of troubles, I would suggest calling BeginScene() yourself before GetBackBuffer(), and if that returns false, don't call GetBackBuffer() at all. If BeginScene() returns false, it means your window doesn't have focus.