#version 430 core

layout (location = 0) in vec2 position;
layout (location = 1) in vec4 color;
layout (location = 2) in vec2 uv;

out Fragment
{
	// @Performance: Are this fields aligned to vec4? Is it better to reorder them?
	vec2 position;
	vec4 color;
	vec2 uv;
} frag;

uniform int width;  // Width  of the screen in pixels
uniform int height; // Height of the screen in pixels

void main()
{
	frag.position = position;
	frag.color = color;
	frag.uv = uv;

	vec2 screen = vec2(width, height);

	vec2 p = position / screen * 2.0 - 1.0; // Position relative to the screen size, in range [-1,+1)
	p.y = -p.y; // OpenGL coordinates have y up, pixel coordinates have y down

	gl_Position = vec4(p, 0.0, 1.0);
}
