我正在使用Robert Green GLWallpaperService jar文件开发openGL动态壁纸。 运行代码后没有壁纸做蚂蚁绘制任务 屏幕----
02-16 11:09:31.941: E/AndroidRuntime(6286): FATAL EXCEPTION: GLThread 9
02-16 11:09:31.941: E/AndroidRuntime(6286): java.lang.NullPointerException
02-16 11:09:31.941: E/AndroidRuntime(6286): at com.inoxmobile.waterlwp.WaterLiveWallpaperRenderer.onDrawFrame(WaterLiveWallpaperRenderer.java:152)
02-16 11:09:31.941: E/AndroidRuntime(6286): at
com.inoxmobile.waterlwp.GLThread.guardedRun(GLWallpaperService.java:683)
02-16 11:09:31.941: E/AndroidRuntime(6286):at com.inoxmobile.waterlwp.GLThread.run(GLWallpaperService.java:541)
我正在使用此代码-----
public void onDrawFrame(GL10 gl)
{
if (gl == null)
return;
gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
gl.glEnableClientState(GL10.GL_NORMAL_ARRAY);
gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
if (usebg) {
gl.glDepthMask(false);
mBackground.draw(gl);//Exception come Here..........
gl.glDepthMask(true);
}
gl.glMatrixMode(GL10.GL_MODELVIEW);
gl.glLoadIdentity();
//if (usebg){
//mBackground.Init(gl);
//mBackground.setDims(mWidth, mHeight);
//}
}
答案 0 :(得分:1)
您确定已在mBackground
或此类的构造函数中初始化onCreate()
吗?请记住,如果您只有成员声明,
private Background mBackground;
这相当于
private Background mBackground = null;