resample_image(3)
π resample_image β Arcan Lua API π
okay bestie, this is the resample_image(3) page from the Arcan Lua API, and it's literally the βscale an image to new dimensions using a shaderβ function. It's giving off-screen pass energy, and we're gonna go through every form, every note, and both extremely cursed misuse examples, no cap. π
β¨
β¨ NAME β¨
resample_image β scale an image to new dimensions using a shader. That's the whole pitch: textured object goes in, shader says how to resample, new width/height comes out. π
π§ SYNOPSIS π§
okay so the synopsis starts with nil, then gives you three call shapes β pick your fighter, bestie:
nil
resample_image( vid:src, shid:shader, int:width, int:height,
bool:nosynch )
resample_image( vid:src, shid:shader, int:width, int:height, vid:dst )
resample_image( vid:src, shid:shader, int:width, int:height, vid:dst,
bool:nosynch )
π DESCRIPTION π
This function takes the textured object referenced by src and resamples it to width and height output using the shader specified in shader. So src is the textured object, shader is the glow-up recipe, and width/height are the new dimensions. slay. π
If you use the second argument form, the backing store of dst will be replaced with the resampled output rather than the backing store of src. Translation: dst gets the new hotness, not src. π
If the nosynch argument is specified (default to false), the local memory copy of the backing store will be ignored. That means the backing can't be reconstructed if the engine suspends to an external source, which might lead to the data being lost β or the time to suspend increases to account for creation of the local copy. So yeah, be careful with that one. β οΈ
π NOTES π
- The resampled storage is subject to the same limitations as other image functions that create a storage buffer, exceeding
MAX_SOURCEW,MAX_SOURCEHis a terminal state transition. Like, terminal terminal β no coming back, bestie. π - This function internally aggregates several regular calls into one and presented here more for a convenience use of a complex setup. The flow can be modeled as:
- create temporary renderbuffer with a temporary output and a null object reusing the storage in
vid. - apply shader, do an off-screen pass into the renderbuffer.
- switch
glstorefrom temporary intovid, readback into local buffer and update initial state values (width,height, ..).
- create temporary renderbuffer with a temporary output and a null object reusing the storage in
πΈ EXAMPLE πΈ
here's the normal example β yes, the shader function is literally also named resample_image0, we love consistency:
function resample_image0()
local img = load_image("test.png");
local shid = build_shader(nil, [[
uniform sampler2D map_diffuse;
varying vec2 texco;
void resample_image0()
{
vec4 col = texture2D(map_diffuse, texco);
gl_FragColor = vec4(1.0, col.g, col.b, 1.0);
}
]], "redscale");
resample_image(img, shid, 640, 480);
show_image(img);
end
π MISUSE π
this first misuse is the βnegative dimensionsβ moment: resample_image(img, shid, -64, -64); β bestie, why π. The manual files it under MISUSE, so that's your warning:
function resample_image0()
local img = load_image("test.png");
local shid = build_shader(nil, [[
uniform sampler2D map_diffuse;
varying vec2 texco;
void resample_image0()
{
vec4 col = texture2D(map_diffuse, texco);
gl_FragColor = vec4(1.0, col.g, col.b, 1.0);
}
]], "redscale");
resample_image(img, shid, -64, -64);
end
π MISUSE π
and this second misuse goes big-big: resample_image(img, shid, 6400, 4800);. Again, filed under MISUSE in the manual β do not treat this as a cute suggestion. π
function resample_image1()
local img = load_image("test.png");
local shid = build_shader(nil, [[
uniform sampler2D map_diffuse;
varying vec2 texco;
void resample_image1()
{
vec4 col = texture2D(map_diffuse, texco);
gl_FragColor = vec4(1.0, col.g, col.b, 1.0);
}
]], "redscale");
resample_image(img, shid, 6400, 4800);
end
π SEE ALSO: π
image
with love from the image source/version, dated <month>October 2026</month> β resample_image(3) ππ«Ά
π¦ 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