Clear background alpha consistently for solid and gradient backgrounds.

Transparent for offscreen and opaque for widgets.
This commit is contained in:
Leonardo Zide 2024-10-03 18:11:56 -07:00
parent 0ded25b7ea
commit a27b69c9fd
2 changed files with 9 additions and 8 deletions

View file

@ -131,6 +131,11 @@ public:
void SetGLContext(QOpenGLContext* GLContext, QOpenGLWidget* Widget);
void SetOffscreenContext();
bool IsOffscreen() const
{
return mWidget != nullptr;
}
void ClearColorAndDepth(const lcVector4& ClearColor);
void ClearDepth();

View file

@ -995,10 +995,11 @@ void lcView::DrawBackground(int CurrentTileRow, int TotalTileRows, int CurrentTi
}
const lcPreferences& Preferences = lcGetPreferences();
float Alpha = mContext->IsOffscreen() ? 0.0f : 1.0f;
if (!Preferences.mBackgroundGradient)
{
lcVector4 BackgroundColor(lcVector3FromColor(Preferences.mBackgroundSolidColor), 0.0f);
lcVector4 BackgroundColor(lcVector3FromColor(Preferences.mBackgroundSolidColor), Alpha);
mContext->ClearColorAndDepth(BackgroundColor);
return;
}
@ -1027,28 +1028,23 @@ void lcView::DrawBackground(int CurrentTileRow, int TotalTileRows, int CurrentTi
double TopRed = LC_RGBA_RED(ColorTop);
double TopGreen = LC_RGBA_GREEN(ColorTop);
double TopBlue = LC_RGBA_BLUE(ColorTop);
double TopAlpha = LC_RGBA_ALPHA(ColorTop);
double BottomRed = LC_RGBA_RED(ColorBottom);
double BottomGreen = LC_RGBA_GREEN(ColorBottom);
double BottomBlue = LC_RGBA_BLUE(ColorBottom);
double BottomAlpha = LC_RGBA_ALPHA(ColorBottom);
const double DeltaRed = BottomRed - TopRed;
const double DeltaGreen = BottomGreen - TopGreen;
const double DeltaBlue = BottomBlue - TopBlue;
const double DeltaAlpha = BottomAlpha - TopAlpha;
BottomRed = TopRed + DeltaRed * t2;
BottomGreen = TopGreen + DeltaGreen * t2;
BottomBlue = TopBlue + DeltaBlue * t2;
BottomAlpha = TopAlpha + DeltaAlpha * t2;
TopRed = TopRed + DeltaRed * t1;
TopGreen = TopGreen + DeltaGreen * t1;
TopBlue = TopBlue + DeltaBlue * t1;
TopAlpha = TopAlpha + DeltaAlpha * t1;
const quint32 Color1 = LC_RGBA(TopRed, TopGreen, TopBlue, TopAlpha);
const quint32 Color2 = LC_RGBA(BottomRed, BottomGreen, BottomBlue, BottomAlpha);
const quint32 Color1 = LC_RGBA(TopRed, TopGreen, TopBlue, Alpha);
const quint32 Color2 = LC_RGBA(BottomRed, BottomGreen, BottomBlue, Alpha);
struct lcBackgroundVertex
{