made rendering transparent (for obs capture) work with scaling and terminal
This commit is contained in:
parent
cafd9f8132
commit
63c1def130
|
@ -62,7 +62,7 @@ public class Test extends BaseGame {
|
|||
@Override
|
||||
protected void update(double delta) {
|
||||
var mouse = window.getMousePos();
|
||||
term.clear(Color.BLACK);
|
||||
term.clear(Color.TRANS_BLACK);
|
||||
var col = window.isMouseDown(0) ? Color.RED : Color.GREEN;
|
||||
term.setBackgroundColor(Vec2i.div(mouse, term.getFullCharSize()), col);
|
||||
if(window.isMouseClicked(1)) {
|
||||
|
|
|
@ -176,10 +176,11 @@ class RenderContext extends BaseRenderContext implements IRenderContext {
|
|||
tbr = Vec2i.sub(tex.getTexArea().getBottomRight(), topleft);
|
||||
}
|
||||
|
||||
glUniform3f(tintIndex,
|
||||
glUniform4f(tintIndex,
|
||||
color.getR() / 255.0f,
|
||||
color.getG() / 255.0f,
|
||||
color.getB() / 255.0f
|
||||
color.getB() / 255.0f,
|
||||
color.getA() / 255.0f
|
||||
);
|
||||
//color.getA() / 255.0f);
|
||||
|
||||
|
|
|
@ -34,12 +34,16 @@ public class Window extends BaseWindow {
|
|||
layout(binding = 0) uniform sampler2D tex;
|
||||
layout(location = 3) uniform ivec2 texOffset;
|
||||
layout(location = 4) uniform ivec2 texSize;
|
||||
layout(location = 5) uniform vec3 tint;
|
||||
layout(location = 5) uniform vec4 tint;
|
||||
out vec4 color;
|
||||
void main() {
|
||||
//color = vec4(vec2(texCoord).x/1000.f, 0.2f, 0.7f, 1.0f);
|
||||
//color = texture(tex, texCoord);
|
||||
color = texelFetch(tex, ivec2(mod(texCoord, texSize)) + texOffset, 0) * vec4(tint, 1.0f);
|
||||
vec4 col = texelFetch(tex, ivec2(mod(texCoord, texSize)) + texOffset, 0);
|
||||
|
||||
if(tint.a > 0.0) {
|
||||
color = col * tint;
|
||||
}
|
||||
}
|
||||
""";
|
||||
|
||||
|
@ -61,7 +65,10 @@ public class Window extends BaseWindow {
|
|||
out vec4 color;
|
||||
void main() {
|
||||
//color = vec4(vec2(texCoord).x/1000.f, 0.2f, 0.7f, 1.0f);
|
||||
color = texture(tex, texCoord);
|
||||
vec4 col = texture(tex, texCoord);
|
||||
if(col.a > 0.0) {
|
||||
color = col;
|
||||
}
|
||||
//color = texelFetch(tex, ivec2(texCoord), 0);
|
||||
//color = vec4(1.0, 1.0, 1.0, 1.0);
|
||||
//color = vec4(texCoord.xy, 0.0, 1.0);
|
||||
|
@ -122,11 +129,11 @@ public class Window extends BaseWindow {
|
|||
glBindTexture(GL_TEXTURE_2D, framebufferTex);
|
||||
glTexImage2D(GL_TEXTURE_2D,
|
||||
0,
|
||||
GL_RGB,
|
||||
GL_RGBA,
|
||||
size.getX(),
|
||||
size.getY(),
|
||||
0,
|
||||
GL_RGB,
|
||||
GL_RGBA,
|
||||
GL_UNSIGNED_BYTE,
|
||||
0
|
||||
);
|
||||
|
@ -229,10 +236,11 @@ public class Window extends BaseWindow {
|
|||
);
|
||||
}
|
||||
//glEnd();
|
||||
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
glViewport(0, 0, windowSize.getX(), windowSize.getY());
|
||||
programScaler.use();
|
||||
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
|
||||
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, framebufferTex);
|
||||
|
@ -319,7 +327,7 @@ public class Window extends BaseWindow {
|
|||
glBindFramebuffer(GL_FRAMEBUFFER, framebuffer);
|
||||
glViewport(0, 0, size.getX(), size.getY());
|
||||
textureAtlas.update();
|
||||
glClearColor(0.f, 0.f, 0.f, 1.0f);
|
||||
glClearColor(0.f, 0.f, 0.f, 0.0f);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
program.use();
|
||||
//glBegin(GL_TRIANGLES);
|
||||
|
|
|
@ -12,6 +12,7 @@ public final class Color {
|
|||
public final static Color YELLOW = new Color(255, 255, 0);
|
||||
public final static Color MAGENTA = new Color(255, 0, 255);
|
||||
public final static Color CYAN = new Color(0, 255, 255);
|
||||
public final static Color TRANS_BLACK = new Color(0, 0, 0, 0);
|
||||
private final int r, g, b, a;
|
||||
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ public class Terminal {
|
|||
cell.fullChar = 0;
|
||||
cell.secondChar = 0;
|
||||
cell.halfWidth = false;
|
||||
cell.bgColor = Color.BLACK;
|
||||
cell.bgColor = Color.TRANS_BLACK;
|
||||
cell.fgColor = Color.WHITE;
|
||||
cells.add(cell);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue