Results 1 to 2 of 2

Thread: Get screen texture

  1. #1
    Lesser Knight
    Join Date
    Sep 2010
    Posts
    41

    Default Get screen texture

    Hello, I want to make some effect with distortion of rendered image. So, for example, I have a world and a cycle where all sprites are drawen.

    And I have some another object class which should take some rect from already rendered sprites and distort it with shader, for example.

    I know that such things are made with post processing. But post processing takes the final picture and I need only the picture which is rendered untill my 'super' object works.

    The graph is like this:

    Sprite 1 is rendered
    Sprite 2 is rendered
    Sprite 3 is rendered
    [Here my objects takes the resulted screen-texture and work with it, render reworker image]
    Sprite 4 is rendered
    [Final, rendering framebuffer to screen]

    Is this possible? If yes, how can I get the texture from framebuffer which is alredy rendered? Btw, I don't have direct access for rendering of all another sprites, so I can't just set to render them into my own texture.

  2. #2
    ClanLib Developer
    Join Date
    Sep 2006
    Location
    Denmark
    Posts
    554

    Default

    This is usually achieved by creating a texture with the dimensions of the frame buffer. Then create you own frame buffer object (CL_FrameBuffer) and make it active on the graphic context. You then render the scene into this frame buffer.

    Code:
    CL_Texture texture(gc, gc.get_width(), gc.get_height(), cl_rgba8);
    CL_FrameBuffer framebuffer(gc);
    framebuffer.attach_colorbuffer(0, texture);
    gc.set_frame_buffer(framebuffer);
    render_scene(gc);
    gc.reset_frame_buffer();
    post_process_render(gc, texture);
    Note: This code example is written from memory and might not be entirely accurate in how it uses ClanLib. But it illustrates the general idea.

Similar Threads

  1. Texture Coordinates
    By hmroz in forum Proton SDK
    Replies: 5
    Last Post: 04-11-2011, 12:58 PM
  2. Texture instead of gradient
    By Ockonal in forum Official ClanLib SDK Forums
    Replies: 2
    Last Post: 12-25-2010, 08:18 AM
  3. The texture won't clear
    By Ockonal in forum Official ClanLib SDK Forums
    Replies: 2
    Last Post: 10-08-2010, 07:41 AM
  4. New Texture 3D example
    By rombust in forum Official ClanLib SDK Forums
    Replies: 0
    Last Post: 11-24-2009, 02:12 PM
  5. relationship between GC and Texture?
    By logixoul in forum Official ClanLib SDK Forums
    Replies: 4
    Last Post: 07-07-2008, 07:17 AM

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •