Results 1 to 2 of 2

Thread: ClanLib 2.0 & MRT (Multi-Render-Targets)

  1. #1

    Default ClanLib 2.0 & MRT (Multi-Render-Targets)

    I'm implementing a normal map shader that uses MRT (multi-render-targets), with color attachment 0 for diffuse maps and color attachment 1 for normal maps.
    I decided to do this in order to minimize rendering passes and optimize performance.

    I created a frame buffer with 2 color attachments:
    In my fragment shader I use a code like this:
    vec4 diffuse = texture2D(baseMap, Texcoord) * fvDiffuse;
    vec4 normal = texture2D(bumpMap,Texcoord);  
    gl_FragData[0] = diffuse;   
    gl_FragData[1] = normal
    so in only one pass I can write to both diffuse and normal maps.

    But in order to make it work properly I have to manually enable drawing multiple buffers for that frame buffer with the OpenGL function drawBuffers(), for example:
    CLenum buffers[] = { CL_GLDefines::CL_COLOR_ATTACHMENT0, CL_GLDefines::CL_COLOR_ATTACHMENT1 };
    So my question is: does ClanLib 2.0.2 support drawing to multiple color attachments without accessing directly to OpenGL functions?

    Thanks for any help!

    Last edited by wizardofoz; 06-01-2009 at 10:41 AM.

  2. #2
    ClanLib Developer
    Join Date
    Sep 2006


    I was not aware that OpenGL required a special function call to enable the color buffers. So that is why ClanLib doesn't do it for you, because the clanGL target simply assumed that attaching two color buffers would automatically mean you could use both.

    It is of course not our intention that you have to call an OpenGL function directly to finish the job. I guess one option is that when you bind a frame buffer (gc.set_frame_buffer), then it will enable all the color buffers in the frame buffer.

    If that sounds like a sane suggestion, then the code you pasted needs to go to CL_OpenGLGraphicContext::set_frame_buffer(). Unless this is a state that is attributed to the specific frame buffer object. If that is the case, this needs to be an extra function on CL_FrameBuffer + CL_FrameBufferProvider + CL_OpenGLFrameBuffer.

Similar Threads

  1. Multiple Targets with ClanLib 0.9
    By rombust in forum Official ClanLib SDK Forums
    Replies: 1
    Last Post: 03-27-2009, 07:37 PM
  2. Render Targets
    By ShadowDust in forum Novashell Game Creation System
    Replies: 0
    Last Post: 12-21-2008, 08:13 AM
  3. Using one frame of multi-frame image strip, and a little bit of oddness
    By Uhfgood in forum Novashell Game Creation System
    Replies: 2
    Last Post: 07-03-2008, 02:10 AM
  4. Display targets and input
    By void_kill in forum Official ClanLib SDK Forums
    Replies: 0
    Last Post: 03-23-2007, 11:56 PM



Posting Permissions

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