test_shaderattrib.py 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. from panda3d import core
  2. def test_shaderattrib_flags():
  3. # Ensure the old single-flag behavior still works
  4. shattr = core.ShaderAttrib.make()
  5. # Make sure we have the flag
  6. shattr = shattr.set_flag(core.ShaderAttrib.F_hardware_skinning, True)
  7. assert shattr.get_flag(core.ShaderAttrib.F_hardware_skinning)
  8. # Make sure we don't have a flag that we didn't set
  9. assert not shattr.get_flag(core.ShaderAttrib.F_subsume_alpha_test)
  10. # Clear it, we should not longer have the flag
  11. shattr = shattr.clear_flag(core.ShaderAttrib.F_hardware_skinning)
  12. assert not shattr.get_flag(core.ShaderAttrib.F_hardware_skinning)
  13. # Set a flag to false, we shouldn't have it
  14. shattr = shattr.set_flag(core.ShaderAttrib.F_hardware_skinning, False)
  15. assert not shattr.get_flag(core.ShaderAttrib.F_hardware_skinning)
  16. # Ensure the new behavior works
  17. shattr = core.ShaderAttrib.make()
  18. # Make sure we have the flags
  19. shattr = shattr.set_flag(core.ShaderAttrib.F_hardware_skinning | core.ShaderAttrib.F_subsume_alpha_test, True)
  20. assert shattr.get_flag(core.ShaderAttrib.F_hardware_skinning | core.ShaderAttrib.F_subsume_alpha_test)
  21. # Make sure we don't have a flag that we didn't set
  22. assert not shattr.get_flag(core.ShaderAttrib.F_shader_point_size)
  23. # ...group of flags we didn't set
  24. assert not shattr.get_flag(core.ShaderAttrib.F_disable_alpha_write | core.ShaderAttrib.F_shader_point_size)
  25. # Make sure they clear correctly
  26. shattr = shattr.clear_flag(core.ShaderAttrib.F_hardware_skinning | core.ShaderAttrib.F_subsume_alpha_test)
  27. assert not shattr.get_flag(core.ShaderAttrib.F_hardware_skinning | core.ShaderAttrib.F_subsume_alpha_test)
  28. # Set group to false
  29. shattr = shattr.set_flag(core.ShaderAttrib.F_hardware_skinning | core.ShaderAttrib.F_subsume_alpha_test, False)
  30. assert not shattr.get_flag(core.ShaderAttrib.F_hardware_skinning | core.ShaderAttrib.F_subsume_alpha_test)
  31. def test_shaderattrib_compare():
  32. shattr1 = core.ShaderAttrib.make()
  33. shattr2 = core.ShaderAttrib.make()
  34. assert shattr1.compare_to(shattr2) == 0
  35. assert shattr2.compare_to(shattr1) == 0
  36. shattr2 = core.ShaderAttrib.make().set_flag(core.ShaderAttrib.F_subsume_alpha_test, False)
  37. assert shattr1.compare_to(shattr2) != 0
  38. assert shattr2.compare_to(shattr1) != 0
  39. shattr1 = core.ShaderAttrib.make().set_flag(core.ShaderAttrib.F_subsume_alpha_test, False)
  40. assert shattr1.compare_to(shattr2) == 0
  41. assert shattr2.compare_to(shattr1) == 0
  42. shattr2 = core.ShaderAttrib.make().set_flag(core.ShaderAttrib.F_subsume_alpha_test, True)
  43. assert shattr1.compare_to(shattr2) != 0
  44. assert shattr2.compare_to(shattr1) != 0