alloc_surface(3)

πŸ“¦
version 0.7.1 Β· 2 versions
, in nixos 26.05

πŸ’– alloc_surface(3) πŸ’–

okay so real quick β€” this page is from the Arcan Lua API manual, and it's genuinely one of the handiest little calls in the whole thing, so buckle up bestie πŸŽ€


✨ NAME ✨

alloc_surface β€” creates an empty, non-visible surface with a preset storage. that's it, that's the whole vibe πŸ’…


πŸ¦‹ SYNOPSIS πŸ¦‹

vid
alloc_surface( int:width, int:height )
alloc_surface( int:width, int:height, bool:noalpha )
alloc_surface( int:width, int:height, bool:noalpha, int:quality )

three flavours, pick your fighter πŸ’œ


🌸 DESCRIPTION 🌸

so like, some operations β€” especially record and rendertargets β€” literally need a storage buffer to work with. they can't just manifest one out of pure main character energy, they need somewhere to put pixels.

now, you could use fill_surface for those operations too, but alloc_surface is giving efficiency queen: it results in one less transfer. and optionally you get some control over the storage format and quality. obsessed. πŸ”₯

here's the tea on the args:

  • if noalpha is set (true, !0) the texture format for the underlying backing store will be set to one where the alpha channel corresponds to fullbright (ignore/nobright). no half-transparent nonsense, we're going full send πŸ’€
  • quality can be set to one of the following:
    • ALLOC_QUALITY_LOW
    • ALLOC_QUALITY_NORMAL
    • ALLOC_QUALITY_HIGH
    • ALLOC_QUALITY_FLOAT 16
    • ALLOC_QUALITY_FLOAT 32

🧚 NOTES 🧚

  1. only ALLOC_QUALITY_NORMAL is guaranteed to be a valid target for map_video_display and similar operations. the others are living dangerously, and honestly? respect. πŸ™ˆ
  2. note that not all storage modes will support all forms of filtering, or mipmapping. if in doubt, disable vfilter and manually sample in a shader. ngl that's the safe play, no cap ✨
heads up bestie β€” those two notes are the difference between "slay" and "why is my render target doing that". read them twice. 🫢

⭐ EXAMPLE ⭐

function alloc_surface0()
      local vid = fill_surface(640, 480);
      assert(vid ~= BADID)
      print("allocated: ", vid, 640, 480);
      show_image(vid);
end

look at her go 😭 allocating at 640 Γ— 480, checking it against BADID like a responsible icon, printing, then show_image. we love a full pipeline. πŸ‘‘


πŸ’€ MISUSE πŸ’€

function alloc_surface0()
      fill_surface(-1, -1);
end

negative dimensions? absolutely not. that's a vibe check failure fr fr πŸ™ˆ


πŸ’€ MISUSE πŸ’€

function alloc_surface1()
      fill_surface(1000000, 100000000);
end

a million by a hundred million. bestie. bestie. that is not a surface, that's a cry for help 😭 your GPU is not ok


🌈 SEE ALSO: 🌈

  • image

okay that's the whole page, you're officially caught up πŸ’– stay hydrated, keep your quality at ALLOC_QUALITY_NORMAL unless you know exactly what you're doing, and remember: this gem comes to you from the Arcan Lua API manual, dated October 2026 β€” see you in the next group chat, mwah πŸŽ€πŸ’œπŸ¦‹

πŸ“¦ where this page comes from