@@ -619,91 +619,22 @@ static rserr_t GLimp_SetMode( int mode, bool fullscreen, bool noborder )
619
619
stencilBits = r_stencilbits->integer ;
620
620
samples = r_ext_multisample->integer ;
621
621
622
- for ( i = 0 ; i < 16 ; i++ )
622
+ for ( i = 0 ; i < 4 ; i++ )
623
623
{
624
- int testColorBits, testDepthBits, testStencilBits ;
624
+ int testColorBits, testCore ;
625
625
626
- // 0 - default
627
- // 1 - minus colorbits
628
- // 2 - minus depthbits
629
- // 3 - minus stencil
630
- if ( ( i % 4 ) == 0 && i )
631
- {
632
- // one pass, reduce
633
- switch ( i / 4 )
634
- {
635
- case 2 :
636
- if ( colorBits == 24 )
637
- {
638
- colorBits = 16 ;
639
- }
640
-
641
- break ;
642
-
643
- case 1 :
644
- if ( depthBits == 24 )
645
- {
646
- depthBits = 16 ;
647
- }
648
- else if ( depthBits == 16 )
649
- {
650
- depthBits = 8 ;
651
- }
652
-
653
- case 3 :
654
- if ( stencilBits == 24 )
655
- {
656
- stencilBits = 16 ;
657
- }
658
- else if ( stencilBits == 16 )
659
- {
660
- stencilBits = 8 ;
661
- }
662
- }
663
- }
626
+ // 0 - 24 bit color, core
627
+ // 1 - 24 bit color, compat
628
+ // 2 - 16 bit color, core
629
+ // 3 - 16 bit color, compat
630
+ testColorBits = (i >= 2 ) ? 16 : 24 ;
631
+ testCore = ((i & 1 ) == 0 );
664
632
665
- testColorBits = colorBits;
666
- testDepthBits = depthBits;
667
- testStencilBits = stencilBits;
668
-
669
- if ( ( i % 4 ) == 3 )
670
- {
671
- // reduce colorbits
672
- if ( testColorBits == 24 )
673
- {
674
- testColorBits = 16 ;
675
- }
676
- }
677
-
678
- if ( ( i % 4 ) == 2 )
679
- {
680
- // reduce depthbits
681
- if ( testDepthBits == 24 )
682
- {
683
- testDepthBits = 16 ;
684
- }
685
- else if ( testDepthBits == 16 )
686
- {
687
- testDepthBits = 8 ;
688
- }
689
- }
633
+ if ( testCore && !r_glCoreProfile->integer )
634
+ continue ;
690
635
691
- if ( ( i % 4 ) == 1 )
692
- {
693
- // reduce stencilbits
694
- if ( testStencilBits == 24 )
695
- {
696
- testStencilBits = 16 ;
697
- }
698
- else if ( testStencilBits == 16 )
699
- {
700
- testStencilBits = 8 ;
701
- }
702
- else
703
- {
704
- testStencilBits = 0 ;
705
- }
706
- }
636
+ if ( testColorBits > colorBits )
637
+ continue ;
707
638
708
639
if ( testColorBits == 24 )
709
640
{
@@ -717,27 +648,27 @@ static rserr_t GLimp_SetMode( int mode, bool fullscreen, bool noborder )
717
648
SDL_GL_SetAttribute ( SDL_GL_RED_SIZE, perChannelColorBits );
718
649
SDL_GL_SetAttribute ( SDL_GL_GREEN_SIZE, perChannelColorBits );
719
650
SDL_GL_SetAttribute ( SDL_GL_BLUE_SIZE, perChannelColorBits );
720
- SDL_GL_SetAttribute ( SDL_GL_ALPHA_SIZE, alphaBits );
721
- SDL_GL_SetAttribute ( SDL_GL_DEPTH_SIZE, testDepthBits );
722
- SDL_GL_SetAttribute ( SDL_GL_STENCIL_SIZE, testStencilBits );
723
- SDL_GL_SetAttribute ( SDL_GL_MULTISAMPLEBUFFERS, samples ? 1 : 0 );
724
- SDL_GL_SetAttribute ( SDL_GL_MULTISAMPLESAMPLES, samples );
725
651
SDL_GL_SetAttribute ( SDL_GL_DOUBLEBUFFER, 1 );
726
652
727
653
if ( !r_glAllowSoftware->integer )
728
654
{
729
655
SDL_GL_SetAttribute ( SDL_GL_ACCELERATED_VISUAL, 1 );
730
656
}
731
657
732
- if ( r_glCoreProfile-> integer || r_glDebugProfile->integer )
658
+ if ( testCore || r_glDebugProfile->integer )
733
659
{
734
660
int major = r_glMajorVersion->integer ;
735
661
int minor = r_glMinorVersion->integer ;
736
662
663
+ if ( testCore && (major < 3 || (major == 3 && minor < 2 )) ) {
664
+ major = 3 ;
665
+ minor = 2 ;
666
+ }
667
+
737
668
SDL_GL_SetAttribute ( SDL_GL_CONTEXT_MAJOR_VERSION, major );
738
669
SDL_GL_SetAttribute ( SDL_GL_CONTEXT_MINOR_VERSION, minor );
739
670
740
- if ( r_glCoreProfile-> integer )
671
+ if ( testCore )
741
672
{
742
673
SDL_GL_SetAttribute ( SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE );
743
674
}
@@ -771,8 +702,9 @@ static rserr_t GLimp_SetMode( int mode, bool fullscreen, bool noborder )
771
702
SDL_GL_SetSwapInterval ( r_swapInterval->integer );
772
703
773
704
glConfig.colorBits = testColorBits;
774
- glConfig.depthBits = testDepthBits;
775
- glConfig.stencilBits = testStencilBits;
705
+ glConfig.depthBits = depthBits;
706
+ glConfig.stencilBits = stencilBits;
707
+ glConfig2.glCoreProfile = testCore;
776
708
777
709
Log::Notice (" Using %d Color bits, %d depth, %d stencil display." ,
778
710
glConfig.colorBits , glConfig.depthBits , glConfig.stencilBits );
0 commit comments