Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages

  
 
  

home | help
resample_image(3)		 Arcan Lua API		     resample_image(3)

NAME
       resample_image -	scale an image to new dimensions using a shader

SYNOPSIS
       nil
       resample_image(	vid:src,  shid:shader, int:width, int:height, bool:no-
       synch )
       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	resam-
       ples to width  and height  output using the shader specified in	shader
       .  If  the second argument form is used,	the backing store of dst  will
       be replaced with	the resampled output rather than the backing store  of
       src . If	the nosynch  argument is specified (default to false), the lo-
       cal  memory  copy of the	backing	store will be ignored. This means that
       the backing can't be reconstructed if the engine	suspends to an	exter-
       nal  source which might lead to the data	being lost or the time to sus-
       pend increases to account for creation of the local copy.

NOTES
       1      The resampled storage is subject	to  the	 same  limitations  as
	      other image functions that create	a storage buffer, exceeding

	      MAX_SOURCEW , MAX_SOURCEH	 is a terminal state transition.

       2      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: 1. create temporary render-
	      buffer with a temporary output and a  null  object  reusing  the
	      storage in vid.  2. apply	shader,	do an off-screen pass into the
	      renderbuffer.   3. switch	glstore	from temporary into vid, read-
	      back into	local buffer and update	initial	state  values  (width,
	      height, ..).

EXAMPLE
       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
       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
       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				  April	2025		     resample_image(3)

Want to link to this manual page? Use this URL:
<https://man.freebsd.org/cgi/man.cgi?query=resample_image&sektion=3&manpath=FreeBSD+Ports+14.3.quarterly>

home | help