BulbDrawLitSurface.gml 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. // Feather disable all
  2. /// @param bulbRenderer
  3. /// @param surface
  4. /// @param [x]
  5. /// @param [y]
  6. /// @param [width]
  7. /// @param [height]
  8. /// @param [textureFiltering]
  9. /// @param [alphaBlend=false]
  10. function BulbDrawLitSurface(_renderer, _surface, _x = undefined, _y = undefined, _width = undefined, _height = undefined, _textureFiltering = undefined, _alphaBlend = false)
  11. {
  12. if (surface_get_target() == _surface)
  13. {
  14. __BulbError("Cannot call BulbDrawLitSurface() when the destination surface and drawn surface are the same\nIf you are drawing the application surface, use a Post-Draw event or GUI draw event");
  15. }
  16. if ((_x == undefined) || (_y == undefined) || (_width == undefined) || (_height == undefined))
  17. {
  18. var _positionArray = application_get_position();
  19. _x = _positionArray[0];
  20. _y = _positionArray[1];
  21. _width = _positionArray[2] - _x;
  22. _height = _positionArray[3] - _y;
  23. }
  24. if (_renderer == undefined)
  25. {
  26. if (_textureFiltering != undefined)
  27. {
  28. var _oldTextureFiltering = gpu_get_tex_filter();
  29. gpu_set_tex_filter(_textureFiltering);
  30. }
  31. if (_alphaBlend != undefined)
  32. {
  33. var _oldAlphaBlend = gpu_get_blendenable();
  34. gpu_set_blendenable(_alphaBlend);
  35. }
  36. draw_surface_stretched(_surface, _x, _y, _width, _height);
  37. if (_textureFiltering != undefined)
  38. {
  39. gpu_set_tex_filter(_oldTextureFiltering);
  40. }
  41. if (_alphaBlend != undefined)
  42. {
  43. gpu_set_blendenable(_oldAlphaBlend);
  44. }
  45. }
  46. else
  47. {
  48. _renderer.DrawLitSurface(_surface, _x, _y, _width, _height, _textureFiltering, _alphaBlend);
  49. }
  50. }