Use the texture of a render target in a polygon [SOLVED]

I have this code which draws the whole game world into a render target:

render.set_render_target(self.pp_game_world)

default_renderer()

draw_game_world()

render.enable_texture(0, self.pp_game_world, render.BUFFER_COLOR_BIT)

But how do i actually use the texture of this render target? I need to attach it to a quad i will be using to do post processing.

When you call render.enable_texture(0, self.pp_game_world, render.BUFFER_COLOR_BIT) it means that the color buffer of the render target will be available as texture 0 in the shader of whatever you render.draw() next.

I’m sorry, i didnt understand what i should do with that information. What does it mean that it will be the texture 0 in the shader? How do i access this texture in the shader?

It will be available as tex0 in your fragment program:

uniform lowp sampler2D tex0;
1 Like

much thanks, i will try it

It works, kinda. With this code:

render.set_render_target(self.pp_game_world)

  default_renderer()
  draw_game_world()

  render.enable_texture(0, self.pp_game_world, render.BUFFER_COLOR_BIT)

  render.set_render_target(render.RENDER_TARGET_DEFAULT)
  default_renderer()
  draw_post_processing()

  render.disable_texture(0)

in the quad shader:

varying mediump vec2 var_texcoord0;
uniform lowp sampler2D tex0;
//---------------------------------------------------------------------------
void main()
{
    gl_FragColor=texture2D(tex0, var_texcoord0);
}

i get this result:

it should be just the defold logo, but its all wrong.