getPointer.lua 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. return {
  2. deprecated = true,
  3. tag = 'buffer-transfer',
  4. summary = 'Get a writable pointer to the Buffer\'s memory.',
  5. description = [[
  6. Returns a pointer to GPU memory and schedules a copy from this pointer to the buffer's data. The
  7. data in the pointer will replace the data in the buffer. This is intended for use with the
  8. LuaJIT FFI or for passing to C libraries.
  9. ]],
  10. arguments = {
  11. offset = {
  12. type = 'number',
  13. default = '0',
  14. description = 'A byte offset in the buffer to write to.'
  15. },
  16. extent = {
  17. type = 'number',
  18. default = 'nil',
  19. description = 'The number of bytes to replace. If nil, writes to the rest of the buffer.'
  20. }
  21. },
  22. returns = {
  23. pointer = {
  24. type = 'lightuserdata',
  25. description = 'A pointer to the Buffer\'s memory.'
  26. }
  27. },
  28. variants = {
  29. {
  30. arguments = { 'offset', 'extent' },
  31. returns = { 'pointer' }
  32. }
  33. },
  34. notes = [[
  35. The pointer remains valid until the next call to `lovr.graphics.submit`, during which the data
  36. in the pointer will be uploaded to the buffer.
  37. The initial contents of the pointer are undefined.
  38. Special care should be taken when writing data:
  39. - Reading data from the pointer will be very slow on some systems, and should be avoided.
  40. - It is better to write data to the pointer sequentially. Random access may be slower.
  41. ]],
  42. related = {
  43. 'Blob:getPointer',
  44. 'Buffer:mapData'
  45. }
  46. }