bool g_TextureBrowser_shaderlistOnly = false;
bool g_TextureBrowser_fixedSize = false;
bool g_TextureBrowser_filterNotex = false;
+bool g_TextureBrowser_enableAlpha = false;
}
class DeferredAdjustment
void TextureBrowser_filterNotex( const BoolImportCallback& importer );
typedef FreeCaller1<const BoolImportCallback&, TextureBrowser_filterNotex> TextureBrowserFilterNotexExport;
+void TextureBrowser_enableAlpha( const BoolImportCallback& importer );
+typedef FreeCaller1<const BoolImportCallback&, TextureBrowser_enableAlpha> TextureBrowserEnableAlphaExport;
+
class TextureBrowser
{
public:
ToggleItem m_showshaderlistonly_item;
ToggleItem m_fixedsize_item;
ToggleItem m_filternotex_item;
+ToggleItem m_enablealpha_item;
guint m_sizeHandler;
guint m_exposeHandler;
m_showshaderlistonly_item( TextureBrowserShowShaderlistOnlyExport() ),
m_fixedsize_item( TextureBrowserFixedSizeExport() ),
m_filternotex_item( TextureBrowserFilterNotexExport() ),
+ m_enablealpha_item( TextureBrowserEnableAlphaExport() ),
m_heightChanged( true ),
m_originInvalid( true ),
m_scrollAdjustment( TextureBrowser_scrollChanged, this ),
}
typedef FreeCaller1<const BoolImportCallback&, TextureBrowser_filterNotex> TextureBrowser_filterNotexExport;
+void TextureBrowser_enableAlpha( const BoolImportCallback& importer ){
+ importer( g_TextureBrowser_enableAlpha );
+}
+typedef FreeCaller1<const BoolImportCallback&, TextureBrowser_enableAlpha> TextureBrowser_enableAlphaExport;
+
void TextureBrowser_SetHideUnused( TextureBrowser& textureBrowser, bool hideUnused ){
if ( hideUnused ) {
textureBrowser.m_hideUnused = true;
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
glDisable( GL_DEPTH_TEST );
- glDisable( GL_BLEND );
+ if ( g_TextureBrowser_enableAlpha ) {
+ glEnable( GL_BLEND );
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ }
+ else {
+ glDisable( GL_BLEND );
+ }
glOrtho( 0, textureBrowser.width, originy - textureBrowser.height, originy, -100, 100 );
glEnable( GL_TEXTURE_2D );
}
}
+ // draw checkerboard for transparent textures
+ if ( g_TextureBrowser_enableAlpha )
+ {
+ glDisable( GL_TEXTURE_2D );
+ glBegin( GL_QUADS );
+ int font_height = TextureBrowser_fontHeight( textureBrowser );
+ for ( int i = 0; i < nHeight; i += 8 )
+ for ( int j = 0; j < nWidth; j += 8 )
+ {
+ unsigned char color = (i + j) / 8 % 2 ? 0x66 : 0x99;
+ glColor3ub( color, color, color );
+ int left = j;
+ int right = std::min(j+8, nWidth);
+ int top = i;
+ int bottom = std::min(i+8, nHeight);
+ glVertex2i(x + right, y - nHeight - font_height + top);
+ glVertex2i(x + left, y - nHeight - font_height + top);
+ glVertex2i(x + left, y - nHeight - font_height + bottom);
+ glVertex2i(x + right, y - nHeight - font_height + bottom);
+ }
+ glEnd();
+ glEnable( GL_TEXTURE_2D );
+ }
+
// Draw the texture
glBindTexture( GL_TEXTURE_2D, q->texture_number );
GlobalOpenGL_debugAssertNoErrors();
gtk_widget_set_sensitive( g_TextureBrowser.m_shader_info_item, FALSE );
}
+ menu_separator( menu );
+ create_check_menu_item_with_mnemonic( menu, "Show Transparency", "EnableAlpha" );
+
return textures_menu_item;
}
TextureBrowser_activeShadersChanged( GlobalTextureBrowser() );
}
+void TextureBrowser_EnableAlpha(){
+ g_TextureBrowser_enableAlpha ^= 1;
+ GlobalTextureBrowser().m_enablealpha_item.update();
+ TextureBrowser_activeShadersChanged( GlobalTextureBrowser() );
+}
+
void TextureBrowser_exportTitle( const StringImportCallback& importer ){
StringOutputStream buffer( 64 );
buffer << "Textures: ";
GlobalToggles_insert( "ToggleShowShaderlistOnly", FreeCaller<TextureBrowser_ToggleShowShaderListOnly>(), ToggleItem::AddCallbackCaller( g_TextureBrowser.m_showshaderlistonly_item ) );
GlobalToggles_insert( "FixedSize", FreeCaller<TextureBrowser_FixedSize>(), ToggleItem::AddCallbackCaller( g_TextureBrowser.m_fixedsize_item ) );
GlobalToggles_insert( "FilterNotex", FreeCaller<TextureBrowser_FilterNotex>(), ToggleItem::AddCallbackCaller( g_TextureBrowser.m_filternotex_item ) );
+ GlobalToggles_insert( "EnableAlpha", FreeCaller<TextureBrowser_EnableAlpha>(), ToggleItem::AddCallbackCaller( g_TextureBrowser.m_enablealpha_item ) );
GlobalPreferenceSystem().registerPreference( "TextureScale",
makeSizeStringImportCallback( TextureBrowserSetScaleCaller( g_TextureBrowser ) ),
GlobalPreferenceSystem().registerPreference( "ShowShaderlistOnly", BoolImportStringCaller( g_TextureBrowser_shaderlistOnly ), BoolExportStringCaller( g_TextureBrowser_shaderlistOnly ) );
GlobalPreferenceSystem().registerPreference( "FixedSize", BoolImportStringCaller( g_TextureBrowser_fixedSize ), BoolExportStringCaller( g_TextureBrowser_fixedSize ) );
GlobalPreferenceSystem().registerPreference( "FilterNotex", BoolImportStringCaller( g_TextureBrowser_filterNotex ), BoolExportStringCaller( g_TextureBrowser_filterNotex ) );
+ GlobalPreferenceSystem().registerPreference( "EnableAlpha", BoolImportStringCaller( g_TextureBrowser_enableAlpha ), BoolExportStringCaller( g_TextureBrowser_enableAlpha ) );
GlobalPreferenceSystem().registerPreference( "LoadShaders", IntImportStringCaller( reinterpret_cast<int&>( GlobalTextureBrowser().m_startupShaders ) ), IntExportStringCaller( reinterpret_cast<int&>( GlobalTextureBrowser().m_startupShaders ) ) );
GlobalPreferenceSystem().registerPreference( "WheelMouseInc", SizeImportStringCaller( GlobalTextureBrowser().m_mouseWheelScrollIncrement ), SizeExportStringCaller( GlobalTextureBrowser().m_mouseWheelScrollIncrement ) );
GlobalPreferenceSystem().registerPreference( "SI_Colors0", Vector3ImportStringCaller( GlobalTextureBrowser().color_textureback ), Vector3ExportStringCaller( GlobalTextureBrowser().color_textureback ) );