Browse Source

Define MOBILE_GRAPHICS or DESKTOP_GRAPHICS in GraphicsDefs.h based on the platform. Avoid GetPlatform() and string compare in Technique.

Lasse Öörni 11 years ago
parent
commit
7e350343d5
2 changed files with 13 additions and 11 deletions
  1. 8 0
      Source/Urho3D/Graphics/GraphicsDefs.h
  2. 5 11
      Source/Urho3D/Graphics/Technique.cpp

+ 8 - 0
Source/Urho3D/Graphics/GraphicsDefs.h

@@ -30,6 +30,14 @@ namespace Urho3D
 
 
 class Vector3;
 class Vector3;
 
 
+/// Graphics capability support level. Emscripten also uses OpenGL ES but will have higher capability than actual mobiles,
+/// so it is not included
+#if defined(ANDROID) || defined(IOS) || defined(RPI)
+#define MOBILE_GRAPHICS
+#else
+#define DESKTOP_GRAPHICS
+#endif
+
 /// Primitive type.
 /// Primitive type.
 enum PrimitiveType
 enum PrimitiveType
 {
 {

+ 5 - 11
Source/Urho3D/Graphics/Technique.cpp

@@ -69,9 +69,6 @@ static const char* lightingModeNames[] =
     0
     0
 };
 };
 
 
-static bool desktopSupportChecked = false;
-static bool desktopSupportResult = false;
-
 Pass::Pass(StringHash type) :
 Pass::Pass(StringHash type) :
     type_(type),
     type_(type),
     blendMode_(BLEND_REPLACE),
     blendMode_(BLEND_REPLACE),
@@ -173,14 +170,11 @@ Technique::Technique(Context* context) :
     Graphics* graphics = GetSubsystem<Graphics>();
     Graphics* graphics = GetSubsystem<Graphics>();
     sm3Support_ = graphics ? graphics->GetSM3Support() : true;
     sm3Support_ = graphics ? graphics->GetSM3Support() : true;
     
     
-    if (!desktopSupportChecked)
-    {
-        String platformString = GetPlatform();
-        desktopSupportResult = (platformString == "Windows" || platformString == "Mac OS X" || platformString == "Linux");
-        desktopSupportChecked = true;
-    }
-    
-    desktopSupport_ = desktopSupportResult;
+    #ifdef DESKTOP_GRAPHICS
+    desktopSupport_ = true;
+    #else
+    desktopSupport_ = false;
+    #endif
 }
 }
 
 
 Technique::~Technique()
 Technique::~Technique()