Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- '//Global Objects/Variables required:
- Dim Swap(0 To 1) As Direct3DSwapChain8 'represents our additional windows
- Dim D3DWin(0 To 1) As D3DPRESENT_PARAMETERS 'creation information on the additional windows
- Dim DepthBufferSurf As Direct3DSurface8 'the global Depth buffer
- Dim RenderSurface(0 To 2) As Direct3DSurface8 'the 3 windows...
- '//1. Create Device as normal
- '-make sure it's in windowed mode, make it use the first picture box (Picture1.hWnd)
- '//2. Create additional swap chains - we're going to create 2 more (total of 3).
- '-In the main initialisation function, after creating the device
- '-Each swap chain represents an additional viewport
- D3D.GetAdapterDisplayMode 0, DispMode
- D3DWin(0).Windowed = 1 '//Tell it we're using Windowed Mode
- D3DWin(0).SwapEffect = D3DSWAPEFFECT_COPY_VSYNC '//We'll refresh when the monitor does
- D3DWin(0).BackBufferFormat = DispMode.Format '//We'll use the format we just retrieved...
- D3DWin(0).EnableAutoDepthStencil = 1
- D3DWin(0).hDeviceWindow = frmMain.Picture2.hWnd
- Set Swap(0) = D3DDevice.CreateAdditionalSwapChain(D3DWin(0))
- D3DWin(1).Windowed = 1 '//Tell it we're using Windowed Mode
- D3DWin(1).SwapEffect = D3DSWAPEFFECT_COPY_VSYNC '//We'll refresh when the monitor does
- D3DWin(1).BackBufferFormat = DispMode.Format '//We'll use the format we just retrieved...
- D3DWin(1).EnableAutoDepthStencil = 1
- D3DWin(1).hDeviceWindow = frmMain.Picture3.hWnd
- Set Swap(1) = D3DDevice.CreateAdditionalSwapChain(D3DWin(1))
- '//3. Retrieve pointers to all the relevant surfaces.
- '-We recycle the same depth buffer, but should you want separate ones you can create a surface of the correct size
- '-and make it of format D3DFMT_D16 (or any other valid depth buffer format).
- Set RenderSurface(0) = D3DDevice.GetBackBuffer(0, D3DBACKBUFFER_TYPE_MONO)
- Set DepthBufferSurf = D3DDevice.GetDepthStencilSurface()
- Set RenderSurface(1) = Swap(0).GetBackBuffer(0, D3DBACKBUFFER_TYPE_MONO)
- Set RenderSurface(2) = Swap(1).GetBackBuffer(0, D3DBACKBUFFER_TYPE_MONO)
- '//4. Restructure our rendering loop.
- '-note that we're rendering 3 times, which is effectively 3 frames, expect frame rate to drop...
- '##START RENDERING OF FIRST WINDOW##
- D3DDevice.SetRenderTarget RenderSurface(0), DepthBufferSurf, 0
- 'All subsequent calls for rendering will affect the first window
- D3DDevice.Clear 0, ByVal 0, D3DCLEAR_TARGET Or D3DCLEAR_ZBUFFER, &HFF, 1#, 0
- D3DDevice.BeginScene
- 'ALL RENDERING FOR FIRST WINDOW IN HERE!!
- D3DDevice.EndScene
- 'display the first window.
- D3DDevice.Present ByVal 0, ByVal 0, 0, ByVal 0
- '##START RENDERING OF SECOND WINDOW##
- D3DDevice.SetRenderTarget RenderSurface(1), DepthBufferSurf, 0
- 'All subsequent calls for rendering will affect the first window
- D3DDevice.Clear 0, ByVal 0, D3DCLEAR_TARGET Or D3DCLEAR_ZBUFFER, &HFF, 1#, 0
- D3DDevice.BeginScene
- 'ALL RENDERING FOR FIRST WINDOW IN HERE!!
- D3DDevice.EndScene
- 'display the first window.
- Swap(0).Present ByVal 0, ByVal 0, 0, ByVal 0
- '##START RENDERING OF THIRD WINDOW##
- D3DDevice.SetRenderTarget RenderSurface(2), DepthBufferSurf, 0
- 'All subsequent calls for rendering will affect the first window
- D3DDevice.Clear 0, ByVal 0, D3DCLEAR_TARGET Or D3DCLEAR_ZBUFFER, &HFF, 1#, 0
- D3DDevice.BeginScene
- 'ALL RENDERING FOR FIRST WINDOW IN HERE!!
- D3DDevice.EndScene
- 'display the first window.
- Swap(1).Present ByVal 0, ByVal 0, 0, ByVal 0
- '//IMPORTANT NOTE:
- 'ALL SURFACES MUST BE THE SAME SIZE, WHEN USING PICTURE BOXES (AS WE HAVE)
- 'ALL OF THEM MUST BE THE SAME SIZE, OR IN DESCENDING ORDER (1=>2=>3=>4), IF
- 'NOT, YOU'LL GET A FATAL ERROR!!
- ' - ALSO -
- 'YOU CAN HAVE ONLY 1 VIEWPORT IN FULLSCREEN MODE AT A TIME.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement