define_rendertarget(3)
π define_rendertarget(3) β Create an offscreen rendering pipe π
okay bestie, welcome to define_rendertarget(3) from the Library Functions Manual. This is the offscreen render pipe creator, and she is expensive yet powerful β no cap. β¨
π NAME π
define_rendertarget β Create an offscreen rendering pipe.
π¦ SYNOPSIS π¦
bool:status
define_rendertarget( vid:dst, t_vid:vtbl )
define_rendertarget( vid:dst, t_vid:vtbl, int:detach )
define_rendertarget( vid:dst, t_vid:vtbl, int:detach, int:scale )
define_rendertarget( vid:dst, t_vid:vtbl, int:detach, int:scale,
int:rate )
define_rendertarget( vid:dst, t_vid:vtbl, int:detach, int:scale,
int:rate, int:format )
define_rendertarget( vid:dst, t_vid:vtbl, int:detach, int:scale )
define_rendertarget( int:rate, int:format, float:hppcm, float:vppcm )
πΈ DESCRIPTION πΈ
This function creates a separate rendering pipeline that sends its output to the storage of another vid-connected object. The preconditions are that the dst is not part of the integer-indexed vtbl and that it has a textured backing store. alloc_surface is a particularly good function for creating a surface that can be used as a valid dst. This is an expensive yet powerful function that is the basis for many advanced effects, but also for offscreen composition and both synchronous and asynchronous GPU -> CPU transfers. π
The optional args, one by one:
detachβ optional; can be set toRENDERTARGET_DETACHorRENDERTARGET_NODETACH, and the default isRENDERTARGET_DETACH. ForRENDERTARGET_DETACH, all members ofvtblare disconnected from the main pipeline and only used when updatingdst, while their association is kept inRENDERTARGET_NODETACH.scaleβ optional; determines how the various output-relative properties e.g. object size should be handled in the case thatdstdoes not have the same dimensions as the current canvas. The default isRENDERTARGET_NOSCALE, where the object would simply be clipped if its final positions fall outside the dimensions of thedst. ForRENDERTARGET_SCALE, a scale transform that maps coordinates in the current canvas dimensions to those of thedst.rateβ optional; determines how often the rendertarget should be updated. A value of0disables automatic updates andrendertarget_forceupdateneeds to be called manually whenever the rendertarget is to be updated. A value ofINT_MIN < n < 0means that the rendertarget should only be updated everynvideo frames, and a value ofINT_MAX > n > 0means that the contents should be updated everynlogic ticks. Default is-1(every frame).formatβ optional; defines additional flags for the backing store ofdst. Possible values areRENDERTARGET_COLOR(default),RENDERTARGET_DEPTH,RENDERTARGET_FULLand the additional bitfieldsRENDERTARGET_MULTISAMPLEandRENDERTARGET_ALPHA. The difference betweenCOLORandFULLis that a stencil buffer (for certain clipping operations) is not always present inCOLOR.DEPTHis a special case primarily used when only the contents of the depth buffer is to be used. This operation converts the backing store from having a textured backing to aDEPTHone and makes a lot of other operations invalid. Its primary purpose is depth-buffer based 3D effects (e.g. shadow mapping). Note that you can control the format of the output throughalloc_surface.MULTISAMPLEβ a bitflag that can be set (bit.bor) for when you need higher quality rendering/anti-aliasing. It comes at a high cost when the rendertarget is updated both from the process itself and from an additional internal sampling of the multisample buffer into the datastore pointed to bydst. It is also likely to break if you are running on weak/old hardware on a GLES 2 level of acceleration. πALPHAβ another bitflag that can be set in order for the alpha channel contents to be kept rather than resolved.
π₯ NOTES π₯
- Using the same object or backing store for
dstand as a member ofvtblresults in undefined contents indst. π RENDERTARGET_SCALEtransform factors are not updated when/if the default canvas is resized.WORLDIDcan not be immediately used as part of the vid table, but it is possible to useimage_sharestorageto anull_surfaceand then use that as part of the vid table. The two caveats in that case is that the contents of thenull_surfacewill have its Y axis inverted and if the new rendertarget is visible in theWORLDID, the contents will quickly converge to an undefined state from the resulting feedback loop. π
π EXAMPLE π
okay bestie, here's the example β keep it exactly like this:
function define_rendertarget0()
local a = color_surface(64, 64, 0, 255, 0);
local rtgt = alloc_surface(320, 200);
define_rendertarget(rtgt, {a});
show_image({rtgt, a});
move_image(rtgt, 100, 100, 100);
move_image(rtgt, 0, 0, 100);
image_transform_cycle(rtgt, true);
end
π SEE ALSO: π
xoxo, your offscreen-render bestie π β from the Arcan Lua API, October 2026. periodt. π
π¦ where this page comes from
- nixos 26.05: arcan 0.7.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms