mirror of
https://github.com/ZDoom/gzdoom.git
synced 2025-02-22 12:01:13 +00:00
Add TexMan.SetCameraTextureAspectRatio
Allows ZScript to change the aspect ratio of a camera texture.
This commit is contained in:
parent
6432e4f6a8
commit
20d16381f8
3 changed files with 27 additions and 0 deletions
|
@ -320,6 +320,8 @@ public:
|
||||||
void NeedUpdate() { bNeedsUpdate = true; }
|
void NeedUpdate() { bNeedsUpdate = true; }
|
||||||
void SetUpdated(bool rendertype) { bNeedsUpdate = false; bFirstUpdate = false; bLastUpdateType = rendertype; }
|
void SetUpdated(bool rendertype) { bNeedsUpdate = false; bFirstUpdate = false; bLastUpdateType = rendertype; }
|
||||||
|
|
||||||
|
void SetAspectRatio(double aspectScale, bool useTextureRatio) { aspectRatio = aspectScale * (useTextureRatio? ((float)Width / Height) : 1); }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
bool bLastUpdateType = false;
|
bool bLastUpdateType = false;
|
||||||
|
|
|
@ -78,6 +78,30 @@ DEFINE_ACTION_FUNCTION_NATIVE(_TexMan, SetCameraToTexture, SetCameraToTexture)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void SetCameraTextureAspectRatio(const FString &texturename, double aspectScale, bool useTextureRatio)
|
||||||
|
{
|
||||||
|
FTextureID textureid = TexMan.CheckForTexture(texturename, ETextureType::Wall, FTextureManager::TEXMAN_Overridable);
|
||||||
|
if (textureid.isValid())
|
||||||
|
{
|
||||||
|
// Only proceed if the texture actually has a canvas.
|
||||||
|
auto tex = TexMan.GetGameTexture(textureid);
|
||||||
|
if (tex && tex->isHardwareCanvas())
|
||||||
|
{
|
||||||
|
static_cast<FCanvasTexture *>(tex->GetTexture())->SetAspectRatio(aspectScale, useTextureRatio);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
DEFINE_ACTION_FUNCTION_NATIVE(_TexMan, SetCameraTextureAspectRatio, SetCameraTextureAspectRatio)
|
||||||
|
{
|
||||||
|
PARAM_PROLOGUE;
|
||||||
|
PARAM_STRING(texturename);
|
||||||
|
PARAM_FLOAT(aspect);
|
||||||
|
PARAM_BOOL(useTextureRatio);
|
||||||
|
SetCameraTextureAspectRatio(texturename, aspect, useTextureRatio);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
//=====================================================================================
|
//=====================================================================================
|
||||||
//
|
//
|
||||||
// sector_t exports
|
// sector_t exports
|
||||||
|
|
|
@ -26,6 +26,7 @@ extend struct _
|
||||||
extend struct TexMan
|
extend struct TexMan
|
||||||
{
|
{
|
||||||
native static void SetCameraToTexture(Actor viewpoint, String texture, double fov);
|
native static void SetCameraToTexture(Actor viewpoint, String texture, double fov);
|
||||||
|
native static void SetCameraTextureAspectRatio(String texture, double aspectScale, bool useTextureRatio = true);
|
||||||
deprecated("3.8", "Use Level.ReplaceTextures() instead") static void ReplaceTextures(String from, String to, int flags)
|
deprecated("3.8", "Use Level.ReplaceTextures() instead") static void ReplaceTextures(String from, String to, int flags)
|
||||||
{
|
{
|
||||||
level.ReplaceTextures(from, to, flags);
|
level.ReplaceTextures(from, to, flags);
|
||||||
|
|
Loading…
Reference in a new issue