com*_*314 6 android surfaceview android-emulator
当运行简单的代码在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) {
}
}
Run Code Online (Sandbox Code Playgroud)
活动:
<?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>
Run Code Online (Sandbox Code Playgroud)
系统信息:
AVD信息:
应用信息:
此外,我可以在没有这些问题的同一个模拟器中运行OpenGL ES 2.0代码.
| 归档时间: |
|
| 查看次数: |
3799 次 |
| 最近记录: |