I started my current program (a Mandelbrot) on an Arduino Due and a 480X320 TFT LCD. It was/is in C++. It (the screen) was also very small and (the sketch) was very slow.... :( I decided to port the program (sketch) to my desktop and Visual Studio Express 2015 and a 1920X1080 TV monitor.
Anyway, my problem....
As you see I have included the "CALLBACK WndProc" method. Also, as the comment, the mandelbrot method runs in the WM_PAINT "case". It paints the (generic) mandelbrot(straight forward, nothing special and not relevant to my question) increases the "zoom" value from 1 to 70 trillion in 10% steps, 339 displays altogether. The run takes about 40 minutes and at 70 trillion zoom the display gets "blocky" as I suspect I have reached the "precision" limit of "doubles & floats"!?
During this 40 minutes I can't click the mouse nor touch the keyboard nor allow the screensaver to cut in nor switch to another process without the process "freezing"! I suspect while the mandelbrot displays 339 times it must switch off multi programming or something. If I "click" the "close(X)" gadget a requester comes up saying "Not responding" and I have to "force close" the program, which is "frozen".
After the 40 minutes, the last screen just stays on the display but if I click the "X" it closes down correctly and properly obviously because the WM_PAINT process is complete?
My question....
How do I allow the program to respond to the mouse, keyboard, process changes, loss of focus etc? I would (later) like to use the mouse to change the "focus" of the mandelbrot zooming process etc? Use the keyboard to enter new focus co-ordinates and iteration counts etc?
Obviously, by displaying 339 "zoomed" mandelbrots I'm switching something "off" and a mouse or keyboard "press" freezes the process!?
I read SOME hints about multi-threading???? There isn't much on the web about this :(
I didn't know whether to put this topic in "Beginners" or "Programming" forums?
Also (much later) could I process the displays as/into a video file? AVI, WMV or MP4. I'm not particular. :) Or could I output each display as a JPG, PNG, bitmap, ... or some "picture" format and create a video from the snapshots?
I am a retired analyst/programmer (mainframes and batch processes and a total newbie in C++) and this isn't homework :D
JFYI the Arduino takes 15 minutes to paint the 480X320 mandelbrot and my desktop takes 7 seconds to paint the same 1920X1080 one :D
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
|
LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) {/* Window Procedure WndProc */
switch (message) {
case WM_PAINT:
SetWindowHandle(hwnd);
madelbrot();//display, increase zoom, redisplay, 300 times
break;
case WM_CLOSE:
if (MessageBox(hwnd, "Really quit?", "My Mandelbrot Fractal - Programming Techniques", MB_OKCANCEL) == IDOK) DestroyWindow(hwnd);
return 0;// Else: User canceled. Do nothing.
case WM_DESTROY:
PostQuitMessage(0);
return 0;
case WM_KEYDOWN:
if (wParam == VK_ESCAPE) {
PostQuitMessage(0);
return 0;
}
g_Keys[wParam & 0xFF] = true;
break;
case WM_KEYUP:
g_Keys[wParam & 0xFF] = false;
break;
default:
break; // FAIL to call DefWindowProc //
}
return DefWindowProc(hwnd, message, wParam, lParam);
|