TextureBlend.bb 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. ; TextureBlend Example
  2. ; --------------------
  3. Graphics3D 640,480
  4. SetBuffer BackBuffer()
  5. camera=CreateCamera()
  6. ; Choose a background colour which isn't the same colour as anything else, to avoid confusion
  7. CameraClsColor camera,255,0,0
  8. light=CreateLight()
  9. RotateEntity light,90,0,0
  10. cube=CreateCube()
  11. PositionEntity cube,0,0,5
  12. ; Load textures
  13. tex0=LoadTexture( "media/b3dlogo.jpg" )
  14. tex1=LoadTexture( "media/chorme-2.bmp" )
  15. ; Texture cube with textures
  16. EntityTexture cube,tex0,0,0
  17. EntityTexture cube,tex1,0,1
  18. tex0_blend_info$="no texture"
  19. tex1_blend_info$="no texture"
  20. While Not KeyDown( 1 )
  21. ; Change texture 0 blending mode
  22. If KeyHit( 11 )=True
  23. tex0_blend=tex0_blend+1
  24. If tex0_blend=4 Then tex0_blend=0
  25. If tex0_blend=0 Then tex0_blend_info$="no texture"
  26. If tex0_blend=1 Then tex0_blend_info$="no blend"
  27. If tex0_blend=2 Then tex0_blend_info$="multiply"
  28. If tex0_blend=3 Then tex0_blend_info$="add"
  29. EndIf
  30. ; Change texture 1 blending mode
  31. If KeyHit( 2 )=True
  32. tex1_blend=tex1_blend+1
  33. If tex1_blend=4 Then tex1_blend=0
  34. If tex1_blend=0 Then tex1_blend_info$="no texture"
  35. If tex1_blend=1 Then tex1_blend_info$="no blend"
  36. If tex1_blend=2 Then tex1_blend_info$="multiply"
  37. If tex1_blend=3 Then tex1_blend_info$="add"
  38. EndIf
  39. ; Set texture blend modes
  40. TextureBlend tex0,tex0_blend
  41. TextureBlend tex1,tex1_blend
  42. TurnEntity cube,0.1,0.1,0.1
  43. RenderWorld
  44. Text 0,0,"Press 0 to change texture 0's blending mode"
  45. Text 0,20,"Press 1 to change texture 1's blending mode"
  46. Text 0,40,"TextureBlend tex0,"+tex0_blend+" ("+tex0_blend_info$+")"
  47. Text 0,60,"TextureBlend tex1,"+tex1_blend+" ("+tex1_blend_info$+")"
  48. Flip
  49. Wend
  50. End