title: OpenGL Texture Size Limits. Providing alternate resources for specific Android devices
body: <p>Within my Android App, which is an OpenGL ES 2.0 game, I've included 4 sets of graphic resources like so</p>
  
  <ul>
  <li>ldpi</li>
  <li>mdpi</li>
  <li>hdpi</li>
  <li>xhdpi</li>
  </ul>
  
  <p>Now, within my <strong>xhdpi</strong> folder, the largest asset I have is 2560 x 1838 as I'm targeting large screens here (for example the Google Nexus 10 tablet which gets its resources from the XHDPI folder).  Up until now, everything has worked on the devices on which I've tested (Google Nexus 10, Samsung Galaxy S3, S4 &amp; S5, Nexus 4 &amp; 5 etc etc....)</p>
  
  <p>I've recently heard from a user who has encountered problems running this on an HTC One X+ handset (I believe there are other reasons for this besides the one I'm talking about here so I have a separate question open for the other issues).</p>
  
  <p>The thing is, according to: <a href="http://gfxbench.com/device.jsp?benchmark=gfx30&amp;os=Android&amp;api=gl&amp;D=HTC%20One%20X%2B%20%28Endeavor%20C2%2C%20Evitare%20UL%2C%20EVARE_UL%20-%20Tegra%203%29&amp;testgroup=info" rel="nofollow">this</a>, the maximum texture size for the this phone is 2048x2048, but then according to <a href="http://blog.blundell-apps.com/list-of-android-devices-with-pixel-density-buckets/" rel="nofollow">this</a> this phone gets its resources from the XHDPI folder.</p>
  
  <p>So, it won't display the textures from this atlas (it's an atlas of backgrounds containing 6 separate backgrounds of 1280*612.</p>
  
  <p>Now I have two options that I am aware of to fix this:</p>
  
  <ul>
  <li><p>Reduce the size of the backgrounds.  <strong>Ruled out as this would compromise quality on larger-screen devices (like the nexus 10)</strong></p></li>
  <li><p>Split into 2 atlases <strong>would rather not do this as would like to keep all backgrounds in 1 atlas to optimise loading speed (and just to keep things tidy)</strong> </p></li>
  </ul>
  
  <p>Are there any other options?  Am I able to provide, within a sub folder of <strong>xhdpi</strong> another folder that fits within the 1X+'s limits?  And if so, how do I get the device to grab resources from there?</p>
  
  <p>I'm doing this blind as I don't have an 1X+ on which to test this, but from what I've read, I believe having assets larger than 2048 x 2048 is going to cause problems on this device.</p>
  
  <p>This is my code for applying textures:</p>
  
  <pre><code>public static int LoadTexture(GLSurfaceView view, Bitmap imgTex){
  
      //Array for texture
      int textures[] = new int[1];
      try {
          //texture name
          GLES20.glGenTextures(1, textures, 0);
          //Bind textures
          GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, textures[0]);
          //Set parameters for texture
          GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR);
          GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR);
  
          //Apply texture
          GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, imgTex, 0);
  
          //clamp texture
          GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_T,GLES20.GL_CLAMP_TO_EDGE);
          GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_S,GLES20.GL_CLAMP_TO_EDGE);
  
      } catch (Exception e){
  
      }
      //Increase texture count
      textureCount++;
      //Return texture
      return textures[0];
  }
  </code></pre>