Monday, May 14, 2012

HW accelerated activity - how to get OpenGL texture size limit?


I'm trying to enable hw acceleration in Honeycomb, and display some Bitmaps on Canvas. All works fine, but for large bitmaps (>2048 in one dimension), I get error in log:



OpenGLRenderer: Bitmap too large to be uploaded into a texture



I know this is because of hw limitation, and can work-around it by reducing max bitmap size to be displayed if hw acceleration is enabled (checking by View.isHardwareAccelerated()).



My question is: how to easily determine max texture size available for Bitmap drawing by hardware. 2048 seems to be limit on my device, but it may be different on different ones.



Edit: I'm not creating OpenGL app, just normal app, which can utilize hw acceleration. Thus I'm not familiar with OpenGL at all, I just see OpenGL related error in log, and look to solve it.


Source: Tips4all

3 comments:

  1. Currently the minimum limit is 2048px (i.e. the hardware must support textures at least 2048x2048.) In ICS we will introduce a new API on the Canvas class that will give you this information. I don't remember the exact name I picked but it will be something like Canvas.getMaxBitmapWidth()/getMaxBitmapHeight().

    ReplyDelete
  2. According to the specification, calling glGetIntegerv with GL_MAX_TEXTURE_SIZE.


    GL_MAX_TEXTURE_SIZE params returns one value. The value gives a rough estimate of the largest texture that the GL can handle. The value must be at least 64.


    http://www.khronos.org/opengles/sdk/docs/man/xhtml/glGet.xml

    ReplyDelete
  3. EDIT: Answer removed as community voted it to be wrong

    ReplyDelete