__BulbRendererDefineNormal.gml 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. // Feather disable all
  2. function __BulbRendererDefineNormal()
  3. {
  4. normalMap = BULB_DEFAULT_USE_NORMAL_MAP;
  5. __oldNormalMap = undefined;
  6. __normalSurface = undefined;
  7. GetNormalMapSurface = function()
  8. {
  9. if (not normalMap)
  10. {
  11. __BulbError("Cannot call .GetNormalMapSurface(), `normalMap` is not set to `true`");
  12. }
  13. if ((__surfaceWidth <= 0) || (__surfaceHeight <= 0)) return undefined;
  14. if ((__normalSurface != undefined) && ((surface_get_width(__normalSurface) != __surfaceWidth) || (surface_get_height(__normalSurface) != __surfaceHeight)))
  15. {
  16. surface_free(__normalSurface);
  17. __normalSurface = undefined;
  18. }
  19. if ((__normalSurface == undefined) || !surface_exists(__normalSurface))
  20. {
  21. __normalSurface = surface_create(__surfaceWidth, __surfaceHeight);
  22. surface_set_target(__normalSurface);
  23. BulbNormalMapClear();
  24. surface_reset_target();
  25. }
  26. return __normalSurface;
  27. }
  28. DrawNormalMapDebug = function(_x, _y, _width, _height)
  29. {
  30. draw_surface_stretched(GetNormalMapSurface(), _x, _y, _width, _height);
  31. }
  32. __FreeNormalMapSurface = function()
  33. {
  34. if ((__normalSurface != undefined) && surface_exists(__normalSurface))
  35. {
  36. surface_free(__normalSurface);
  37. __normalSurface = undefined;
  38. }
  39. }
  40. }