Results 1 to 7 of 7

Thread: Render to Image

  1. #1
    Peasant
    Join Date
    Apr 2010
    Posts
    9

    Default Render to Image

    Hi Forum,

    I've got a problem.
    I am using something like this:
    Code:
    CL_Draw::circle(gc, pos.x, pos.y, radi, col);
    The problem is that first I want to draw/render all the geomatrie (circle, line, quad,...) to an image and after that I want to display a region of that image.

    What I have to do?

    Best regards ^^....

  2. #2
    Peasant
    Join Date
    Apr 2010
    Posts
    9

    Default

    Okay,

    I hade done something like this:
    Code:
    	CL_FrameBuffer fb(gc);
    	CL_Texture texture(gc, gc.get_width(), gc.get_height(), cl_rgba);
    
    	CL_FrameBuffer framebuffer;
    	framebuffer = CL_FrameBuffer(gc);
    	framebuffer.attach_color_buffer(0, texture);
    
    	gc.set_frame_buffer(framebuffer);
    	mRenderer.draw(gc,mViewOfSpielfeld.get(),mRectOnScreenToRender);
    	gc.reset_frame_buffer();
    	
    	CL_Draw::texture(gc,texture,CL_Quadf(CL_Rectf(000,000,800,800)) );
    But nothing is shown... just a black screen

  3. #3
    ClanLib Developer
    Join Date
    May 2007
    Posts
    1,824

    Default

    Try replacing

    Code:
    CL_Draw::texture(gc,texture,CL_Quadf(CL_Rectf(000,000,800,800)) );
    With....

    Code:
    gc.set_texture(0, texture);
    gc.set_program_object(cl_program_single_texture);
    CL_Draw::texture(gc, CL_Rectf(0,0,800,800) );
    gc.reset_texture(0);
    Maybe the CL_Draw::texture is better with...
    Code:
    CL_Draw::texture(gc, CL_Rectf(xoffset,yoffset, texture.get_size() ));
    If scaling is not required

  4. #4
    Peasant
    Join Date
    Apr 2010
    Posts
    9

    Default

    No... still black screen

    My whole code:
    Code:
    	CL_FrameBuffer fb(gc);
    	CL_Texture texture(gc, gc.get_width(), gc.get_height(), cl_rgba);
    	texture.set_min_filter(cl_filter_linear);
    	texture.set_mag_filter(cl_filter_linear);
    
    	CL_FrameBuffer framebuffer;
    	framebuffer = CL_FrameBuffer(gc);
    	framebuffer.attach_color_buffer(0, texture);
    	gc.set_frame_buffer(framebuffer);
    	mRenderer.draw(gc,mViewOfSpielfeld.get(),mRectOnScreenToRender);
    	gc.reset_frame_buffer();
    	
    	gc.set_texture(0, texture);
    	gc.set_program_object(cl_program_single_texture);
    	CL_Draw::texture(gc, CL_Rectf(0,0,800,800) );
    	gc.reset_texture(0);
    P.s.:
    I'm using "ClanLib-VC9Precompiled-static-mt-Win32-2.2.9".

  5. #5
    Peasant
    Join Date
    Apr 2010
    Posts
    9

    Default

    Ok, I ( thanks judas) fixed the problem, cause the reason why I had try this, is to clip a region.
    Code:
    	gc.set_cliprect(mRectOnScreenToRender);
    	mRenderer.draw(gc,mViewOfSpielfeld.get(),mRectOnScreenToRender);
    	gc.reset_cliprect();

  6. #6
    ClanLib Developer
    Join Date
    May 2007
    Posts
    1,824

    Default

    Strange, I can't understand why that would be required. The default should contain the entire image. Never mind

  7. #7
    Master Sorcerer
    Join Date
    Sep 2006
    Location
    Denmark
    Posts
    554

    Default

    His original method did not work because he was using clanGUI with the texture WM. That meant the reset_framebuffer call did not restore the gc to the framebuffer used by the WM.

Similar Threads

  1. Best way to render big background?
    By rggjan in forum Official ClanLib SDK Forums
    Replies: 8
    Last Post: 08-11-2011, 02:55 PM
  2. Render to texture
    By Ockonal in forum Official ClanLib SDK Forums
    Replies: 3
    Last Post: 06-23-2011, 10:29 AM
  3. Software render fail
    By Ockonal in forum Official ClanLib SDK Forums
    Replies: 2
    Last Post: 12-24-2010, 10:32 PM
  4. Render Targets
    By ShadowDust in forum Novashell Game Creation System
    Replies: 0
    Last Post: 12-21-2008, 08:13 AM
  5. Rendering into my custom image and then drawing this image to the display
    By ValkaVALES in forum Official ClanLib SDK Forums
    Replies: 4
    Last Post: 07-03-2007, 09:53 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
  •