Skip to content

Commit 06a057d

Browse files
committed
3ds: fix blending
1 parent b3ad886 commit 06a057d

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

source/platforms/3ds/ctr_renderer.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -172,15 +172,16 @@ void CTRRenderer::draw(VertexArray *vertexArray,
172172
vtx->texcoord[1] = texture ? v.texCoords.y /
173173
(texture->getTextureRect().height *
174174
(texture->getTextureRect().height / texture->getSize().y)) : 0;
175-
vtx->blend[0] = 0; // reserved for future expansion
176-
vtx->blend[1] = texture ? (v.color != Color::White ? 1.0f : 0) : 1.0f;
175+
vtx->blend[0] = 0;
176+
float blend = v.color.r == 255 && v.color.g == 255 && v.color.b == 255 ? 0 : 1;
177+
vtx->blend[1] = texture ? blend : 1.0f;
177178
vtx->color = v.color.toABGR();
178179
}
179180

180-
size_t len = ctx.vtxBufPos - ctx.vtxBufLastPos;
181-
if (!len) return;
182-
C3D_DrawArrays(type, ctx.vtxBufLastPos, len);
183-
ctx.vtxBufLastPos = ctx.vtxBufPos;
181+
if (ctx.vtxBufPos - ctx.vtxBufLastPos) {
182+
C3D_DrawArrays(type, ctx.vtxBufLastPos, ctx.vtxBufPos - ctx.vtxBufLastPos);
183+
ctx.vtxBufLastPos = ctx.vtxBufPos;
184+
}
184185
}
185186

186187
void CTRRenderer::clear() {

test/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ int main(int argc, char **argv) {
3030
auto *tex = new C2DTexture(renderer->getIo()->getDataPath() + "gbatemp.png");
3131
if (tex->available) {
3232
tex->setPosition(rect->getSize().x / 2, rect->getSize().y / 2);
33-
//tex->setScale(0.5f * scaling, 0.5f * scaling);
33+
tex->setScale(0.5f * scaling, 0.5f * scaling);
3434
tex->setOrigin(Origin::Center);
3535
rect->add(tex);
3636
}

0 commit comments

Comments
 (0)