Author Topic: Can the framebuffer decide where to display the image  (Read 868 times)

Offline Melssj5

  • double
  • *****
  • Posts: 715
    • View Profile
Can the framebuffer decide where to display the image
« on: January 05, 2017, 06:23:54 am »
Hi, its been a log time away from here. I am trying to do a VR test. I have 2 cameras and want to render the first one in the left and the second one in the right.

Using the Config X offset wont work becausse the will draw different things on each side. What I want is to do something like this....

setContentView(R.layout.main);
      LinearLayout canvas=(LinearLayout)findViewById(R.id.mainLayout);
      canvas.addView(mGLView1);
      canvas.addView(mGLView2);

render camera 1 and
fb.display (mGLView1);

render camera 2 and
fb.display (mGLView2);

Or should I use a Texture artifact and then blit it into the front of the screen.... wouldnt this make it lose the 3d depth=????
Nada por ahora

Offline Melssj5

  • double
  • *****
  • Posts: 715
    • View Profile
Re: Can the framebuffer decide where to display the image
« Reply #1 on: January 05, 2017, 07:06:21 am »
I used the texture blitting aproach, the problem es that the texture is being rewriten again leaving gargabe on it. If I re initialize them, then inmediatelly gives me a memory error.

Which is the best way to do this rendering by bliting textures and dont use the 100% of the memory inmedately.?

Actually I tried some code reorganization but still the same... and suddenly the app never worked again... did ctrl Z until leaving on a previous state but it never worked again.

W/Adreno-EGLSUB: <SwapBuffers:1348>: Invalid native buffer. Failed to queueBuffer
W/Adreno-EGLSUB: <updater_thread:436>: native buffer is NULL
« Last Edit: January 05, 2017, 07:59:56 am by Melssj5 »
Nada por ahora

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11776
    • View Profile
    • http://www.jpct.net
Re: Can the framebuffer decide where to display the image
« Reply #2 on: January 05, 2017, 08:57:26 am »
This has some example code: http://www.jpct.net/forum2/index.php/topic,4814.msg32913.html#msg32913. Maybe that helps.

Offline Melssj5

  • double
  • *****
  • Posts: 715
    • View Profile
Re: Can the framebuffer decide where to display the image
« Reply #3 on: January 05, 2017, 05:09:58 pm »
Well, In fact.. I used the code you suggested there, the problem I am facing is that the texture build from the render is not being cleaned but overwriten and if I do = new Texture(w,h); on every render then it throws OutOfMemoryError in the first 2 seconds.

The another problem I am facing is that it stopped working suddenly and now I receive the message

W/Adreno-EGLSUB: <SwapBuffers:1348>: Invalid native buffer. Failed to queueBuffer
W/Adreno-EGLSUB: <updater_thread:436>: native buffer is NULL
Nada por ahora

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11776
    • View Profile
    • http://www.jpct.net
Re: Can the framebuffer decide where to display the image
« Reply #4 on: January 05, 2017, 05:56:13 pm »
Ok, but you are not supposed to create a new texture on each render. Why are you doing that? The code posted in the thread doesn't do that either...???

Offline Melssj5

  • double
  • *****
  • Posts: 715
    • View Profile
Re: Can the framebuffer decide where to display the image
« Reply #5 on: January 05, 2017, 07:51:25 pm »
Sure the code doesnt do that and I wasnt doing it either before, but when the texture is redered I got it mixed with previous states.

I have no access to the code right now but.... lets say I have a world with a cube, then I draw the framebuffer into a texture and blit it. then I move the camera and render it again into the same texture, when I blit it again I see 2 cubes, not only one.
Nada por ahora

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11776
    • View Profile
    • http://www.jpct.net
Re: Can the framebuffer decide where to display the image
« Reply #6 on: January 06, 2017, 02:45:02 pm »
I'm not sure what you mean. You need two textures for this to work, not just one. Just like the example code does it. Does the example work for you?

Offline Melssj5

  • double
  • *****
  • Posts: 715
    • View Profile
Re: Can the framebuffer decide where to display the image
« Reply #7 on: January 06, 2017, 03:30:10 pm »
Sorry, I guess my English its a shame.... :'(

I have 2 textures, one blited on the left and one blited on the rigth.

on each one of the textures happens this:

" lets say I have a world with a cube, then I draw the framebuffer into a texture and blit it. then I move the camera and render it again into the same texture, when I blit it again I see 2 cubes, not only one.".... then I move the camera and render for third time and then each texture will show 3 cubes, on the fourth render each texture will show 4 cubes and so on.....

If I construct the texture on every loop of the render it is corrected but the memory fails after the very first renders.....
Nada por ahora

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11776
    • View Profile
    • http://www.jpct.net
Re: Can the framebuffer decide where to display the image
« Reply #8 on: January 06, 2017, 07:17:17 pm »
Seems like as if you are simply not clearing the image. Again: Does the example work for you or does it have the same problem?

Offline Melssj5

  • double
  • *****
  • Posts: 715
    • View Profile
Re: Can the framebuffer decide where to display the image
« Reply #9 on: January 06, 2017, 07:21:34 pm »
I Will test the example at night in home and write back.... but just in case..... how do I clear the image?? the piece of code was taken from the example but maybe I deleted something...
Nada por ahora

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11776
    • View Profile
    • http://www.jpct.net
Re: Can the framebuffer decide where to display the image
« Reply #10 on: January 06, 2017, 07:30:27 pm »
Just like any other frame buffer. The textures are just render targets. They behave just like a normal frame buffer in every aspect.

Offline Melssj5

  • double
  • *****
  • Posts: 715
    • View Profile
Re: Can the framebuffer decide where to display the image
« Reply #11 on: January 06, 2017, 07:36:18 pm »
oh you mean I missed calling to fb.clear();  ??? That was the first thing I checked and rechecked. the problem is that the texture is not being cleared. Anyway I will load the example code you posted and will test it again.

Another question...is it imposible to load two GLVIEWs  and select on which write each render, just like like textures targets, but with the GLViews??? I am worrying about performance and memory ussage.
Nada por ahora

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11776
    • View Profile
    • http://www.jpct.net
Re: Can the framebuffer decide where to display the image
« Reply #12 on: January 06, 2017, 09:08:04 pm »
I'm not sure if that's possible, but if it were, it would require twice the texture memory, because you would have two GL contexts. Apart from that, jPCT-AE isn't designed to render in two contexts at the same time, so...

Using textures as render targets has no performance penalty. Of course it uses some memory, but that should be nothing to worry about.

Offline Melssj5

  • double
  • *****
  • Posts: 715
    • View Profile
Re: Can the framebuffer decide where to display the image
« Reply #13 on: January 07, 2017, 05:34:50 am »
 :'( :'( :'( :'( :'( :'(

Its working now....

I checked and re checked.... and re checked and everything seemed the same, finally I deleted my code copied yours and began to work fine.....

I dont know why or how but its working anyway. Thanks a lot.
Nada por ahora