Browse Source

Added a clipplane hardware check since not all android devices support 4

Tim Newell 12 years ago
parent
commit
ce46f2ac88
1 changed files with 24 additions and 8 deletions
  1. 24 8
      engine/source/2d/sceneobject/Scroller.cc

+ 24 - 8
engine/source/2d/sceneobject/Scroller.cc

@@ -321,14 +321,27 @@ void Scroller::sceneRender( const SceneRenderState* pSceneRenderState, const Sce
     GLdouble right[4] = {-1, 0, 0, renderOOBB1.x};
     GLdouble top[4] = {0, -1, 0, renderOOBB3.y};
     GLdouble bottom[4] = {0, 1, 0, -renderOOBB0.y};
+
+    //This is to prevent some android devices from throwing opengl errors. For instance the tegra 3 only supports 1
+    int maxClip = 4;
+    glGetIntegerv(GL_MAX_CLIP_PLANES, &maxClip);
+
     glClipPlane(GL_CLIP_PLANE0, left);
-    glClipPlane(GL_CLIP_PLANE1, right);
-    glClipPlane(GL_CLIP_PLANE2, top);
+
+    if (maxClip > 1)
+    	glClipPlane(GL_CLIP_PLANE1, right);
+    if (maxClip > 2)
+    	glClipPlane(GL_CLIP_PLANE2, top);
+    if (maxClip > 3)
     glClipPlane(GL_CLIP_PLANE3, bottom);
+
     glEnable(GL_CLIP_PLANE0);
-    glEnable(GL_CLIP_PLANE1);
-    glEnable(GL_CLIP_PLANE2);
-    glEnable(GL_CLIP_PLANE3);
+    if (maxClip > 1)
+    	glEnable(GL_CLIP_PLANE1);
+    if (maxClip > 2)
+    	glEnable(GL_CLIP_PLANE2);
+    if (maxClip > 3)
+    	glEnable(GL_CLIP_PLANE3);
 
     // Render repeat Y.
     for ( S32 repeatIndexY = 0; repeatIndexY < wholeRegionY; ++repeatIndexY )
@@ -374,9 +387,12 @@ void Scroller::sceneRender( const SceneRenderState* pSceneRenderState, const Sce
 
     // Disable the OOBB clip-planes.
     glDisable(GL_CLIP_PLANE0);
-    glDisable(GL_CLIP_PLANE1);
-    glDisable(GL_CLIP_PLANE2);
-    glDisable(GL_CLIP_PLANE3);
+    if (maxClip > 1)
+    	glDisable(GL_CLIP_PLANE1);
+    if (maxClip > 2)
+    	glDisable(GL_CLIP_PLANE2);
+    if (maxClip > 3)
+    	glDisable(GL_CLIP_PLANE3);
 }
 
 //------------------------------------------------------------------------------