Below I have a sample that 'should' work with PocketHAL, it just initializes a window and calls a dumb pixels drawing routine for 5 secs, afterwards it quits.
However on my Ipaq3850 I notice the program is running for 5 secs, but unfortunately the screen stays untouched, just as the swap is doing nothing.
Can someone try this out on his device? just paste the code in evc++ it should compile.
I guess something is missing, but can't figure out what, did following actions:
-create display
-initialize display
-ask for backbuffer ptr
-fill it
-swap it
should work no?
anxious waiting for feedback, joost
However on my Ipaq3850 I notice the program is running for 5 secs, but unfortunately the screen stays untouched, just as the swap is doing nothing.
Can someone try this out on his device? just paste the code in evc++ it should compile.
I guess something is missing, but can't figure out what, did following actions:
-create display
-initialize display
-ask for backbuffer ptr
-fill it
-swap it
should work no?
anxious waiting for feedback, joost
- Code:
#include <atlbase.h>
#include "pockethal.h"
Display *display;
DisplayParameters params; //use default params
HINSTANCE hInst;
HWND MainWindow = NULL;
TCHAR szAppName[] = TEXT("pockethal");
TCHAR szTitle[] = TEXT("pockethal");
LRESULT CALLBACK MainProc(HWND hWnd, UINT Message, WPARAM wParam, LPARAM lParam);
void DrawSomething() {
// fills the screen with a color during one second, repeated 5 times
for (int s=0; s<5; s++) {
Surface *buffer = display->GetBackBuffer();
if (!buffer) return;
uint16_t *buffptr = buffer->GetPixels();
memset(buffptr,0x20 * s, 320*200*2); // fill the buffer with a color
display->Swap();
Sleep(1000); // wait 1 second
}
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,LPTSTR lpCmdLine,int nCmdShow)
{
HWND hWndThis = NULL;
WNDCLASS WindowClass;
// Window Setup
hWndThis = FindWindow(szAppName, szTitle);
if (hWndThis)
{
SetForegroundWindow(hWndThis);
return 0;
}
hInst = hInstance;
if (!hPrevInstance)
{
WindowClass.style = CS_HREDRAW | CS_VREDRAW;
WindowClass.lpfnWndProc = MainProc;
WindowClass.cbClsExtra = 0;
WindowClass.cbWndExtra = 0;
WindowClass.hInstance = hInstance;
WindowClass.hIcon = NULL;
WindowClass.hCursor = NULL;
WindowClass.hbrBackground = NULL;
WindowClass.lpszMenuName = NULL;
WindowClass.lpszClassName = szAppName;
if (!RegisterClass(&WindowClass;)) // if can't register window class then quit program.
return 0;
}
MainWindow = CreateWindow(szAppName,
szTitle,
WS_VISIBLE | WS_POPUP,
0,
0,
240,
320,
NULL,
NULL,
hInstance,
NULL);
SHFullScreen(MainWindow, SHFS_HIDESTARTICON);
SHFullScreen(MainWindow, SHFS_HIDESIPBUTTON);
SHFullScreen(MainWindow, SHFS_HIDETASKBAR);
MoveWindow(MainWindow, 0, 0, 240, 320, TRUE);
ShowWindow(MainWindow, nCmdShow);
UpdateWindow(MainWindow);
// PocketHAL setup
display = Display::Create();
display->Initialize(MainWindow,params);
DrawSomething(); // draw for 5 secs
delete display;
return 0;
}
LRESULT CALLBACK MainProc(HWND hWnd, UINT Message, WPARAM wParam, LPARAM lParam)
{
return DefWindowProc(hWnd, Message, wParam, lParam);
}