#version 460

#extension GL_EXT_buffer_reference : require
#extension GL_GOOGLE_include_directive : require

#include "structures.glsl"

layout (location = 0) in vec2 in_gui_pos_0;
layout (location = 1) in vec2 in_gui_pos_1;
layout (location = 2) in vec4 in_col;

layout (location = 0) out vec4 out_color;

void main()
{
	// Draw with 6 indices, gl_VertexIndex will use the appropriate index, iterates through 0-3 and not 0-5
	vec2 dst_pos = gl_VertexIndex == 0 ? vec2(in_gui_pos_0.x, in_gui_pos_1.y) :
								 gl_VertexIndex == 1 ? vec2(in_gui_pos_0.x, in_gui_pos_0.y) :
								 gl_VertexIndex == 2 ? vec2(in_gui_pos_1.x, in_gui_pos_1.y) :
								 gl_VertexIndex == 3 ? vec2(in_gui_pos_1.x, in_gui_pos_0.y) : vec2(0.0, 0.0);

	out_color = in_col;
	gl_Position = vec4(2 * dst_pos.x / PC.res.x - 1,
										 2 * dst_pos.y / PC.res.y - 1,
										 0,
										 1);
}
