1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-24 07:14:31 +01:00

implement a ping-pong framebuffer

This commit is contained in:
Ted John
2016-06-11 15:18:31 +01:00
parent db01547ae6
commit 2a569dc062
13 changed files with 363 additions and 26 deletions

View File

@@ -0,0 +1,13 @@
#version 330
uniform sampler2D uTexture;
in vec2 fPosition;
in vec2 fTextureCoordinate;
layout (location = 0) out vec4 oColour;
void main()
{
oColour = texture(uTexture, fTextureCoordinate);
}

View File

@@ -0,0 +1,42 @@
#version 330
uniform ivec2 uScreenSize;
uniform ivec4 uBounds;
uniform ivec4 uTextureCoordinates;
in int vIndex;
out vec2 fPosition;
out vec2 fTextureCoordinate;
void main()
{
vec2 pos;
switch (vIndex) {
case 0:
pos = uBounds.xy;
fTextureCoordinate = uTextureCoordinates.xy;
break;
case 1:
pos = uBounds.zy;
fTextureCoordinate = uTextureCoordinates.zy;
break;
case 2:
pos = uBounds.zw;
fTextureCoordinate = uTextureCoordinates.zw;
break;
case 3:
pos = uBounds.xw;
fTextureCoordinate = uTextureCoordinates.xw;
break;
}
fPosition = pos;
// Transform screen coordinates to viewport
pos.x = (pos.x * (2.0 / uScreenSize.x)) - 1.0;
pos.y = (pos.y * (2.0 / uScreenSize.y)) - 1.0;
pos.y *= -1;
gl_Position = vec4(pos, 0.0, 1.0);
}