Can the framebuffer decide where to display the image

Started by Melssj5, January 05, 2017, 06:23:54 AM

Previous topic - Next topic

Melssj5

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

Melssj5

#1
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
Nada por ahora


Melssj5

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

EgonOlsen

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...???

Melssj5

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

EgonOlsen

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?

Melssj5

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

EgonOlsen

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?

Melssj5

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

EgonOlsen

Just like any other frame buffer. The textures are just render targets. They behave just like a normal frame buffer in every aspect.

Melssj5

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

EgonOlsen

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.

Melssj5

 :'( :'( :'( :'( :'( :'(

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