PDA

View Full Version : Render to Image



JoseMan
08-10-2011, 07:31 PM
Hi Forum,

I've got a problem.
I am using something like this:


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 ^^....

JoseMan
08-11-2011, 07:13 PM
Okay,

I hade done something like this:


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(),mRectOnSc reenToRender);
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 :(

rombust
08-12-2011, 06:27 PM
Try replacing


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

With....


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...


CL_Draw::texture(gc, CL_Rectf(xoffset,yoffset, texture.get_size() ));

If scaling is not required

JoseMan
08-12-2011, 07:05 PM
No... still black screen :(

My whole 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(),mRectOnSc reenToRender);
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".

JoseMan
08-12-2011, 07:50 PM
Ok, I ( thanks judas) fixed the problem, cause the reason why I had try this, is to clip a region.


gc.set_cliprect(mRectOnScreenToRender);
mRenderer.draw(gc,mViewOfSpielfeld.get(),mRectOnSc reenToRender);
gc.reset_cliprect();

rombust
08-13-2011, 06:58 AM
Strange, I can't understand why that would be required. The default should contain the entire image. Never mind :)

Magnus Norddahl
08-13-2011, 08:28 AM
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.