Переглянути джерело

force initial antialias state; enable multisample when transparency requires it

David Rose 21 роки тому
батько
коміт
1064603147

+ 11 - 1
panda/src/glstuff/glGraphicsStateGuardian_src.I

@@ -94,7 +94,9 @@ enable_multisample(bool val) {
     if (val) {
       GLP(Enable)(GL_MULTISAMPLE);
     } else {
-      GLP(Disable)(GL_MULTISAMPLE);
+      if (!_multisample_alpha_one_enabled && !_multisample_alpha_mask_enabled) {
+        GLP(Disable)(GL_MULTISAMPLE);
+      }
     }
   }
 }
@@ -262,8 +264,12 @@ enable_multisample_alpha_one(bool val) {
       _multisample_alpha_one_enabled = val;
       if (val) {
         GLP(Enable)(GL_SAMPLE_ALPHA_TO_ONE);
+        GLP(Enable)(GL_MULTISAMPLE);
       } else {
         GLP(Disable)(GL_SAMPLE_ALPHA_TO_ONE);
+        if (!_multisample_enabled) {
+          GLP(Disable)(GL_MULTISAMPLE);
+        }
       }
     }
   }
@@ -280,8 +286,12 @@ enable_multisample_alpha_mask(bool val) {
     _multisample_alpha_mask_enabled = val;
     if (val) {
       GLP(Enable)(GL_SAMPLE_ALPHA_TO_COVERAGE);
+      GLP(Enable)(GL_MULTISAMPLE);
     } else {
       GLP(Disable)(GL_SAMPLE_ALPHA_TO_COVERAGE);
+      if (!_multisample_enabled) {
+        GLP(Disable)(GL_MULTISAMPLE);
+      }
     }
   }
 }

+ 8 - 1
panda/src/glstuff/glGraphicsStateGuardian_src.cxx

@@ -438,8 +438,15 @@ reset() {
     _buffer_mask &= ~RenderBuffer::T_back;
   }
 
-  // Set up the specific state values to GL's known initial values.
+  // Ensure the initial state is what we say it should be (in some
+  // cases, we don't want the GL default settings; in others, we have
+  // to force the point with some drivers that aren't strictly
+  // compliant w.r.t. initial settings).
   GLP(FrontFace)(GL_CCW);
+  GLP(Disable)(GL_MULTISAMPLE);
+  GLP(Disable)(GL_LINE_SMOOTH);
+  GLP(Disable)(GL_POINT_SMOOTH);
+  GLP(Disable)(GL_POLYGON_SMOOTH);
 
   // Set up all the enabled/disabled flags to GL's known initial
   // values: everything off.