Advertisement
Guest User

Untitled

a guest
Dec 19th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. '//Global Objects/Variables required:
  2.     Dim Swap(0 To 1) As Direct3DSwapChain8 'represents our additional windows
  3.     Dim D3DWin(0 To 1) As D3DPRESENT_PARAMETERS 'creation information on the additional windows
  4.     Dim DepthBufferSurf As Direct3DSurface8 'the global Depth buffer
  5.     Dim RenderSurface(0 To 2) As Direct3DSurface8 'the 3 windows...
  6.  
  7. '//1. Create Device as normal
  8. '-make sure it's in windowed mode, make it use the first picture box (Picture1.hWnd)
  9.  
  10. '//2. Create additional swap chains - we're going to create 2 more (total of 3).
  11. '-In the main initialisation function, after creating the device
  12. '-Each swap chain represents an additional viewport
  13.     D3D.GetAdapterDisplayMode 0, DispMode
  14.      D3DWin(0).Windowed = 1 '//Tell it we're using Windowed Mode
  15.     D3DWin(0).SwapEffect = D3DSWAPEFFECT_COPY_VSYNC '//We'll refresh when the monitor does
  16.     D3DWin(0).BackBufferFormat = DispMode.Format '//We'll use the format we just retrieved...
  17.     D3DWin(0).EnableAutoDepthStencil = 1
  18.      D3DWin(0).hDeviceWindow = frmMain.Picture2.hWnd
  19.  
  20.      Set Swap(0) = D3DDevice.CreateAdditionalSwapChain(D3DWin(0))
  21.  
  22.      D3DWin(1).Windowed = 1  '//Tell it we're using Windowed Mode
  23.     D3DWin(1).SwapEffect = D3DSWAPEFFECT_COPY_VSYNC  '//We'll refresh when the monitor does
  24.     D3DWin(1).BackBufferFormat = DispMode.Format  '//We'll use the format we just retrieved...
  25.     D3DWin(1).EnableAutoDepthStencil = 1
  26.      D3DWin(1).hDeviceWindow = frmMain.Picture3.hWnd
  27.  
  28.      Set Swap(1) = D3DDevice.CreateAdditionalSwapChain(D3DWin(1))
  29.  
  30. '//3. Retrieve pointers to all the relevant surfaces.
  31. '-We recycle the same depth buffer, but should you want separate ones you can create a surface of the correct size
  32. '-and make it of format D3DFMT_D16 (or any other valid depth buffer format).
  33.     Set RenderSurface(0) = D3DDevice.GetBackBuffer(0, D3DBACKBUFFER_TYPE_MONO)
  34.          Set DepthBufferSurf = D3DDevice.GetDepthStencilSurface()
  35.      Set RenderSurface(1) = Swap(0).GetBackBuffer(0, D3DBACKBUFFER_TYPE_MONO)
  36.      Set RenderSurface(2) = Swap(1).GetBackBuffer(0, D3DBACKBUFFER_TYPE_MONO)
  37.  
  38. '//4. Restructure our rendering loop.
  39. '-note that we're rendering 3 times, which is effectively 3 frames, expect frame rate to drop...
  40.    '##START RENDERING OF FIRST WINDOW##
  41.    D3DDevice.SetRenderTarget RenderSurface(0), DepthBufferSurf, 0
  42.         'All subsequent calls for rendering will affect the first window
  43.        D3DDevice.Clear 0, ByVal 0, D3DCLEAR_TARGET Or D3DCLEAR_ZBUFFER, &HFF, 1#, 0
  44.         D3DDevice.BeginScene
  45.             'ALL RENDERING FOR FIRST WINDOW IN HERE!!
  46.        D3DDevice.EndScene
  47.         'display the first window.
  48.        D3DDevice.Present ByVal 0, ByVal 0, 0, ByVal 0
  49.        
  50.     '##START RENDERING OF SECOND WINDOW##
  51.    D3DDevice.SetRenderTarget RenderSurface(1), DepthBufferSurf, 0
  52.         'All subsequent calls for rendering will affect the first window
  53.        D3DDevice.Clear 0, ByVal 0, D3DCLEAR_TARGET Or D3DCLEAR_ZBUFFER, &HFF, 1#, 0
  54.         D3DDevice.BeginScene
  55.             'ALL RENDERING FOR FIRST WINDOW IN HERE!!
  56.        D3DDevice.EndScene
  57.         'display the first window.
  58.        Swap(0).Present ByVal 0, ByVal 0, 0, ByVal 0
  59.        
  60.     '##START RENDERING OF THIRD WINDOW##
  61.    D3DDevice.SetRenderTarget RenderSurface(2), DepthBufferSurf, 0
  62.         'All subsequent calls for rendering will affect the first window
  63.        D3DDevice.Clear 0, ByVal 0, D3DCLEAR_TARGET Or D3DCLEAR_ZBUFFER, &HFF, 1#, 0
  64.         D3DDevice.BeginScene
  65.             'ALL RENDERING FOR FIRST WINDOW IN HERE!!
  66.        D3DDevice.EndScene
  67.         'display the first window.
  68.        Swap(1).Present ByVal 0, ByVal 0, 0, ByVal 0
  69.  
  70.  
  71. '//IMPORTANT NOTE:
  72. 'ALL SURFACES MUST BE THE SAME SIZE, WHEN USING PICTURE BOXES (AS WE HAVE)
  73. 'ALL OF THEM MUST BE THE SAME SIZE, OR IN DESCENDING ORDER (1=>2=>3=>4), IF
  74. 'NOT, YOU'LL GET A FATAL ERROR!!
  75. ' - ALSO -
  76. 'YOU CAN HAVE ONLY 1 VIEWPORT IN FULLSCREEN MODE AT A TIME.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement