newCanvas.lua 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. return {
  2. tag = 'graphicsObjects',
  3. summary = 'Create a new Canvas.',
  4. description = [[
  5. Creates a new Canvas. You can specify Textures to attach to it, or just specify a width and
  6. height and attach textures later using `Canvas:setTexture`.
  7. Once created, you can render to the Canvas using `Canvas:renderTo`, or
  8. `lovr.graphics.setCanvas`.
  9. ]],
  10. arguments = {
  11. width = {
  12. type = 'number',
  13. description = 'The width of the canvas, in pixels.'
  14. },
  15. height = {
  16. type = 'number',
  17. description = 'The height of the canvas, in pixels.'
  18. },
  19. ['...'] = {
  20. type = 'Texture',
  21. description = 'One or more Textures to attach to the Canvas.'
  22. },
  23. attachments = {
  24. type = 'table',
  25. description = 'A table of textures, layers, and mipmaps (in any combination) to attach.'
  26. },
  27. flags = {
  28. type = 'table',
  29. default = '{}',
  30. description = 'Optional settings for the Canvas.',
  31. table = {
  32. {
  33. name = 'format',
  34. type = 'TextureFormat',
  35. default = [['rgba']],
  36. description = [[
  37. The format of a Texture to create and attach to this Canvas, or false if no Texture
  38. should be created. This is ignored if Textures are already passed in.
  39. ]]
  40. },
  41. {
  42. name = 'depth',
  43. type = 'TextureFormat',
  44. default = [['d16']],
  45. description = [[
  46. A depth TextureFormat to use for the Canvas depth buffer, or false for no depth buffer.
  47. Note that this can also be a table with `format` and `readable` keys.
  48. ]]
  49. },
  50. {
  51. name = 'stereo',
  52. type = 'boolean',
  53. default = 'true',
  54. description = 'Whether the Canvas is stereo.'
  55. },
  56. {
  57. name = 'msaa',
  58. type = 'number',
  59. default = '0',
  60. description = 'The number of MSAA samples to use for antialiasing.'
  61. },
  62. {
  63. name = 'mipmaps',
  64. type = 'boolean',
  65. default = 'true',
  66. description = [[
  67. Whether the Canvas will automatically generate mipmaps for its attached textures.
  68. ]]
  69. }
  70. }
  71. }
  72. },
  73. returns = {
  74. canvas = {
  75. type = 'Canvas',
  76. description = 'The new Canvas.'
  77. }
  78. },
  79. variants = {
  80. {
  81. description = 'Create an empty Canvas with no Textures attached.',
  82. arguments = { 'width', 'height', 'flags' },
  83. returns = { 'canvas' }
  84. },
  85. {
  86. description = 'Create a Canvas with attached Textures.',
  87. arguments = { '...', 'flags' },
  88. returns = { 'canvas' }
  89. },
  90. {
  91. description = [[
  92. Create a Canvas with attached Textures, using specific layers and mipmap levels from each
  93. one. Layers and mipmaps can be specified after each Texture as numbers, or a table of a
  94. Texture, layer, and mipmap can be used for each attachment.
  95. ]],
  96. arguments = { 'attachments', 'flags' },
  97. returns = { 'canvas' }
  98. }
  99. },
  100. notes = [[
  101. Textures created by this function will have `clamp` as their `WrapMode`.
  102. Stereo Canvases will either have their width doubled or use array textures for their
  103. attachments, depending on their implementation.
  104. ]],
  105. related = {
  106. 'lovr.graphics.setCanvas',
  107. 'lovr.graphics.getCanvas',
  108. 'Canvas:renderTo'
  109. }
  110. }