Author Topic: creating FrameBuffer  (Read 1112 times)

Offline Colli

  • byte
  • *
  • Posts: 13
    • View Profile
creating FrameBuffer
« on: September 22, 2012, 10:39:26 am »
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 :

Code: [Select]
mGLView.queueEvent(new Runnable() {
public void run() {
renderer.createBuffer();
}
});

but i just get an error:
Quote
09-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!





Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11748
    • View Profile
    • http://www.jpct.net
Re: creating FrameBuffer
« Reply #1 on: September 22, 2012, 05:28:04 pm »
Which OpenGL mode are you using? 1.x or 2.0?

Offline Colli

  • byte
  • *
  • Posts: 13
    • View Profile
Re: creating FrameBuffer
« Reply #2 on: September 22, 2012, 05:43:59 pm »
2.0

here is the createBuffer() method in MyRenderer class:

Code: [Select]
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 :
Quote
09-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!
« Last Edit: September 22, 2012, 05:59:15 pm by Colli »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11748
    • View Profile
    • http://www.jpct.net
Re: creating FrameBuffer
« Reply #3 on: September 22, 2012, 06:00:57 pm »
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?

Offline Colli

  • byte
  • *
  • Posts: 13
    • View Profile
Re: creating FrameBuffer
« Reply #4 on: September 22, 2012, 06:20:36 pm »
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?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11748
    • View Profile
    • http://www.jpct.net
Re: creating FrameBuffer
« Reply #5 on: September 22, 2012, 09:18:07 pm »
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?