creating FrameBuffer

Started by Colli, September 22, 2012, 10:39:26 AM

Previous topic - Next topic

Colli

Hi,

Sorry I am asking again for help ;D , but I am wondering if it is possible to create FrameBuffer not in the methods onSurfaceCreate, onSurfaceChanged, onSurfaceDestroyed. Now i am creating the framebuffer in the onSurfaceChanged, and it takes about 2 seconds to create and it causes lags when starting the scene, that is why i would like to create it before the actual rendering begins(so before that when the user starts the level). I tried to run it on the GL thread this way :

mGLView.queueEvent(new Runnable() {
public void run() {
renderer.createBuffer();
}
});


but i just get an error:
Quote09-22 08:34:17.470: E/AndroidRuntime(610): java.lang.RuntimeException: [ 1348302857466 ] - ERROR: java.lang.RuntimeException: [ 1348302857454 ] - ERROR: java.lang.RuntimeException: [ 1348302857418 ] - ERROR: java.lang.RuntimeException: [ 1348302857409 ] - ERROR: Failed to load and compile vertex shaders!





EgonOlsen

Which OpenGL mode are you using? 1.x or 2.0?

Colli

#2
2.0

here is the createBuffer() method in MyRenderer class:

public void createBuffer(){
Log.e("Creating buffer 5" , " ");
fb = new FrameBuffer(320, 480); // these values are just for now
Log.e("Buffer created " , " ");
}


maybe this can help :
Quote09-22 15:49:50.150: I/jPCT-AE(614): [ 1348328990157 ] - ERROR: Failed to load and compile vertex shaders!
09-22 15:49:50.159: I/jPCT-AE(614): [ 1348328990161 ] - WARNING: Unable to load shader!

EgonOlsen

Then there's obviously no valid context (or maybe not bound to the thread to are trying to access it from). I'm not doing anything but executing gl commands, which should be possible as long as the context is fine. Are you sure that your code executes AFTER onSurfaceXXX has been run?

Colli

then there is the problem. the onSurfaceXXX runs after the renderer.createBuffer() call. So how should i create the context before the rendering starts? Now i am doing it : setContentView(mGLView), and the frameBuffer is created in onSurfaceChanged() ,but the frameBuffer creation takes a bit too much time, so how to create this FrameBuffer, before the setContentView() is called?

EgonOlsen

My guess is, that you can't unless you hack deeply into how the GLSurfaceView works...no view, no context and no context, no gl calls...an no gl calls, no FrameBuffer. What takes the time here is compiling the shaders. I wonder, why this takes 2 seconds though. Which device are you using for this?