multi_tex.bb 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. Global info1$="Multitexturing demo"
  2. Include "../start.bb"
  3. AmbientLight 0,0,0
  4. ;Load base texture
  5. logo=LoadTexture( "blitzlogo.bmp" )
  6. ;create next grid texture
  7. grid=CreateTexture( 64,64,0 )
  8. ScaleTexture grid,.5,.5
  9. SetBuffer TextureBuffer( grid )
  10. Color 255,255,255:Rect 0,0,32,32
  11. Color 128,128,128:Rect 32,0,32,32
  12. Color 128,128,128:Rect 0,32,32,32
  13. Color 255,255,255:Rect 32,32,32,32
  14. Color 0,0,255
  15. SetBuffer BackBuffer()
  16. Color 255,255,255
  17. ;load top environment texture
  18. env=LoadTexture( "spheremap.bmp",67 )
  19. ;create cube
  20. cube=CreateCube()
  21. EntityTexture cube,logo,0,0
  22. EntityTexture cube,grid,0,1
  23. EntityTexture cube,env,0,2
  24. UpdateNormals cube
  25. camera=CreateCamera()
  26. PositionEntity camera,0,0,-4
  27. light=CreateLight()
  28. TurnEntity light,45,45,0
  29. LightColor light,255,0,0
  30. light=CreateLight()
  31. TurnEntity light,-45,45,0
  32. LightColor light,0,255,0
  33. light=CreateLight()
  34. TurnEntity light,45,-45,0
  35. LightColor light,0,0,255
  36. hw=True
  37. HWMultiTex hw
  38. blend1=2
  39. blend2=2
  40. blend3=1
  41. TextureBlend logo,blend1
  42. TextureBlend grid,blend2
  43. TextureBlend env,blend3
  44. While Not KeyHit(1)
  45. If KeyHit(59)
  46. blend1=blend1+1
  47. If blend1=4 blend1=0
  48. TextureBlend logo,blend1
  49. EndIf
  50. If KeyHit(60)
  51. blend2=blend2+1
  52. If blend2=4 blend2=0
  53. TextureBlend grid,blend2
  54. EndIf
  55. If KeyHit(61)
  56. blend3=blend3+1
  57. If blend3=4 blend3=0
  58. TextureBlend env,blend3
  59. EndIf
  60. If KeyHit(57)
  61. hw=Not hw
  62. HWMultiTex hw
  63. EndIf
  64. If KeyDown(30)
  65. TranslateEntity camera,0,0,.1
  66. EndIf
  67. If KeyDown(44)
  68. TranslateEntity camera,0,0,-.1
  69. EndIf
  70. off#=off#-.01
  71. PositionTexture logo,off,0
  72. TurnEntity cube,.1,.2,.3
  73. UpdateWorld
  74. RenderWorld
  75. Text 0,FontHeight()*0,"(F1) TextureBlend 1="+mode$(blend1)
  76. Text 0,FontHeight()*1,"(F2) TextureBlend 2="+mode$(blend2)
  77. Text 0,FontHeight()*2,"(F3) TextureBlend 3="+mode$(blend3)
  78. If hw t$="On" Else t$="Off"
  79. Text 0,FontHeight()*4,"(SPC) HW Multitexture="+t$
  80. Flip
  81. Wend
  82. End
  83. Function mode$( mode )
  84. Select mode
  85. Case 0:Return "0 (Off)"
  86. Case 1:Return "1 (Alpha)"
  87. Case 2:Return "2 (Multiply)"
  88. Case 3:Return "3 (Add)"
  89. End Select
  90. Return "Unkown"
  91. End Function