@@ -313,6 +313,9 @@ GRAPHICS OPTIONS MENU
313313#define ID_NETWORK 109
314314#define ID_RATIO 110
315315
316+ #define ID_ANISOTROPY 111
317+ #define ID_MSAA 112
318+
316319typedef struct {
317320 menuframework_s menu ;
318321
@@ -341,6 +344,8 @@ typedef struct {
341344 menulist_s colordepth ;
342345 menulist_s geometry ;
343346 menulist_s filter ;
347+ menulist_s anisotropy ;
348+ menulist_s msaa ;
344349 menutext_s driverinfo ;
345350
346351// STONELANCE
@@ -361,6 +366,8 @@ typedef struct
361366 int texturebits ;
362367 int geometry ;
363368 int filter ;
369+ int anisotropy ;
370+ int msaa ;
364371 int driver ;
365372 qboolean extensions ;
366373} InitialVideoOptions_s ;
@@ -371,22 +378,22 @@ static graphicsoptions_t s_graphicsoptions;
371378static InitialVideoOptions_s s_ivo_templates [] =
372379{
373380 {
374- 6 , qtrue , 3 , 0 , 2 , 2 , 2 , 1 , 0 , qtrue
381+ 6 , qtrue , 3 , 0 , 2 , 2 , 2 , 1 , 0 , 0 , 0 , qtrue
375382 },
376383 {
377- 4 , qtrue , 2 , 0 , 2 , 2 , 1 , 1 , 0 , qtrue // JDC: this was tq 3
384+ 4 , qtrue , 2 , 0 , 2 , 2 , 1 , 1 , 0 , 0 , 0 , qtrue // JDC: this was tq 3
378385 },
379386 {
380- 3 , qtrue , 2 , 0 , 0 , 0 , 1 , 0 , 0 , qtrue
387+ 3 , qtrue , 2 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , qtrue
381388 },
382389 {
383- 2 , qtrue , 1 , 0 , 1 , 0 , 0 , 0 , 0 , qtrue
390+ 2 , qtrue , 1 , 0 , 1 , 0 , 0 , 0 , 0 , 0 , 0 , qtrue
384391 },
385392 {
386- 2 , qtrue , 1 , 1 , 1 , 0 , 0 , 0 , 0 , qtrue
393+ 2 , qtrue , 1 , 1 , 1 , 0 , 0 , 0 , 0 , 0 , 0 , qtrue
387394 },
388395 {
389- 3 , qtrue , 1 , 0 , 0 , 0 , 1 , 0 , 0 , qtrue
396+ 3 , qtrue , 1 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , qtrue
390397 }
391398};
392399
@@ -550,6 +557,8 @@ static void GraphicsOptions_GetInitialVideo( void )
550557 s_ivo .lighting = s_graphicsoptions .lighting .curvalue ;
551558 s_ivo .geometry = s_graphicsoptions .geometry .curvalue ;
552559 s_ivo .filter = s_graphicsoptions .filter .curvalue ;
560+ s_ivo .anisotropy = s_graphicsoptions .anisotropy .curvalue ;
561+ s_ivo .msaa = s_graphicsoptions .msaa .curvalue ;
553562 s_ivo .texturebits = s_graphicsoptions .texturebits .curvalue ;
554563}
555564
@@ -624,6 +633,10 @@ static void GraphicsOptions_CheckConfig( void )
624633 continue ;
625634 if ( s_ivo_templates [i ].filter != s_graphicsoptions .filter .curvalue )
626635 continue ;
636+ if ( s_ivo_templates [i ].anisotropy != s_graphicsoptions .anisotropy .curvalue )
637+ continue ;
638+ if ( s_ivo_templates [i ].msaa != s_graphicsoptions .msaa .curvalue )
639+ continue ;
627640// if ( s_ivo_templates[i].texturebits != s_graphicsoptions.texturebits.curvalue )
628641// continue;
629642 s_graphicsoptions .list .curvalue = i ;
@@ -668,6 +681,15 @@ static void GraphicsOptions_UpdateMenuItems( void )
668681 {
669682 s_graphicsoptions .texturebits .curvalue = 1 ;
670683 }
684+ s_graphicsoptions .anisotropy .curvalue = 0 ;
685+ s_graphicsoptions .msaa .curvalue = 0 ;
686+ s_graphicsoptions .anisotropy .generic .flags |= QMF_GRAYED ;
687+ s_graphicsoptions .msaa .generic .flags |= QMF_GRAYED ;
688+ }
689+ else
690+ {
691+ s_graphicsoptions .anisotropy .generic .flags &= ~QMF_GRAYED ;
692+ s_graphicsoptions .msaa .generic .flags &= ~QMF_GRAYED ;
671693 }
672694
673695 s_graphicsoptions .apply .generic .flags |= QMF_HIDDEN |QMF_INACTIVE ;
@@ -712,6 +734,14 @@ static void GraphicsOptions_UpdateMenuItems( void )
712734 {
713735 s_graphicsoptions .apply .generic .flags &= ~(QMF_HIDDEN |QMF_INACTIVE );
714736 }
737+ if ( s_ivo .anisotropy != s_graphicsoptions .anisotropy .curvalue )
738+ {
739+ s_graphicsoptions .apply .generic .flags &= ~(QMF_HIDDEN |QMF_INACTIVE );
740+ }
741+ if ( s_ivo .msaa != s_graphicsoptions .msaa .curvalue )
742+ {
743+ s_graphicsoptions .apply .generic .flags &= ~(QMF_HIDDEN |QMF_INACTIVE );
744+ }
715745
716746 GraphicsOptions_CheckConfig ();
717747}
@@ -812,6 +842,37 @@ static void GraphicsOptions_ApplyChanges( void *unused, int notification )
812842 trap_Cvar_Set ( "r_textureMode" , "GL_LINEAR_MIPMAP_NEAREST" );
813843 }
814844
845+ if ( s_graphicsoptions .anisotropy .curvalue == 0 )
846+ {
847+ trap_Cvar_SetValue ( "r_ext_texture_filter_anisotropic" , 0 );
848+ trap_Cvar_SetValue ( "r_ext_max_anisotropy" , 1 );
849+ }
850+ else
851+ {
852+ static const int anisoValues [] = { 2 , 4 , 8 , 16 };
853+ int anisoIndex = s_graphicsoptions .anisotropy .curvalue - 1 ;
854+ if ( anisoIndex < 0 )
855+ anisoIndex = 0 ;
856+ if ( anisoIndex > 3 )
857+ anisoIndex = 3 ;
858+ trap_Cvar_SetValue ( "r_ext_texture_filter_anisotropic" , 1 );
859+ trap_Cvar_SetValue ( "r_ext_max_anisotropy" , anisoValues [anisoIndex ] );
860+ }
861+
862+ {
863+ static const int msaaValues [] = { 0 , 2 , 4 };
864+ int msaaIndex = s_graphicsoptions .msaa .curvalue ;
865+ if ( msaaIndex < 0 )
866+ msaaIndex = 0 ;
867+ if ( msaaIndex > 2 )
868+ msaaIndex = 2 ;
869+ trap_Cvar_SetValue ( "r_ext_multisample" , msaaValues [msaaIndex ] );
870+ if ( !Q_stricmp ( UI_Cvar_VariableString ( "cl_renderer" ), "opengl2" ) )
871+ {
872+ trap_Cvar_SetValue ( "r_ext_framebuffer_multisample" , msaaValues [msaaIndex ] );
873+ }
874+ }
875+
815876 trap_Cmd_ExecuteText ( EXEC_APPEND , "vid_restart\n" );
816877}
817878
@@ -858,6 +919,8 @@ static void GraphicsOptions_Event( void* ptr, int event ) {
858919 s_graphicsoptions .texturebits .curvalue = ivo -> texturebits ;
859920 s_graphicsoptions .geometry .curvalue = ivo -> geometry ;
860921 s_graphicsoptions .filter .curvalue = ivo -> filter ;
922+ s_graphicsoptions .anisotropy .curvalue = ivo -> anisotropy ;
923+ s_graphicsoptions .msaa .curvalue = ivo -> msaa ;
861924 s_graphicsoptions .fs .curvalue = ivo -> fullscreen ;
862925 break ;
863926
@@ -991,6 +1054,35 @@ static void GraphicsOptions_SetMenuItems( void )
9911054 s_graphicsoptions .filter .curvalue = 1 ;
9921055 }
9931056
1057+ if ( trap_Cvar_VariableValue ( "r_ext_texture_filter_anisotropic" ) <= 0 )
1058+ {
1059+ s_graphicsoptions .anisotropy .curvalue = 0 ;
1060+ }
1061+ else
1062+ {
1063+ int aniso = (int )trap_Cvar_VariableValue ( "r_ext_max_anisotropy" );
1064+ if ( aniso >= 16 )
1065+ s_graphicsoptions .anisotropy .curvalue = 4 ;
1066+ else if ( aniso >= 8 )
1067+ s_graphicsoptions .anisotropy .curvalue = 3 ;
1068+ else if ( aniso >= 4 )
1069+ s_graphicsoptions .anisotropy .curvalue = 2 ;
1070+ else if ( aniso >= 2 )
1071+ s_graphicsoptions .anisotropy .curvalue = 1 ;
1072+ else
1073+ s_graphicsoptions .anisotropy .curvalue = 0 ;
1074+ }
1075+
1076+ {
1077+ int msaa = (int )trap_Cvar_VariableValue ( "r_ext_multisample" );
1078+ if ( msaa >= 4 )
1079+ s_graphicsoptions .msaa .curvalue = 2 ;
1080+ else if ( msaa >= 2 )
1081+ s_graphicsoptions .msaa .curvalue = 1 ;
1082+ else
1083+ s_graphicsoptions .msaa .curvalue = 0 ;
1084+ }
1085+
9941086 if ( trap_Cvar_VariableValue ( "r_lodBias" ) > 0 )
9951087 {
9961088 if ( trap_Cvar_VariableValue ( "r_subdivisions" ) >= 20 )
@@ -1085,6 +1177,24 @@ void GraphicsOptions_MenuInit( void )
10851177 "Trilinear" ,
10861178 NULL
10871179 };
1180+
1181+ static const char * anisotropy_names [] =
1182+ {
1183+ "Off" ,
1184+ "2x" ,
1185+ "4x" ,
1186+ "8x" ,
1187+ "16x" ,
1188+ NULL
1189+ };
1190+
1191+ static const char * msaa_names [] =
1192+ {
1193+ "Off" ,
1194+ "2x" ,
1195+ "4x" ,
1196+ NULL
1197+ };
10881198 static const char * quality_names [] =
10891199 {
10901200 "Low" ,
@@ -1305,7 +1415,29 @@ void GraphicsOptions_MenuInit( void )
13051415 s_graphicsoptions .filter .generic .x = 400 ;
13061416 s_graphicsoptions .filter .generic .y = y ;
13071417 s_graphicsoptions .filter .itemnames = filter_names ;
1308- y += 2 * BIGCHAR_HEIGHT ;
1418+ y += BIGCHAR_HEIGHT + 2 ;
1419+
1420+ s_graphicsoptions .anisotropy .generic .type = MTYPE_SPINCONTROL ;
1421+ s_graphicsoptions .anisotropy .generic .name = "Anisotropic:" ;
1422+ s_graphicsoptions .anisotropy .generic .flags = QMF_PULSEIFFOCUS |QMF_SMALLFONT ;
1423+ s_graphicsoptions .anisotropy .generic .x = 400 ;
1424+ s_graphicsoptions .anisotropy .generic .y = y ;
1425+ s_graphicsoptions .anisotropy .generic .id = ID_ANISOTROPY ;
1426+ s_graphicsoptions .anisotropy .generic .callback = GraphicsOptions_Event ;
1427+ s_graphicsoptions .anisotropy .itemnames = anisotropy_names ;
1428+ y += BIGCHAR_HEIGHT + 2 ;
1429+
1430+ s_graphicsoptions .msaa .generic .type = MTYPE_SPINCONTROL ;
1431+ s_graphicsoptions .msaa .generic .name = "MSAA:" ;
1432+ s_graphicsoptions .msaa .generic .flags = QMF_PULSEIFFOCUS |QMF_SMALLFONT ;
1433+ s_graphicsoptions .msaa .generic .x = 400 ;
1434+ s_graphicsoptions .msaa .generic .y = y ;
1435+ s_graphicsoptions .msaa .generic .id = ID_MSAA ;
1436+ s_graphicsoptions .msaa .generic .callback = GraphicsOptions_Event ;
1437+ s_graphicsoptions .msaa .itemnames = msaa_names ;
1438+ y += BIGCHAR_HEIGHT + 2 ;
1439+
1440+ y += BIGCHAR_HEIGHT + 8 ;
13091441
13101442 s_graphicsoptions .driverinfo .generic .type = MTYPE_PTEXT ;
13111443 s_graphicsoptions .driverinfo .generic .flags = QMF_CENTER_JUSTIFY |QMF_PULSEIFFOCUS ;
@@ -1389,6 +1521,8 @@ void GraphicsOptions_MenuInit( void )
13891521 Menu_AddItem ( & s_graphicsoptions .menu , ( void * ) & s_graphicsoptions .tq );
13901522 Menu_AddItem ( & s_graphicsoptions .menu , ( void * ) & s_graphicsoptions .texturebits );
13911523 Menu_AddItem ( & s_graphicsoptions .menu , ( void * ) & s_graphicsoptions .filter );
1524+ Menu_AddItem ( & s_graphicsoptions .menu , ( void * ) & s_graphicsoptions .anisotropy );
1525+ Menu_AddItem ( & s_graphicsoptions .menu , ( void * ) & s_graphicsoptions .msaa );
13921526 Menu_AddItem ( & s_graphicsoptions .menu , ( void * ) & s_graphicsoptions .driverinfo );
13931527
13941528 Menu_AddItem ( & s_graphicsoptions .menu , ( void * ) & s_graphicsoptions .back );
@@ -1439,4 +1573,3 @@ void UI_GraphicsOptionsMenu( void ) {
14391573 Menu_SetCursorToItem ( & s_graphicsoptions .menu , & s_graphicsoptions .graphics );
14401574}
14411575
1442-
0 commit comments