setPixels.lua 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. return {
  2. tag = 'texture-transfer',
  3. summary = 'Replace pixels in the Texture.',
  4. description = [[
  5. Sets pixels in the texture. The source data can be an `Image` with the pixels to upload, or
  6. another `Texture` object to copy from.
  7. ]],
  8. arguments = {
  9. image = {
  10. type = 'Image',
  11. description = 'The image to copy to the texture.'
  12. },
  13. texture = {
  14. type = 'Texture',
  15. description = 'The texture to copy from.'
  16. },
  17. dstx = {
  18. type = 'number',
  19. default = '0',
  20. description = 'The x offset to copy to.'
  21. },
  22. dsty = {
  23. type = 'number',
  24. default = '0',
  25. description = 'The y offset to copy to.'
  26. },
  27. dstlayer = {
  28. type = 'number',
  29. default = '1',
  30. description = 'The index of the layer to copy to.'
  31. },
  32. dstmipmap = {
  33. type = 'number',
  34. default = '1',
  35. description = 'The index of the mipmap level to copy to.'
  36. },
  37. srcx = {
  38. type = 'number',
  39. default = '0',
  40. description = 'The x offset to copy from.'
  41. },
  42. srcy = {
  43. type = 'number',
  44. default = '0',
  45. description = 'The y offset to copy from.'
  46. },
  47. srclayer = {
  48. type = 'number',
  49. default = '1',
  50. description = 'The index of the layer to copy from.'
  51. },
  52. srcmipmap = {
  53. type = 'number',
  54. default = '1',
  55. description = 'The index of the mipmap level to copy from.'
  56. },
  57. width = {
  58. type = 'number',
  59. default = 'nil',
  60. description = [[
  61. The width of the region of pixels to copy. If nil, the maximum possible width will be used,
  62. based on the widths of the source/destination and the offset parameters.
  63. ]]
  64. },
  65. height = {
  66. type = 'number',
  67. default = 'nil',
  68. description = [[
  69. The height of the region of pixels to copy. If nil, the maximum possible height will be
  70. used, based on the heights of the source/destination and the offset parameters.
  71. ]]
  72. },
  73. layers = {
  74. type = 'number',
  75. default = 'nil',
  76. description = 'The number of layers to copy. If nil, copies as many layers as possible.'
  77. },
  78. srcwidth = {
  79. type = 'number',
  80. default = 'width',
  81. description = [[
  82. The width of the region in the source texture to copy. If it doesn't match `width`, the
  83. copy will be scaled up or down to fit.
  84. ]]
  85. },
  86. srcheight = {
  87. type = 'number',
  88. default = 'width',
  89. description = [[
  90. The height of the region in the source texture to copy. If it doesn't match `height`, the
  91. copy will be scaled up or down to fit.
  92. ]]
  93. },
  94. srcdepth = {
  95. type = 'number',
  96. default = 'layers',
  97. description = 'The depth of the region in the source texture to copy (`3d` textures only).'
  98. },
  99. filter = {
  100. type = 'FilterMode',
  101. default = [['linear']],
  102. description = [[
  103. The filtering mode used to scale the copy when the source and destination sizes don't match.
  104. ]]
  105. }
  106. },
  107. returns = {},
  108. variants = {
  109. {
  110. arguments = { 'image', 'dstx', 'dsty', 'dstlayer', 'dstmipmap', 'srcx', 'srcy', 'srclayer', 'srcmipmap', 'width', 'height', 'layers' },
  111. returns = {}
  112. },
  113. {
  114. arguments = { 'texture', 'dstx', 'dsty', 'dstlayer', 'dstmipmap', 'srcx', 'srcy', 'srclayer', 'srcmipmap', 'width', 'height', 'layers', 'srcwidth', 'srcheight', 'srcdepth', 'filter' },
  115. returns = {}
  116. }
  117. },
  118. notes = [[
  119. The destination and source textures must have been created with the `transfer` usage.
  120. Multisampled textures can not be copied.
  121. It is not currently possible to copy to or from a texture view.
  122. Copying between textures requires them to have the same format.
  123. When using different region sizes in a texture-to-texture copy:
  124. - It is not possible to mix 3D with non-3D textures.
  125. - Not every texture format is supported, use `lovr.graphics.isFormatSupported` to check.
  126. ]],
  127. related = {
  128. 'Texture:newReadback',
  129. 'Image:paste'
  130. }
  131. }