MatrixGrabber 的问题:java.lang.ClassCastException:com.google.android.gles_jni.GLImpl
我有一个 GLSurfaceView 类,它必须显示带有纹理的正方形。我试图使屏幕适合纹理/多边形尺寸,然后我需要使用投影。
我使用 3 个类来与 android 1.5 兼容:
MatrixGrabber.java MatrixStack.java MatrixTrackingGL.java
这是给出错误的代码部分:
private MatrixGrabber mg = new MatrixGrabber(); //create the matrix grabber object in your initialization code
.
.
.
DisplayMetrics dm = new DisplayMetrics();
((Activity)context).getWindowManager().getDefaultDisplay().getMetrics(dm);
screenW=dm.widthPixels;
screenH=dm.heightPixels;
modelMatrix=mg.mModelView;
projMatrix=mg.mProjection;
mView[0] = 0;
mView[1] = 0;
mView[2] = screenW; //width
mView[3] = screenH; //height
.
.
.
public void onDrawFrame(GL10 gl) {
//Clear Screen And Depth Buffer
gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
gl.glLoadIdentity(); //Reset The Current Modelview Matrix
mg.getCurrentProjection(gl);
mg.getCurrentModelView(gl);
.
.
.
这是错误:
02-17 09:13:59.952: WARN/dalvikvm(11405): threadid=8: thread exiting with uncaught exception (group=0x4001d7e0)
02-17 09:13:59.960: ERROR/AndroidRuntime(11405): FATAL EXCEPTION: GLThread 9
02-17 09:13:59.960: ERROR/AndroidRuntime(11405): java.lang.ClassCastException: com.google.android.gles_jni.GLImpl
02-17 09:13:59.960: ERROR/AndroidRuntime(11405): at com.DemoMagazine.MatrixGrabber.getMatrix(MatrixGrabber.java:56)
02-17 09:13:59.960: ERROR/AndroidRuntime(11405): at com.DemoMagazine.MatrixGrabber.getCurrentProjection(MatrixGrabber.java:52)
02-17 09:13:59.960: ERROR/AndroidRuntime(11405): at com.DemoMagazine.SquareGLSurfaceView.onDrawFrame(SquareGLSurfaceView.java:112)
02-17 09:13:59.960: ERROR/AndroidRuntime(11405): at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1332)
02-17 09:13:59.960: ERROR/AndroidRuntime(11405): at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1116)
i have a GLSurfaceView class that must show a square with a texture. I'm trying to fit the screen with the texture/polygon dimensions, then i need to use projections.
I'm using 3 classes to have compatibility with android 1.5:
MatrixGrabber.java
MatrixStack.java
MatrixTrackingGL.java
This is the part of the code that it is giving the error:
private MatrixGrabber mg = new MatrixGrabber(); //create the matrix grabber object in your initialization code
.
.
.
DisplayMetrics dm = new DisplayMetrics();
((Activity)context).getWindowManager().getDefaultDisplay().getMetrics(dm);
screenW=dm.widthPixels;
screenH=dm.heightPixels;
modelMatrix=mg.mModelView;
projMatrix=mg.mProjection;
mView[0] = 0;
mView[1] = 0;
mView[2] = screenW; //width
mView[3] = screenH; //height
.
.
.
public void onDrawFrame(GL10 gl) {
//Clear Screen And Depth Buffer
gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
gl.glLoadIdentity(); //Reset The Current Modelview Matrix
mg.getCurrentProjection(gl);
mg.getCurrentModelView(gl);
.
.
.
And this is the error:
02-17 09:13:59.952: WARN/dalvikvm(11405): threadid=8: thread exiting with uncaught exception (group=0x4001d7e0)
02-17 09:13:59.960: ERROR/AndroidRuntime(11405): FATAL EXCEPTION: GLThread 9
02-17 09:13:59.960: ERROR/AndroidRuntime(11405): java.lang.ClassCastException: com.google.android.gles_jni.GLImpl
02-17 09:13:59.960: ERROR/AndroidRuntime(11405): at com.DemoMagazine.MatrixGrabber.getMatrix(MatrixGrabber.java:56)
02-17 09:13:59.960: ERROR/AndroidRuntime(11405): at com.DemoMagazine.MatrixGrabber.getCurrentProjection(MatrixGrabber.java:52)
02-17 09:13:59.960: ERROR/AndroidRuntime(11405): at com.DemoMagazine.SquareGLSurfaceView.onDrawFrame(SquareGLSurfaceView.java:112)
02-17 09:13:59.960: ERROR/AndroidRuntime(11405): at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1332)
02-17 09:13:59.960: ERROR/AndroidRuntime(11405): at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1116)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我在尝试获取矩阵时也遇到了一些问题,但在您的情况下,它们似乎已修复,将矩阵模式设置为我将要获得的模式:
并记住您现在处于投影模式,如果需要,您可以去返回模型视图。这对我有用。
问候!
I had some problems as well trying to get the matrix, but they seem to be fixed setting the matrixmode to the one i am going to get, in your case:
and remember you are now in projection mode, if you need so you can go back to modelview. This worked for me.
Regards!