2 Copyright (C) 1999-2006 Id Software, Inc. and contributors.
3 For a list of contributors, see the accompanying CONTRIBUTORS file.
5 This file is part of GtkRadiant.
7 GtkRadiant is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 GtkRadiant is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GtkRadiant; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 #include <util/buffer.h>
25 #include "debugging/debugging.h"
28 #include "itextures.h"
30 #include "preferencesystem.h"
33 #include "texturelib.h"
34 #include "container/hashfunc.h"
35 #include "container/cache.h"
36 #include "generic/callback.h"
41 #include "preferences.h"
47 eTextures_NEAREST = 0,
48 eTextures_NEAREST_MIPMAP_NEAREST = 1,
49 eTextures_NEAREST_MIPMAP_LINEAR = 2,
51 eTextures_LINEAR_MIPMAP_NEAREST = 4,
52 eTextures_LINEAR_MIPMAP_LINEAR = 5,
53 eTextures_MAX_ANISOTROPY = 6,
56 enum TextureCompressionFormat
58 TEXTURECOMPRESSION_NONE = 0,
59 TEXTURECOMPRESSION_RGBA = 1,
60 TEXTURECOMPRESSION_RGBA_S3TC_DXT1 = 2,
61 TEXTURECOMPRESSION_RGBA_S3TC_DXT3 = 3,
62 TEXTURECOMPRESSION_RGBA_S3TC_DXT5 = 4,
65 struct texture_globals_t
68 // texture compression format
69 TextureCompressionFormat m_nTextureCompressionFormat;
73 bool bTextureCompressionSupported; // is texture compression supported by hardware?
74 GLint texture_components;
76 // temporary values that should be initialised only once at run-time
77 bool m_bOpenGLCompressionSupported;
78 bool m_bS3CompressionSupported;
80 texture_globals_t( GLint components ) :
81 m_nTextureCompressionFormat( TEXTURECOMPRESSION_NONE ),
83 bTextureCompressionSupported( false ),
84 texture_components( components ),
85 m_bOpenGLCompressionSupported( false ),
86 m_bS3CompressionSupported( false ){
90 texture_globals_t g_texture_globals( GL_RGBA );
92 void SetTexParameters( ETexturesMode mode ){
93 float maxAniso = QGL_maxTextureAnisotropy();
95 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 1.0f );
98 if ( mode == eTextures_MAX_ANISOTROPY ) {
99 mode = eTextures_LINEAR_MIPMAP_LINEAR;
104 case eTextures_NEAREST:
105 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
106 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
108 case eTextures_NEAREST_MIPMAP_NEAREST:
109 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST );
110 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
112 case eTextures_NEAREST_MIPMAP_LINEAR:
113 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_LINEAR );
114 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
116 case eTextures_LINEAR:
117 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
118 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
120 case eTextures_LINEAR_MIPMAP_NEAREST:
121 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST );
122 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
124 case eTextures_LINEAR_MIPMAP_LINEAR:
125 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR );
126 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
128 case eTextures_MAX_ANISOTROPY:
129 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, maxAniso );
132 globalOutputStream() << "invalid texture mode\n";
136 ETexturesMode g_texture_mode = eTextures_LINEAR_MIPMAP_LINEAR;
141 u::BufferVal<256> g_gammatable;
142 void ResampleGamma( float fGamma ){
144 if ( fGamma == 1.0 ) {
145 for ( i = 0; i < 256; i++ )
150 for ( i = 0; i < 256; i++ )
152 inf = (int)( 255 * pow( static_cast<double>( ( i + 0.5 ) / 255.5 ), static_cast<double>( fGamma ) ) + 0.5 );
159 g_gammatable[i] = inf;
164 inline const int& min_int( const int& left, const int& right ){
165 return std::min( left, right );
168 int max_tex_size = 0;
169 const int max_texture_quality = 3;
170 LatchedInt g_Textures_textureQuality( 3, "Texture Quality" );
172 /// \brief This function does the actual processing of raw RGBA data into a GL texture.
173 /// It will also resample to power-of-two dimensions, generate the mipmaps and adjust gamma.
174 void LoadTextureRGBA( qtexture_t* q, unsigned char* pPixels, int nWidth, int nHeight ){
175 static float fGamma = -1;
178 int nCount = nWidth * nHeight;
180 if ( fGamma != g_texture_globals.fGamma ) {
181 fGamma = g_texture_globals.fGamma;
182 ResampleGamma( fGamma );
188 total[0] = total[1] = total[2] = 0.0f;
190 // resample texture gamma according to user settings
191 for ( int i = 0; i < ( nCount * 4 ); i += 4 )
193 for ( int j = 0; j < 3; j++ )
195 total[j] += ( pPixels + i )[j];
196 byte b = ( pPixels + i )[j];
197 ( pPixels + i )[j] = g_gammatable[b];
201 q->color[0] = total[0] / ( nCount * 255 );
202 q->color[1] = total[1] / ( nCount * 255 );
203 q->color[2] = total[2] / ( nCount * 255 );
205 glGenTextures( 1, &q->texture_number );
207 glBindTexture( GL_TEXTURE_2D, q->texture_number );
209 SetTexParameters( g_texture_mode );
212 while ( gl_width < nWidth )
216 while ( gl_height < nHeight )
219 bool resampled = false;
220 if ( !( gl_width == nWidth && gl_height == nHeight ) ) {
222 outpixels = (byte *)malloc( gl_width * gl_height * 4 );
223 R_ResampleTexture( pPixels, nWidth, nHeight, outpixels, gl_width, gl_height, 4 );
230 int quality_reduction = max_texture_quality - g_Textures_textureQuality.m_value;
231 int target_width = min_int( gl_width >> quality_reduction, max_tex_size );
232 int target_height = min_int( gl_height >> quality_reduction, max_tex_size );
234 while ( gl_width > target_width || gl_height > target_height )
236 GL_MipReduce( outpixels, outpixels, gl_width, gl_height, target_width, target_height );
238 if ( gl_width > target_width ) {
241 if ( gl_height > target_height ) {
247 glTexImage2D( GL_TEXTURE_2D, mip++, g_texture_globals.texture_components, gl_width, gl_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, outpixels );
248 while ( gl_width > 1 || gl_height > 1 )
250 GL_MipReduce( outpixels, outpixels, gl_width, gl_height, 1, 1 );
252 if ( gl_width > 1 ) {
255 if ( gl_height > 1 ) {
259 glTexImage2D( GL_TEXTURE_2D, mip++, g_texture_globals.texture_components, gl_width, gl_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, outpixels );
262 glBindTexture( GL_TEXTURE_2D, 0 );
274 void Texture_InitPalette( byte *pal ){
278 auto gammatable = u::buffer<256>();
281 gamma = g_texture_globals.fGamma;
283 if ( gamma == 1.0 ) {
284 for ( i = 0 ; i < 256 ; i++ )
289 for ( i = 0 ; i < 256 ; i++ )
291 inf = (int)( 255 * pow( ( i + 0.5 ) / 255.5, gamma ) + 0.5 );
302 for ( i = 0 ; i < 256 ; i++ )
304 r = gammatable[pal[0]];
305 g = gammatable[pal[1]];
306 b = gammatable[pal[2]];
309 //v = (r<<24) + (g<<16) + (b<<8) + 255;
312 //tex_palette[i] = v;
313 tex_palette[i * 3 + 0] = r;
314 tex_palette[i * 3 + 1] = g;
315 tex_palette[i * 3 + 2] = b;
325 HashTable<CopiedString, CopiedString, HashStringNoCase, StringEqualNoCase> strings;
326 strings["Monkey"] = "bleh";
327 strings["MonkeY"] = "blah";
331 const TestHashtable g_testhashtable;
335 typedef std::pair<LoadImageCallback, CopiedString> TextureKey;
337 void qtexture_realise( qtexture_t& texture, const TextureKey& key ){
338 texture.texture_number = 0;
339 if ( !string_empty( key.second.c_str() ) ) {
340 Image* image = key.first.loadImage( key.second.c_str() );
342 LoadTextureRGBA( &texture, image->getRGBAPixels(), image->getWidth(), image->getHeight() );
343 texture.surfaceFlags = image->getSurfaceFlags();
344 texture.contentFlags = image->getContentFlags();
345 texture.value = image->getValue();
347 globalOutputStream() << "Loaded Texture: \"" << key.second.c_str() << "\"\n";
348 GlobalOpenGL_debugAssertNoErrors();
352 globalErrorStream() << "Texture load failed: \"" << key.second.c_str() << "\"\n";
357 void qtexture_unrealise( qtexture_t& texture ){
358 if ( GlobalOpenGL().contextValid && texture.texture_number != 0 ) {
359 glDeleteTextures( 1, &texture.texture_number );
360 GlobalOpenGL_debugAssertNoErrors();
364 class TextureKeyEqualNoCase
367 bool operator()( const TextureKey& key, const TextureKey& other ) const {
368 return key.first == other.first && string_equal_nocase( key.second.c_str(), other.second.c_str() );
372 class TextureKeyHashNoCase
375 typedef hash_t hash_type;
376 hash_t operator()( const TextureKey& key ) const {
377 return hash_combine( string_hash_nocase( key.second.c_str() ), pod_hash( key.first ) );
381 #define DEBUG_TEXTURES 0
383 class TexturesMap : public TexturesCache
385 class TextureConstructor
387 TexturesMap* m_cache;
389 explicit TextureConstructor( TexturesMap* cache )
392 qtexture_t* construct( const TextureKey& key ){
393 qtexture_t* texture = new qtexture_t( key.first, key.second.c_str() );
394 if ( m_cache->realised() ) {
395 qtexture_realise( *texture, key );
399 void destroy( qtexture_t* texture ){
400 if ( m_cache->realised() ) {
401 qtexture_unrealise( *texture );
407 typedef HashedCache<TextureKey, qtexture_t, TextureKeyHashNoCase, TextureKeyEqualNoCase, TextureConstructor> qtextures_t;
408 qtextures_t m_qtextures;
409 TexturesCacheObserver* m_observer;
410 std::size_t m_unrealised;
413 virtual ~TexturesMap() = default;
414 TexturesMap() : m_qtextures( TextureConstructor( this ) ), m_observer( 0 ), m_unrealised( 1 ){
416 typedef qtextures_t::iterator iterator;
419 return m_qtextures.begin();
422 return m_qtextures.end();
425 LoadImageCallback defaultLoader() const {
426 return LoadImageCallback( 0, QERApp_LoadImage );
428 Image* loadImage( const char* name ){
429 return defaultLoader().loadImage( name );
431 qtexture_t* capture( const char* name ){
432 return capture( defaultLoader(), name );
434 qtexture_t* capture( const LoadImageCallback& loader, const char* name ){
436 globalOutputStream() << "textures capture: " << makeQuoted( name ) << '\n';
438 return m_qtextures.capture( TextureKey( loader, name ) ).get();
440 void release( qtexture_t* texture ){
442 globalOutputStream() << "textures release: " << makeQuoted( texture->name ) << '\n';
444 m_qtextures.release( TextureKey( texture->load, texture->name ) );
446 void attach( TexturesCacheObserver& observer ){
447 ASSERT_MESSAGE( m_observer == 0, "TexturesMap::attach: cannot attach observer" );
448 m_observer = &observer;
450 void detach( TexturesCacheObserver& observer ){
451 ASSERT_MESSAGE( m_observer == &observer, "TexturesMap::detach: cannot detach observer" );
455 if ( --m_unrealised == 0 ) {
456 g_texture_globals.bTextureCompressionSupported = false;
458 if ( GlobalOpenGL().ARB_texture_compression() ) {
459 g_texture_globals.bTextureCompressionSupported = true;
460 g_texture_globals.m_bOpenGLCompressionSupported = true;
463 if ( GlobalOpenGL().EXT_texture_compression_s3tc() ) {
464 g_texture_globals.bTextureCompressionSupported = true;
465 g_texture_globals.m_bS3CompressionSupported = true;
468 switch ( g_texture_globals.texture_components )
472 case GL_COMPRESSED_RGBA_ARB:
473 if ( !g_texture_globals.m_bOpenGLCompressionSupported ) {
474 globalOutputStream() << "OpenGL extension GL_ARB_texture_compression not supported by current graphics drivers\n";
475 g_texture_globals.m_nTextureCompressionFormat = TEXTURECOMPRESSION_NONE;
476 g_texture_globals.texture_components = GL_RGBA;
479 case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
480 case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
481 case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
482 if ( !g_texture_globals.m_bS3CompressionSupported ) {
483 globalOutputStream() << "OpenGL extension GL_EXT_texture_compression_s3tc not supported by current graphics drivers\n";
484 if ( g_texture_globals.m_bOpenGLCompressionSupported ) {
485 g_texture_globals.m_nTextureCompressionFormat = TEXTURECOMPRESSION_RGBA;
486 g_texture_globals.texture_components = GL_COMPRESSED_RGBA_ARB;
490 g_texture_globals.m_nTextureCompressionFormat = TEXTURECOMPRESSION_NONE;
491 g_texture_globals.texture_components = GL_RGBA;
496 globalOutputStream() << "Unknown texture compression selected, reverting\n";
497 g_texture_globals.m_nTextureCompressionFormat = TEXTURECOMPRESSION_NONE;
498 g_texture_globals.texture_components = GL_RGBA;
503 glGetIntegerv( GL_MAX_TEXTURE_SIZE, &max_tex_size );
504 if ( max_tex_size == 0 ) {
508 for ( qtextures_t::iterator i = m_qtextures.begin(); i != m_qtextures.end(); ++i )
510 if ( !( *i ).value.empty() ) {
511 qtexture_realise( *( *i ).value, ( *i ).key );
514 if ( m_observer != 0 ) {
515 m_observer->realise();
520 if ( ++m_unrealised == 1 ) {
521 if ( m_observer != 0 ) {
522 m_observer->unrealise();
524 for ( qtextures_t::iterator i = m_qtextures.begin(); i != m_qtextures.end(); ++i )
526 if ( !( *i ).value.empty() ) {
527 qtexture_unrealise( *( *i ).value );
533 return m_unrealised == 0;
537 TexturesMap* g_texturesmap;
539 TexturesCache& GetTexturesCache(){
540 return *g_texturesmap;
544 void Textures_Realise(){
545 g_texturesmap->realise();
548 void Textures_Unrealise(){
549 g_texturesmap->unrealise();
553 Callback g_texturesModeChangedNotify;
555 void Textures_setModeChangedNotify( const Callback& notify ){
556 g_texturesModeChangedNotify = notify;
559 void Textures_ModeChanged(){
560 if ( g_texturesmap->realised() ) {
561 SetTexParameters( g_texture_mode );
563 for ( TexturesMap::iterator i = g_texturesmap->begin(); i != g_texturesmap->end(); ++i )
565 glBindTexture( GL_TEXTURE_2D, ( *i ).value->texture_number );
566 SetTexParameters( g_texture_mode );
569 glBindTexture( GL_TEXTURE_2D, 0 );
571 g_texturesModeChangedNotify();
574 void Textures_SetMode( ETexturesMode mode ){
575 if ( g_texture_mode != mode ) {
576 g_texture_mode = mode;
578 Textures_ModeChanged();
582 void Textures_setTextureComponents( GLint texture_components ){
583 if ( g_texture_globals.texture_components != texture_components ) {
584 Textures_Unrealise();
585 g_texture_globals.texture_components = texture_components;
590 void Textures_UpdateTextureCompressionFormat(){
591 GLint texture_components = GL_RGBA;
593 switch ( g_texture_globals.m_nTextureCompressionFormat )
595 case ( TEXTURECOMPRESSION_NONE ):
597 texture_components = GL_RGBA;
600 case ( TEXTURECOMPRESSION_RGBA ):
602 texture_components = GL_COMPRESSED_RGBA_ARB;
605 case ( TEXTURECOMPRESSION_RGBA_S3TC_DXT1 ):
607 texture_components = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT;
610 case ( TEXTURECOMPRESSION_RGBA_S3TC_DXT3 ):
612 texture_components = GL_COMPRESSED_RGBA_S3TC_DXT3_EXT;
615 case ( TEXTURECOMPRESSION_RGBA_S3TC_DXT5 ):
617 texture_components = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT;
622 Textures_setTextureComponents( texture_components );
625 void TextureCompressionImport( TextureCompressionFormat& self, int value ){
626 if ( !g_texture_globals.m_bOpenGLCompressionSupported
627 && g_texture_globals.m_bS3CompressionSupported
634 self = TEXTURECOMPRESSION_NONE;
637 self = TEXTURECOMPRESSION_RGBA;
640 self = TEXTURECOMPRESSION_RGBA_S3TC_DXT1;
643 self = TEXTURECOMPRESSION_RGBA_S3TC_DXT3;
646 self = TEXTURECOMPRESSION_RGBA_S3TC_DXT5;
649 Textures_UpdateTextureCompressionFormat();
651 typedef ReferenceCaller1<TextureCompressionFormat, int, TextureCompressionImport> TextureCompressionImportCaller;
653 void TextureGammaImport( float& self, float value ){
654 if ( self != value ) {
655 Textures_Unrealise();
660 typedef ReferenceCaller1<float, float, TextureGammaImport> TextureGammaImportCaller;
662 void TextureModeImport( ETexturesMode& self, int value ){
666 Textures_SetMode( eTextures_NEAREST );
669 Textures_SetMode( eTextures_NEAREST_MIPMAP_NEAREST );
672 Textures_SetMode( eTextures_LINEAR );
675 Textures_SetMode( eTextures_NEAREST_MIPMAP_LINEAR );
678 Textures_SetMode( eTextures_LINEAR_MIPMAP_NEAREST );
681 Textures_SetMode( eTextures_LINEAR_MIPMAP_LINEAR );
684 Textures_SetMode( eTextures_MAX_ANISOTROPY );
687 typedef ReferenceCaller1<ETexturesMode, int, TextureModeImport> TextureModeImportCaller;
689 void TextureModeExport( ETexturesMode& self, const IntImportCallback& importer ){
692 case eTextures_NEAREST:
695 case eTextures_NEAREST_MIPMAP_NEAREST:
698 case eTextures_LINEAR:
701 case eTextures_NEAREST_MIPMAP_LINEAR:
704 case eTextures_LINEAR_MIPMAP_NEAREST:
707 case eTextures_LINEAR_MIPMAP_LINEAR:
710 case eTextures_MAX_ANISOTROPY:
717 typedef ReferenceCaller1<ETexturesMode, const IntImportCallback&, TextureModeExport> TextureModeExportCaller;
719 void Textures_constructPreferences( PreferencesPage& page ){
721 const char* percentages[] = { "12.5%", "25%", "50%", "100%", };
724 STRING_ARRAY_RANGE( percentages ),
725 LatchedIntImportCaller( g_Textures_textureQuality ),
726 IntExportCaller( g_Textures_textureQuality.m_latched )
734 FloatImportCallback( TextureGammaImportCaller( g_texture_globals.fGamma ) ),
735 FloatExportCallback( FloatExportCaller( g_texture_globals.fGamma ) )
738 const char* texture_mode[] = { "Nearest", "Nearest Mipmap", "Linear", "Bilinear", "Bilinear Mipmap", "Trilinear", "Anisotropy" };
740 "Texture Render Mode",
741 STRING_ARRAY_RANGE( texture_mode ),
742 IntImportCallback( TextureModeImportCaller( g_texture_mode ) ),
743 IntExportCallback( TextureModeExportCaller( g_texture_mode ) )
747 const char* compression_none[] = { "None" };
748 const char* compression_opengl[] = { "None", "OpenGL ARB" };
749 const char* compression_s3tc[] = { "None", "S3TC DXT1", "S3TC DXT3", "S3TC DXT5" };
750 const char* compression_opengl_s3tc[] = { "None", "OpenGL ARB", "S3TC DXT1", "S3TC DXT3", "S3TC DXT5" };
751 StringArrayRange compression(
752 ( g_texture_globals.m_bOpenGLCompressionSupported )
753 ? ( g_texture_globals.m_bS3CompressionSupported )
754 ? STRING_ARRAY_RANGE( compression_opengl_s3tc )
755 : STRING_ARRAY_RANGE( compression_opengl )
756 : ( g_texture_globals.m_bS3CompressionSupported )
757 ? STRING_ARRAY_RANGE( compression_s3tc )
758 : STRING_ARRAY_RANGE( compression_none )
761 "Hardware Texture Compression",
763 TextureCompressionImportCaller( g_texture_globals.m_nTextureCompressionFormat ),
764 IntExportCaller( reinterpret_cast<int&>( g_texture_globals.m_nTextureCompressionFormat ) )
768 void Textures_constructPage( PreferenceGroup& group ){
769 PreferencesPage page( group.createPage( "Textures", "Texture Settings" ) );
770 Textures_constructPreferences( page );
772 void Textures_registerPreferencesPage(){
773 PreferencesDialog_addDisplayPage( FreeCaller1<PreferenceGroup&, Textures_constructPage>() );
776 void TextureCompression_importString( const char* string ){
777 g_texture_globals.m_nTextureCompressionFormat = static_cast<TextureCompressionFormat>( atoi( string ) );
778 Textures_UpdateTextureCompressionFormat();
780 typedef FreeCaller1<const char*, TextureCompression_importString> TextureCompressionImportStringCaller;
783 void Textures_Construct(){
784 g_texturesmap = new TexturesMap;
786 GlobalPreferenceSystem().registerPreference( "TextureCompressionFormat", TextureCompressionImportStringCaller(), IntExportStringCaller( reinterpret_cast<int&>( g_texture_globals.m_nTextureCompressionFormat ) ) );
787 GlobalPreferenceSystem().registerPreference( "TextureFiltering", IntImportStringCaller( reinterpret_cast<int&>( g_texture_mode ) ), IntExportStringCaller( reinterpret_cast<int&>( g_texture_mode ) ) );
788 GlobalPreferenceSystem().registerPreference( "TextureQuality", IntImportStringCaller( g_Textures_textureQuality.m_latched ), IntExportStringCaller( g_Textures_textureQuality.m_latched ) );
789 GlobalPreferenceSystem().registerPreference( "SI_Gamma", FloatImportStringCaller( g_texture_globals.fGamma ), FloatExportStringCaller( g_texture_globals.fGamma ) );
791 g_Textures_textureQuality.useLatched();
793 Textures_registerPreferencesPage();
795 Textures_ModeChanged();
797 void Textures_Destroy(){
798 delete g_texturesmap;
802 #include "modulesystem/modulesmap.h"
803 #include "modulesystem/singletonmodule.h"
804 #include "modulesystem/moduleregistry.h"
806 class TexturesDependencies :
807 public GlobalRadiantModuleRef,
808 public GlobalOpenGLModuleRef,
809 public GlobalPreferenceSystemModuleRef
811 ImageModulesRef m_image_modules;
813 TexturesDependencies() :
814 m_image_modules( GlobalRadiant().getRequiredGameDescriptionKeyValue( "texturetypes" ) ){
816 ImageModules& getImageModules(){
817 return m_image_modules.get();
823 TexturesCache* m_textures;
825 typedef TexturesCache Type;
826 STRING_CONSTANT( Name, "*" );
829 Textures_Construct();
831 m_textures = &GetTexturesCache();
836 TexturesCache* getTable(){
841 typedef SingletonModule<TexturesAPI, TexturesDependencies> TexturesModule;
842 typedef Static<TexturesModule> StaticTexturesModule;
843 StaticRegisterModule staticRegisterTextures( StaticTexturesModule::instance() );
845 ImageModules& Textures_getImageModules(){
846 return StaticTexturesModule::instance().getDependencies().getImageModules();