Starting to learn shaders - what is the GLSL version of mapTexCoords()?

Hello all

Ive been learning how to write shaders for Openframeworks?

How can I write an example like this through GLSL?

planeFull.set(500, 389, 2, 2);
planeFull.mapTexCoords(0, 0, 500, 389);

From this code - the texture coordinates go from 0,0 to 250, 194

When I am writing code for placing where am image on a shape or plane, how do I move the texture coordinates?


I am getting this image to my screen

my vertex shader code is as follows -

#version 150

uniform mat4 modelViewProjectionMatrix;
in vec4 position;
in vec2 texcoord;

out vec2 varyingtexcoord;

void main(){

varyingtexcoord = texcoord;

gl_Position = modelViewProjectionMatrix * position;


and my fragment code is

// fragment shader

#version 150

#define PI 3.14159265359

uniform sampler2DRect webcam_texture;
uniform vec2 u_resolution;
uniform vec2 u_mouse;
uniform float u_time;
uniform float u_alpha;

in vec2 varyingtexcoord;

out vec4 outputColor;

void main()

//vec2 st = gl_FragCoord.y/u_resolution.xy;
//st.x *= u_resolution.x/u_resolution.y;

//vec3 color = vec3(0.);
//color = vec3(0.1,0.2,abs(sin(u_time)));

//outputColor = vec4(varyingtexcoord,0.0,1.0);

vec4 texel0 = texture(webcam_texture, varyingtexcoord);
outputColor = vec4(texel0);


im getting some signal into my shader but the coordinates are all wrong

where am i going wrong? any help would be amazing!