private void drawBoundTexture(BasicTexture texture, int x, int y, int width, int height) {
   // Test whether it has been rotated or flipped, if so, glDrawTexiOES
   // won't work
   if (isMatrixRotatedOrFlipped(mMatrixValues)) {
     if (texture.hasBorder()) {
       setTextureCoords(
           1.0f / texture.getTextureWidth(),
           1.0f / texture.getTextureHeight(),
           (texture.getWidth() - 1.0f) / texture.getTextureWidth(),
           (texture.getHeight() - 1.0f) / texture.getTextureHeight());
     } else {
       setTextureCoords(
           0,
           0,
           (float) texture.getWidth() / texture.getTextureWidth(),
           (float) texture.getHeight() / texture.getTextureHeight());
     }
     textureRect(x, y, width, height);
   } else {
     // draw the rect from bottom-left to top-right
     float points[] = mapPoints(mMatrixValues, x, y + height, x + width, y);
     x = (int) (points[0] + 0.5f);
     y = (int) (points[1] + 0.5f);
     width = (int) (points[2] + 0.5f) - x;
     height = (int) (points[3] + 0.5f) - y;
     if (width > 0 && height > 0) {
       ((GL11Ext) mGL).glDrawTexiOES(x, y, 0, width, height);
       mCountTextureOES++;
     }
   }
 }
Beispiel #2
0
  public void drawTexture(BasicTexture texture, int x, int y, int width, int height, float alpha) {

    if (!mTexture2DEnabled) {
      mGL.glEnable(GL11.GL_TEXTURE_2D);
      mTexture2DEnabled = true;
    }

    if (!texture.bind(this, mGL)) {
      throw new RuntimeException("cannot bind" + texture.toString());
    }
    if (width <= 0 || height <= 0) return;

    Matrix matrix = mTransformation.getMatrix();
    matrix.getValues(mMatrixValues);

    // Test whether it has been rotated or flipped, if so, glDrawTexiOES
    // won't work
    if (isMatrixRotatedOrFlipped(mMatrixValues)) {
      putRectangle(
          0,
          0,
          (texture.mWidth - 0.5f) / texture.mTextureWidth,
          (texture.mHeight - 0.5f) / texture.mTextureHeight,
          mUvBuffer,
          mUvPointer);
      setAlphaValue(alpha);
      drawRect(x, y, width, height, mMatrixValues);
    } else {
      // draw the rect from bottom-left to top-right
      float points[] = mapPoints(matrix, x, y + height, x + width, y);
      x = (int) points[0];
      y = (int) points[1];
      width = (int) points[2] - x;
      height = (int) points[3] - y;
      if (width > 0 && height > 0) {
        setAlphaValue(alpha);
        ((GL11Ext) mGL).glDrawTexiOES(x, y, 0, width, height);
      }
    }
  }