TextureBuffer.htm 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <html>
  2. <head>
  3. <title>Blitz3D Docs</title>
  4. <link rel=stylesheet href=../css/commands.css type=text/css>
  5. </head>
  6. <body>
  7. <h1>TextureBuffer ( texture[,frame] )</h1>
  8. <h1>Parameters</h1>
  9. <table>
  10. <tr>
  11. <td>
  12. texture - texture handle <br />
  13. frame (optional) - texture frame
  14. </td>
  15. </tr>
  16. </table>
  17. <h1>Description</h1>
  18. <table>
  19. <tr>
  20. <td>
  21. Returns the handle of a texture's drawing buffer. <br />
  22. <br />
  23. This can be used with SetBuffer to perform 2D drawing operations to the texture, although it's usually faster to draw to an image, and then copy the image buffer across to the texture buffer using CopyRect. <br />
  24. <br />
  25. You cannot render 3D to a texture buffer; 3D can only be rendered to the back buffer. To display 3D graphics on a texture, use CopyRect to copy the contents of the back buffer to a texture buffer.
  26. </td>
  27. </tr>
  28. </table>
  29. <h1><a href=../3d_examples/TextureBuffer.bb>Example</a></h1>
  30. <table>
  31. <tr>
  32. <td>
  33. ; TextureBuffer Example <br />
  34. ; --------------------- <br />
  35. <br />
  36. Graphics3D 640,480 <br />
  37. SetBuffer BackBuffer() <br />
  38. <br />
  39. camera=CreateCamera() <br />
  40. <br />
  41. light=CreateLight() <br />
  42. RotateEntity light,90,0,0 <br />
  43. <br />
  44. cube=CreateCube() <br />
  45. PositionEntity cube,0,0,5 <br />
  46. <br />
  47. ; Create texture of size 256x256 <br />
  48. tex=CreateTexture(256,256) <br />
  49. <br />
  50. ; Set buffer - texture buffer <br />
  51. SetBuffer TextureBuffer(tex) <br />
  52. <br />
  53. ; Clear texture buffer with background white color <br />
  54. ClsColor 255,255,255 <br />
  55. Cls <br />
  56. <br />
  57. ; Draw text on texture <br />
  58. font=LoadFont("arial",24) <br />
  59. SetFont font <br />
  60. Color 0,0,0 <br />
  61. Text 0,0,"This texture" <br />
  62. Text 0,40,"was created using" : Color 0,0,255 <br />
  63. Text 0,80,"CreateTexture()" : Color 0,0,0 <br />
  64. Text 0,120,"and drawn to using" : Color 0,0,255 <br />
  65. Text 0,160,"SetBuffer TextureBuffer()" <br />
  66. <br />
  67. ; Texture cube with texture <br />
  68. EntityTexture cube,tex <br />
  69. <br />
  70. ; Set buffer - backbuffer <br />
  71. SetBuffer BackBuffer() <br />
  72. <br />
  73. While Not KeyDown( 1 ) <br />
  74. <br />
  75. pitch#=0 <br />
  76. yaw#=0 <br />
  77. roll#=0 <br />
  78. <br />
  79. If KeyDown( 208 )=True Then pitch#=-1 <br />
  80. If KeyDown( 200 )=True Then pitch#=1 <br />
  81. If KeyDown( 203 )=True Then yaw#=-1 <br />
  82. If KeyDown( 205 )=True Then yaw#=1 <br />
  83. If KeyDown( 45 )=True Then roll#=-1 <br />
  84. If KeyDown( 44 )=True Then roll#=1 <br />
  85. <br />
  86. TurnEntity cube,pitch#,yaw#,roll# <br />
  87. <br />
  88. RenderWorld <br />
  89. Flip <br />
  90. <br />
  91. Wend <br />
  92. <br />
  93. End
  94. </td>
  95. </tr>
  96. </table>
  97. <br>
  98. <a target=_top href=../index.htm>Index</a><br>
  99. <br>
  100. Click <a href=http://www.blitzbasic.co.nz/b3ddocs/command.php?name=TextureBuffer&ref=comments target=_blank>here</a> to view the latest version of this page online</body>
  101. </html>