- fixed startup and font init crashes.

This commit is contained in:
Christoph Oelckers 2020-05-04 20:06:54 +02:00
commit 3fd4d08004
15 changed files with 271 additions and 132 deletions

View file

@ -677,7 +677,7 @@ void F2DDrawer::AddPoly(FGameTexture* img, FVector4* vt, size_t vtcount, unsigne
//
//==========================================================================
void F2DDrawer::AddFlatFill(int left, int top, int right, int bottom, FGameTexture *src, bool local_origin)
void F2DDrawer::AddFlatFill(int left, int top, int right, int bottom, FGameTexture *src, int local_origin, double flatscale)
{
float fU1, fU2, fV1, fV2;
@ -690,27 +690,83 @@ void F2DDrawer::AddFlatFill(int left, int top, int right, int bottom, FGameTextu
dg.mTexture = src;
dg.mFlags = DTF_Wrap;
// scaling is not used here.
if (!local_origin)
{
fU1 = float(left) / (float)src->GetDisplayWidth();
fV1 = float(top) / (float)src->GetDisplayHeight();
fU2 = float(right) / (float)src->GetDisplayWidth();
fV2 = float(bottom) / (float)src->GetDisplayHeight();
}
else
float fs = 1.f / float(flatscale);
bool flipc = false;
switch (local_origin)
{
case 0:
fU1 = float(left) / (float)src->GetDisplayWidth() * fs;
fV1 = float(top) / (float)src->GetDisplayHeight() * fs;
fU2 = float(right) / (float)src->GetDisplayWidth() * fs;
fV2 = float(bottom) / (float)src->GetDisplayHeight() * fs;
break;
case 1:
fU1 = 0;
fV1 = 0;
fU2 = float(right - left) / (float)src->GetDisplayWidth();
fV2 = float(bottom - top) / (float)src->GetDisplayHeight();
fU2 = float(right - left) / (float)src->GetDisplayWidth() * fs;
fV2 = float(bottom - top) / (float)src->GetDisplayHeight() * fs;
break;
// The following are for drawing frames with elements of pnly one orientation
case 2: // flip vertically
fU1 = 0;
fV2 = 0;
fU2 = float(right - left) / (float)src->GetDisplayWidth() * fs;
fV1 = float(bottom - top) / (float)src->GetDisplayHeight() * fs;
break;
case 3: // flip horizontally
fU2 = 0;
fV1 = 0;
fU1 = float(right - left) / (float)src->GetDisplayWidth() * fs;
fV2 = float(bottom - top) / (float)src->GetDisplayHeight() * fs;
break;
case 4: // flip vertically and horizontally
fU2 = 0;
fV2 = 0;
fU1 = float(right - left) / (float)src->GetDisplayWidth() * fs;
fV1 = float(bottom - top) / (float)src->GetDisplayHeight() * fs;
break;
case 5: // flip coordinates
fU1 = 0;
fV1 = 0;
fU2 = float(bottom - top) / (float)src->GetDisplayWidth() * fs;
fV2 = float(right - left) / (float)src->GetDisplayHeight() * fs;
break;
case 6: // flip coordinates and vertically
fU2 = 0;
fV1 = 0;
fU1 = float(bottom - top) / (float)src->GetDisplayWidth() * fs;
fV2 = float(right - left) / (float)src->GetDisplayHeight() * fs;
break;
case 7: // flip coordinates and horizontally
fU1 = 0;
fV2 = 0;
fU2 = float(bottom - top) / (float)src->GetDisplayWidth() * fs;
fV1 = float(right - left) / (float)src->GetDisplayHeight() * fs;
break;
}
dg.mVertIndex = (int)mVertices.Reserve(4);
auto ptr = &mVertices[dg.mVertIndex];
ptr->Set(left, top, 0, fU1, fV1, 0xffffffff); ptr++;
ptr->Set(left, bottom, 0, fU1, fV2, 0xffffffff); ptr++;
ptr->Set(right, top, 0, fU2, fV1, 0xffffffff); ptr++;
if (local_origin < 4)
{
ptr->Set(left, bottom, 0, fU1, fV2, 0xffffffff); ptr++;
ptr->Set(right, top, 0, fU2, fV1, 0xffffffff); ptr++;
}
else
{
ptr->Set(left, bottom, 0, fU2, fV1, 0xffffffff); ptr++;
ptr->Set(right, top, 0, fU1, fV2, 0xffffffff); ptr++;
}
ptr->Set(right, bottom, 0, fU2, fV2, 0xffffffff); ptr++;
dg.mIndexIndex = mIndices.Size();
dg.mIndexCount += 6;
@ -721,11 +777,11 @@ void F2DDrawer::AddFlatFill(int left, int top, int right, int bottom, FGameTextu
//===========================================================================
//
//
//
//
//===========================================================================
void F2DDrawer::AddColorOnlyQuad(int x1, int y1, int w, int h, PalEntry color, FRenderStyle *style)
void F2DDrawer::AddColorOnlyQuad(int x1, int y1, int w, int h, PalEntry color, FRenderStyle *style, bool prepend)
{
RenderCommand dg;
@ -741,7 +797,13 @@ void F2DDrawer::AddColorOnlyQuad(int x1, int y1, int w, int h, PalEntry color, F
dg.mIndexIndex = mIndices.Size();
dg.mIndexCount += 6;
AddIndices(dg.mVertIndex, 6, 0, 1, 2, 1, 3, 2);
AddCommand(&dg);
if (!prepend) AddCommand(&dg);
else
{
// Only needed by Raze's fullscreen blends because they are being calculated late when half of the 2D content has already been submitted,
// This ensures they are below the HUD, not above it.
mData.Insert(0, dg);
}
}
void F2DDrawer::ClearScreen(PalEntry color)