google/grafika

Draw bitmap on frame (GLES)

anonym24 opened this issue · 3 comments

I don't really know how to work with GLES yet

But I downloaded Grafika project https://github.com/google/grafika and tried some samples

I've added some code to onDrawFrame (GLSurfaceView) method of CameraCaptureActivity.java https://github.com/google/grafika/blob/master/app/src/main/java/com/android/grafika/CameraCaptureActivity.java#L678

It's supposed to draw bitmap but nothing changes on the frame

public void onDrawFrame(GL10 gl) {
    
    ...

    Bitmap bitmap = Bitmap.createBitmap(256, 256, Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(bitmap);
    bitmap.eraseColor(0);

    Paint paint = new Paint();
    paint.setTextSize(18);
    paint.setAntiAlias(true);
    paint.setARGB(0xff, 0xff, 0xff, 0xff);
    paint.setTextAlign(Paint.Align.LEFT);
    paint.setTextScaleX(0.5f);
    canvas.drawText("TEST TEXT", 0, 0, paint);

    GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, bitmap, 0);

    bitmap.recycle();
}

their drawBox function works fine:

GLES20.glEnable(GLES20.GL_SCISSOR_TEST);
GLES20.glScissor(0, 0, 100, 100);
GLES20.glClearColor(1.0f, 0.0f, 0.0f, 1.0f);
GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT);
GLES20.glDisable(GLES20.GL_SCISSOR_TEST);

it draws small rectangle at left bottom corner

So how can I create bitmap, edit it (Canvas) and then convert to GL texture and draw on frame?

@crearo I tried next #74 (comment)

but it didn't work

@crearo do you know what could be a problem?