mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-12-01 08:31:45 +00:00
- added DFrameBuffer::HasBegun2D to allow scripting to test if 2D drawing is active (instead of using IsLocked, which may return false when vid_hw2d is active)
This commit is contained in:
parent
054d9a5bcc
commit
d160424aea
6 changed files with 14 additions and 10 deletions
|
@ -1700,7 +1700,7 @@ DEFINE_ACTION_FUNCTION(DBaseStatusBar, DrawTexture)
|
|||
PARAM_FLOAT_DEF(h);
|
||||
PARAM_FLOAT_DEF(scaleX);
|
||||
PARAM_FLOAT_DEF(scaleY);
|
||||
if (!screen->IsLocked()) ThrowAbortException(X_OTHER, "Attempt to draw to screen outside a draw function");
|
||||
if (!screen->HasBegun2D()) ThrowAbortException(X_OTHER, "Attempt to draw to screen outside a draw function");
|
||||
self->DrawGraphic(FSetTextureID(texid), x, y, flags, alpha, w, h, scaleX, scaleY);
|
||||
return 0;
|
||||
}
|
||||
|
@ -1717,7 +1717,7 @@ DEFINE_ACTION_FUNCTION(DBaseStatusBar, DrawImage)
|
|||
PARAM_FLOAT_DEF(h);
|
||||
PARAM_FLOAT_DEF(scaleX);
|
||||
PARAM_FLOAT_DEF(scaleY);
|
||||
if (!screen->IsLocked()) ThrowAbortException(X_OTHER, "Attempt to draw to screen outside a draw function");
|
||||
if (!screen->HasBegun2D()) ThrowAbortException(X_OTHER, "Attempt to draw to screen outside a draw function");
|
||||
self->DrawGraphic(TexMan.CheckForTexture(texid, FTexture::TEX_Any), x, y, flags, alpha, w, h, scaleX, scaleY);
|
||||
return 0;
|
||||
}
|
||||
|
@ -1910,7 +1910,7 @@ DEFINE_ACTION_FUNCTION(DBaseStatusBar, DrawString)
|
|||
PARAM_INT_DEF(wrapwidth);
|
||||
PARAM_INT_DEF(linespacing);
|
||||
|
||||
if (!screen->IsLocked()) ThrowAbortException(X_OTHER, "Attempt to draw to screen outside a draw function");
|
||||
if (!screen->HasBegun2D()) ThrowAbortException(X_OTHER, "Attempt to draw to screen outside a draw function");
|
||||
|
||||
// resolve auto-alignment before making any adjustments to the position values.
|
||||
if (!(flags & DI_SCREEN_MANUAL_ALIGN))
|
||||
|
@ -2015,7 +2015,7 @@ DEFINE_ACTION_FUNCTION(DBaseStatusBar, Fill)
|
|||
PARAM_FLOAT(w);
|
||||
PARAM_FLOAT(h);
|
||||
PARAM_INT_DEF(flags);
|
||||
if (!screen->IsLocked()) ThrowAbortException(X_OTHER, "Attempt to draw to screen outside a draw function");
|
||||
if (!screen->HasBegun2D()) ThrowAbortException(X_OTHER, "Attempt to draw to screen outside a draw function");
|
||||
self->Fill(color, x, y, w, h);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ public:
|
|||
OpenGLSWFrameBuffer(void *hMonitor, int width, int height, int bits, int refreshHz, bool fullscreen, bool bgra);
|
||||
~OpenGLSWFrameBuffer();
|
||||
|
||||
|
||||
bool HasBegun2D() override { return In2D || IsLocked(); }
|
||||
bool IsValid() override;
|
||||
bool Lock(bool buffered) override;
|
||||
void Unlock() override;
|
||||
|
|
|
@ -137,7 +137,7 @@ DEFINE_ACTION_FUNCTION(_Screen, DrawTexture)
|
|||
PARAM_FLOAT(x);
|
||||
PARAM_FLOAT(y);
|
||||
|
||||
if (!screen->IsLocked()) ThrowAbortException(X_OTHER, "Attempt to draw to screen outside a draw function");
|
||||
if (!screen->HasBegun2D()) ThrowAbortException(X_OTHER, "Attempt to draw to screen outside a draw function");
|
||||
|
||||
FTexture *tex = animate ? TexMan(FSetTextureID(texid)) : TexMan[FSetTextureID(texid)];
|
||||
VMVa_List args = { param + 4, 0, numparam - 4 };
|
||||
|
@ -961,7 +961,7 @@ DEFINE_ACTION_FUNCTION(_Screen, Clear)
|
|||
PARAM_INT(y2);
|
||||
PARAM_INT(color);
|
||||
PARAM_INT_DEF(palcol);
|
||||
if (!screen->IsLocked()) ThrowAbortException(X_OTHER, "Attempt to draw to screen outside a draw function");
|
||||
if (!screen->HasBegun2D()) ThrowAbortException(X_OTHER, "Attempt to draw to screen outside a draw function");
|
||||
screen->Clear(x1, y1, x2, y2, palcol, color);
|
||||
return 0;
|
||||
}
|
||||
|
@ -1013,7 +1013,7 @@ DEFINE_ACTION_FUNCTION(_Screen, Dim)
|
|||
PARAM_INT(y1);
|
||||
PARAM_INT(w);
|
||||
PARAM_INT(h);
|
||||
if (!screen->IsLocked()) ThrowAbortException(X_OTHER, "Attempt to draw to screen outside a draw function");
|
||||
if (!screen->HasBegun2D()) ThrowAbortException(X_OTHER, "Attempt to draw to screen outside a draw function");
|
||||
screen->Dim(color, float(amount), x1, y1, w, h);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -116,7 +116,7 @@ DEFINE_ACTION_FUNCTION(_Screen, DrawChar)
|
|||
PARAM_FLOAT(y);
|
||||
PARAM_INT(chr);
|
||||
|
||||
if (!screen->IsLocked()) ThrowAbortException(X_OTHER, "Attempt to draw to screen outside a draw function");
|
||||
if (!screen->HasBegun2D()) ThrowAbortException(X_OTHER, "Attempt to draw to screen outside a draw function");
|
||||
VMVa_List args = { param + 5, 0, numparam - 5 };
|
||||
screen->DrawChar(font, cr, x, y, chr, args);
|
||||
return 0;
|
||||
|
@ -242,7 +242,7 @@ DEFINE_ACTION_FUNCTION(_Screen, DrawText)
|
|||
PARAM_FLOAT(y);
|
||||
PARAM_STRING(chr);
|
||||
|
||||
if (!screen->IsLocked()) ThrowAbortException(X_OTHER, "Attempt to draw to screen outside a draw function");
|
||||
if (!screen->HasBegun2D()) ThrowAbortException(X_OTHER, "Attempt to draw to screen outside a draw function");
|
||||
VMVa_List args = { param + 5, 0, numparam - 5 };
|
||||
const char *txt = chr[0] == '$' ? GStrings(&chr[1]) : chr.GetChars();
|
||||
screen->DrawText(font, cr, x, y, txt, args);
|
||||
|
|
|
@ -410,6 +410,9 @@ public:
|
|||
// Returns true if hardware-accelerated 2D has been entered, false if not.
|
||||
virtual bool Begin2D(bool copy3d);
|
||||
|
||||
// Returns true if Begin2D has been called and 2D drawing is now active
|
||||
virtual bool HasBegun2D() { return IsLocked(); }
|
||||
|
||||
// DrawTexture calls after Begin2D use native textures.
|
||||
|
||||
// Draws the blending rectangle over the viewwindow if in hardware-
|
||||
|
|
|
@ -105,6 +105,7 @@ public:
|
|||
D3DFB (UINT adapter, int width, int height, bool bgra, bool fullscreen);
|
||||
~D3DFB ();
|
||||
|
||||
bool HasBegun2D() override { return In2D || IsLocked(); }
|
||||
bool IsValid ();
|
||||
bool Lock (bool buffered);
|
||||
void Unlock ();
|
||||
|
|
Loading…
Reference in a new issue