title: LabelMaker throws GL_INVALID_ENUM
body: <p>I have been trying to use the <a href="http://www.linuxtopia.org/online_books/android/devguide/guide/samples/ApiDemos/src/com/example/android/apis/graphics/spritetext/LabelMaker.html" rel="nofollow noreferrer"><code>LabelMaker</code></a> example to display my games FPS on the screen when toggled. When I enable the toggle however my log fills up with this message: (One for every call to draw)</p>
  <p><code>&amp;lt;qglDrvAPI_glTexImage2D:1913&amp;gt;: GL_INVALID_ENUM</code></p>
  <p>Debugging the <code>LabelMaker</code> source I can see that the log message is added when the generated <code>Bitmap</code> is drawn to the OpenGL texture, but I cannot figure out why:</p>
  <pre><code>public void endAdding(GL10 gl) {
      checkState(STATE_ADDING, STATE_INITIALIZED);
      gl.glBindTexture(GL10.GL_TEXTURE_2D, mTextureID);
      GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, mBitmap, 0);  // Problem Line
      // Reclaim storage used by bitmap and canvas.
      mBitmap.recycle();
      mBitmap = null;
      mCanvas = null;
  }
  </code></pre>
  <p>My calling code in <code>onDrawFrame</code>:</p>
  <pre><code>if(renderFPS){
          Paint textPaint = new Paint();
          textPaint.setTextSize(32);
          textPaint.setAntiAlias(true);
  
          textPaint.setARGB(0xff, 0x00, 0x00, 0x00);
          
          this.labelMaker.beginAdding(gl);
          int fpsLabel =  this.labelMaker.add(gl, Double.toString(currentFPS), textPaint);
          this.labelMaker.endAdding(gl);
          
          this.labelMaker.beginDrawing(gl, this.mViewWidth, this.mViewHeight);
          this.labelMaker.draw(gl, 10, 10, fpsLabel);
          this.labelMaker.endDrawing(gl);
      }
  </code></pre>
  <p><strong>EDIT:</strong></p>
  <p>I've added a call to write the Bitmap to the SD card to verify that the Bitmap is valid and it works. I've also noticed it seems it does not cause the problem on the first call, instead it then gives continues and reports an error when the texture is drawn:</p>
  <pre><code>public void draw(GL10 gl, float x, float y, int labelID) {
      checkState(STATE_DRAWING, STATE_DRAWING);
      Label label = mLabels.get(labelID);
      gl.glEnable(GL10.GL_TEXTURE_2D);
      ((GL11)gl).glTexParameteriv(GL10.GL_TEXTURE_2D,
              GL11Ext.GL_TEXTURE_CROP_RECT_OES, label.mCrop, 0);
      ((GL11Ext)gl).glDrawTexiOES((int) x, (int) y, 0,  // Where the problem starts.
              (int) label.width, (int) label.height);
  }
  </code></pre>
  <p>That it when it starts to give an error on the <code>texImage2D</code> call.</p>
  <p><strong>EDIT 2:</strong>
  I realized I made a silly mistake and put my call to clear the color and depth buffers after this call. Which was causing the screen to be cleared after the texture is rendered. So the code is actually functioning, but it is also throwing this log message. Still no ideas why?</p>