Hi all !
I'am French then sorry for my bad english... If you could, please reply me with simple sentences.
I have an annoying problem.
The StackTrace :
07-04 14:41:30.914: D/ACRA(13291): Wait for Toast + worker ended. Kill Application ? true
07-04 14:41:30.914: I/v_hwc(100): hwc prepare: 3D composition
07-04 14:41:30.930: I/v_hwc(100): hwc prepare: 3D composition
07-04 14:41:30.930: E/AndroidRuntime(13291): FATAL EXCEPTION: GLThread 354
07-04 14:41:30.930: E/AndroidRuntime(13291): java.lang.RuntimeException: [ 1372948890650 ] - ERROR: java.lang.RuntimeException: [ 1372948890645 ] - ERROR: java.lang.RuntimeException: [ 1372948890637 ] - ERROR: java.lang.RuntimeException: [ 1372948890634 ] - ERROR: glAttachShader - vertex shader: glError 1281
07-04 14:41:30.930: E/AndroidRuntime(13291): at com.threed.jpct.Logger.log(Logger.java:189)
07-04 14:41:30.930: E/AndroidRuntime(13291): at com.threed.jpct.GLSLShader.checkError(GLSLShader.java:982)
07-04 14:41:30.930: E/AndroidRuntime(13291): at com.threed.jpct.GLSLShader.createProgram(GLSLShader.java:948)
07-04 14:41:30.930: E/AndroidRuntime(13291): at com.threed.jpct.GLSLShader.loadProgram(GLSLShader.java:940)
07-04 14:41:30.930: E/AndroidRuntime(13291): at com.threed.jpct.GLSLShader.<init>(GLSLShader.java:261)
07-04 14:41:30.930: E/AndroidRuntime(13291): at com.threed.jpct.GL20.<init>(GL20.java:117)
07-04 14:41:30.930: E/AndroidRuntime(13291): at java.lang.Class.newInstanceImpl(Native Method)
07-04 14:41:30.930: E/AndroidRuntime(13291): at java.lang.Class.newInstance(Class.java:1319)
07-04 14:41:30.930: E/AndroidRuntime(13291): at com.threed.jpct.GLRenderer.init(GLRenderer.java:377)
07-04 14:41:30.930: E/AndroidRuntime(13291): at com.threed.jpct.GLRenderer.init(GLRenderer.java:367)
07-04 14:41:30.930: E/AndroidRuntime(13291): at com.threed.jpct.FrameBuffer.<init>(FrameBuffer.java:92)
07-04 14:41:30.930: E/AndroidRuntime(13291): at com.threed.jpct.FrameBuffer.<init>(FrameBuffer.java:117)
07-04 14:41:30.930: E/AndroidRuntime(13291): at fr.me.project.activities.utils.threedimensions.ThreeDimensionsRenderer.onSurfaceChanged(ThreeDimensionsRenderer.java:142)
07-04 14:41:30.930: E/AndroidRuntime(13291): at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1455)
07-04 14:41:30.930: E/AndroidRuntime(13291): at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1216)
07-04 14:41:30.930: E/AndroidRuntime(13291): at com.threed.jpct.Logger.log(Logger.java:189)
07-04 14:41:30.930: E/AndroidRuntime(13291): at com.threed.jpct.Logger.log(Logger.java:148)
07-04 14:41:30.930: E/AndroidRuntime(13291): at com.threed.jpct.GLSLShader.<init>(GLSLShader.java:265)
07-04 14:41:30.930: E/AndroidRuntime(13291): at com.threed.jpct.GL20.<init>(GL20.java:117)
07-04 14:41:30.930: E/AndroidRuntime(13291): at java.lang.Class.newInstanceImpl(Native Method)
07-04 14:41:30.930: E/AndroidRuntime(13291): at java.lang.Class.newInstance(Class.java:1319)
07-04 14:41:30.930: E/AndroidRuntime(13291): at com.threed.jpct.GLRenderer.init(GLRenderer.java:377)
07-04 14:41:30.930: E/AndroidRuntime(13291): at com.threed.jpct.GLRenderer.init(GLRenderer.java:367)
07-04 14:41:30.930: E/AndroidRuntime(13291): at com.threed.jpct.FrameBuffer.<init>(FrameBuffer.java:92)
07-04 14:41:30.930: E/AndroidRuntime(13291): at com.threed.jpct.FrameBuffer.<init>(FrameBuffer.java:117)
07-04 14:41:30.930: E/AndroidRuntime(13291): at fr.me.project.activities.utils.threedimensions.ThreeDimensionsRenderer.onSurfaceChanged(ThreeDimensionsRenderer.java:142)
07-04 14:41:30.930: E/AndroidRuntime(13291): at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1455)
07-04 14:41:30.930: E/AndroidRuntime(13291): at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1216)
07-04 14:41:30.930: E/AndroidRuntime(13291): at com.threed.jpct.Logger.log(Logger.java:189)
07-04 14:41:30.930: E/AndroidRuntime(13291): at com.threed.jpct.Logger.log(Logger.java:136)
07-04 14:41:30.930: E/AndroidRuntime(13291): at com.threed.jpct.GLRenderer.init(GLRenderer.java:379)
07-04 14:41:30.930: E/AndroidRuntime(13291): at com.threed.jpct.GLRenderer.init(GLRenderer.java:367)
07-04 14:41:30.930: E/AndroidRuntime(13291): at com.threed.jpct.FrameBuffer.<init>(FrameBuffer.java:92)
07-04 14:41:30.930: E/AndroidRuntime(13291): at com.threed.jpct.FrameBuffer.<init>(FrameBuffer.java:117)
07-04 14:41:30.930: E/AndroidRuntime(13291): at fr.me.project.activities.utils.threedimensions.ThreeDimensionsRenderer.onSurfaceChanged(ThreeDimensionsRenderer.java:142)
07-04 14:41:30.930: E/AndroidRuntime(13291): at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1455)
07-04 14:41:30.930: E/AndroidRuntime(13291): at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1216)
07-04 14:41:30.930: E/AndroidRuntime(13291): at com.threed.jpct.Logger.log(Logger.java:189)
07-04 14:41:30.930: E/AndroidRuntime(13291): at com.threed.jpct.Logger.log(Logger.java:148)
07-04 14:41:30.930: E/AndroidRuntime(13291): at com.threed.jpct.FrameBuffer.<init>(FrameBuffer.java:94)
07-04 14:41:30.930: E/AndroidRuntime(13291): at com.threed.jpct.FrameBuffer.<init>(FrameBuffer.java:117)
07-04 14:41:30.930: E/AndroidRuntime(13291): at fr.me.project.activities.utils.threedimensions.ThreeDimensionsRenderer.onSurfaceChanged(ThreeDimensionsRenderer.java:142)
07-04 14:41:30.930: E/AndroidRuntime(13291): at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1455)
07-04 14:41:30.930: E/AndroidRuntime(13291): at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1216)
07-04 14:41:30.938: W/ActivityManager(250): Force finishing activity fr.me.project/.activities.finalcontrol.ControlFinalActivity
The simplified source code without useless comment, imports, flourish :
The renderer :
public class ThreeDimensionsRenderer implements GLSurfaceView.Renderer{
private FrameBuffer fb = null;
protected World world = null;
private ThreeDimensionsActivity master = null;
private ThreeDimensionsActivity context = null;
//Others thread can add Object3D to add or remove on scene
/**
* Objects to delete
*/
private List<Object3D> toRemoveObject = null;
/**
* Objects to add
*/
private List<Object3D> toAddObject = null;
public ThreeDimensionsRenderer(ThreeDimensionsActivity master, ThreeDimensionsActivity context) {
this.master = master;
this.context = context;
}
@Override
public void onSurfaceChanged(GL10 gl, int w, int h) {
if (fb != null) {
fb.dispose();
}
fb = new FrameBuffer( w, h);
if (master == null) {
world = new World();
MemoryHelper.compact();
if (master == null) {
master = context;
}
}
}
@Override
public void onSurfaceCreated(GL10 gl, EGLConfig config) {
}
@Override
public void onDrawFrame(GL10 gl) {
Camera cam = world.getCamera();
//Add objects to add
for(Object3D ob : this.toAddObject){
world.addObject(ob);
}
//Remove objects to remove
for(Object3D ob : this.toRemoveObject){
world.removeObject(ob.getID());
}
this.toRemoveObject.clear();
this.toAddObject.clear();
//Rendering
fb.clear(new RGBColor(100, 113, 122));
world.renderScene(fb);
world.draw(fb); //PROBLEM ON SECOND TIME
fb.display();
}
public void addObjetToAdd(Object3D ob){
this.toAddObject.add(ob);
}
public void addObjectToRemove(Object3D ob){
this.toRemoveObject.add(ob);
}
}
And the Activity :
public abstract class ThreeDimensionsActivity extends Activity{
private static ThreeDimensionsActivity master = null;
protected GLSurfaceView mGLView;
protected ThreeDimensionsRenderer mRenderer = null;
@Override
protected final void onCreate(Bundle savedInstanceState) {
if (master != null) {
this.copy(master);
}
super.onCreate(savedInstanceState);
this.setContentView(this.getLayoutId());
//OpenGL config
this.mGLView = (GLSurfaceView) this.findViewById(this.getOpenGLSurfaceViewId());
this.mGLView.setEGLContextClientVersion(2);
this.mGLView.setEGLConfigChooser(new AAConfigChooser(this.mGLView));
this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
//Renderer creation
mRenderer = new ThreeDimensionsRenderer(master, this);
this.mGLView.setRenderer(mRenderer);
}
@Override
protected final void onPause() {
super.onPause();
mGLView.onPause();
}
@Override
protected void onResume() {
super.onResume();
mGLView.onResume();
}
@Override
protected final void onStop() {
super.onStop();
}
private void copy(Object src) {
try {
Field[] fs = src.getClass().getDeclaredFields();
for (Field f : fs) {
f.setAccessible(true);
f.set(this, f.get(src));
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}
protected boolean isFullscreenOpaque() {
return true;
}
public ThreeDimensionsRenderer getRenderer(){
return this.mRenderer;
}
}
We can see a comment "//PROBLEM ON SECOND TIME" : it's here that the problem appear. But only the second time.
Explanations :
1 - On my application, i start a first 3D activity... Works fine.
2 - On this activity, call an other activity (an UI activity). Works fine.
3 - And, when i press previous android button, the 3D activity should appear. But the exception arrive.
Thanks.
marksman