Ejemplo n.º 1
0
  public void drawMesh(
      BasicTexture tex, int x, int y, int xyBuffer, int uvBuffer, int indexBuffer, int indexCount) {
    float alpha = mAlpha;
    if (!bindTexture(tex)) return;

    mGLState.setBlendEnabled(mBlendEnabled && (!tex.isOpaque() || alpha < OPAQUE_ALPHA));
    mGLState.setTextureAlpha(alpha);

    // Reset the texture matrix. We will set our own texture coordinates
    // below.
    setTextureCoords(0, 0, 1, 1);

    saveTransform();
    translate(x, y);

    mGL.glLoadMatrixf(mMatrixValues, 0);

    mGL.glBindBuffer(GL11.GL_ARRAY_BUFFER, xyBuffer);
    mGL.glVertexPointer(2, GL11.GL_FLOAT, 0, 0);

    mGL.glBindBuffer(GL11.GL_ARRAY_BUFFER, uvBuffer);
    mGL.glTexCoordPointer(2, GL11.GL_FLOAT, 0, 0);

    mGL.glBindBuffer(GL11.GL_ELEMENT_ARRAY_BUFFER, indexBuffer);
    mGL.glDrawElements(GL11.GL_TRIANGLE_STRIP, indexCount, GL11.GL_UNSIGNED_BYTE, 0);

    mGL.glBindBuffer(GL11.GL_ARRAY_BUFFER, mBoxCoords);
    mGL.glVertexPointer(2, GL11.GL_FLOAT, 0, 0);
    mGL.glTexCoordPointer(2, GL11.GL_FLOAT, 0, 0);

    restoreTransform();
    mCountDrawMesh++;
  }
Ejemplo n.º 2
0
 private void setTextureCoords(float left, float top, float right, float bottom) {
   mGL.glMatrixMode(GL11.GL_TEXTURE);
   mTextureMatrixValues[0] = right - left;
   mTextureMatrixValues[5] = bottom - top;
   mTextureMatrixValues[10] = 1;
   mTextureMatrixValues[12] = left;
   mTextureMatrixValues[13] = top;
   mTextureMatrixValues[15] = 1;
   mGL.glLoadMatrixf(mTextureMatrixValues, 0);
   mGL.glMatrixMode(GL11.GL_MODELVIEW);
 }
Ejemplo n.º 3
0
  private void textureRect(float x, float y, float width, float height) {
    GL11 gl = mGL;

    saveTransform();
    translate(x, y);
    scale(width, height, 1);

    gl.glLoadMatrixf(mMatrixValues, 0);
    gl.glDrawArrays(GL11.GL_TRIANGLE_STRIP, OFFSET_FILL_RECT, 4);

    restoreTransform();
    mCountTextureRect++;
  }
Ejemplo n.º 4
0
  public void fillRect(float x, float y, float width, float height, int color) {
    mGLState.setColorMode(color, mAlpha);
    GL11 gl = mGL;

    saveTransform();
    translate(x, y);
    scale(width, height, 1);

    gl.glLoadMatrixf(mMatrixValues, 0);
    gl.glDrawArrays(GL11.GL_TRIANGLE_STRIP, OFFSET_FILL_RECT, 4);

    restoreTransform();
    mCountFillRect++;
  }
Ejemplo n.º 5
0
  public void drawLine(float x1, float y1, float x2, float y2, GLPaint paint) {
    GL11 gl = mGL;

    mGLState.setColorMode(paint.getColor(), mAlpha);
    mGLState.setLineWidth(paint.getLineWidth());

    saveTransform();
    translate(x1, y1);
    scale(x2 - x1, y2 - y1, 1);

    gl.glLoadMatrixf(mMatrixValues, 0);
    gl.glDrawArrays(GL11.GL_LINE_STRIP, OFFSET_DRAW_LINE, 2);

    restoreTransform();
    mCountDrawLine++;
  }
Ejemplo n.º 6
0
  public void drawRect(float x, float y, float width, float height, GLPaint paint) {
    GL11 gl = mGL;

    mGLState.setColorMode(paint.getColor(), mAlpha);
    mGLState.setLineWidth(paint.getLineWidth());

    saveTransform();
    translate(x, y);
    scale(width, height, 1);

    gl.glLoadMatrixf(mMatrixValues, 0);
    gl.glDrawArrays(GL11.GL_LINE_LOOP, OFFSET_DRAW_RECT, 4);

    restoreTransform();
    mCountDrawLine++;
  }
Ejemplo n.º 7
0
 private void setTextureCoords(float[] mTextureTransform) {
   mGL.glMatrixMode(GL11.GL_TEXTURE);
   mGL.glLoadMatrixf(mTextureTransform, 0);
   mGL.glMatrixMode(GL11.GL_MODELVIEW);
 }