How strange are these problems?
-
OK, I have the following code which starts my app rolling: int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR szCommandLine, int nCmdShow) { if (FAILED(InitApp(hInstance, nCmdShow))) return 0; //* MSG msg; while(GetMessage(&msg, NULL, 0, 0)) { TranslateMessage(&msg); ProcessMessage(&msg); } return 0; } I have set up my own WindowProc (Fullscreen Exclusive) and initialised DirectDraw, a Primary Surface and Direct3D (global variables initialised in InitApp). OK, if I then load a bitmap into a plain offscreen surface (same res as screen), and bltfast it to the Primary Surface back buffer at the //* point and call the primary buffer flip() routine, the bitmap appears, magic. However, if I then bltfast the same picture to the backbuffer (that was the primary surface before the flip) but at a ddiferent position and then call the primary buffer flip() routine again, it is blank (sometimes I get a flicker of the picture before it goes blank). So something must be clearing the data of the primary buffer, I assume? Now for the strange things: 1.) If I set up a timer and handle it in my window proc, with the exact same code, it works, I get a small animation where the picture moves from point a to point b. 2.) Every time I start the app the initial Primary Surface gets cleared and is blank (Is this perhaps to do with my WindowClass which sets the screen to blackness - even though the primary surface hasn't been created at this point?), but the back buffer retains any previous image that was drawn into it. Yes thats right, if I eliminate all drawing code and merely flip() the Primary Surface, up comes the image I displayed in a previous debug initiation, but if I flip again its blank etc. 3.) Now for the one that will have you rocking. Assuming the bltfast code etc. is by the //* position of my code above. Insert the line MessageBox(GetActiveWindow(), "YAY", "YAY", MB_OK); at that point, but above the bltfast code, IT WORKS! You get a message box and then once you click ok, the primary surface flips a couple of times and leaves you with a beautiful bitmap (no blank surface). If anyone can answer any of these strange problems, I would well appreciate it. I have had to buy head and shoulders shampoo cos I've scratched my head so much. "When I left you I was but the learner, now I am the master" - Darth Vader