Skip to content

Commit

Permalink
fix texture compression preference
Browse files Browse the repository at this point in the history
  • Loading branch information
Garux committed Jul 21, 2023
1 parent 4d870a3 commit 7cefa2b
Showing 1 changed file with 36 additions and 15 deletions.
51 changes: 36 additions & 15 deletions radiant/textures.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -763,6 +763,9 @@ void TextureModeExport( ETexturesMode& self, const IntImportCallback& importer )
}
typedef ReferenceCaller1<ETexturesMode, const IntImportCallback&, TextureModeExport> TextureModeExportCaller;

#include <QComboBox>
#include <QEvent>

void Textures_constructPreferences( PreferencesPage& page ){
{
const char* percentages[] = { "100%", "50%", "25%", "12.5%", };
Expand Down Expand Up @@ -790,25 +793,43 @@ void Textures_constructPreferences( PreferencesPage& page ){
);
}
{
const char* compression_none[] = { "None" };
const char* compression_opengl[] = { "None", "OpenGL ARB" };
const char* compression_s3tc[] = { "None", "S3TC DXT1", "S3TC DXT3", "S3TC DXT5" };
const char* compression_opengl_s3tc[] = { "None", "OpenGL ARB", "S3TC DXT1", "S3TC DXT3", "S3TC DXT5" };
const StringArrayRange compression(
( g_texture_globals.m_bOpenGLCompressionSupported )
? ( g_texture_globals.m_bS3CompressionSupported )
? StringArrayRange( compression_opengl_s3tc )
: StringArrayRange( compression_opengl )
: ( g_texture_globals.m_bS3CompressionSupported )
? StringArrayRange( compression_s3tc )
: StringArrayRange( compression_none )
);
page.appendCombo(
//. note workaround: openGL is initialised after prefs dlg is constructed
//. solution for now is to defer dependent preference construction
class Filter : public QObject
{
using QObject::QObject;
protected:
bool eventFilter( QObject *obj, QEvent *event ) override {
if( event->type() == QEvent::Polish ) {
const char* compression_none[] = { "None" };
const char* compression_opengl[] = { "None", "OpenGL ARB" };
const char* compression_s3tc[] = { "None", "S3TC DXT1", "S3TC DXT3", "S3TC DXT5" };
const char* compression_opengl_s3tc[] = { "None", "OpenGL ARB", "S3TC DXT1", "S3TC DXT3", "S3TC DXT5" };
const StringArrayRange compression(
( g_texture_globals.m_bOpenGLCompressionSupported )
? ( g_texture_globals.m_bS3CompressionSupported )
? StringArrayRange( compression_opengl_s3tc )
: StringArrayRange( compression_opengl )
: ( g_texture_globals.m_bS3CompressionSupported )
? StringArrayRange( compression_s3tc )
: StringArrayRange( compression_none )
);
QComboBox *combo = static_cast<QComboBox *>( obj );
for( const char *c : compression )
combo->addItem( c );
obj->removeEventFilter( this );
}
return QObject::eventFilter( obj, event ); // standard event processing
}
};

QComboBox *combo = page.appendCombo(
"Hardware Texture Compression",
compression,
StringArrayRange(),
TextureCompressionImportCaller( g_texture_globals.m_nTextureCompressionFormat ),
IntExportCaller( reinterpret_cast<int&>( g_texture_globals.m_nTextureCompressionFormat ) )
);
combo->installEventFilter( new Filter( combo ) );
}
page.appendCheckBox( "", "Anisotropy",
FreeCaller1<bool, Textures_SetAnisotropy>(),
Expand Down

0 comments on commit 7cefa2b

Please sign in to comment.