kwin: add support for y-inverted textures to the Cube effect
This commit is contained in:
parent
aa14d53b71
commit
827f9219be
1 changed files with 47 additions and 19 deletions
|
@ -939,6 +939,15 @@ void CubeEffect::paintCubeCap()
|
||||||
float texY2 = 0.0;
|
float texY2 = 0.0;
|
||||||
float texY3 = 0.0;
|
float texY3 = 0.0;
|
||||||
if (texture) {
|
if (texture) {
|
||||||
|
if (capTexture->isYInverted()) {
|
||||||
|
texX1 = x1 / (rect.width()) + 0.5;
|
||||||
|
texY1 = 0.5 + z1 / zTexture * 0.5;
|
||||||
|
texX2 = x2 / (rect.width()) + 0.5;
|
||||||
|
texY2 = 0.5 + z2 / zTexture * 0.5;
|
||||||
|
texX3 = x3 / (rect.width()) + 0.5;
|
||||||
|
texY3 = 0.5 + z3 / zTexture * 0.5;
|
||||||
|
texCoords << texX1 << texY1;
|
||||||
|
} else {
|
||||||
texX1 = x1 / (rect.width()) + 0.5;
|
texX1 = x1 / (rect.width()) + 0.5;
|
||||||
texY1 = 0.5 - z1 / zTexture * 0.5;
|
texY1 = 0.5 - z1 / zTexture * 0.5;
|
||||||
texX2 = x2 / (rect.width()) + 0.5;
|
texX2 = x2 / (rect.width()) + 0.5;
|
||||||
|
@ -947,6 +956,7 @@ void CubeEffect::paintCubeCap()
|
||||||
texY3 = 0.5 - z3 / zTexture * 0.5;
|
texY3 = 0.5 - z3 / zTexture * 0.5;
|
||||||
texCoords << texX1 << texY1;
|
texCoords << texX1 << texY1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
verts << x1 << 0.0 << z1;
|
verts << x1 << 0.0 << z1;
|
||||||
if (texture) {
|
if (texture) {
|
||||||
texCoords << texX2 << texY2;
|
texCoords << texX2 << texY2;
|
||||||
|
@ -990,6 +1000,14 @@ void CubeEffect::paintCylinderCap()
|
||||||
const float z3 = segment * (i - 1) * cos(azimuthAngle2);
|
const float z3 = segment * (i - 1) * cos(azimuthAngle2);
|
||||||
const float z4 = segment * i * cos(azimuthAngle2);
|
const float z4 = segment * i * cos(azimuthAngle2);
|
||||||
if (texture) {
|
if (texture) {
|
||||||
|
if (capTexture->isYInverted()) {
|
||||||
|
texCoords << (radius + x1) / (radius * 2.0f) << (z1 + radius) / (radius * 2.0f);
|
||||||
|
texCoords << (radius + x2) / (radius * 2.0f) << (z2 + radius) / (radius * 2.0f);
|
||||||
|
texCoords << (radius + x3) / (radius * 2.0f) << (z3 + radius) / (radius * 2.0f);
|
||||||
|
texCoords << (radius + x4) / (radius * 2.0f) << (z4 + radius) / (radius * 2.0f);
|
||||||
|
texCoords << (radius + x3) / (radius * 2.0f) << (z3 + radius) / (radius * 2.0f);
|
||||||
|
texCoords << (radius + x2) / (radius * 2.0f) << (z2 + radius) / (radius * 2.0f);
|
||||||
|
} else {
|
||||||
texCoords << (radius + x1) / (radius * 2.0f) << 1.0f - (z1 + radius) / (radius * 2.0f);
|
texCoords << (radius + x1) / (radius * 2.0f) << 1.0f - (z1 + radius) / (radius * 2.0f);
|
||||||
texCoords << (radius + x2) / (radius * 2.0f) << 1.0f - (z2 + radius) / (radius * 2.0f);
|
texCoords << (radius + x2) / (radius * 2.0f) << 1.0f - (z2 + radius) / (radius * 2.0f);
|
||||||
texCoords << (radius + x3) / (radius * 2.0f) << 1.0f - (z3 + radius) / (radius * 2.0f);
|
texCoords << (radius + x3) / (radius * 2.0f) << 1.0f - (z3 + radius) / (radius * 2.0f);
|
||||||
|
@ -997,6 +1015,7 @@ void CubeEffect::paintCylinderCap()
|
||||||
texCoords << (radius + x3) / (radius * 2.0f) << 1.0f - (z3 + radius) / (radius * 2.0f);
|
texCoords << (radius + x3) / (radius * 2.0f) << 1.0f - (z3 + radius) / (radius * 2.0f);
|
||||||
texCoords << (radius + x2) / (radius * 2.0f) << 1.0f - (z2 + radius) / (radius * 2.0f);
|
texCoords << (radius + x2) / (radius * 2.0f) << 1.0f - (z2 + radius) / (radius * 2.0f);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
verts << x1 << 0.0 << z1;
|
verts << x1 << 0.0 << z1;
|
||||||
verts << x2 << 0.0 << z2;
|
verts << x2 << 0.0 << z2;
|
||||||
verts << x3 << 0.0 << z3;
|
verts << x3 << 0.0 << z3;
|
||||||
|
@ -1038,6 +1057,14 @@ void CubeEffect::paintSphereCap()
|
||||||
const float x4 = radius * sin(topAngle) * sin((90.0 + (j + 1) * 10.0) * M_PI / 180.0);
|
const float x4 = radius * sin(topAngle) * sin((90.0 + (j + 1) * 10.0) * M_PI / 180.0);
|
||||||
const float z4 = radius * sin(topAngle) * cos((90.0 + (j + 1) * 10.0) * M_PI / 180.0);
|
const float z4 = radius * sin(topAngle) * cos((90.0 + (j + 1) * 10.0) * M_PI / 180.0);
|
||||||
if (texture) {
|
if (texture) {
|
||||||
|
if (capTexture->isYInverted()) {
|
||||||
|
texCoords << x4 / (rect.width()) + 0.5 << 0.5 + z4 / zTexture * 0.5;
|
||||||
|
texCoords << x1 / (rect.width()) + 0.5 << 0.5 + z1 / zTexture * 0.5;
|
||||||
|
texCoords << x2 / (rect.width()) + 0.5 << 0.5 + z2 / zTexture * 0.5;
|
||||||
|
texCoords << x2 / (rect.width()) + 0.5 << 0.5 + z2 / zTexture * 0.5;
|
||||||
|
texCoords << x3 / (rect.width()) + 0.5 << 0.5 + z3 / zTexture * 0.5;
|
||||||
|
texCoords << x4 / (rect.width()) + 0.5 << 0.5 + z4 / zTexture * 0.5;
|
||||||
|
} else {
|
||||||
texCoords << x4 / (rect.width()) + 0.5 << 0.5 - z4 / zTexture * 0.5;
|
texCoords << x4 / (rect.width()) + 0.5 << 0.5 - z4 / zTexture * 0.5;
|
||||||
texCoords << x1 / (rect.width()) + 0.5 << 0.5 - z1 / zTexture * 0.5;
|
texCoords << x1 / (rect.width()) + 0.5 << 0.5 - z1 / zTexture * 0.5;
|
||||||
texCoords << x2 / (rect.width()) + 0.5 << 0.5 - z2 / zTexture * 0.5;
|
texCoords << x2 / (rect.width()) + 0.5 << 0.5 - z2 / zTexture * 0.5;
|
||||||
|
@ -1045,6 +1072,7 @@ void CubeEffect::paintSphereCap()
|
||||||
texCoords << x3 / (rect.width()) + 0.5 << 0.5 - z3 / zTexture * 0.5;
|
texCoords << x3 / (rect.width()) + 0.5 << 0.5 - z3 / zTexture * 0.5;
|
||||||
texCoords << x4 / (rect.width()) + 0.5 << 0.5 - z4 / zTexture * 0.5;
|
texCoords << x4 / (rect.width()) + 0.5 << 0.5 - z4 / zTexture * 0.5;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
verts << x4 << yTop << z4;
|
verts << x4 << yTop << z4;
|
||||||
verts << x1 << yTop << z1;
|
verts << x1 << yTop << z1;
|
||||||
verts << x2 << yBottom << z2;
|
verts << x2 << yBottom << z2;
|
||||||
|
|
Loading…
Reference in a new issue