summaryrefslogtreecommitdiffstats
path: root/src/render
diff options
context:
space:
mode:
author_AG <gennariarmando@outlook.com>2019-07-03 17:26:15 +0200
committer_AG <gennariarmando@outlook.com>2019-07-03 17:30:26 +0200
commit69b5c9f1e0aff9bc32f903b39f5c1673b43a9b37 (patch)
treec7136d627079976fc976cd7b6d66e7ef46cf79f1 /src/render
parentfixed boat rendering (diff)
downloadre3-69b5c9f1e0aff9bc32f903b39f5c1673b43a9b37.tar
re3-69b5c9f1e0aff9bc32f903b39f5c1673b43a9b37.tar.gz
re3-69b5c9f1e0aff9bc32f903b39f5c1673b43a9b37.tar.bz2
re3-69b5c9f1e0aff9bc32f903b39f5c1673b43a9b37.tar.lz
re3-69b5c9f1e0aff9bc32f903b39f5c1673b43a9b37.tar.xz
re3-69b5c9f1e0aff9bc32f903b39f5c1673b43a9b37.tar.zst
re3-69b5c9f1e0aff9bc32f903b39f5c1673b43a9b37.zip
Diffstat (limited to 'src/render')
-rw-r--r--src/render/Clouds.cpp46
-rw-r--r--src/render/Credits.cpp8
-rw-r--r--src/render/Draw.cpp13
-rw-r--r--src/render/Draw.h7
-rw-r--r--src/render/Font.cpp6
-rw-r--r--src/render/Hud.cpp34
-rw-r--r--src/render/MBlur.h1
7 files changed, 71 insertions, 44 deletions
diff --git a/src/render/Clouds.cpp b/src/render/Clouds.cpp
index 6854c80c..bf572841 100644
--- a/src/render/Clouds.cpp
+++ b/src/render/Clouds.cpp
@@ -208,15 +208,15 @@ CClouds::Render(void)
int br = CTimeCycle::GetFluffyCloudsBottomRed();
int bg = CTimeCycle::GetFluffyCloudsBottomGreen();
int bb = CTimeCycle::GetFluffyCloudsBottomBlue();
- if(sundist < SCREENW/2){
- hilight = (1.0f - coverage) * (1.0f - sundist/(SCREENW/2));
+ if(sundist < SCREEN_WIDTH/2){
+ hilight = (1.0f - coverage) * (1.0f - sundist/(SCREEN_WIDTH/2));
tr = tr*(1.0f-hilight) + 255*hilight;
tg = tg*(1.0f-hilight) + 190*hilight;
tb = tb*(1.0f-hilight) + 190*hilight;
br = br*(1.0f-hilight) + 255*hilight;
bg = bg*(1.0f-hilight) + 190*hilight;
bb = bb*(1.0f-hilight) + 190*hilight;
- if(sundist < SCREENW/10)
+ if(sundist < SCREEN_WIDTH/10)
CCoronas::SunBlockedByClouds = true;
}else
hilight = 0.0f;
@@ -317,16 +317,16 @@ CClouds::RenderBackground(int16 topred, int16 topgreen, int16 topblue,
}
}
ms_colourBottom = ms_colourTop;
- CRect r(0, 0, SCREENW, SCREENH);
+ CRect r(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
CSprite2d::DrawRect(r, ms_colourBottom, ms_colourBottom, ms_colourTop, ms_colourTop);
}else{
ms_horizonZ = CSprite::CalcHorizonCoors();
// Draw top/bottom gradient
- float gradheight = SCREENH/2.0f;
+ float gradheight = SCREEN_HEIGHT/2.0f;
float topedge = ms_horizonZ - gradheight;
float botpos, toppos;
- if(ms_horizonZ > 0.0f && topedge < SCREENH){
+ if(ms_horizonZ > 0.0f && topedge < SCREEN_HEIGHT){
ms_colourTop.r = topred;
ms_colourTop.g = topgreen;
ms_colourTop.b = topblue;
@@ -336,14 +336,14 @@ CClouds::RenderBackground(int16 topred, int16 topgreen, int16 topblue,
ms_colourBottom.b = botblue;
ms_colourBottom.a = alpha;
- if(ms_horizonZ < SCREENH)
+ if(ms_horizonZ < SCREEN_HEIGHT)
botpos = ms_horizonZ;
else{
- float f = (ms_horizonZ - SCREENH)/gradheight;
+ float f = (ms_horizonZ - SCREEN_HEIGHT)/gradheight;
ms_colourBottom.r = topred*f + (1.0f-f)*botred;
ms_colourBottom.g = topgreen*f + (1.0f-f)*botgreen;
ms_colourBottom.b = topblue*f + (1.0f-f)*botblue;
- botpos = SCREENH;
+ botpos = SCREEN_HEIGHT;
}
if(topedge >= 0.0f)
toppos = topedge;
@@ -354,17 +354,17 @@ CClouds::RenderBackground(int16 topred, int16 topgreen, int16 topblue,
ms_colourTop.b = botblue*f + (1.0f-f)*topblue;
toppos = 0.0f;
}
- CSprite2d::DrawRect(CRect(0, toppos, SCREENW, botpos),
+ CSprite2d::DrawRect(CRect(0, toppos, SCREEN_WIDTH, botpos),
ms_colourBottom, ms_colourBottom, ms_colourTop, ms_colourTop);
}
// draw the small stripe (whatever it's supposed to be)
- if(ms_horizonZ > -SMALLSTRIPHEIGHT && ms_horizonZ < SCREENH){
+ if(ms_horizonZ > -SMALLSTRIPHEIGHT && ms_horizonZ < SCREEN_HEIGHT){
// Same colour as fog
ms_colourTop.r = (topred + 2 * botred) / 3;
ms_colourTop.g = (topgreen + 2 * botgreen) / 3;
ms_colourTop.b = (topblue + 2 * botblue) / 3;
- CSprite2d::DrawRect(CRect(0, ms_horizonZ, SCREENW, ms_horizonZ+SMALLSTRIPHEIGHT),
+ CSprite2d::DrawRect(CRect(0, ms_horizonZ, SCREEN_WIDTH, ms_horizonZ+SMALLSTRIPHEIGHT),
ms_colourTop, ms_colourTop, ms_colourTop, ms_colourTop);
}
@@ -379,8 +379,8 @@ CClouds::RenderBackground(int16 topred, int16 topgreen, int16 topblue,
ms_colourBottom.b = topblue;
ms_colourBottom.a = alpha;
- botpos = min(SCREENH, topedge);
- CSprite2d::DrawRect(CRect(0, 0, SCREENW, botpos),
+ botpos = min(SCREEN_HEIGHT, topedge);
+ CSprite2d::DrawRect(CRect(0, 0, SCREEN_WIDTH, botpos),
ms_colourBottom, ms_colourBottom, ms_colourTop, ms_colourTop);
}
@@ -403,22 +403,22 @@ CClouds::RenderHorizon(void)
ms_colourBottom.a = 230;
ms_colourTop.a = 80;
- if(ms_horizonZ > SCREENH)
+ if(ms_horizonZ > SCREEN_HEIGHT)
return;
- float z1 = min(ms_horizonZ + SMALLSTRIPHEIGHT, SCREENH);
- CSprite2d::DrawRectXLU(CRect(0, ms_horizonZ, SCREENW, z1),
+ float z1 = min(ms_horizonZ + SMALLSTRIPHEIGHT, SCREEN_HEIGHT);
+ CSprite2d::DrawRectXLU(CRect(0, ms_horizonZ, SCREEN_WIDTH, z1),
ms_colourBottom, ms_colourBottom, ms_colourTop, ms_colourTop);
// This is just weird
- float a = SCREENH/400.0f * HORIZSTRIPHEIGHT +
- SCREENH/300.0f * max(TheCamera.GetPosition().z, 0.0f);
+ float a = SCREEN_HEIGHT/400.0f * HORIZSTRIPHEIGHT +
+ SCREEN_HEIGHT/300.0f * max(TheCamera.GetPosition().z, 0.0f);
float b = TheCamera.GetUp().z < 0.0f ?
- SCREENH :
- SCREENH * fabs(TheCamera.GetRight().z);
+ SCREEN_HEIGHT :
+ SCREEN_HEIGHT * fabs(TheCamera.GetRight().z);
float z2 = z1 + (a + b)*TheCamera.LODDistMultiplier;
- z2 = min(z2, SCREENH);
- CSprite2d::DrawRect(CRect(0, z1, SCREENW, z2),
+ z2 = min(z2, SCREEN_HEIGHT);
+ CSprite2d::DrawRect(CRect(0, z1, SCREEN_WIDTH, z2),
ms_colourBottom, ms_colourBottom, ms_colourTop, ms_colourTop);
}
diff --git a/src/render/Credits.cpp b/src/render/Credits.cpp
index 8365d02b..6d20c1ff 100644
--- a/src/render/Credits.cpp
+++ b/src/render/Credits.cpp
@@ -39,11 +39,11 @@ CCredits::PrintCreditSpace(float space, uint32 &line)
void
CCredits::PrintCreditText(float scaleX, float scaleY, wchar *text, uint32 &lineoffset, float scrolloffset)
{
- float start = SCREENH + 50.0f;
+ float start = SCREEN_HEIGHT + 50.0f;
float y = lineoffset + start - scrolloffset;
if(y > -50.0f && y < start){
CFont::SetScale(scaleX, scaleY);
- CFont::PrintString(SCREENW/2.0f, y, (uint16*)text);
+ CFont::PrintString(SCREEN_WIDTH/2.0f, y, (uint16*)text);
}
lineoffset += scaleY*25.0f;
}
@@ -62,7 +62,7 @@ CCredits::Render(void)
scrolloffset = (CTimer::GetTimeInMilliseconds() - CreditsStartTime) / 24.0f;
CFont::SetJustifyOff();
CFont::SetBackgroundOff();
- CFont::SetCentreSize(SCREENW - 20);
+ CFont::SetCentreSize(SCREEN_WIDTH - 20);
CFont::SetCentreOn();
CFont::SetPropOn();
CFont::SetColor(CRGBA(220, 220, 220, 220));
@@ -489,7 +489,7 @@ CCredits::Render(void)
if(TheCamera.m_WideScreenOn)
TheCamera.DrawBordersForWideScreen();
- if(lineoffset + SCREENH - scrolloffset < -10.0f)
+ if(lineoffset + SCREEN_HEIGHT - scrolloffset < -10.0f)
bCreditsGoing = false;
}
diff --git a/src/render/Draw.cpp b/src/render/Draw.cpp
index 922d96d4..f825ba42 100644
--- a/src/render/Draw.cpp
+++ b/src/render/Draw.cpp
@@ -20,12 +20,24 @@ uint8 &CDraw::FadeBlue = *(uint8*)0x95CD53;
float
CDraw::FindAspectRatio(void)
{
+#ifndef ASPECT_RATIO_SCALE
if(FrontEndMenuManager.m_PrefsUseWideScreen)
return 16.0f/9.0f;
else
return 4.0f/3.0f;
+#else
+ switch (FrontEndMenuManager.m_PrefsUseWideScreen) {
+ case AR_AUTO:
+ return SCREEN_WIDTH / SCREEN_HEIGHT;
+ case AR_4_3:
+ return 4.0f / 3.0f;
+ case AR_16_9:
+ return 16.0f / 9.0f;
+ };
+#endif
}
+#ifdef ASPECT_RATIO_SCALE
// convert a 4:3 hFOV to vFOV,
// then convert that vFOV to hFOV for our aspect ratio,
// i.e. HOR+
@@ -41,6 +53,7 @@ CDraw::ConvertFOV(float hfov)
hfov = atan(tan(vfov/2) * ar2) *2;
return RADTODEG(hfov);
}
+#endif
void
CDraw::SetFOV(float fov)
diff --git a/src/render/Draw.h b/src/render/Draw.h
index 3349c6c9..ad14e5a9 100644
--- a/src/render/Draw.h
+++ b/src/render/Draw.h
@@ -1,5 +1,12 @@
#pragma once
+enum eAspectRatio
+{
+ AR_AUTO,
+ AR_4_3,
+ AR_16_9,
+};
+
class CDraw
{
private:
diff --git a/src/render/Font.cpp b/src/render/Font.cpp
index 2130fb95..59023960 100644
--- a/src/render/Font.cpp
+++ b/src/render/Font.cpp
@@ -83,7 +83,7 @@ CFont::Initialise(void)
Sprite[1].SetTexture("pager", "pager_mask");
Sprite[2].SetTexture("font1", "font1_mask");
SetScale(1.0f, 1.0f);
- SetSlantRefPoint(SCREENW, 0.0f);
+ SetSlantRefPoint(SCREEN_WIDTH, 0.0f);
SetSlant(0.0);
SetColor(CRGBA(0xFF, 0xFF, 0xFF, 0));
SetJustifyOff();
@@ -123,8 +123,8 @@ CFont::InitPerFrame(void)
void
CFont::PrintChar(float x, float y, uint16 c)
{
- if(x <= 0.0f || x >= SCREENW ||
- y <= 0.0f || y >= SCREENH) // BUG: game uses SCREENW again
+ if(x <= 0.0f || x >= SCREEN_WIDTH ||
+ y <= 0.0f || y >= SCREEN_HEIGHT) // BUG: game uses SCREENW again
return;
float w = GetCharacterWidth(c) / 32.0f;
diff --git a/src/render/Hud.cpp b/src/render/Hud.cpp
index e5a44221..0e132392 100644
--- a/src/render/Hud.cpp
+++ b/src/render/Hud.cpp
@@ -125,6 +125,15 @@ WRAPPER void CHud::Draw(void) { EAXJMP(0x5052A0); }
#else
void CHud::Draw()
{
+ RwRenderStateSet(rwRENDERSTATEFOGENABLE, (void*)FALSE);
+ RwRenderStateSet(rwRENDERSTATESRCBLEND, (void*)rwBLENDSRCALPHA);
+ RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDINVSRCALPHA);
+ RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)TRUE);
+ RwRenderStateSet(rwRENDERSTATETEXTUREADDRESS, (void*)rwTEXTUREADDRESSMIRROR);
+ RwRenderStateSet(rwRENDERSTATETEXTURERASTER, (void*)FALSE);
+ RwRenderStateSet(rwRENDERSTATESHADEMODE, (void*)rwSHADEMODEFLAT);
+ RwRenderStateSet(rwRENDERSTATETEXTUREFILTER, (void*)rwFILTERLINEAR);
+
if (CReplay::IsPlayingBack())
return;
@@ -167,18 +176,15 @@ void CHud::Draw()
float fStep = sin((CTimer::GetTimeInMilliseconds() & 1023) * 0.0061328127);
float fMultBright = SpriteBrightness * 0.03f * (0.25f * fStep + 0.75f);
CRect rect;
-
- float fWidescreenOffset[2] = { 0.0f, 0.0f };
-
- if (FrontEndMenuManager.m_PrefsUseWideScreen) {
- fWidescreenOffset[0] = 0.0f;
- fWidescreenOffset[1] = SCREEN_SCALE_Y(18.0f);
- }
-
+#ifndef ASPECT_RATIO_SCALE
if (Mode_RunAround && TheCamera.Cams->Using3rdPersonMouseCam()) {
- float f3rdX = SCREENW * TheCamera.m_f3rdPersonCHairMultX + fWidescreenOffset[0];
- float f3rdY = SCREENH * TheCamera.m_f3rdPersonCHairMultY - fWidescreenOffset[1];
-
+ float f3rdX = SCREEN_WIDTH * TheCamera.m_f3rdPersonCHairMultX;
+ float f3rdY = SCREEN_HEIGHT * TheCamera.m_f3rdPersonCHairMultY;
+#else
+ if (Mode_RunAround && TheCamera.Cams->Using3rdPersonMouseCam()) {
+ float f3rdX = (((TheCamera.m_f3rdPersonCHairMultX - 0.5f) / ((CDraw::GetAspectRatio()) / (DEFAULT_ASPECT_RATIO))) + 0.5f) * SCREEN_WIDTH;
+ float f3rdY = SCREEN_HEIGHT * TheCamera.m_f3rdPersonCHairMultY + SCREEN_SCALE_Y(-2.0f);
+#endif
if (CWorld::Players[CWorld::PlayerInFocus].m_pPed && WeaponType == WEAPONTYPE_M16) {
rect.left = f3rdX - SCREEN_SCALE_X(32.0f * 0.6f);
rect.top = f3rdY - SCREEN_SCALE_Y(32.0f * 0.6f);
@@ -654,7 +660,7 @@ void CHud::Draw()
CFont::SetBackgroundOff();
CFont::SetBackGroundOnlyTextOn();
CFont::SetAlignment(ALIGN_RIGHT);
- CFont::SetRightJustifyWrap(-SCREENW);
+ CFont::SetRightJustifyWrap(-SCREEN_WIDTH);
CFont::SetFontStyle(FONT_HEADING);
CFont::SetScale(SCREEN_SCALE_X(0.8f), SCREEN_SCALE_Y(1.35f));
@@ -917,7 +923,7 @@ void CHud::Draw()
CFont::SetCentreSize(SCREEN_SCALE_X(615.0f));
CFont::SetFontStyle(FONT_HEADING);
- if (BigMessageX[0] >= (SCREENW - 20)) {
+ if (BigMessageX[0] >= (SCREEN_WIDTH - 20)) {
BigMessageInUse[0] += (CTimer::GetTimeStep() * 0.02f * 120.0f);
if (BigMessageInUse[0] >= 120.0f) {
@@ -1190,7 +1196,7 @@ void CHud::DrawAfterFade()
CFont::SetRightJustifyWrap(-500);
CFont::SetRightJustifyOn();
CFont::SetFontStyle(FONT_HEADING);
- if (BigMessageX[1] >= (SCREENW - 20)) {
+ if (BigMessageX[1] >= (SCREEN_WIDTH - 20)) {
BigMessageInUse[1] += (CTimer::GetTimeStep() * 0.02f * 120.0f);
if (BigMessageInUse[1] >= 120.0f) {
diff --git a/src/render/MBlur.h b/src/render/MBlur.h
index baa82b80..42827f99 100644
--- a/src/render/MBlur.h
+++ b/src/render/MBlur.h
@@ -2,6 +2,7 @@
class CMBlur
{
+public:
static RwRaster *&pFrontBuffer;
static bool &ms_bJustInitialised;
static bool &BlurOn;