2016-06-30 00:01:22 -04:00
|
|
|
// Copyright 2016 Joe Wilm, The Alacritty Project Contributors
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
2016-02-23 23:42:58 -05:00
|
|
|
#version 330 core
|
2016-02-27 16:08:39 -05:00
|
|
|
layout (location = 0) in vec2 position;
|
2016-06-04 18:30:17 -04:00
|
|
|
|
2016-06-06 16:20:35 -04:00
|
|
|
// Cell properties
|
|
|
|
layout (location = 1) in vec2 gridCoords;
|
|
|
|
|
|
|
|
// glyph properties
|
|
|
|
layout (location = 2) in vec4 glyph;
|
|
|
|
|
|
|
|
// uv mapping
|
|
|
|
layout (location = 3) in vec4 uv;
|
|
|
|
|
|
|
|
// text fg color
|
|
|
|
layout (location = 4) in vec3 textColor;
|
2016-06-06 19:54:15 -04:00
|
|
|
// Background color
|
|
|
|
layout (location = 5) in vec3 backgroundColor;
|
2016-06-06 16:20:35 -04:00
|
|
|
|
2016-02-23 23:42:58 -05:00
|
|
|
out vec2 TexCoords;
|
2016-06-06 16:20:35 -04:00
|
|
|
out vec3 fg;
|
2016-06-06 19:54:15 -04:00
|
|
|
out vec3 bg;
|
2016-02-23 23:42:58 -05:00
|
|
|
|
2016-06-04 18:30:17 -04:00
|
|
|
// Terminal properties
|
|
|
|
uniform vec2 termDim;
|
|
|
|
uniform vec2 cellDim;
|
|
|
|
|
2017-02-03 18:34:52 -05:00
|
|
|
uniform float visualBell;
|
2016-06-06 19:54:15 -04:00
|
|
|
uniform int backgroundPass;
|
|
|
|
|
2016-06-04 18:30:17 -04:00
|
|
|
// Orthographic projection
|
2016-02-23 23:42:58 -05:00
|
|
|
uniform mat4 projection;
|
2017-02-03 18:34:52 -05:00
|
|
|
flat out float vb;
|
2016-06-06 19:54:15 -04:00
|
|
|
flat out int background;
|
2016-02-23 23:42:58 -05:00
|
|
|
|
|
|
|
void main()
|
|
|
|
{
|
2016-06-06 16:20:35 -04:00
|
|
|
vec2 glyphOffset = glyph.xy;
|
|
|
|
vec2 glyphSize = glyph.zw;
|
|
|
|
vec2 uvOffset = uv.xy;
|
|
|
|
vec2 uvSize = uv.zw;
|
2016-06-05 00:26:28 -04:00
|
|
|
|
2016-06-04 18:30:17 -04:00
|
|
|
// Position of cell from top-left
|
2016-06-09 23:39:40 -04:00
|
|
|
vec2 cellPosition = (cellDim) * gridCoords;
|
2016-06-04 18:30:17 -04:00
|
|
|
|
|
|
|
// Invert Y since framebuffer origin is bottom-left
|
|
|
|
cellPosition.y = termDim.y - cellPosition.y - cellDim.y;
|
|
|
|
|
2016-06-06 19:54:15 -04:00
|
|
|
if (backgroundPass != 0) {
|
|
|
|
cellPosition.y = cellPosition.y - 3;
|
2016-06-09 23:39:40 -04:00
|
|
|
vec2 finalPosition = cellDim * position + cellPosition;
|
2016-06-06 19:54:15 -04:00
|
|
|
gl_Position = projection * vec4(finalPosition.xy, 0.0, 1.0);
|
|
|
|
TexCoords = vec2(0, 0);
|
|
|
|
} else {
|
|
|
|
|
|
|
|
// Glyphs are offset within their cell; account for y-flip
|
|
|
|
vec2 cellOffset = vec2(glyphOffset.x, glyphOffset.y - glyphSize.y);
|
|
|
|
|
|
|
|
// position coordinates are normalized on [0, 1]
|
|
|
|
vec2 finalPosition = glyphSize * position + cellPosition + cellOffset;
|
2016-06-04 18:30:17 -04:00
|
|
|
|
2016-06-06 19:54:15 -04:00
|
|
|
gl_Position = projection * vec4(finalPosition.xy, 0.0, 1.0);
|
|
|
|
TexCoords = uvOffset + vec2(position.x, 1 - position.y) * uvSize;
|
|
|
|
}
|
2016-06-04 18:30:17 -04:00
|
|
|
|
2017-02-03 18:34:52 -05:00
|
|
|
vb = visualBell;
|
2016-06-06 19:54:15 -04:00
|
|
|
background = backgroundPass;
|
|
|
|
bg = backgroundColor / vec3(255.0, 255.0, 255.0);
|
2016-06-06 16:20:35 -04:00
|
|
|
fg = textColor / vec3(255.0, 255.0, 255.0);
|
2016-02-23 23:42:58 -05:00
|
|
|
}
|