]> git.mxchange.org Git - simgear.git/commitdiff
Add bool and int uniform types for shaders, and vertex-program-two-sided
authorTim Moore <timoore33@gmail.com>
Tue, 15 Jun 2010 16:56:51 +0000 (18:56 +0200)
committerTim Moore <timoore33@gmail.com>
Tue, 15 Jun 2010 17:05:18 +0000 (19:05 +0200)
vertex-program-two-sided is an extra parameter written by the code
that creates effects from state sets generated by the ac3d loader. The
objective of this work is to support a workaround for broken
gl_FrontFacing on some Macintosh machines.

simgear/scene/material/Effect.cxx

index 33ceacdae2c94b4eba791b02c226f98ce1564ac3..b4c010f497b66d1b5265f2c9e944714a7de7aece 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2008 - 2009  Tim Moore timoore@redhat.com
+// Copyright (C) 2008 - 2010  Tim Moore timoore33@gmail.com
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Library General Public
@@ -868,6 +868,8 @@ InstallAttributeBuilder<ShaderProgramBuilder> installShaderProgram("program");
 
 EffectNameValue<Uniform::Type> uniformTypesInit[] =
 {
+    {"bool", Uniform::BOOL},
+    {"int", Uniform::INT},
     {"float", Uniform::FLOAT},
     {"float-vec3", Uniform::FLOAT_VEC3},
     {"float-vec4", Uniform::FLOAT_VEC4},
@@ -906,6 +908,12 @@ struct UniformBuilder :public PassAttributeBuilder
         if (!typeProp) {
             props::Type propType = valProp->getType();
             switch (propType) {
+            case props::BOOL:
+                uniformType = Uniform::BOOL;
+                break;
+            case props::INT:
+                uniformType = Uniform::INT;
+                break;
             case props::FLOAT:
             case props::DOUBLE:
                 break;          // default float type;
@@ -1181,6 +1189,9 @@ bool makeParametersFromStateSet(SGPropertyNode* effectRoot, const StateSet* ss)
         }
     }
     makeChild(paramRoot, "cull-face")->setStringValue(cullFaceString);
+    // Macintosh ATI workaround
+    bool vertexTwoSide = cullFaceString == "off";
+    makeChild(paramRoot, "vertex-program-two-side")->setValue(vertexTwoSide);
     const BlendFunc* blendFunc = getStateAttribute<BlendFunc>(ss);
     SGPropertyNode* blendNode = makeChild(paramRoot, "blend");
     if (blendFunc) {