setRenderTarget() method in OpenGL mode for every frame

Started by Klaudiusz, August 07, 2007, 09:56:16 AM

Previous topic - Next topic

Klaudiusz

Hi,

I would like to use mirrored env on the object. Could i ask You for little guide how to do it fast in hardware mode? There is not too much informations on the forum.

Is the frame rendered directly to the texture in OpenGL mode? Or the data it is copied/modified?

Could you provide some simple source code?

Thanks

EgonOlsen

You can call it every frame, there's no problem with that. But i suggest to use the 1.15 beta posted in the News section, because it changes the behaviour slightly and is faster doing render-to-texture if the hardware is capable of frame buffer objects.
Using it is simple: You use a normal clear()-to-display()-section and wrap it into set... and removeRenderTarget() calls. You have then rendered that scene into the texture instead of the framebuffer.

Klaudiusz

Please tell me what i'm doing wrong:

 
            fb.clear(Color.BLACK);                 //normal rendering to the screen
            MyScene.renderScene(fb);
            MyScene.draw(fb);
            fb.update();
            display();

            fb.setRenderTarget(texMan.getTexture("MyTexture")); // the same but switching to texture
            fb.clear(Color.BLACK);                                           //operations at the texture...
            MyScene.renderScene(fb);
            MyScene.draw(fb);
            fb.update();
            fb.removeRenderTarget();   //removing the texture target



Maybe not all steps are needed for secound rendering but it gives me no effect. The texture is still the same...

EgonOlsen



Klaudiusz

Hmmm the same code does't not work on:

Current mode:1024 x 768 x 32 @70Hz
Driver is: ati2dvag/6.14.10.6542 on ATI Technologies Inc. RADEON X550 x86/MMX/3DNow!/SSE2
OpenGL renderer initialized (using 4 texture stages)


I see just white texture and the speed is very very low.

EgonOlsen

#6
That's a very vague description...the code snippet that you've posted looks ok. It has to be something else. Can you post a small test case that reproduces the behaviour on your machine?
Or do you mean that it works on your machine but not on the one with that ATI card? Which version of jPCT are you using? It doesn't seem to be the current beta because a message is missing between "Driver is:..." and "OpenGL renderer..." if it were.

Klaudiusz

#7
I forgot to mension that the white color is a additional color of the object, so the texture is only cleared by fb.clear(Color.BLACK);

The problematic environment i have on my private computer,  everything looks good on machine in my work, where i'm now:

Current mode:1024 x 768 x 32 @75Hz
[ Wed Aug 08 08:09:55 CEST 2007 ] - WARNING: Number of samples (2) not supported
!
Driver is: idisw2km/2.50.4136.2000 on Intel Intel 915G
OpenGL renderer initialized (using 4 texture stages)


I have tryed with many versions of jpct also with the nevest one(1.15 beta).

For now i think it's something wrong with my display() routine. When i remove display() , speed rendering is fast, but ofcorse the texture has been not changed.

I'll make some test routine and i will post it here later.

EgonOlsen

Try to enable a sampling mode without anti-aliasing. Some ATIs are having problems with it when combined with render-to-texture. 1.15 should fix this be using another way to render into the texture, but maybe your ATI (or your driver) doesn't support it. Can you grab 1.15 again (the latest, because i've updated it twice) and post the complete initialization log?

Klaudiusz

I found a reason. Everything is OK when

Config.glMipmap=false;

The problem appears everytime when  Config.glMipmap=true;

EgonOlsen

Oh, i forgot about this one...yes, that's true, but it's already fixed in the latest beta. I can only repeat myself: Use the latest 1.15beta. It fixes some render-to-texture-flaws and improves performance.


EgonOlsen

I'm curios about that Intel machine...does it report something about FBO being used after initializing the renderer with the latest beta?

Klaudiusz

Yes indeed with the nevest version:

Driver is: idisw2km/2.50.4136.2000 on Intel Intel 915G
FBO not supported or disabled!
OpenGL renderer initialized (using 4 texture stages)

EgonOlsen

Thank you. So the Intel (or at least the drivers you are using) doesn't support frame buffer objects. This is just for my records, so that i know what to expect from different chips and what not.