mirror of
https://github.com/ZDoom/gzdoom.git
synced 2025-03-06 17:42:40 +00:00
- Backend update from Raze.
This commit is contained in:
parent
68d3f474ce
commit
f6bfc48d9f
16 changed files with 59 additions and 43 deletions
src
common
audio/sound
fonts
menu
statusbar
utility
rendering
|
@ -131,7 +131,7 @@ public:
|
||||||
void SetMusicVolume (float volume)
|
void SetMusicVolume (float volume)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
SoundHandle LoadSound(uint8_t *sfxdata, int length)
|
SoundHandle LoadSound(uint8_t *sfxdata, int length, int def_loop_start, int def_loop_end)
|
||||||
{
|
{
|
||||||
SoundHandle retval = { NULL };
|
SoundHandle retval = { NULL };
|
||||||
return retval;
|
return retval;
|
||||||
|
|
|
@ -105,7 +105,7 @@ public:
|
||||||
virtual bool IsNull() { return false; }
|
virtual bool IsNull() { return false; }
|
||||||
virtual void SetSfxVolume (float volume) = 0;
|
virtual void SetSfxVolume (float volume) = 0;
|
||||||
virtual void SetMusicVolume (float volume) = 0;
|
virtual void SetMusicVolume (float volume) = 0;
|
||||||
virtual SoundHandle LoadSound(uint8_t *sfxdata, int length) = 0;
|
virtual SoundHandle LoadSound(uint8_t *sfxdata, int length, int def_loop_start, int def_loop_end) = 0;
|
||||||
SoundHandle LoadSoundVoc(uint8_t *sfxdata, int length);
|
SoundHandle LoadSoundVoc(uint8_t *sfxdata, int length);
|
||||||
virtual SoundHandle LoadSoundRaw(uint8_t *sfxdata, int length, int frequency, int channels, int bits, int loopstart, int loopend = -1) = 0;
|
virtual SoundHandle LoadSoundRaw(uint8_t *sfxdata, int length, int frequency, int channels, int bits, int loopstart, int loopend = -1) = 0;
|
||||||
virtual void UnloadSound (SoundHandle sfx) = 0; // unloads a sound from memory
|
virtual void UnloadSound (SoundHandle sfx) = 0; // unloads a sound from memory
|
||||||
|
|
|
@ -1096,7 +1096,7 @@ SoundHandle OpenALSoundRenderer::LoadSoundRaw(uint8_t *sfxdata, int length, int
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
SoundHandle OpenALSoundRenderer::LoadSound(uint8_t *sfxdata, int length)
|
SoundHandle OpenALSoundRenderer::LoadSound(uint8_t *sfxdata, int length, int def_loop_start, int def_loop_end)
|
||||||
{
|
{
|
||||||
SoundHandle retval = { NULL };
|
SoundHandle retval = { NULL };
|
||||||
ALenum format = AL_NONE;
|
ALenum format = AL_NONE;
|
||||||
|
@ -1106,7 +1106,16 @@ SoundHandle OpenALSoundRenderer::LoadSound(uint8_t *sfxdata, int length)
|
||||||
uint32_t loop_start = 0, loop_end = ~0u;
|
uint32_t loop_start = 0, loop_end = ~0u;
|
||||||
zmusic_bool startass = false, endass = false;
|
zmusic_bool startass = false, endass = false;
|
||||||
|
|
||||||
|
if (def_loop_start < 0)
|
||||||
|
{
|
||||||
FindLoopTags(sfxdata, length, &loop_start, &startass, &loop_end, &endass);
|
FindLoopTags(sfxdata, length, &loop_start, &startass, &loop_end, &endass);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
loop_start = def_loop_start;
|
||||||
|
loop_end = def_loop_end;
|
||||||
|
startass = endass = true;
|
||||||
|
}
|
||||||
auto decoder = CreateDecoder(sfxdata, length, true);
|
auto decoder = CreateDecoder(sfxdata, length, true);
|
||||||
if (!decoder)
|
if (!decoder)
|
||||||
return retval;
|
return retval;
|
||||||
|
|
|
@ -34,7 +34,7 @@ public:
|
||||||
|
|
||||||
virtual void SetSfxVolume(float volume);
|
virtual void SetSfxVolume(float volume);
|
||||||
virtual void SetMusicVolume(float volume);
|
virtual void SetMusicVolume(float volume);
|
||||||
virtual SoundHandle LoadSound(uint8_t *sfxdata, int length);
|
virtual SoundHandle LoadSound(uint8_t *sfxdata, int length, int def_loop_start, int def_loop_end);
|
||||||
virtual SoundHandle LoadSoundRaw(uint8_t *sfxdata, int length, int frequency, int channels, int bits, int loopstart, int loopend = -1);
|
virtual SoundHandle LoadSoundRaw(uint8_t *sfxdata, int length, int frequency, int channels, int bits, int loopstart, int loopend = -1);
|
||||||
virtual void UnloadSound(SoundHandle sfx);
|
virtual void UnloadSound(SoundHandle sfx);
|
||||||
virtual unsigned int GetMSLength(SoundHandle sfx);
|
virtual unsigned int GetMSLength(SoundHandle sfx);
|
||||||
|
|
|
@ -382,7 +382,7 @@ static float CalcPitch(int pitchmask, float defpitch, float defpitchmax)
|
||||||
{
|
{
|
||||||
if (defpitchmax > 0.0 && defpitch != defpitchmax)
|
if (defpitchmax > 0.0 && defpitch != defpitchmax)
|
||||||
{
|
{
|
||||||
defpitch = pr_soundpitch.GenRand_Real1() * (defpitchmax - defpitch) + defpitch;
|
defpitch = (float)pr_soundpitch.GenRand_Real1() * (defpitchmax - defpitch) + defpitch;
|
||||||
}
|
}
|
||||||
return defpitch;
|
return defpitch;
|
||||||
}
|
}
|
||||||
|
@ -769,7 +769,7 @@ sfxinfo_t *SoundEngine::LoadSound(sfxinfo_t *sfx)
|
||||||
// If that fails, let the sound system try and figure it out.
|
// If that fails, let the sound system try and figure it out.
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sfx->data = GSnd->LoadSound(sfxdata.Data(), size);
|
sfx->data = GSnd->LoadSound(sfxdata.Data(), size, sfx->LoopStart, sfx->LoopEnd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -97,11 +97,13 @@ constexpr FSoundID INVALID_SOUND = FSoundID::fromInt(-1);
|
||||||
bool bUsed = false;
|
bool bUsed = false;
|
||||||
bool bSingular = false;
|
bool bSingular = false;
|
||||||
bool bTentative = true;
|
bool bTentative = true;
|
||||||
|
bool bExternal = false;
|
||||||
|
|
||||||
TArray<int> UserData;
|
TArray<int> UserData;
|
||||||
|
|
||||||
int RawRate = 0; // Sample rate to use when bLoadRAW is true
|
int RawRate = 0; // Sample rate to use when bLoadRAW is true
|
||||||
int LoopStart = -1; // -1 means no specific loop defined
|
int LoopStart = -1; // -1 means no specific loop defined
|
||||||
|
int LoopEnd = -1; // -1 means no specific loop defined
|
||||||
|
|
||||||
FSoundID link = NO_LINK;
|
FSoundID link = NO_LINK;
|
||||||
constexpr static FSoundID NO_LINK = FSoundID::fromInt(-1);
|
constexpr static FSoundID NO_LINK = FSoundID::fromInt(-1);
|
||||||
|
|
|
@ -120,7 +120,7 @@ FFont::FFont (const char *name, const char *nametemplate, const char *filetempla
|
||||||
sc.MustGetValue(false);
|
sc.MustGetValue(false);
|
||||||
GlobalKerning = sc.Number;
|
GlobalKerning = sc.Number;
|
||||||
}
|
}
|
||||||
if (sc.Compare("Altfont"))
|
else if (sc.Compare("Altfont"))
|
||||||
{
|
{
|
||||||
sc.MustGetString();
|
sc.MustGetString();
|
||||||
AltFontName = sc.String;
|
AltFontName = sc.String;
|
||||||
|
@ -179,6 +179,11 @@ FFont::FFont (const char *name, const char *nametemplate, const char *filetempla
|
||||||
sc.ScriptError("Unknown translation type %s", sc.String);
|
sc.ScriptError("Unknown translation type %s", sc.String);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (sc.Compare("lowercaselatinonly"))
|
||||||
|
{
|
||||||
|
lowercaselatinonly = true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -755,7 +760,7 @@ int FFont::GetCharCode(int code, bool needpic) const
|
||||||
// Use different substitution logic based on the fonts content:
|
// Use different substitution logic based on the fonts content:
|
||||||
// In a font which has both upper and lower case, prefer unaccented small characters over capital ones.
|
// In a font which has both upper and lower case, prefer unaccented small characters over capital ones.
|
||||||
// In a pure upper-case font, do not check for lower case replacements.
|
// In a pure upper-case font, do not check for lower case replacements.
|
||||||
if (!MixedCase)
|
if (!MixedCase || (lowercaselatinonly && code >= 0x380 && code < 0x500))
|
||||||
{
|
{
|
||||||
// Try converting lowercase characters to uppercase.
|
// Try converting lowercase characters to uppercase.
|
||||||
if (myislower(code))
|
if (myislower(code))
|
||||||
|
|
|
@ -167,6 +167,7 @@ public:
|
||||||
forceremap = other.forceremap;
|
forceremap = other.forceremap;
|
||||||
Chars = other.Chars;
|
Chars = other.Chars;
|
||||||
Translations = other.Translations;
|
Translations = other.Translations;
|
||||||
|
lowercaselatinonly = other.lowercaselatinonly;
|
||||||
Lump = other.Lump;
|
Lump = other.Lump;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -189,6 +190,7 @@ protected:
|
||||||
bool noTranslate = false;
|
bool noTranslate = false;
|
||||||
bool MixedCase = false;
|
bool MixedCase = false;
|
||||||
bool forceremap = false;
|
bool forceremap = false;
|
||||||
|
bool lowercaselatinonly = false;
|
||||||
struct CharData
|
struct CharData
|
||||||
{
|
{
|
||||||
FGameTexture *OriginalPic = nullptr;
|
FGameTexture *OriginalPic = nullptr;
|
||||||
|
|
|
@ -924,10 +924,16 @@ void M_Init (void)
|
||||||
}
|
}
|
||||||
catch (CVMAbortException &err)
|
catch (CVMAbortException &err)
|
||||||
{
|
{
|
||||||
|
menuDelegate = nullptr;
|
||||||
err.MaybePrintMessage();
|
err.MaybePrintMessage();
|
||||||
Printf(PRINT_NONOTIFY | PRINT_BOLD, "%s", err.stacktrace.GetChars());
|
Printf(PRINT_NONOTIFY | PRINT_BOLD, "%s", err.stacktrace.GetChars());
|
||||||
I_FatalError("Failed to initialize menus");
|
I_FatalError("Failed to initialize menus");
|
||||||
}
|
}
|
||||||
|
catch (...)
|
||||||
|
{
|
||||||
|
menuDelegate = nullptr;
|
||||||
|
throw;
|
||||||
|
}
|
||||||
M_CreateMenus();
|
M_CreateMenus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -150,13 +150,13 @@ void DeinitMenus()
|
||||||
pair->Value = nullptr;
|
pair->Value = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
MenuDescriptors.Clear();
|
|
||||||
OptionValues.Clear();
|
|
||||||
if (menuDelegate)
|
if (menuDelegate)
|
||||||
{
|
{
|
||||||
menuDelegate->Destroy();
|
menuDelegate->Destroy();
|
||||||
menuDelegate = nullptr;
|
menuDelegate = nullptr;
|
||||||
}
|
}
|
||||||
|
MenuDescriptors.Clear();
|
||||||
|
OptionValues.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
FTextureID GetMenuTexture(const char* const name)
|
FTextureID GetMenuTexture(const char* const name)
|
||||||
|
|
|
@ -368,7 +368,7 @@ void DStatusBarCore::SetScale()
|
||||||
double screenaspect = w / double(h);
|
double screenaspect = w / double(h);
|
||||||
double aspectscale = 1.0;
|
double aspectscale = 1.0;
|
||||||
|
|
||||||
double ViewportAspect = ViewportPixelAspect();
|
const double ViewportAspect = 1. / ViewportPixelAspect();
|
||||||
|
|
||||||
if ((horz == 320 && vert == 200) || (horz == 640 && vert == 400))
|
if ((horz == 320 && vert == 200) || (horz == 640 && vert == 400))
|
||||||
{
|
{
|
||||||
|
@ -387,9 +387,9 @@ void DStatusBarCore::SetScale()
|
||||||
refw = h * refaspect;
|
refw = h * refaspect;
|
||||||
}
|
}
|
||||||
refw *= hud_scalefactor;
|
refw *= hud_scalefactor;
|
||||||
refh *= hud_scalefactor * aspectscale / ViewportAspect;
|
refh *= hud_scalefactor * aspectscale * ViewportAspect;
|
||||||
|
|
||||||
int sby = vert - int(RelTop * hud_scalefactor * aspectscale / ViewportAspect);
|
int sby = vert - int(RelTop * hud_scalefactor * aspectscale * ViewportAspect);
|
||||||
// Use full pixels for destination size.
|
// Use full pixels for destination size.
|
||||||
|
|
||||||
ST_X = xs_CRoundToInt((w - refw) / 2);
|
ST_X = xs_CRoundToInt((w - refw) / 2);
|
||||||
|
|
|
@ -210,9 +210,7 @@ void I_ResetFrameTime()
|
||||||
FirstFrameStartTime += (CurrentFrameStartTime - ft);
|
FirstFrameStartTime += (CurrentFrameStartTime - ft);
|
||||||
}
|
}
|
||||||
|
|
||||||
double I_GetInputFrac(bool const synchronised)
|
double I_GetInputFrac()
|
||||||
{
|
|
||||||
if (!synchronised)
|
|
||||||
{
|
{
|
||||||
const double now = I_msTimeF();
|
const double now = I_msTimeF();
|
||||||
const double result = (now - lastinputtime) * GameTicRate * (1. / 1000.);
|
const double result = (now - lastinputtime) * GameTicRate * (1. / 1000.);
|
||||||
|
@ -220,9 +218,6 @@ double I_GetInputFrac(bool const synchronised)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void I_ResetInputTime()
|
void I_ResetInputTime()
|
||||||
{
|
{
|
||||||
// Reset lastinputtime to current time.
|
// Reset lastinputtime to current time.
|
||||||
|
|
|
@ -42,7 +42,7 @@ uint64_t I_nsTime();
|
||||||
void I_ResetFrameTime();
|
void I_ResetFrameTime();
|
||||||
|
|
||||||
// Return a decimal fraction to scale input operations at framerate
|
// Return a decimal fraction to scale input operations at framerate
|
||||||
double I_GetInputFrac(bool const synchronised);
|
double I_GetInputFrac();
|
||||||
|
|
||||||
// Reset the last input check to after a lengthy operation
|
// Reset the last input check to after a lengthy operation
|
||||||
void I_ResetInputTime();
|
void I_ResetInputTime();
|
||||||
|
|
|
@ -230,7 +230,7 @@ struct TVector2
|
||||||
// Vector length
|
// Vector length
|
||||||
vec_t Length() const
|
vec_t Length() const
|
||||||
{
|
{
|
||||||
return (vec_t)g_sqrt (X*X + Y*Y);
|
return (vec_t)g_sqrt (LengthSquared());
|
||||||
}
|
}
|
||||||
|
|
||||||
vec_t LengthSquared() const
|
vec_t LengthSquared() const
|
||||||
|
@ -613,7 +613,7 @@ struct TVector3
|
||||||
// Vector length
|
// Vector length
|
||||||
double Length() const
|
double Length() const
|
||||||
{
|
{
|
||||||
return g_sqrt (X*X + Y*Y + Z*Z);
|
return g_sqrt (LengthSquared());
|
||||||
}
|
}
|
||||||
|
|
||||||
double LengthSquared() const
|
double LengthSquared() const
|
||||||
|
@ -928,7 +928,7 @@ struct TVector4
|
||||||
// Vector length
|
// Vector length
|
||||||
double Length() const
|
double Length() const
|
||||||
{
|
{
|
||||||
return g_sqrt(X*X + Y*Y + Z*Z + W*W);
|
return g_sqrt(LengthSquared());
|
||||||
}
|
}
|
||||||
|
|
||||||
double LengthSquared() const
|
double LengthSquared() const
|
||||||
|
@ -1450,7 +1450,7 @@ public:
|
||||||
|
|
||||||
double Tan() const
|
double Tan() const
|
||||||
{
|
{
|
||||||
auto bam = BAMs();
|
const auto bam = BAMs();
|
||||||
return g_sinbam(bam) / g_cosbam(bam);
|
return g_sinbam(bam) / g_cosbam(bam);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1487,7 +1487,7 @@ inline TAngle<T> deltaangle(const TAngle<T> &a1, const TAngle<T> &a2)
|
||||||
template<class T>
|
template<class T>
|
||||||
inline TAngle<T> absangle(const TAngle<T> &a1, const TAngle<T> &a2)
|
inline TAngle<T> absangle(const TAngle<T> &a1, const TAngle<T> &a2)
|
||||||
{
|
{
|
||||||
return fabs((a1 - a2).Normalized180());
|
return fabs(deltaangle(a2, a1));
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
|
@ -1528,7 +1528,7 @@ TAngle<T> TVector3<T>::Angle() const
|
||||||
template<class T>
|
template<class T>
|
||||||
TAngle<T> TVector3<T>::Pitch() const
|
TAngle<T> TVector3<T>::Pitch() const
|
||||||
{
|
{
|
||||||
return -VecToAngle(TVector2<T>(X, Y).Length(), Z);
|
return -VecToAngle(XY().Length(), Z);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
|
@ -1694,13 +1694,10 @@ struct TRotator
|
||||||
};
|
};
|
||||||
|
|
||||||
// Create a forward vector from a rotation (ignoring roll)
|
// Create a forward vector from a rotation (ignoring roll)
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
inline TVector3<T>::TVector3 (const TRotator<T> &rot)
|
inline TVector3<T>::TVector3 (const TRotator<T> &rot)
|
||||||
{
|
{
|
||||||
double pcos = rot.Pitch.Cos();
|
XY() = rot.Pitch.Cos() * rot.Yaw.ToVector();
|
||||||
X = pcos * rot.Yaw.Cos();
|
|
||||||
Y = pcos * rot.Yaw.Sin();
|
|
||||||
Z = rot.Pitch.Sin();
|
Z = rot.Pitch.Sin();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -843,7 +843,7 @@ void R_SetupFrame (FRenderViewpoint &viewpoint, FViewWindow &viewwindow, AActor
|
||||||
}
|
}
|
||||||
|
|
||||||
// [MR] Get the input fraction, even if we don't need it this frame. Must run every frame.
|
// [MR] Get the input fraction, even if we don't need it this frame. Must run every frame.
|
||||||
const auto scaleAdjust = I_GetInputFrac(false);
|
const auto scaleAdjust = I_GetInputFrac();
|
||||||
|
|
||||||
// [MR] Process player angle changes if permitted to do so.
|
// [MR] Process player angle changes if permitted to do so.
|
||||||
if (player && (player->cheats & CF_SCALEDNOLERP) && P_NoInterpolation(player, viewpoint.camera))
|
if (player && (player->cheats & CF_SCALEDNOLERP) && P_NoInterpolation(player, viewpoint.camera))
|
||||||
|
|
Loading…
Reference in a new issue