Java Code Examples for javax.microedition.khronos.opengles.GL11#glLoadMatrixf()

The following examples show how to use javax.microedition.khronos.opengles.GL11#glLoadMatrixf() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GLES11Canvas.java    From PhotoMovie with Apache License 2.0 6 votes vote down vote up
@Override
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++;
}
 
Example 2
Source File: GLES11Canvas.java    From PhotoMovie with Apache License 2.0 6 votes vote down vote up
@Override
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++;
}
 
Example 3
Source File: GLCanvasImpl.java    From document-viewer with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void drawRect(final float x, final float y, final float width, final float height, final Paint paint) {
    final GL11 gl = mGL;

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

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

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

    restoreTransform();
}
 
Example 4
Source File: GLCanvasImpl.java    From document-viewer with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void drawRect(final RectF r, final Paint paint) {
    final GL11 gl = mGL;

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

    saveTransform();
    translate(r.left, r.top);
    scale(r.width(), r.height(), 1);

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

    restoreTransform();
}
 
Example 5
Source File: GLCanvasImpl.java    From document-viewer with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void drawLine(final float x1, final float y1, final float x2, final float y2, final Paint paint) {
    final GL11 gl = mGL;

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

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

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

    restoreTransform();
}
 
Example 6
Source File: GLES11Canvas.java    From PhotoMovie with Apache License 2.0 5 votes vote down vote up
@Override
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++;
}
 
Example 7
Source File: GLES11Canvas.java    From PhotoMovie with Apache License 2.0 5 votes vote down vote up
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++;
}
 
Example 8
Source File: GLCanvasImpl.java    From document-viewer with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void fillRect(final float x, final float y, final float width, final float height, final int color) {
    mGLState.setColorMode(color, mAlpha);
    final GL11 gl = mGL;

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

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

    restoreTransform();
}
 
Example 9
Source File: GLCanvasImpl.java    From document-viewer with GNU General Public License v3.0 5 votes vote down vote up
public void fillRect(final RectF r, final int color) {
    mGLState.setColorMode(color, mAlpha);

    final GL11 gl = mGL;

    saveTransform();
    translate(r.left, r.top);
    scale(r.width(), r.height(), 1);

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

    restoreTransform();
}
 
Example 10
Source File: GLCanvasImpl.java    From document-viewer with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void fillPoly(final int color, final PointF... path) {
    mGLState.setColorMode(color, mAlpha);
    final GL11 gl = mGL;

    final int bytes = 2 * path.length * Float.SIZE;
    final FloatBuffer xyBuffer = allocateDirectNativeOrderBuffer(bytes).asFloatBuffer();
    for (int i = 0; i < path.length; i++) {
        xyBuffer.put(path[i].x / mScreenWidth);
        xyBuffer.put(path[i].y / mScreenHeight);
    }
    xyBuffer.position(0);

    saveTransform();
    translate(0, 0);
    scale(mScreenWidth, mScreenHeight, 1);
    gl.glLoadMatrixf(mMatrixValues, 0);

    final int[] name = new int[1];
    GLId.glGenBuffers(1, name, 0);

    gl.glBindBuffer(GL11.GL_ARRAY_BUFFER, name[0]);
    gl.glBufferData(GL11.GL_ARRAY_BUFFER, bytes, xyBuffer, GL11.GL_DYNAMIC_DRAW);
    gl.glVertexPointer(2, GL10.GL_FLOAT, 0, 0);
    gl.glDrawArrays(GL10.GL_TRIANGLE_FAN, 0, path.length);

    restoreTransform();

    gl.glBindBuffer(GL11.GL_ARRAY_BUFFER, mBoxCoords);
    gl.glVertexPointer(2, GL10.GL_FLOAT, 0, 0);
    gl.glTexCoordPointer(2, GL10.GL_FLOAT, 0, 0);
}
 
Example 11
Source File: GLCanvasImpl.java    From document-viewer with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void drawPoly(final int color, final PointF... path) {
    mGLState.setColorMode(color, mAlpha);
    mGLState.setLineWidth(1.5f);
    final GL11 gl = mGL;

    final int bytes = 2 * path.length * Float.SIZE;
    final FloatBuffer xyBuffer = allocateDirectNativeOrderBuffer(bytes).asFloatBuffer();
    for (int i = 0; i < path.length; i++) {
        xyBuffer.put(path[i].x / mScreenWidth);
        xyBuffer.put(path[i].y / mScreenHeight);
    }
    xyBuffer.position(0);

    saveTransform();
    translate(0, 0);
    scale(mScreenWidth, mScreenHeight, 1);
    gl.glLoadMatrixf(mMatrixValues, 0);

    final int[] name = new int[1];
    GLId.glGenBuffers(1, name, 0);

    gl.glBindBuffer(GL11.GL_ARRAY_BUFFER, name[0]);
    gl.glBufferData(GL11.GL_ARRAY_BUFFER, bytes, xyBuffer, GL11.GL_DYNAMIC_DRAW);
    gl.glVertexPointer(2, GL10.GL_FLOAT, 0, 0);
    gl.glDrawArrays(GL10.GL_LINE_LOOP, 0, path.length);

    restoreTransform();

    gl.glBindBuffer(GL11.GL_ARRAY_BUFFER, mBoxCoords);
    gl.glVertexPointer(2, GL10.GL_FLOAT, 0, 0);
    gl.glTexCoordPointer(2, GL10.GL_FLOAT, 0, 0);
}
 
Example 12
Source File: GLCanvasImpl.java    From document-viewer with GNU General Public License v3.0 5 votes vote down vote up
private void textureRect(final float x, final float y, final float width, final float height) {
    final GL11 gl = mGL;

    saveTransform();
    translate(x, y);
    scale(width, height, 1);
    gl.glColor4f(1, 1, 1, 1);
    gl.glLoadMatrixf(mMatrixValues, 0);
    gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, OFFSET_FILL_RECT, 4);

    restoreTransform();
}