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. Double buffering dc with user mapping mode

Double buffering dc with user mapping mode

Scheduled Pinned Locked Moved C / C++ / MFC
questiongraphicsperformance
3 Posts 3 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.
  • E Offline
    E Offline
    edanvoye
    wrote on last edited by
    #1

    The following OnPaint code works very well with single buffering. With it I can zoom in and out, and pan the view. The drawing code doesn't have to be aware of the zoom factor or any other coordinate. But how do I turn this into double buffering ? what mapping mode whould I use on the memory dc ? CPaintDC outputdc( this ); // Client rect (size of window on screen) CRect clientRect; GetClientRect( &clientRect ); // Virtual rect (page coordinates) CRect virtualRect; virtualRect.left = m_CenterPos.x - (clientRect.Width()*m_fZoomFactor)/2; virtualRect.right = m_CenterPos.x + (clientRect.Width()*m_fZoomFactor)/2; virtualRect.top = m_CenterPos.y - (clientRect.Height()*m_fZoomFactor)/2; virtualRect.bottom = m_CenterPos.y + (clientRect.Height()*m_fZoomFactor)/2; // Sets the mapping mode for the specified center position and zoom factor SetMapMode(outputdc, MM_ISOTROPIC); SetWindowExtEx(outputdc, virtualRect.Width(), virtualRect.Height(), NULL); SetViewportExtEx(outputdc, clientRect.Width(), clientRect.Height(), NULL); SetWindowOrgEx(outputdc, virtualRect.left, virtualRect.top, NULL); // Draw EraseBackground( &outputdc, virtualRect ); m_GraphData.DrawData(&outputdc);

    Mircea PuiuM H 2 Replies Last reply
    0
    • E edanvoye

      The following OnPaint code works very well with single buffering. With it I can zoom in and out, and pan the view. The drawing code doesn't have to be aware of the zoom factor or any other coordinate. But how do I turn this into double buffering ? what mapping mode whould I use on the memory dc ? CPaintDC outputdc( this ); // Client rect (size of window on screen) CRect clientRect; GetClientRect( &clientRect ); // Virtual rect (page coordinates) CRect virtualRect; virtualRect.left = m_CenterPos.x - (clientRect.Width()*m_fZoomFactor)/2; virtualRect.right = m_CenterPos.x + (clientRect.Width()*m_fZoomFactor)/2; virtualRect.top = m_CenterPos.y - (clientRect.Height()*m_fZoomFactor)/2; virtualRect.bottom = m_CenterPos.y + (clientRect.Height()*m_fZoomFactor)/2; // Sets the mapping mode for the specified center position and zoom factor SetMapMode(outputdc, MM_ISOTROPIC); SetWindowExtEx(outputdc, virtualRect.Width(), virtualRect.Height(), NULL); SetViewportExtEx(outputdc, clientRect.Width(), clientRect.Height(), NULL); SetWindowOrgEx(outputdc, virtualRect.left, virtualRect.top, NULL); // Draw EraseBackground( &outputdc, virtualRect ); m_GraphData.DrawData(&outputdc);

      Mircea PuiuM Offline
      Mircea PuiuM Offline
      Mircea Puiu
      wrote on last edited by
      #2

      You should create a memory DC compatible with your output DC, draw whatever you need in the memory DC, then blit iits content on the output DC. SkyWalker

      1 Reply Last reply
      0
      • E edanvoye

        The following OnPaint code works very well with single buffering. With it I can zoom in and out, and pan the view. The drawing code doesn't have to be aware of the zoom factor or any other coordinate. But how do I turn this into double buffering ? what mapping mode whould I use on the memory dc ? CPaintDC outputdc( this ); // Client rect (size of window on screen) CRect clientRect; GetClientRect( &clientRect ); // Virtual rect (page coordinates) CRect virtualRect; virtualRect.left = m_CenterPos.x - (clientRect.Width()*m_fZoomFactor)/2; virtualRect.right = m_CenterPos.x + (clientRect.Width()*m_fZoomFactor)/2; virtualRect.top = m_CenterPos.y - (clientRect.Height()*m_fZoomFactor)/2; virtualRect.bottom = m_CenterPos.y + (clientRect.Height()*m_fZoomFactor)/2; // Sets the mapping mode for the specified center position and zoom factor SetMapMode(outputdc, MM_ISOTROPIC); SetWindowExtEx(outputdc, virtualRect.Width(), virtualRect.Height(), NULL); SetViewportExtEx(outputdc, clientRect.Width(), clientRect.Height(), NULL); SetWindowOrgEx(outputdc, virtualRect.left, virtualRect.top, NULL); // Draw EraseBackground( &outputdc, virtualRect ); m_GraphData.DrawData(&outputdc);

        H Offline
        H Offline
        ha_ha_ha
        wrote on last edited by
        #3

        Try applying the exact same transformations and drawing to the memory DC only. When done, call bitblt like this: outputdc.BitBlt(0, 0, clientRect.Width(), clientRect.Height(), &memdc, 0, 0, SRCCOPY);

        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