Add small example

This commit is contained in:
2020-03-18 22:42:04 +01:00
parent d15fb54804
commit b50cb62ac3
16 changed files with 386 additions and 23 deletions

View File

@@ -0,0 +1,8 @@
#version 330 core
layout (location = 0) in vec2 inputVertex;
void main()
{
gl_Position = vec4(inputVertex.x, inputVertex.y, 0.0, 1.0);
}

View File

@@ -0,0 +1,11 @@
#version 330 core
layout (location = 0) in vec2 inputVertex;
uniform float zoom;
uniform vec2 center_pos;
void main()
{
vec4 translated = (vec4(inputVertex.x, inputVertex.y, 0.0, 1.0) - vec4(center_pos.x, center_pos.y, 0.0, 0.0));
gl_Position = vec4(translated.x, translated.y, translated.z, translated.w) * vec4(zoom, zoom, 1, 1);
}

View File

@@ -0,0 +1,8 @@
#version 330 core
out vec4 fragmentColor;
void main()
{
fragmentColor = vec4(1.0, 0.0, 0.0, 0.0);
}

View File

@@ -0,0 +1,8 @@
#version 330 core
out vec4 fragmentColor;
void main()
{
fragmentColor = vec4(1.0, 0.0, 0.0, 0.0);
}

View File

@@ -0,0 +1,11 @@
#version 330 core
layout (location = 0) in vec2 inputVertex;
uniform float zoom;
uniform vec2 pos_offset;
void main()
{
vec2 pos2d = (inputVertex - pos_offset) * zoom;
gl_Position = vec4(pos2d.x , pos2d.y, 0.0, 1.0);
}

View File

@@ -0,0 +1,15 @@
#version 330 core
layout (points) in;
layout (triangle_strip, max_vertices=3) out;
void main()
{
gl_Position = gl_in[0].gl_Position + vec4(-0.1, 0.0, 0.0, 0.0);
EmitVertex();
gl_Position = gl_in[0].gl_Position + vec4(0.0, 0.1, 0.0, 0.0);
EmitVertex();
gl_Position = gl_in[0].gl_Position + vec4(0.1, 0.0, 0.0, 0.0);
EmitVertex();
EndPrimitive();
}

View File

@@ -0,0 +1,17 @@
#version 330 core
layout (points) in;
layout (triangle_strip, max_vertices=3) out;
uniform float zoom;
void main()
{
gl_Position = gl_in[0].gl_Position + vec4(-0.1, 0.0, 0.0, 0.0) * zoom;
EmitVertex();
gl_Position = gl_in[0].gl_Position + vec4(0.0, 0.1, 0.0, 0.0) * zoom;
EmitVertex();
gl_Position = gl_in[0].gl_Position + vec4(0.1, 0.0, 0.0, 0.0) * zoom;
EmitVertex();
EndPrimitive();
}