all repos — mgba @ 6eab8d3418507fb9491f7890357b9d2eaec57383

mGBA Game Boy Advance Emulator

GBA Video: GL OBJ mosaic
Vicki Pfau vi@endrift.com
Mon, 20 May 2019 10:26:01 -0700
commit

6eab8d3418507fb9491f7890357b9d2eaec57383

parent

d84793edeef33a3641ae8b6bbb9741e1cd29cd64

2 files changed, 16 insertions(+), 1 deletions(-)

jump to
M include/mgba/internal/gba/renderers/gl.hinclude/mgba/internal/gba/renderers/gl.h

@@ -103,6 +103,7 @@ GBA_GL_OBJ_INFLAGS,

GBA_GL_OBJ_TRANSFORM, GBA_GL_OBJ_DIMS, GBA_GL_OBJ_OBJWIN, + GBA_GL_OBJ_MOSAIC, GBA_GL_FINALIZE_SCALE = 2, GBA_GL_FINALIZE_LAYERS,
M src/gba/renderers/gl.csrc/gba/renderers/gl.c

@@ -378,6 +378,7 @@ { "inflags", GBA_GL_OBJ_INFLAGS, },

{ "transform", GBA_GL_OBJ_TRANSFORM, }, { "dims", GBA_GL_OBJ_DIMS, }, { "objwin", GBA_GL_OBJ_OBJWIN, }, + { "mosaic", GBA_GL_OBJ_MOSAIC, }, { 0 } };

@@ -392,6 +393,7 @@ "uniform ivec4 inflags;\n"

"uniform mat2x2 transform;\n" "uniform ivec4 dims;\n" "uniform vec4 objwin;\n" + "uniform ivec4 mosaic;\n" "out vec4 color;\n" "out vec4 flags;\n" "out vec3 window;\n"

@@ -400,7 +402,14 @@

"vec4 renderTile(int tile, int paletteId, ivec2 localCoord);\n" "void main() {\n" - " ivec2 coord = ivec2(transform * (texCoord - dims.zw / 2) + dims.xy / 2);\n" + " vec2 incoord = texCoord;\n" + " if (mosaic.x > 1) {\n" + " incoord.x -= mod(mosaic.z + incoord.x, mosaic.x);\n" + " }\n" + " if (mosaic.y > 1) {\n" + " incoord.y -= mod(mosaic.w + incoord.y, mosaic.y);\n" + " }\n" + " ivec2 coord = ivec2(transform * (incoord - dims.zw / 2) + dims.xy / 2);\n" " if ((coord & ~(dims.xy - 1)) != ivec2(0, 0)) {\n" " discard;\n" " }\n"

@@ -1304,6 +1313,11 @@ glDrawBuffers(3, (GLenum[]) { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1, GL_COLOR_ATTACHMENT2 });

} else { glUniform4f(uniforms[GBA_GL_OBJ_OBJWIN], 0, 0, 0, 0); glDrawBuffers(2, (GLenum[]) { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1 }); + } + if (GBAObjAttributesAIsMosaic(sprite->a)) { + glUniform4i(uniforms[GBA_GL_OBJ_MOSAIC], GBAMosaicControlGetObjV(renderer->mosaic), GBAMosaicControlGetObjH(renderer->mosaic), x, spriteY); + } else { + glUniform4i(uniforms[GBA_GL_OBJ_MOSAIC], 0, 0, 0, 0); } glEnableVertexAttribArray(0); glDrawArrays(GL_TRIANGLE_FAN, 0, 4);