簡體   English   中英

Android SurfaceView模擬器OpenGL錯誤

[英]Android SurfaceView Emulator OpenGL Errors

當運行簡單的代碼在SurfaceView中繪制時,我在Android模擬器中遇到了幾個OpenGL錯誤。 因此,在模擬器中運行時,SurfaceView不會繪制。 相同的代碼在設備上正確運行(在本例中為Amazon Fire HD 8(2017 - KFDOWI))。

以下是錯誤:

模擬器:android / android-emugl / host / libs / Translator / GLES_V2 / GLESv2Imp.cpp:glReadPixels:2827錯誤0x502

模擬器:sPrepareTexImage2D:3087驗證失敗

模擬器:android / android-emugl / host / libs / Translator / GLES_V2 / GLESv2Imp.cpp:glTexImage2D:3133錯誤0x500

模擬器:sPrepareTexImage2D:3087驗證失敗

模擬器:android / android-emugl / host / libs / Translator / GLES_V2 / GLESv2Imp.cpp:glTexImage2D:3133錯誤0x500

模擬器:android / android-emugl / host / libs / Translator / GLES_V2 / GLESv2Imp.cpp:glTexSubImage2D:3237錯誤0x500

這是代碼:

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.util.AttributeSet;
import android.view.SurfaceHolder;
import android.view.SurfaceView;

public class CustomSurfaceView extends SurfaceView implements SurfaceHolder.Callback  {

    private SurfaceHolder surfaceHolder;

    public CustomSurfaceView(Context context) {
        super(context);
        init();
    }

        public CustomSurfaceView(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
        init();
    }

    private void init() {
        this.surfaceHolder = getHolder();
        surfaceHolder.addCallback(this);
    }

    @Override
    public void surfaceCreated(SurfaceHolder surfaceHolder) {
        Canvas canvas = surfaceHolder.lockCanvas();
        canvas.drawColor(Color.RED);
        surfaceHolder.unlockCanvasAndPost(canvas);
    }

    @Override
    public void surfaceChanged(SurfaceHolder surfaceHolder, int i, int i1, int i2) {
    }

    @Override
    public void surfaceDestroyed(SurfaceHolder surfaceHolder) {
    }
}

活動:

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="MainActivity">

    <CustomSurfaceView
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

</android.support.constraint.ConstraintLayout>

系統信息:

  • MacOS High Sierra 10.13.2
  • 16 GB RAM
  • Android Studio 3.0.1
  • JRE 1.8.0_152
  • HAXM 6.2.1

AVD信息:

  • API 25
  • 圖形:自動
  • 內存:1536 MB

應用信息:

  • API 26
  • 最低SDK:19

此外,我可以在沒有這些問題的同一個模擬器中運行OpenGL ES 2.0代碼。

禁用硬件加速。

[打開虛擬設備配置 - >編輯虛擬設備 - >使用軟件模式圖形]

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM