mirror of
https://github.com/DrBeef/Raze.git
synced 2025-02-16 17:01:39 +00:00
Additional 2D drawer for fullscreen palette blend (for damage/pickups)
and also for drawing the crosshair and fps counter. Required for RazeXR since the standard HUD 2D drawer is now scalable.
This commit is contained in:
parent
4b2b6da3da
commit
dff31bcad2
12 changed files with 34 additions and 18 deletions
|
@ -44,7 +44,9 @@
|
|||
#include "texturemanager.h"
|
||||
|
||||
static F2DDrawer drawer = F2DDrawer();
|
||||
static F2DDrawer blend_drawer = F2DDrawer(true);
|
||||
F2DDrawer* twod = &drawer;
|
||||
F2DDrawer* twod_blend = &blend_drawer;
|
||||
|
||||
EXTERN_CVAR(Float, transsouls)
|
||||
CVAR(Float, classic_scaling_factor, 1.0, CVAR_ARCHIVE)
|
||||
|
|
|
@ -64,8 +64,9 @@ enum class SpecialDrawCommand {
|
|||
class F2DDrawer
|
||||
{
|
||||
public:
|
||||
F2DDrawer() {
|
||||
F2DDrawer(bool forceFullscreen = false) {
|
||||
this->transform.Identity();
|
||||
this->forceFullscreen = forceFullscreen;
|
||||
}
|
||||
|
||||
enum EDrawType : uint8_t
|
||||
|
@ -193,6 +194,7 @@ public:
|
|||
TArray<RenderCommand> mData;
|
||||
int Width, Height;
|
||||
bool isIn2D;
|
||||
bool forceFullscreen;
|
||||
bool locked = false; // prevents clearing of the data so it can be reused multiple times (useful for screen fades)
|
||||
float screenFade = 1.f;
|
||||
DVector2 offset;
|
||||
|
|
|
@ -241,6 +241,7 @@ double AspectPspriteOffset(float aspect);
|
|||
int AspectMultiplier(float aspect);
|
||||
bool AspectTallerThanWide(float aspect);
|
||||
|
||||
extern F2DDrawer* twod_blend;
|
||||
extern F2DDrawer* twod;
|
||||
|
||||
int GetUIScale(F2DDrawer* drawer, int altval);
|
||||
|
|
|
@ -584,6 +584,7 @@ void OpenGLFrameBuffer::Draw2D()
|
|||
{
|
||||
GLRenderer->mBuffers->BindCurrentFB();
|
||||
::Draw2D(twod, gl_RenderState);
|
||||
::Draw2D(twod_blend, gl_RenderState);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -442,6 +442,7 @@ void OpenGLFrameBuffer::Draw2D()
|
|||
{
|
||||
GLRenderer->mBuffers->BindCurrentFB();
|
||||
::Draw2D(twod, gl_RenderState);
|
||||
::Draw2D(twod_blend, gl_RenderState);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -86,17 +86,17 @@ int HWViewpointBuffer::Bind(FRenderState &di, unsigned int index)
|
|||
void HWViewpointBuffer::Set2D(F2DDrawer *drawer, FRenderState &di, int width, int height, int pll)
|
||||
{
|
||||
const bool isIn2D = drawer == nullptr || drawer->isIn2D;
|
||||
const bool isDrawingFullscreen = (gamestate != GS_LEVEL) || menuactive != MENU_Off;
|
||||
const bool isDrawingFullscreen = (gamestate != GS_LEVEL) || menuactive != MENU_Off || drawer->forceFullscreen;
|
||||
{
|
||||
HWViewpointUniforms matrices;
|
||||
|
||||
matrices.mViewMatrix.loadIdentity();
|
||||
matrices.mNormalViewMatrix.loadIdentity();
|
||||
matrices.mViewHeight = 0;
|
||||
matrices.mGlobVis = 1.f;
|
||||
matrices.mPalLightLevels = pll;
|
||||
matrices.mClipLine.X = -10000000.0f;
|
||||
matrices.mShadowmapFilter = gl_shadowmap_filter;
|
||||
matrices.mViewMatrix.loadIdentity();
|
||||
matrices.mNormalViewMatrix.loadIdentity();
|
||||
matrices.mViewHeight = 0;
|
||||
matrices.mGlobVis = 1.f;
|
||||
matrices.mPalLightLevels = pll;
|
||||
matrices.mClipLine.X = -10000000.0f;
|
||||
matrices.mShadowmapFilter = gl_shadowmap_filter;
|
||||
|
||||
if (isDrawingFullscreen && isIn2D) //fullscreen 2D
|
||||
{
|
||||
|
|
|
@ -500,6 +500,7 @@ void VulkanRenderDevice::InitLightmap(int LMTextureSize, int LMTextureCount, TAr
|
|||
void VulkanRenderDevice::Draw2D()
|
||||
{
|
||||
::Draw2D(twod, *mRenderState);
|
||||
::Draw2D(twod_blend, *mRenderState);
|
||||
}
|
||||
|
||||
void VulkanRenderDevice::WaitForCommands(bool finish)
|
||||
|
|
|
@ -139,7 +139,7 @@ void ST_DrawCrosshair(int phealth, double xpos, double ypos, double scale, DAngl
|
|||
|
||||
if (crosshairscale > 0.0f)
|
||||
{
|
||||
size = twod->GetHeight() * crosshairscale * 0.005;
|
||||
size = twod_blend->GetHeight() * crosshairscale * 0.005;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -204,7 +204,7 @@ void ST_DrawCrosshair(int phealth, double xpos, double ypos, double scale, DAngl
|
|||
color = crosshaircolor;
|
||||
}
|
||||
|
||||
DrawTexture(twod, CrosshairImage,
|
||||
DrawTexture(twod_blend, CrosshairImage,
|
||||
xpos, ypos,
|
||||
DTA_DestWidth, w,
|
||||
DTA_DestHeight, h,
|
||||
|
|
|
@ -1412,7 +1412,7 @@ void DrawCrosshair(int deftile, int health, double xdelta, double ydelta, double
|
|||
if (tile)
|
||||
{
|
||||
double crosshair_scale = crosshairscale > 0.0f ? crosshairscale * scale : 1.;
|
||||
DrawTexture(twod, tile, 160 + xdelta, 100 + ydelta, DTA_Color, color, DTA_Rotate, angle.Degrees(),
|
||||
DrawTexture(twod_blend, tile, 160 + xdelta, 100 + ydelta, DTA_Color, color, DTA_Rotate, angle.Degrees(),
|
||||
DTA_FullscreenScale, FSMode_Fit320x200, DTA_ScaleX, crosshair_scale, DTA_ScaleY, crosshair_scale, DTA_CenterOffsetRel, true,
|
||||
DTA_ViewportX, viewport3d.Left(), DTA_ViewportY, viewport3d.Top(), DTA_ViewportWidth, viewport3d.Width(), DTA_ViewportHeight, viewport3d.Height(), TAG_DONE);
|
||||
|
||||
|
|
|
@ -131,10 +131,10 @@ void DrawRateStuff()
|
|||
{
|
||||
FString fpsbuff = statFPS();
|
||||
|
||||
int textScale = active_con_scale(twod);
|
||||
int textScale = active_con_scale(twod_blend);
|
||||
int rate_x = (screen->GetWidth() / 2) / textScale - (NewConsoleFont->StringWidth(&fpsbuff[0]) / 2);
|
||||
twod->AddColorOnlyQuad(rate_x * textScale, 0, screen->GetWidth(), NewConsoleFont->GetHeight() * textScale, MAKEARGB(255, 0, 0, 0));
|
||||
DrawText(twod, NewConsoleFont, CR_WHITE, rate_x, screen->GetHeight() / 2, (char*)&fpsbuff[0],
|
||||
DrawText(twod_blend, NewConsoleFont, CR_WHITE, rate_x, screen->GetHeight() / 2, (char*)&fpsbuff[0],
|
||||
DTA_VirtualWidth, screen->GetWidth() / textScale,
|
||||
DTA_VirtualHeight, screen->GetHeight() / textScale,
|
||||
DTA_KeepRatio, true, TAG_DONE);
|
||||
|
|
|
@ -423,14 +423,22 @@ void Display()
|
|||
screen->FrameTime = I_msTimeFS();
|
||||
tileUpdateAnimations();
|
||||
screen->BeginFrame();
|
||||
|
||||
//Player Sprite
|
||||
twodpsp.Clear();
|
||||
twodpsp.SetSize(screen->GetWidth(), screen->GetHeight());
|
||||
twodpsp.ClearClipRect();
|
||||
|
||||
//Adjustable HUD
|
||||
twod->Clear();
|
||||
//twod->SetSize(screen->GetWidth(), screen->GetHeight());
|
||||
twod->Begin(screen->GetWidth(), screen->GetHeight());
|
||||
twod->ClearClipRect();
|
||||
|
||||
//Fullscreen Palette Blends and Crosshair
|
||||
twod_blend->Clear();
|
||||
twod_blend->Begin(screen->GetWidth(), screen->GetHeight());
|
||||
twod_blend->ClearClipRect();
|
||||
|
||||
if (gamestate == GS_LEVEL && menuactive == MENU_Off) {
|
||||
RazeXR_setUseScreenLayer(false);
|
||||
}
|
||||
|
|
|
@ -479,14 +479,14 @@ void DrawFullscreenBlends()
|
|||
if (tint_blood_r | tint_blood_g | tint_blood_b)
|
||||
{
|
||||
PalEntry color2(255, max(-tint_blood_r, 0), max(-tint_blood_g, 0), max(-tint_blood_b, 0));
|
||||
twod->AddColorOnlyQuad(0, 0, twod->GetWidth(), twod->GetHeight(), color2, &LegacyRenderStyles[STYLE_Subtract], true);
|
||||
twod_blend->AddColorOnlyQuad(0, 0, twod_blend->GetWidth(), twod_blend->GetHeight(), color2, &LegacyRenderStyles[STYLE_Subtract], true);
|
||||
PalEntry color(255, max(tint_blood_r, 0), max(tint_blood_g, 0), max(tint_blood_b, 0));
|
||||
twod->AddColorOnlyQuad(0, 0, twod->GetWidth(), twod->GetHeight(), color, &LegacyRenderStyles[STYLE_Add], true);
|
||||
twod_blend->AddColorOnlyQuad(0, 0, twod_blend->GetWidth(), twod_blend->GetHeight(), color, &LegacyRenderStyles[STYLE_Add], true);
|
||||
}
|
||||
|
||||
if (palfadergb.a > 0)
|
||||
{
|
||||
twod->AddColorOnlyQuad(0, 0, twod->GetWidth(), twod->GetHeight(), palfadergb, &LegacyRenderStyles[STYLE_Translucent], true);
|
||||
twod_blend->AddColorOnlyQuad(0, 0, twod_blend->GetWidth(), twod_blend->GetHeight(), palfadergb, &LegacyRenderStyles[STYLE_Translucent], true);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue