Syncronization with the hardware
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: Syncronization with the hardware

Hybrid View

  1. #1
    Join Date
    Nov 2007
    Posts
    613

    Syncronization with the hardware

    Can I synchronize a thread with the monitor refresh ? Probably I could, because DirectX can, just I don't know how.

    More specifically, how can I predict the time a monitor refresh will occur ?

    (Although I'm a Visual C++ programmer I can take a little assembly language if necessary.)
    Share on Google+

  2. #2
    Join Date
    Apr 2010
    Posts
    15

    Re: Syncronization with the hardware

    What kind of synchronization do you want done by the thread? Are you looking to have it resume processing or stop processing (the current frame) and go on to something else?

    (I'm no expert on DirectX or other graphics topics, so take the following with the appropriate amound of salt.) If there is an API call involved (DriectX), you could set up an event that is signaled just before or after the monitor refresh. The thread to be synchronized can monitor the event and sychronize when it is signaled. Use WaitForSingleObject and give it a timeout value of zero. This will return immediately with the status of the event. If the event is auto-reset, the WaitForSingleObject call will reset it for the next synchronization.

    Is that the kind of thing you're looking for?
    Clay Breshears
    Intel Innovative Software Education

    "There are no evil threads; just threads programmed for evil."
    Share on Google+

  3. #3
    Join Date
    Nov 2007
    Posts
    613

    Re: Syncronization with the hardware

    I'm not expert in DirectX either, otherwise I wouldn't need any sychronization, DirectX does it natively.

    Knowng DirectX is great and I'll learn it when I'll have more time, but for simpler graphics, to me it looks like using a giant truck to carry an envelope.

    The cause somebody is looking for the monitor refresh is usually the desire of getting flicker free picture changes. I don't want a refresh to occur when half of the picture is drawn.

    (Double buffering greatly reduces flickering but still doesn't elliminate it totally, a refresh can still occur during that unique BitBlt form the memory DC to the window DC.)

    As about the difference between resuming or stopping processing I don't think it's important, I can write code to handle any of the two scenarios.

    The key issue is to have a clue about the moment the monitor refresh occur (a timer, an event, a value at a port, a function to get the timer status of refeshing, a small code to query the display adapter, etc).
    Share on Google+

  4. #4
    Lindley is offline Elite Member Power Poster
    Join Date
    Oct 2007
    Location
    Fairfax, VA
    Posts
    10,885

    Re: Syncronization with the hardware

    I don't know about DX, but many swap_buffers implementations are synced to the monitor refresh by default. I know glutSwapBuffers() is, because I had to fight it to get that disabled when I didn't want to be refresh-rate-limited.
    Share on Google+

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center