Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"isExternalTextureRetina" display default #440

Merged
merged 19 commits into from Aug 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion librtt/Display/Rtt_DisplayDefaults.cpp
Expand Up @@ -47,7 +47,8 @@ DisplayDefaults::DisplayDefaults()
fIsNativeTextBoxFontSizeScaled( true ),
fShaderCompilerVerbose( kShaderCompilerVerboseDefault ),
fIsAnchorClamped( true ),
fIsImageSheetSampledInsideFrame( false )
fIsImageSheetSampledInsideFrame( false ),
fIsExternalTextureRetina( true )
{
}

Expand Down
4 changes: 4 additions & 0 deletions librtt/Display/Rtt_DisplayDefaults.h
Expand Up @@ -60,6 +60,9 @@ class DisplayDefaults

bool IsImageSheetSampledInsideFrame() const { return fIsImageSheetSampledInsideFrame;}
void SetImageSheetSampledInsideFrame( bool newValue ) { fIsImageSheetSampledInsideFrame = newValue; }

bool IsExternalTextureRetina() const { return fIsExternalTextureRetina;}
void SetExternalTextureRetina( bool newValue ) { fIsExternalTextureRetina = newValue; }
public:
bool IsV1Compatibility() const { return fV1Compatibility; }
void SetV1Compatibility( bool newValue ) { fV1Compatibility = newValue; }
Expand Down Expand Up @@ -96,6 +99,7 @@ class DisplayDefaults
bool fShaderCompilerVerbose;
bool fIsAnchorClamped;
bool fIsImageSheetSampledInsideFrame;
bool fIsExternalTextureRetina;
};

// ----------------------------------------------------------------------------
Expand Down
10 changes: 10 additions & 0 deletions librtt/Display/Rtt_LuaLibDisplay.cpp
Expand Up @@ -1808,6 +1808,11 @@ DisplayLibrary::getDefault( lua_State *L )
bool value = defaults.IsImageSheetSampledInsideFrame();
lua_pushboolean( L, value ? 1 : 0 );
}
else if ( ( Rtt_StringCompare( key, "isExternalTextureRetina" ) == 0 ) )
{
bool value = defaults.IsExternalTextureRetina();
lua_pushboolean( L, value ? 1 : 0 );
}
else if ( key )
{
luaL_error( L, "ERROR: display.getDefault() given invalid key (%s)", key );
Expand Down Expand Up @@ -1933,6 +1938,11 @@ DisplayLibrary::setDefault( lua_State *L )
bool value = lua_toboolean( L, index ) ? true : false;
defaults.SetImageSheetSampledInsideFrame( value );
}
else if ( ( Rtt_StringCompare( key, "isExternalTextureRetina" ) == 0 ) )
{
bool value = lua_toboolean( L, index ) ? true : false;
defaults.SetExternalTextureRetina( value );
}
else if ( key )
{
luaL_error( L, "ERROR: display.setDefault() given invalid key (%s)", key );
Expand Down
6 changes: 0 additions & 6 deletions librtt/Display/Rtt_LuaLibGraphics.cpp
Expand Up @@ -78,9 +78,7 @@ class GraphicsLibrary
static int newOutline( lua_State *L ); // This returns an outline in texels.
static int newTexture( lua_State *L );
static int releaseTextures( lua_State *L );
// STEVE CHANGE
static int undefineEffect( lua_State *L );
// /STEVE CHANGE
static int getFontMetrics( lua_State *L );

private:
Expand Down Expand Up @@ -123,9 +121,7 @@ GraphicsLibrary::Open( lua_State *L )
{ "newOutline", newOutline }, // This returns an outline in texels.
{ "newTexture", newTexture },
{ "releaseTextures", releaseTextures },
// STEVE CHANGE
{ "undefineEffect", undefineEffect },
// /STEVE CHANGE
{ "getFontMetrics", getFontMetrics },

{ NULL, NULL }
Expand Down Expand Up @@ -793,7 +789,6 @@ GraphicsLibrary::releaseTextures( lua_State *L )
return result;
}

// STEVE CHANGE
// ----------------------------------------------------------------------------

int
Expand All @@ -810,7 +805,6 @@ GraphicsLibrary::undefineEffect( lua_State *L )

return 1;
}
// /STEVE CHANGE

// ----------------------------------------------------------------------------

Expand Down
4 changes: 3 additions & 1 deletion librtt/Display/Rtt_TextureFactory.cpp
Expand Up @@ -574,7 +574,9 @@ TextureFactory::FindOrCreateExternal(const std::string &cacheKey,
return fOwnedTextures[cacheKey];
}

TextureResource *resource = TextureResourceExternal::Create( *this, callbacks, context, true );
bool isRetina = GetDisplay().GetDefaults().IsExternalTextureRetina();

TextureResource *resource = TextureResourceExternal::Create( *this, callbacks, context, isRetina );
SharedPtr< TextureResource > result = SharedPtr< TextureResource >( resource );

fCache[cacheKey] = CacheEntry( result );
Expand Down