mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
srb2::Draw: inherit global cliprect by default
- Let srb2::Draw be mixed seamlessly with C-style V_SetClipRect
This commit is contained in:
parent
fc40d86a73
commit
510c82ca6d
5 changed files with 31 additions and 8 deletions
|
|
@ -251,18 +251,23 @@ void Chain::sticker(patch_t* end_graphic, UINT8 color) const
|
||||||
|
|
||||||
Chain::Clipper::Clipper(const Chain& chain)
|
Chain::Clipper::Clipper(const Chain& chain)
|
||||||
{
|
{
|
||||||
V_SetClipRect(
|
V_SaveClipRect(&save_);
|
||||||
FloatToFixed(chain.clipx1_),
|
|
||||||
FloatToFixed(chain.clipy1_),
|
if (chain.clip_)
|
||||||
FloatToFixed(chain.clipx2_ - chain.clipx1_),
|
{
|
||||||
FloatToFixed(chain.clipy2_ - chain.clipy1_),
|
V_SetClipRect(
|
||||||
chain.flags_
|
FloatToFixed(chain.clipx1_),
|
||||||
);
|
FloatToFixed(chain.clipy1_),
|
||||||
|
FloatToFixed(chain.clipx2_ - chain.clipx1_),
|
||||||
|
FloatToFixed(chain.clipy2_ - chain.clipy1_),
|
||||||
|
chain.flags_
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Chain::Clipper::~Clipper()
|
Chain::Clipper::~Clipper()
|
||||||
{
|
{
|
||||||
V_ClearClipRect();
|
V_RestoreClipRect(&save_);
|
||||||
}
|
}
|
||||||
|
|
||||||
patch_t* Draw::cache_patch(const char* name)
|
patch_t* Draw::cache_patch(const char* name)
|
||||||
|
|
|
||||||
|
|
@ -195,6 +195,9 @@ public:
|
||||||
{
|
{
|
||||||
explicit Clipper(const Chain& chain);
|
explicit Clipper(const Chain& chain);
|
||||||
~Clipper();
|
~Clipper();
|
||||||
|
|
||||||
|
private:
|
||||||
|
cliprect_t save_;
|
||||||
};
|
};
|
||||||
|
|
||||||
float x_ = 0.f;
|
float x_ = 0.f;
|
||||||
|
|
@ -207,6 +210,7 @@ public:
|
||||||
float clipx2_ = BASEVIDWIDTH;
|
float clipx2_ = BASEVIDWIDTH;
|
||||||
float clipy1_ = 0.f;
|
float clipy1_ = 0.f;
|
||||||
float clipy2_ = BASEVIDHEIGHT;
|
float clipy2_ = BASEVIDHEIGHT;
|
||||||
|
bool clip_ = false;
|
||||||
|
|
||||||
INT32 flags_ = 0;
|
INT32 flags_ = 0;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -87,6 +87,7 @@ inline Draw::Chain& Draw::Chain::clipx(float left, float right)
|
||||||
{
|
{
|
||||||
clipx1_ = left;
|
clipx1_ = left;
|
||||||
clipx2_ = right;
|
clipx2_ = right;
|
||||||
|
clip_ = true;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -94,6 +95,7 @@ inline Draw::Chain& Draw::Chain::clipy(float top, float bottom)
|
||||||
{
|
{
|
||||||
clipy1_ = top;
|
clipy1_ = top;
|
||||||
clipy2_ = bottom;
|
clipy2_ = bottom;
|
||||||
|
clip_ = true;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -715,6 +715,16 @@ void V_ClearClipRect(void)
|
||||||
cliprect.enabled = false;
|
cliprect.enabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void V_SaveClipRect(cliprect_t *copy)
|
||||||
|
{
|
||||||
|
*copy = cliprect;
|
||||||
|
}
|
||||||
|
|
||||||
|
void V_RestoreClipRect(const cliprect_t *copy)
|
||||||
|
{
|
||||||
|
cliprect = *copy;
|
||||||
|
}
|
||||||
|
|
||||||
static UINT8 hudplusalpha[11] = { 10, 8, 6, 4, 2, 0, 0, 0, 0, 0, 0};
|
static UINT8 hudplusalpha[11] = { 10, 8, 6, 4, 2, 0, 0, 0, 0, 0, 0};
|
||||||
static UINT8 hudminusalpha[11] = { 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5};
|
static UINT8 hudminusalpha[11] = { 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -192,6 +192,8 @@ struct cliprect_t
|
||||||
const cliprect_t *V_GetClipRect(void);
|
const cliprect_t *V_GetClipRect(void);
|
||||||
void V_SetClipRect(fixed_t x, fixed_t y, fixed_t w, fixed_t h, INT32 flags);
|
void V_SetClipRect(fixed_t x, fixed_t y, fixed_t w, fixed_t h, INT32 flags);
|
||||||
void V_ClearClipRect(void);
|
void V_ClearClipRect(void);
|
||||||
|
void V_SaveClipRect(cliprect_t *copy);
|
||||||
|
void V_RestoreClipRect(const cliprect_t *copy);
|
||||||
|
|
||||||
// defines for old functions
|
// defines for old functions
|
||||||
#define V_DrawPatch(x,y,s,p) V_DrawFixedPatch((x)<<FRACBITS, (y)<<FRACBITS, FRACUNIT, s|V_NOSCALESTART|V_NOSCALEPATCH, p, NULL)
|
#define V_DrawPatch(x,y,s,p) V_DrawFixedPatch((x)<<FRACBITS, (y)<<FRACBITS, FRACUNIT, s|V_NOSCALESTART|V_NOSCALEPATCH, p, NULL)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue