CreateTexture.bb 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. ; CreateTexture Example
  2. ; ---------------------
  3. Graphics3D 640,480
  4. SetBuffer BackBuffer()
  5. camera=CreateCamera()
  6. light=CreateLight()
  7. RotateEntity light,90,0,0
  8. cube=CreateCube()
  9. PositionEntity cube,0,0,5
  10. ; Create texture of size 256x256
  11. tex=CreateTexture( 256,256 )
  12. ; Set buffer - texture buffer
  13. SetBuffer TextureBuffer( tex )
  14. ; Clear texture buffer with background white color
  15. ClsColor 255,255,255
  16. Cls
  17. ; Draw text on texture
  18. font=LoadFont( "arial",24 )
  19. SetFont font
  20. Color 0,0,0
  21. Text 0,0,"This texture"
  22. Text 0,40,"was created using" : Color 0,0,255
  23. Text 0,80,"CreateTexture()" : Color 0,0,0
  24. Text 0,120,"and drawn to using" : Color 0,0,255
  25. Text 0,160,"SetBuffer TextureBuffer()"
  26. ; Texture cube with texture
  27. EntityTexture cube,tex
  28. ; Set buffer - backbuffer
  29. SetBuffer BackBuffer()
  30. While Not KeyDown( 1 )
  31. pitch#=0
  32. yaw#=0
  33. roll#=0
  34. If KeyDown( 208 )=True Then pitch#=-1
  35. If KeyDown( 200 )=True Then pitch#=1
  36. If KeyDown( 203 )=True Then yaw#=-1
  37. If KeyDown( 205 )=True Then yaw#=1
  38. If KeyDown( 45 )=True Then roll#=-1
  39. If KeyDown( 44 )=True Then roll#=1
  40. TurnEntity cube,pitch#,yaw#,roll#
  41. RenderWorld
  42. Flip
  43. Wend
  44. End