Skip to content

Commit

Permalink
поддержка SetNoShaderCache. пока только для скриптов
Browse files Browse the repository at this point in the history
  • Loading branch information
joye-ramone authored and xrSimpodin committed Oct 1, 2023
1 parent 3dfc212 commit 1ef0dd4
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@ function save_load_dialog:InitControlsLoad()
xml:InitStatic("form:caption", self.form)

xml:InitStatic("form:picture", self.form):SetWindowName("static_pict")
local picture = self:GetStatic("static_pict")
picture:SetNoShaderCache(true)

xml:InitStatic("form:file_info", self.form)

Expand Down
2 changes: 1 addition & 1 deletion ogsr_engine/Include/xrRender/UIShader.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class IUIShader
public:
virtual ~IUIShader() { ; }
virtual void Copy(IUIShader& _in) = 0;
virtual void create(LPCSTR sh, LPCSTR tex = 0) = 0;
virtual void create(LPCSTR sh, LPCSTR tex = 0, bool no_cache = false) = 0;
virtual bool inited() = 0;
//virtual void destroy() = 0;
};
Expand Down
12 changes: 11 additions & 1 deletion ogsr_engine/Layers/xrRender/dxUIShader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,16 @@ static ref_shader& GetCachedUIShader(const char* sh, const char* tex)

void dxUIShader::Copy(IUIShader& _in) { *this = *((dxUIShader*)&_in); }

void dxUIShader::create(LPCSTR sh, LPCSTR tex) { hShader = GetCachedUIShader(sh, tex); }
void dxUIShader::create(LPCSTR sh, LPCSTR tex, bool no_cache)
{
if (no_cache)
{
hShader.create(sh, tex);
}
else
{
hShader = GetCachedUIShader(sh, tex);
}
}

//void dxUIShader::destroy() { hShader.destroy(); }
2 changes: 1 addition & 1 deletion ogsr_engine/Layers/xrRender/dxUIShader.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class dxUIShader : public IUIShader
public:
virtual ~dxUIShader() { ; }
virtual void Copy(IUIShader& _in);
virtual void create(LPCSTR sh, LPCSTR tex = 0);
virtual void create(LPCSTR sh, LPCSTR tex = 0, bool no_cache = false);
virtual bool inited() { return hShader; }
//virtual void destroy();

Expand Down
3 changes: 3 additions & 0 deletions ogsr_engine/xrGame/UICustomItem.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class CUICustomItem
flValidOriginalRect = (1 << 1),
flValidHeadingPivot = (1 << 2),
flFixedLTWhileHeading = (1 << 3),
flNoShaderCache = (1 << 4),
};

//прямоугольник(в пикселях)
Expand All @@ -38,6 +39,7 @@ class CUICustomItem
public:
CUICustomItem();
virtual ~CUICustomItem();

IC void SetRect(float x1, float y1, float x2, float y2)
{
iVisRect.set(x1, y1, x2, y2);
Expand All @@ -58,6 +60,7 @@ class CUICustomItem

Fvector2 GetHeadingPivot() { return iHeadingPivot; }
void ResetHeadingPivot();

IC bool GetFixedLTWhileHeading() const { return !!uFlags.test(flFixedLTWhileHeading); }

void Render(const Fvector2& pos, u32 color, float x1, float y1, float x2, float y2);
Expand Down
2 changes: 1 addition & 1 deletion ogsr_engine/xrGame/UIStaticItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ CUIStaticItem::~CUIStaticItem() {}

void CUIStaticItem::CreateShader(LPCSTR tex, LPCSTR sh)
{
hShader->create(sh, tex);
hShader->create(sh, tex, !!uFlags.test(flNoShaderCache));

#ifdef DEBUG
dbg_tex_name = tex;
Expand Down
3 changes: 3 additions & 0 deletions ogsr_engine/xrGame/UIStaticItem.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class CUIStaticItem : public IUISimpleTextureControl, public CUICustomItem
#ifdef DEBUG
shared_str dbg_tex_name;
#endif

CUIStaticItem();
virtual ~CUIStaticItem();

Expand All @@ -54,6 +55,8 @@ class CUIStaticItem : public IUISimpleTextureControl, public CUICustomItem

void ResetOriginalRect() { uFlags.set(flValidOriginalRect, FALSE); }

void SetNoShaderCache(const bool v) { uFlags.set(flNoShaderCache, v); }

void Init(LPCSTR tex, LPCSTR sh, float left, float top, u32 align);

void Render();
Expand Down
3 changes: 3 additions & 0 deletions ogsr_engine/xrGame/ui/UIStatic.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ class CUIStatic : public CUIWindow, public CUISingleTextureOwner, public IUIText
virtual Frect GetOriginalRect() const { return m_UIStaticItem.GetOriginalRect(); }
//
void SetVTextAlignment(EVTextAlignment al);

void SetNoShaderCache(bool v) { m_UIStaticItem.SetNoShaderCache(v); }

virtual void SetColor(u32 color) { m_UIStaticItem.SetColor(color); }
u32 GetColor() const { return m_UIStaticItem.GetColor(); }
u32& GetColorRef() { return m_UIStaticItem.GetColorRef(); }
Expand Down
1 change: 1 addition & 0 deletions ogsr_engine/xrGame/ui/UIStatic_script.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ void CUIStatic::script_register(lua_State* L)
.def("GetOriginalRect", &CUIStatic::GetOriginalRect)
.def("SetOriginalRect", (void(CUIStatic::*)(float, float, float, float)) & CUIStatic::SetOriginalRect)
.def("ResetOriginalRect", &CUIStatic::ResetOriginalRect)
.def("SetNoShaderCache", &CUIStatic::SetNoShaderCache)
.def("SetStretchTexture", &CUIStatic::SetStretchTexture)
.def("GetStretchTexture", &CUIStatic::GetStretchTexture)

Expand Down

0 comments on commit 1ef0dd4

Please sign in to comment.