Results 1 to 3 of 3

Thread: The texture won't clear

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

    Default The texture won't clear

    Hello, I added a few shaders to sample app. There is multipass rendering (real texture + bloom pass + blur horizontal + blur vertical). The problem is that when I change the position of drawable triangles (image) the old bloomed+blured part is still available there. In a few seconds I see the trace of moving.



    Maybe I have to clear somehow the texture of framebuffer?
    A little piece code:
    Code:
            
            CL_ProgramObject mProgramBlurH = ...;
            CL_ProgramObject mProgramBlurV = ...;
            CL_ProgramObject mProgramBloom = ...;
    
            CL_Texture mBlurTexture = CL_Texture(mGC, mGC.get_width(), mGC.get_height());
            CL_FrameBuffer mBlurBuf = CL_FrameBuffer(mGC);
    
            CL_Texture mBloomTexture = CL_Texture(mGC, mGC.get_width(), mGC.get_height());
            CL_FrameBuffer mBloomBuf = CL_FrameBuffer(mGC);
    
            CL_Texture mSceneTexture = CL_Texture(mGC, mGC.get_width(), mGC.get_height());
            CL_FrameBuffer mSceneBuf = CL_FrameBuffer(mGC);
    
           mBlurBuf.attach_color_buffer(0, mBlurTexture);
           mBloomBuf.attach_color_buffer(0, mBloomTexture);
           mSceneBuf.attach_color_buffer(0, mSceneTexture);
    And render part:
    Code:
        float moonX = Calculation new position here;
        float moonY = Calculation new position here;
    
        // Draw simple CL_Image object of moon
        mMoon.draw(mGC, moonX, moonY);
    
        //////// Shaders passes
    
        // Render moon to own buffer
        mGC.set_frame_buffer(mSceneBuf);
        mMoon.draw(mGC, moonX, moonY);
        mGC.reset_frame_buffer();
    
        // Bloom pass
        mGC.set_frame_buffer(mBloomBuf);
        mGC.set_texture(0, mSceneTexture);
        renderMoon(mProgramBloom);
        mGC.reset_texture(0);
        mGC.reset_frame_buffer();
    
        // Horizontal Blur pass
        mGC.set_frame_buffer(mBlurBuf);
        mGC.set_texture(0, mBloomTexture);
        renderMoon(mProgramBlurH);
        mGC.reset_texture(0);
        mGC.reset_frame_buffer();
    
        // Vertical Blur pass
        mGC.set_texture(0, mBlurTexture);
        renderMoon(mProgramBlurV);
        mGC.reset_texture(0);

  2. #2
    ClanLib Developer
    Join Date
    Sep 2006
    Location
    Bergen, Norway
    Posts
    588

    Default

    yes, just call gc.clear(..color..)

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

    Default

    Quote Originally Posted by sphair View Post
    yes, just call gc.clear(..color..)
    That's not all. I also have to call pop_modelview():
    Code:
        mGC.set_frame_buffer(mSceneBuf);
        mGC.clear();
        mMoon.draw(mGC, moonX, moonY);
        mGC.reset_frame_buffer();
    
        // Bloom pass
        mGC.set_frame_buffer(mBloomBuf);
        mGC.set_texture(0, mSceneTexture);
        renderMoon(mProgramBloom);
        mGC.pop_modelview();
        mGC.reset_texture(0);
        mGC.reset_frame_buffer();
    
        // Horizontal Blur pass
        mGC.set_frame_buffer(mBlurBuf);
        mGC.set_texture(0, mBloomTexture);
        renderMoon(mProgramBlurH);
        mGC.pop_modelview();
        mGC.reset_texture(0);
        mGC.reset_frame_buffer();

Similar Threads

  1. New Texture 3D example
    By rombust in forum Official ClanLib SDK Forums
    Replies: 0
    Last Post: 11-24-2009, 02:12 PM
  2. The Texture Filtering Problem
    By rombust in forum Official ClanLib SDK Forums
    Replies: 4
    Last Post: 08-13-2009, 07:42 AM
  3. Some Texture Grid Questions
    By catch22 in forum Official ClanLib SDK Forums
    Replies: 2
    Last Post: 07-12-2009, 04:48 AM
  4. ClanLib 0.9 Texture Packer
    By sphair in forum Official ClanLib SDK Forums
    Replies: 4
    Last Post: 05-15-2009, 05:45 AM
  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
  •