gl renderer: extend border cells

webgl-renderer
cpsdqs 7 years ago
parent 9ed8412edd
commit c89d3d2254
Signed by untrusted user: cpsdqs
GPG Key ID: 3F59586BB7448DD1
  1. 19
      js/term/webgl_renderer.js

@ -44,6 +44,7 @@ module.exports = class WebGLRenderer extends EventEmitter {
this.screenAttrs = [] this.screenAttrs = []
this.screenSelection = [] this.screenSelection = []
this.cursor = {} this.cursor = {}
this.reverseVideo = false
this.hasBlinkingCells = false this.hasBlinkingCells = false
this.statusScreen = null this.statusScreen = null
@ -209,8 +210,11 @@ precision mediump float;
attribute vec2 position; attribute vec2 position;
uniform mat4 projection; uniform mat4 projection;
uniform vec2 char_pos; uniform vec2 char_pos;
uniform vec2 extend;
void main() { void main() {
gl_Position = projection * vec4(char_pos + position, 0.0, 1.0); vec2 scale = vec2(1.0 + abs(extend.x), 1.0 + abs(extend.y));
vec2 offset = min(vec2(0.0, 0.0), extend);
gl_Position = projection * vec4(char_pos + offset + scale * position, 0.0, 1.0);
} }
`, ` `, `
precision highp float; precision highp float;
@ -248,6 +252,7 @@ void main() {
uniforms: { uniforms: {
projection: gl.getUniformLocation(bgShader, 'projection'), projection: gl.getUniformLocation(bgShader, 'projection'),
charPos: gl.getUniformLocation(bgShader, 'char_pos'), charPos: gl.getUniformLocation(bgShader, 'char_pos'),
extend: gl.getUniformLocation(bgShader, 'extend'),
color: gl.getUniformLocation(bgShader, 'color') color: gl.getUniformLocation(bgShader, 'color')
} }
} }
@ -333,7 +338,7 @@ void main() {
} }
if (attrs & ATTR_INVERSE) [fg, bg] = [bg, fg] // swap - reversed character colors if (attrs & ATTR_INVERSE) [fg, bg] = [bg, fg] // swap - reversed character colors
if (this.screen.reverseVideo) [fg, bg] = [bg, fg] // swap - reversed all screen if (this.reverseVideo) [fg, bg] = [bg, fg] // swap - reversed all screen
if (attrs & ATTR_BLINK && !this.blinkStyleOn) { if (attrs & ATTR_BLINK && !this.blinkStyleOn) {
// blinking is enabled and blink style is off // blinking is enabled and blink style is off
@ -352,6 +357,16 @@ void main() {
gl.uniform2f(this.bgShader.uniforms.charPos, x, y) gl.uniform2f(this.bgShader.uniforms.charPos, x, y)
gl.uniform4f(this.bgShader.uniforms.color, ...this.getColor(bg)) gl.uniform4f(this.bgShader.uniforms.color, ...this.getColor(bg))
let extendX = 0
let extendY = 0
if (x === 0) extendX = -1
if (x === width - 1) extendX = 1
if (y === 0) extendY = -1
if (y === height - 1) extendY = 1
gl.uniform2f(this.bgShader.uniforms.extend, extendX, extendY)
this.drawSquare() this.drawSquare()
if (text.trim()) { if (text.trim()) {

Loading…
Cancel
Save