render.go 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. package al
  2. /*
  3. #include <stdlib.h>
  4. #include <allegro5/allegro.h>
  5. #include "helpers.h"
  6. */
  7. import "C"
  8. type RenderState = C.ALLEGRO_RENDER_STATE
  9. const (
  10. ALPHA_TEST = RenderState(C.ALLEGRO_ALPHA_TEST )
  11. WRITE_MASK = RenderState(C.ALLEGRO_WRITE_MASK )
  12. DEPTH_TEST = RenderState(C.ALLEGRO_DEPTH_TEST )
  13. DEPTH_FUNCTION = RenderState(C.ALLEGRO_DEPTH_FUNCTION )
  14. ALPHA_FUNCTION = RenderState(C.ALLEGRO_ALPHA_FUNCTION )
  15. ALPHA_TEST_VALUE = RenderState(C.ALLEGRO_ALPHA_TEST_VALUE)
  16. )
  17. func (rs RenderState) toC() C.ALLEGRO_RENDER_STATE {
  18. return C.ALLEGRO_RENDER_STATE(rs)
  19. }
  20. // not usable as such, cast to int in stead
  21. // type RenderFunction = C.ALLEGRO_RENDER_FUNCTION
  22. const (
  23. RENDER_NEVER = int(C.ALLEGRO_RENDER_NEVER )
  24. RENDER_ALWAYS = int(C.ALLEGRO_RENDER_ALWAYS )
  25. RENDER_LESS = int(C.ALLEGRO_RENDER_LESS )
  26. RENDER_EQUAL = int(C.ALLEGRO_RENDER_EQUAL )
  27. RENDER_LESS_EQUAL = int(C.ALLEGRO_RENDER_LESS_EQUAL )
  28. RENDER_GREATER = int(C.ALLEGRO_RENDER_GREATER )
  29. RENDER_NOT_EQUAL = int(C.ALLEGRO_RENDER_NOT_EQUAL )
  30. RENDER_GREATER_EQUAL = int(C.ALLEGRO_RENDER_GREATER_EQUAL)
  31. )
  32. // not usable as such, cast to int in stead
  33. // type WriteMaskFlags C.ALLEGRO_WRITE_MASK_FLAGS
  34. const (
  35. MASK_RED = int(C.ALLEGRO_MASK_RED )
  36. MASK_GREEN = int(C.ALLEGRO_MASK_GREEN)
  37. MASK_BLUE = int(C.ALLEGRO_MASK_BLUE )
  38. MASK_ALPHA = int(C.ALLEGRO_MASK_ALPHA)
  39. MASK_DEPTH = int(C.ALLEGRO_MASK_DEPTH)
  40. MASK_RGB = int(C.ALLEGRO_MASK_RGB )
  41. MASK_RGBA = int(C.ALLEGRO_MASK_RGBA )
  42. )
  43. func SetRenderState(state RenderState, value int) {
  44. C.al_set_render_state(state.toC(), C.int(value))
  45. }