Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How strange are these problems?

How strange are these problems?

Scheduled Pinned Locked Moved C / C++ / MFC
graphicsdebuggingquestion
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Alan Chambers
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups