home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 5_2007-2008.ISO / data / Zips / Post-Proce2075897172007.psc / clsRenderTarget.cls < prev    next >
Text File  |  2007-07-16  |  2KB  |  66 lines

  1. VERSION 1.0 CLASS
  2. BEGIN
  3.   MultiUse = -1  'True
  4.   Persistable = 0  'NotPersistable
  5.   DataBindingBehavior = 0  'vbNone
  6.   DataSourceBehavior  = 0  'vbNone
  7.   MTSTransactionMode  = 0  'NotAnMTSObject
  8. END
  9. Attribute VB_Name = "clsRenderTarget"
  10. Attribute VB_GlobalNameSpace = False
  11. Attribute VB_Creatable = True
  12. Attribute VB_PredeclaredId = False
  13. Attribute VB_Exposed = False
  14.  
  15. Option Explicit
  16.  
  17.  
  18. Public objTexture As Direct3DTexture8
  19.  
  20. Private objLastRT As Direct3DSurface8
  21. Private objLastDepth As Direct3DSurface8
  22. Private objThisRT As Direct3DSurface8
  23. Private objThisDepth As Direct3DSurface8
  24.  
  25.  
  26. Public Sub rtCreate(Width As Long, Height As Long)
  27.   
  28.   Set objTexture = objD3DDev.CreateTexture(Width, Height, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT)
  29.   
  30.   Set objThisRT = objTexture.GetSurfaceLevel(0)
  31.   Set objThisDepth = objD3DDev.CreateDepthStencilSurface(Width, Height, D3DFMT_D24S8, D3DMULTISAMPLE_NONE)
  32.  
  33. End Sub
  34.  
  35.  
  36. Public Sub rtAquire()
  37.   
  38.   Set objLastRT = objD3DDev.GetRenderTarget
  39.   Set objLastDepth = objD3DDev.GetDepthStencilSurface
  40.  
  41. End Sub
  42.  
  43.  
  44. Public Sub rtDestroy(TrueRT As Boolean)
  45.   
  46.   If TrueRT Then
  47.     Set objLastRT = Nothing
  48.     Set objLastDepth = Nothing
  49.   End If
  50.   Set objTexture = Nothing
  51.   Set objThisRT = Nothing
  52.   Set objThisDepth = Nothing
  53.   
  54. End Sub
  55.  
  56.  
  57. Public Sub rtEnable(rtSwitch As Boolean)
  58.   
  59.   If rtSwitch Then
  60.     objD3DDev.SetRenderTarget objThisRT, objThisDepth, 0
  61.   Else
  62.     objD3DDev.SetRenderTarget objLastRT, objLastDepth, 0
  63.   End If
  64.   
  65. End Sub
  66.