Runtime exception when changed to Opengl ES 2.0

Started by gamerfan, October 25, 2011, 10:28:39 AM

Previous topic - Next topic

gamerfan

I am getting the following Runtime Exception when I change to OpenGL ES 2.0.I have updated with the latest japct-ae.jar.


10-25 13:50:59.462: ERROR/AndroidRuntime(592): java.lang.RuntimeException: [ 1319530859409 ] - ERROR: java.lang.RuntimeException: [ 1319530859350 ] - ERROR: java.lang.RuntimeException: [ 1319530859305 ] - ERROR: java.lang.RuntimeException: [ 1319530859286 ] - ERROR: Couldn't read file from InputStream
10-25 13:50:59.462: ERROR/AndroidRuntime(592):     at com.threed.jpct.Logger.log(Logger.java:189)
10-25 13:50:59.462: ERROR/AndroidRuntime(592):     at com.threed.jpct.Loader.loadBinaryFile(Loader.java:1111)
10-25 13:50:59.462: ERROR/AndroidRuntime(592):     at com.threed.jpct.Loader.loadTextFile(Loader.java:71)
10-25 13:50:59.462: ERROR/AndroidRuntime(592):     at com.threed.jpct.Loader.loadTextFile(Loader.java:61)
10-25 13:50:59.462: ERROR/AndroidRuntime(592):     at com.threed.jpct.GLSLShader.<init>(GLSLShader.java:210)
10-25 13:50:59.462: ERROR/AndroidRuntime(592):     at com.threed.jpct.GL20.<init>(GL20.java:118)
10-25 13:50:59.462: ERROR/AndroidRuntime(592):     at java.lang.Class.newInstanceImpl(Native Method)
10-25 13:50:59.462: ERROR/AndroidRuntime(592):     at java.lang.Class.newInstance(Class.java:1429)
10-25 13:50:59.462: ERROR/AndroidRuntime(592):     at com.threed.jpct.GLRenderer.init(GLRenderer.java:469)
10-25 13:50:59.462: ERROR/AndroidRuntime(592):     at com.threed.jpct.GLRenderer.init(GLRenderer.java:458)
10-25 13:50:59.462: ERROR/AndroidRuntime(592):     at com.threed.jpct.FrameBuffer.<init>(FrameBuffer.java:92)
10-25 13:50:59.462: ERROR/AndroidRuntime(592):     at com.threed.jpct.FrameBuffer.<init>(FrameBuffer.java:117)
10-25 13:50:59.462: ERROR/AndroidRuntime(592):     at org.me.home.GameActivity$MyRenderer.onSurfaceChanged(GameActivity.java:207)

I have done the modifications the way it were specified in wiki.Am I missing anything?

EgonOlsen

It seems to be unable to find the default shader files. They should be located in the jpct-ae.jar. Are you by any chance using the classes in extracted form or something? Apart from that, keep in mind that the emulator doesn't support OpenGL ES 2.0 anyway. However, this shouldn't prevent the files from being found.

gamerfan

No I have not extracted any classes from jar file. 
Quote
Apart from that, keep in mind that the emulator doesn't support OpenGL ES 2.0 anyway
:'(

EgonOlsen

I'm putting the shaders in the jar and since that works fine when using Eclipse for building the APK, i though that it's fine to do this. But after reading a little more about this topic, this doesn't seem to be the case. The Eclipse seems to be able to handle it, but other ways to build the APK don't seem to be able to handle this, which is a pity. I'll think about a solution....

EgonOlsen

BLARGH...i don't like Android's intrusive way of dealing with resources...anyway, i've found a solution for this problem in a way that i provide an optional zip-file with the shaders and a ShaderLocator that you can use to load them. However, this isn't in any released version for now and if there's no need to release it now, i would like to postpone it.

Because you are using the emulator, you can't use ES 2.0 anyway...so if you really need this for an actual device (or anyone else does), please let me know. Otherwise, i won't upload it for now.

gamerfan

@EgonOlsen.Please hold on.I want some other clarifications as well.Using OpenGL ES earlier version, I know that I cannot use shader in android emulator. But when I googled around , I came to know that shading mechanism can implemented using pixel shader as well .So can I use pixel shader implementation with OpenGL ES version 1.0 in the framework?

Secondly, I am not using OpenGL ES version 2.0 immdiately as I do not have any device.So you do not have to upload it now.

Third thing, can we have a mechanism using JNI so that it will work on Android emulator as well?

EgonOlsen

Pixel shaders are a part of shaders...only that they are called fragment shaders in OpenGL for whatever reason. So...no, there's no way to use any kind of shaders in an ES 1.x context.

JNI will work in the emulator, because it emulates a complete Android system with software and hardware...just not a gpu, which is a pity.

weeman

I have the exact same problem, but with the new version (1.25).

Can anyone help me?

EgonOlsen

Please post the exception (just to be sure that it's the exact same problem). If it is, the solution is also the same.

weeman

Here it is:


10-20 15:41:10.795: E/AndroidRuntime(27988): java.lang.RuntimeException: [ 1350758470788 ] - ERROR: java.lang.RuntimeException: [ 1350758470784 ] - ERROR: java.lang.RuntimeException: [ 1350758470778 ] - ERROR: java.lang.RuntimeException: [ 1350758470773 ] - ERROR: Couldn't read file from InputStream
10-20 15:41:10.795: E/AndroidRuntime(27988): at com.threed.jpct.Logger.log(Logger.java:189)
10-20 15:41:10.795: E/AndroidRuntime(27988): at com.threed.jpct.Loader.loadBinaryFile(Loader.java:1073)
10-20 15:41:10.795: E/AndroidRuntime(27988): at com.threed.jpct.Loader.loadTextFile(Loader.java:67)
10-20 15:41:10.795: E/AndroidRuntime(27988): at com.threed.jpct.Loader.loadTextFile(Loader.java:57)
10-20 15:41:10.795: E/AndroidRuntime(27988): at com.threed.jpct.ShaderLocator.loadFromJar(ShaderLocator.java:90)
10-20 15:41:10.795: E/AndroidRuntime(27988): at com.threed.jpct.ShaderLocator.getShaderCode(ShaderLocator.java:51)
10-20 15:41:10.795: E/AndroidRuntime(27988): at com.threed.jpct.GLSLShader.<init>(GLSLShader.java:235)
10-20 15:41:10.795: E/AndroidRuntime(27988): at com.threed.jpct.GL20.<init>(GL20.java:117)
10-20 15:41:10.795: E/AndroidRuntime(27988): at java.lang.Class.newInstanceImpl(Native Method)
10-20 15:41:10.795: E/AndroidRuntime(27988): at java.lang.Class.newInstance(Class.java:1319)
10-20 15:41:10.795: E/AndroidRuntime(27988): at com.threed.jpct.GLRenderer.init(GLRenderer.java:374)
10-20 15:41:10.795: E/AndroidRuntime(27988): at com.threed.jpct.GLRenderer.init(GLRenderer.java:364)
10-20 15:41:10.795: E/AndroidRuntime(27988): at com.threed.jpct.FrameBuffer.<init>(FrameBuffer.java:90)
10-20 15:41:10.795: E/AndroidRuntime(27988): at com.threed.jpct.FrameBuffer.<init>(FrameBuffer.java:115)
10-20 15:41:10.795: E/AndroidRuntime(27988): at com.threed.jpct.example.MyRenderer.onSurfaceChanged(MyRenderer.java:88)
10-20 15:41:10.795: E/AndroidRuntime(27988): at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1455)
10-20 15:41:10.795: E/AndroidRuntime(27988): at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1216)
10-20 15:41:10.795: E/AndroidRuntime(27988): at com.threed.jpct.Logger.log(Logger.java:189)
10-20 15:41:10.795: E/AndroidRuntime(27988): at com.threed.jpct.Logger.log(Logger.java:148)
10-20 15:41:10.795: E/AndroidRuntime(27988): at com.threed.jpct.GLSLShader.<init>(GLSLShader.java:258)
10-20 15:41:10.795: E/AndroidRuntime(27988): at com.threed.jpct.GL20.<init>(GL20.java:117)
10-20 15:41:10.795: E/AndroidRuntime(27988): at java.lang.Class.newInstanceImpl(Native Method)
10-20 15:41:10.795: E/AndroidRuntime(27988): at java.lang.Class.newInstance(Class.java:1319)
10-20 15:41:10.795: E/AndroidRuntime(27988): at com.threed.jpct.GLRenderer.init(GLRenderer.java:374)
10-20 15:41:10.795: E/AndroidRuntime(27988): at com.threed.jpct.GLRenderer.init(GLRenderer.java:364)
10-20 15:41:10.795: E/AndroidRuntime(27988): at com.threed.jpct.FrameBuffer.<init>(FrameBuffer.java:90)
10-20 15:41:10.795: E/AndroidRuntime(27988): at com.threed.jpct.FrameBuffer.<init>(FrameBuffer.java:115)
10-20 15:41:10.795: E/AndroidRuntime(27988): at com.threed.jpct.example.MyRenderer.onSurfaceChanged(MyRenderer.java:88)
10-20 15:41:10.795: E/AndroidRuntime(27988): at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1455)
10-20 15:41:10.795: E/AndroidRuntime(27988): at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1216)
10-20 15:41:10.795: E/AndroidRuntime(27988): at com.threed.jpct.Logger.log(Logger.java:189)
10-20 15:41:10.795: E/AndroidRuntime(27988): at com.threed.jpct.Logger.log(Logger.java:136)
10-20 15:41:10.795: E/AndroidRuntime(27988): at com.threed.jpct.GLRenderer.init(GLRenderer.java:376)
10-20 15:41:10.795: E/AndroidRuntime(27988): at com.threed.jpct.GLRenderer.init(GLRenderer.java:364)
10-20 15:41:10.795: E/AndroidRuntime(27988): at com.threed.jpct.FrameBuffer.<init>(FrameBuffer.java:90)
10-20 15:41:10.795: E/AndroidRuntime(27988): at com.threed.jpct.FrameBuffer.<init>(FrameBuffer.java:115)
10-20 15:41:10.795: E/AndroidRuntime(27988): at com.threed.jpct.example.MyRenderer.onSurfaceChanged(MyRenderer.java:88)
10-20 15:41:10.795: E/AndroidRuntime(27988): at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1455)
10-20 15:41:10.795: E/AndroidRuntime(27988): at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1216)
10-20 15:41:10.795: E/AndroidRuntime(27988): at com.threed.jpct.Logger.log(Logger.java:189)
10-20 15:41:10.795: E/AndroidRuntime(27988): at com.threed.jpct.Logger.log(Logger.java:148)
10-20 15:41:10.795: E/AndroidRuntime(27988): at com.threed.jpct.FrameBuffer.<init>(FrameBuffer.java:92)
10-20 15:41:10.795: E/AndroidRuntime(27988): at com.threed.jpct.FrameBuffer.<init>(FrameBuffer.java:115)
10-20 15:41:10.795: E/AndroidRuntime(27988): at com.threed.jpct.example.MyRenderer.onSurfaceChanged(MyRenderer.java:88)
10-20 15:41:10.795: E/AndroidRuntime(27988): at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1455)
10-20 15:41:10.795: E/AndroidRuntime(27988): at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1216)


I'm not using the emulator, i'm using a samsung galaxy sII.

EgonOlsen

Well, then the solution is the same too: Use the ShaderLocator class to make it load the shaders. I've no idea why this happens with some devices or platforms...

weeman

Thanks man, i got it working. To be more specific, here is what i did:

- I put the jpct_shaders.zip file in the res/raw directory.
- I added this line right after initializing the GLSurfaceView:

mGLView.setEGLContextClientVersion(2);


- Finally, i added this lines right before initializing the FrameBuffer:

ShaderLocator sl = new ShaderLocator(demo.getResources(),R.raw.jpct_shaders);
GLSLShader.setShaderLocator(sl);


That's all. Thank you very much.