Author Topic: setRenderTarget() method in OpenGL mode for every frame  (Read 7192 times)

Offline Klaudiusz

  • int
  • **
  • Posts: 75
    • View Profile
setRenderTarget() method in OpenGL mode for every frame
« 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

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Re: setRenderTarget() method in OpenGL mode for every frame
« Reply #1 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.

Offline Klaudiusz

  • int
  • **
  • Posts: 75
    • View Profile
Re: setRenderTarget() method in OpenGL mode for every frame
« Reply #2 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...

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Re: setRenderTarget() method in OpenGL mode for every frame
« Reply #3 on: August 07, 2007, 12:14:57 pm »
There's no display()-call in the second section.

Offline Klaudiusz

  • int
  • **
  • Posts: 75
    • View Profile
Re: setRenderTarget() method in OpenGL mode for every frame
« Reply #4 on: August 07, 2007, 12:34:05 pm »
:)

So simple... thank You:)

Offline Klaudiusz

  • int
  • **
  • Posts: 75
    • View Profile
Re: setRenderTarget() method in OpenGL mode for every frame
« Reply #5 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.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Re: setRenderTarget() method in OpenGL mode for every frame
« Reply #6 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.
« Last Edit: August 07, 2007, 10:57:01 pm by EgonOlsen »

Offline Klaudiusz

  • int
  • **
  • Posts: 75
    • View Profile
Re: setRenderTarget() method in OpenGL mode for every frame
« Reply #7 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.
« Last Edit: August 08, 2007, 08:23:32 am by Klaudiusz »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Re: setRenderTarget() method in OpenGL mode for every frame
« Reply #8 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?

Offline Klaudiusz

  • int
  • **
  • Posts: 75
    • View Profile
Re: setRenderTarget() method in OpenGL mode for every frame
« Reply #9 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;

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Re: setRenderTarget() method in OpenGL mode for every frame
« Reply #10 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.

Offline Klaudiusz

  • int
  • **
  • Posts: 75
    • View Profile
Re: setRenderTarget() method in OpenGL mode for every frame
« Reply #11 on: August 08, 2007, 07:53:23 pm »
Yes... Now it's fine. Thank you.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Re: setRenderTarget() method in OpenGL mode for every frame
« Reply #12 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?

Offline Klaudiusz

  • int
  • **
  • Posts: 75
    • View Profile
Re: setRenderTarget() method in OpenGL mode for every frame
« Reply #13 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)

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Re: setRenderTarget() method in OpenGL mode for every frame
« Reply #14 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.