Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 6th, 2012  |  syntax: None  |  size: 0.98 KB  |  hits: 14  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. How to get device context in Direct3D10
  2. // create the texture
  3.     m_pDevice->CreateTexture(m_width, m_height, 1, 0, D3DFMT_X8R8G8B8, D3DPOOL_DEFAULT, &m_pTexture, NULL);
  4.     // get its surface (target surface)
  5.     m_pTexture->GetSurfaceLevel(0, &m_pSurface);
  6.     // create the second surface (source surface)
  7.     m_pDevice->CreateOffscreenPlainSurface(m_width, m_height, D3DFMT_X8R8G8B8, D3DPOOL_SYSTEMMEM, &m_pSurfaceMem, NULL);
  8.  
  9.     // drawing to Direct3D, this is called in loop
  10.     ...
  11.     m_pSurfaceMem->GetDC(&hdc);
  12.  
  13.     HRGN hrgn = CreateRectRgnIndirect(lprc);
  14.     SelectClipRgn(hdc, hrgn);
  15.     RECTL clipRect = { 0, 0, m_width, m_height };
  16.  
  17.     // This draws to the source surface
  18.     m_pViewObject->Draw(DVASPECT_TRANSPARENT, 1, NULL, NULL, NULL, hdc, &clipRect, &clipRect, NULL, 0);
  19.  
  20.     m_pSurfaceMem->ReleaseDC(hdc);
  21.     DeleteObject(hrgn);
  22.  
  23.     POINT pt = {lprc->left, lprc->top};
  24.     // Now update the target surface
  25.     m_pDevice->UpdateSurface(m_pSurfaceMem, lprc, m_pSurface, &pt);