www.jpct.net

jPCT - a 3d engine for Java => Support => Topic started by: Klaudiusz on August 07, 2007, 09:56:16 am

Title: setRenderTarget() method in OpenGL mode for every frame
Post by: Klaudiusz on August 07, 2007, 09:56:16 am
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
Title: Re: setRenderTarget() method in OpenGL mode for every frame
Post by: EgonOlsen on August 07, 2007, 10:24:01 am
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.
Title: Re: setRenderTarget() method in OpenGL mode for every frame
Post by: Klaudiusz on August 07, 2007, 11:43:58 am
Please tell me what i'm doing wrong:

Code: [Select]
 
            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...
Title: Re: setRenderTarget() method in OpenGL mode for every frame
Post by: EgonOlsen on August 07, 2007, 12:14:57 pm
There's no display()-call in the second section.
Title: Re: setRenderTarget() method in OpenGL mode for every frame
Post by: Klaudiusz on August 07, 2007, 12:34:05 pm
:)

So simple... thank You:)
Title: Re: setRenderTarget() method in OpenGL mode for every frame
Post by: Klaudiusz on August 07, 2007, 07:34:00 pm
Hmmm the same code does't not work on:

Code: [Select]
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.
Title: Re: setRenderTarget() method in OpenGL mode for every frame
Post by: EgonOlsen on August 07, 2007, 10:54:14 pm
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.
Title: Re: setRenderTarget() method in OpenGL mode for every frame
Post by: Klaudiusz on August 08, 2007, 08:22:01 am
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:

Code: [Select]
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.
Title: Re: setRenderTarget() method in OpenGL mode for every frame
Post by: EgonOlsen on August 08, 2007, 08:28:12 am
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?
Title: Re: setRenderTarget() method in OpenGL mode for every frame
Post by: Klaudiusz on August 08, 2007, 05:37:09 pm
I found a reason. Everything is OK when

Code: [Select]
Config.glMipmap=false;
The problem appears everytime when  Config.glMipmap=true;
Title: Re: setRenderTarget() method in OpenGL mode for every frame
Post by: EgonOlsen on August 08, 2007, 06:59:09 pm
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.
Title: Re: setRenderTarget() method in OpenGL mode for every frame
Post by: Klaudiusz on August 08, 2007, 07:53:23 pm
Yes... Now it's fine. Thank you.
Title: Re: setRenderTarget() method in OpenGL mode for every frame
Post by: EgonOlsen on August 08, 2007, 08:02:20 pm
I'm curios about that Intel machine...does it report something about FBO being used after initializing the renderer with the latest beta?
Title: Re: setRenderTarget() method in OpenGL mode for every frame
Post by: Klaudiusz on August 09, 2007, 11:38:03 am
Yes indeed with the nevest version:

Code: [Select]
Driver is: idisw2km/2.50.4136.2000 on Intel Intel 915G
FBO not supported or disabled!
OpenGL renderer initialized (using 4 texture stages)
Title: Re: setRenderTarget() method in OpenGL mode for every frame
Post by: EgonOlsen on August 09, 2007, 01:01:48 pm
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.