Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draw bitmap on frame (GLES) #97

Open
anonym24 opened this issue Jul 18, 2018 · 3 comments
Open

Draw bitmap on frame (GLES) #97

anonym24 opened this issue Jul 18, 2018 · 3 comments

Comments

@anonym24
Copy link

anonym24 commented Jul 18, 2018

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
Copy link

crearo commented Jul 18, 2018

Have a look here.

@anonym24
Copy link
Author

@crearo I tried next #74 (comment)

but it didn't work

@anonym24
Copy link
Author

@crearo do you know what could be a problem?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants