android opengl: createWindowSurface returned EGL_BAD_NATIVE_WINDOW.
2013-06-13 19:14
609 查看
我擦了,这个问题真是个老大难。
我使用的设备是一个三星的pad,2.2系统,型号忘了,反正是之前很流行的一个设备。
尼玛系统文档说好了2.2是支持opengl的呀,肿么就创建window失败呢,百思不得其解啊
折腾了两天呀,最后终于被我发现了苗头了。
我的代码这么写的(代码编译不过了,有些东西被我删了,您就别copy了)
public class MyGLSurface extends GLSurfaceView
{
private TCGLRender mMyGLRender;
public MyGLSurface(Context context, AttributeSet attrs) {
super(context, attrs);
if (getGLVersion(context) == 2) {
mIsSupportGLV2 = true;
}
if (mIsSupportGLV2) {
this.setEGLContextClientVersion(2);
}
mMyGLRender = new TCGLRender(mIsSupportGLV2, mBufFreeSem);
mMyGLRender.setContext(context);
this.setRenderer(mMyGLRender);
this.setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);
}
public void onPause() {
super.onPause();
}
public void onResume() {
super.onResume();
}
public void DrawFrame(byte[] ydatas, byte[] udatas, byte[] vdatas,
int width, int height, int dstWidth, int dstHeight, float degree,
boolean isFull)
{
mMyGLRender.CopyFrame2Render(ydatas, udatas, vdatas, width, height, dstWidth, dstHeight, degree, isFull);
this.requestRender();
}
static public int getGLVersion(Context context) {
ActivityManager am = (ActivityManager) context
.getSystemService(Context.ACTIVITY_SERVICE);
ConfigurationInfo info = am.getDeviceConfigurationInfo();
return (info.reqGlEsVersion >= 0x00020000) ? 2 : 1;
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
{
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
this.setMeasuredDimension(widthMeasureSpec, heightMeasureSpec);
}
}
看到没有,红色的部分就是特么的罪魁祸首了,我揣测2.2系统里面GLSurfaceView里面没有这个方法,所以一直override之后就有问题了
把他删掉就OK了
类似的,可能类似的问题也呼导致这个 EGL_BAD_NATIVE_WINDOW的错误,大家出现的时候可以关注一下
OK,打完收工
我使用的设备是一个三星的pad,2.2系统,型号忘了,反正是之前很流行的一个设备。
尼玛系统文档说好了2.2是支持opengl的呀,肿么就创建window失败呢,百思不得其解啊
折腾了两天呀,最后终于被我发现了苗头了。
我的代码这么写的(代码编译不过了,有些东西被我删了,您就别copy了)
public class MyGLSurface extends GLSurfaceView
{
private TCGLRender mMyGLRender;
public MyGLSurface(Context context, AttributeSet attrs) {
super(context, attrs);
if (getGLVersion(context) == 2) {
mIsSupportGLV2 = true;
}
if (mIsSupportGLV2) {
this.setEGLContextClientVersion(2);
}
mMyGLRender = new TCGLRender(mIsSupportGLV2, mBufFreeSem);
mMyGLRender.setContext(context);
this.setRenderer(mMyGLRender);
this.setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);
}
public void onPause() {
super.onPause();
}
public void onResume() {
super.onResume();
}
public void DrawFrame(byte[] ydatas, byte[] udatas, byte[] vdatas,
int width, int height, int dstWidth, int dstHeight, float degree,
boolean isFull)
{
mMyGLRender.CopyFrame2Render(ydatas, udatas, vdatas, width, height, dstWidth, dstHeight, degree, isFull);
this.requestRender();
}
static public int getGLVersion(Context context) {
ActivityManager am = (ActivityManager) context
.getSystemService(Context.ACTIVITY_SERVICE);
ConfigurationInfo info = am.getDeviceConfigurationInfo();
return (info.reqGlEsVersion >= 0x00020000) ? 2 : 1;
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
{
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
this.setMeasuredDimension(widthMeasureSpec, heightMeasureSpec);
}
}
看到没有,红色的部分就是特么的罪魁祸首了,我揣测2.2系统里面GLSurfaceView里面没有这个方法,所以一直override之后就有问题了
把他删掉就OK了
类似的,可能类似的问题也呼导致这个 EGL_BAD_NATIVE_WINDOW的错误,大家出现的时候可以关注一下
OK,打完收工
相关文章推荐
- Android createWindowSurface failed EGL_BAD_ALLOC 引起Crash的解决方案
- 获取GPU信息 --createWindowSurface EGL_BAD_NATIVE_WINDOW -- failed: EGL_BAD_MATCH
- Android createWindowSurface failed EGL_BAD_ALLOC 引起Crash的解决方案
- Android中native_handle private_handle_t ANativeWindowBuffer ANativeWindow GraphicBuffer Surface的关系
- Android中native_handle private_handle_t ANativeWindowBuffer ANativeWindow GraphicBuffer Surface的关系
- Android中native_handle private_handle_t ANativeWindowBuffer ANativeWindow GraphicBuffer Surface的关系
- 部分Android手机使用OpenGL创建eglCreateWindowSurface失败
- Android中*_handle_t/ANativeWindowBuffer/ANativeWindow/GraphicBuffer/Surface的关系
- Android使用ANativeWindow_fromSurface返回空
- Android中native_handle private_handle_t ANativeWindowBuffer ANativeWindow GraphicBuffer Surface的关系
- fatal error: android/native_window.h: No such file or directory
- at android.view.Surface.unlockCanvasAndPost(Native Method)
- android.view.WindowManager$BadTokenException: Unable to add window — token null
- 解决: android.view.WindowManager BadTokenException:Unable to add Window.Is your activity running?
- android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an appli
- android.view.WindowManager$BadTokenException: Unable to add window — token null
- android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an appli
- android opengl es Must use a native order direct Buffer问题
- 错误:Could not create the Android package. See the Output (Build) window for more details
- android framework surface native 层渲染