本文整理汇总了C++中CL_GraphicContext::set_frame_buffer方法的典型用法代码示例。如果您正苦于以下问题:C++ CL_GraphicContext::set_frame_buffer方法的具体用法?C++ CL_GraphicContext::set_frame_buffer怎么用?C++ CL_GraphicContext::set_frame_buffer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CL_GraphicContext
的用法示例。
在下文中一共展示了CL_GraphicContext::set_frame_buffer方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getTexture
CL_Texture ContainerRenderer::getTexture(CL_GraphicContext& gc) {
if (renderQueue_->requireWorldRepaint() || texture_.is_null()) {
checkTextureSize(gc);
CL_FrameBuffer origBuffer = gc.get_write_frame_buffer();
gc.set_frame_buffer(frameBuffer_);
render(gc);
gc.set_frame_buffer(origBuffer);
}
return texture_;
}
示例2: begin
void ShaderImpl::begin(CL_GraphicContext &p_gc)
{
G_ASSERT(m_initialized);
G_ASSERT(!m_began);
// new texture
m_drawRect = m_parent->getDrawRect(m_boundRect);
m_texture = CL_Texture(p_gc, m_drawRect.get_width(), m_drawRect.get_height());
// attach frame buffer
m_frameBuffer.attach_color_buffer(0, m_texture);
p_gc.set_frame_buffer(m_frameBuffer);
// clear to transparent
p_gc.clear(CL_Colorf::transparent);
// set proper matrix
p_gc.push_modelview();
// get scaling in count
const CL_Mat4f &matrix = p_gc.get_modelview();
const float scaleX = matrix[0];
const float scaleY = matrix[5];
p_gc.mult_translate(-m_drawRect.left / scaleX, -m_drawRect.top / scaleY);
m_began = true;
}
示例3: render_from_lightsource
void App::render_from_lightsource(CL_GraphicContext &gc, CL_FrameBuffer &framebuffer)
{
CL_PrimitivesArray prim_array(gc);
gc.set_frame_buffer(framebuffer);
gc.set_map_mode(cl_user_projection);
CL_Rect viewport_rect2(0, 0, CL_Size(scene.gs->texture_shadow.get_width(), scene.gs->texture_shadow.get_height()));
gc.set_viewport(viewport_rect2);
CL_Mat4f perp = CL_Mat4f::perspective(67.0f, 1.0f, 0.1f, 1000.0f);
gc.set_projection(scene.gs->light_projection);
CL_BufferControl buffer_control;
buffer_control.set_depth_compare_function(cl_comparefunc_lequal);
buffer_control.enable_depth_write(true);
buffer_control.enable_depth_test(true);
buffer_control.enable_stencil_test(false);
buffer_control.enable_color_write(false);
gc.set_buffer_control(buffer_control);
gc.clear_depth(1.0f);
CL_Mat4f modelview_matrix = scene.gs->light_modelview;
scene.Draw(modelview_matrix, gc, true);
gc.reset_program_object();
gc.set_modelview(CL_Mat4f::identity());
gc.set_map_mode(CL_MapMode(cl_map_2d_upper_left));
gc.reset_frame_buffer();
}
示例4: update_text
void ExampleText::update_text(CL_GraphicContext &gc, CL_FrameBuffer &fb_text, CL_Font &font, std::vector<CL_SpanLayout> &layout)
{
gc.set_frame_buffer(fb_text);
CL_Draw::fill(gc, 0.0f, 0.0f, (float)text_window_size, (float)text_window_size, CL_Colorf(0.0f, 0.0f, 0.0f, 1.0f));
CL_String text(cl_format("Frames per second = %1", last_fps));
font.draw_text(gc, 20, 20, text, CL_Colorf::white);
for (unsigned int line_count = 0; line_count < layout.size(); line_count++)
{
layout[line_count].draw_layout(gc);
}
gc.reset_frame_buffer();
}
示例5: start
int App::start(const std::vector<CL_String> &args)
{
CL_OpenGLWindowDescription description;
description.set_title("NightVision Shader");
description.set_size(CL_Size(1024, 768), true);
CL_DisplayWindow window(description);
CL_InputDevice keyboard = window.get_ic().get_keyboard();
CL_GraphicContext gc = window.get_gc();
CL_Slot slot_input_up = (window.get_ic().get_keyboard()).sig_key_up().connect(this, &App::on_input_up);
CL_Slot slot_window_close = window.sig_window_close().connect(this, &App::window_close);
// Create offscreen texture
CL_Texture texture_offscreen(gc, gc.get_width(), gc.get_height());
texture_offscreen.set_min_filter(cl_filter_nearest);
texture_offscreen.set_mag_filter(cl_filter_nearest);
CL_Texture texture_mask(gc, gc.get_width(), gc.get_height());
texture_mask.set_min_filter(cl_filter_nearest);
texture_mask.set_mag_filter(cl_filter_nearest);
// Create offscreen framebuffer
CL_FrameBuffer framebuffer_offscreen(gc);
framebuffer_offscreen.attach_color_buffer(0, texture_offscreen);
CL_FrameBuffer framebuffer_mask(gc);
framebuffer_mask.attach_color_buffer(0, texture_mask);
CL_Image background(gc, "../PostProcessing/Resources/background.png");
CL_Image ball(gc, "../PostProcessing/Resources/ball.png");
ball.set_alignment(origin_center);
CL_Texture noise_texture(gc, "Resources/noise_texture_0001.png");
noise_texture.set_wrap_mode(cl_wrap_repeat, cl_wrap_repeat);
// Load and link shaders
CL_ProgramObject shader = CL_ProgramObject::load(gc, "Resources/vertex_shader.glsl", "Resources/fragment_shader.glsl");
shader.bind_attribute_location(0, "Position");
shader.bind_attribute_location(2, "TexCoord0");
if (!shader.link())
throw CL_Exception("Unable to link shader program: Error:" + shader.get_info_log());
quit = false;
float amount = 0.0f;
float timer = 0.0f;
float scale = 1.0f;
CL_Font font(gc, "tahoma", 32);
// Shader based on: http://www.geeks3d.com/20091009/shader-library-night-vision-post-processing-filter-glsl/
elapsedTime = 0.0f; // seconds
luminanceThreshold = 0.2f;
colorAmplification = 4.0f;
effectCoverage = 0.65f;
// Render the mask
gc.set_frame_buffer(framebuffer_mask);
gc.clear();
for (float offset=0.0f; offset<=1.0f; offset+=0.01f)
{
CL_Draw::circle(gc, gc.get_width() / 2.0f, gc.get_height() / 2.0f, 400.0f - offset * 64.0f, CL_Colorf(offset, offset, offset, 1.0f));
}
gc.reset_frame_buffer();
unsigned int startTime = CL_System::get_time();
while (!quit)
{
timer = (CL_System::get_time() - startTime) / 1000.0f;
elapsedTime = timer;
// Render standard image to offscreen buffer
gc.set_frame_buffer(framebuffer_offscreen);
background.draw(gc, 0, 0);
ball.draw(gc, gc.get_width() / 2 + 200 * sinf(timer / 2.0f), gc.get_height() / 2 + 200 * cosf(timer / 2.0f));
gc.reset_frame_buffer();
render_night_vision(gc, texture_offscreen, texture_mask, noise_texture, shader);
const int gap = 32;
font.draw_text(gc, 10, 64+gap*0, CL_String("luminanceThreshold : " + CL_StringHelp::float_to_text(luminanceThreshold) + " (Press Q,W)" ));
font.draw_text(gc, 10, 64+gap*1, CL_String("colorAmplification : " + CL_StringHelp::float_to_text(colorAmplification) + " (Press A,S)" ));
font.draw_text(gc, 10, 64+gap*2, CL_String("effectCoverage : " + CL_StringHelp::float_to_text(effectCoverage) + " (Press Z,X)" ));
window.flip();
CL_System::sleep(10);
CL_KeepAlive::process();
}
return 0;
}
示例6: start
int App::start(const std::vector<CL_String> &args)
{
CL_OpenGLWindowDescription description;
description.set_title("Guassian Blur Shader");
description.set_size(CL_Size(1024, 768), true);
CL_DisplayWindow window(description);
CL_InputDevice keyboard = window.get_ic().get_keyboard();
CL_GraphicContext gc = window.get_gc();
CL_Slot slot_input_up = (window.get_ic().get_keyboard()).sig_key_up().connect(this, &App::on_input_up);
CL_Slot slot_window_close = window.sig_window_close().connect(this, &App::window_close);
// Create offscreen texture
CL_Texture texture_offscreen(gc, gc.get_width(), gc.get_height());
texture_offscreen.set_min_filter(cl_filter_nearest);
texture_offscreen.set_mag_filter(cl_filter_nearest);
CL_Texture texture_offscreen2(gc, gc.get_width(), gc.get_height());
texture_offscreen2.set_min_filter(cl_filter_nearest);
texture_offscreen2.set_mag_filter(cl_filter_nearest);
// Create offscreen framebuffer
CL_FrameBuffer framebuffer_offscreen(gc);
framebuffer_offscreen.attach_color_buffer(0, texture_offscreen);
CL_FrameBuffer framebuffer_offscreen2(gc);
framebuffer_offscreen2.attach_color_buffer(0, texture_offscreen2);
CL_Image background(gc, "../PostProcessing/Resources/background.png");
CL_Image ball(gc, "../PostProcessing/Resources/ball.png");
ball.set_alignment(origin_center);
// Load and link shaders
CL_ProgramObject shader = CL_ProgramObject::load(gc, "Resources/vertex_shader.glsl", "Resources/fragment_shader.glsl");
shader.bind_attribute_location(0, "Position");
shader.bind_attribute_location(2, "TexCoord0");
if (!shader.link())
throw CL_Exception("Unable to link shader program: Error:" + shader.get_info_log());
quit = false;
float amount = 0.0f;
float timer = 0.0f;
float scale = 1.0f;
CL_Font font(gc, "tahoma", 32);
blur = 1.0f;
unsigned int startTime = CL_System::get_time();
while (!quit)
{
timer = (CL_System::get_time() - startTime) / 1000.0f;
// Render standard image to offscreen buffer
gc.set_frame_buffer(framebuffer_offscreen);
background.draw(gc, 0, 0);
ball.draw(gc, gc.get_width() / 2 + 200 * sinf(timer / 2.0f), gc.get_height() / 2 + 200 * cosf(timer / 2.0f));
gc.reset_frame_buffer();
gc.set_frame_buffer(framebuffer_offscreen2);
render_gaussian_blur(gc, blur, texture_offscreen, shader, 1.0f / texture_offscreen2.get_width(), 0.0f);
gc.reset_frame_buffer();
render_gaussian_blur(gc, blur, texture_offscreen2, shader, 0.0f, 1.0f / texture_offscreen2.get_height());
CL_String text( "Press 1 to 9 to control blur amount. Currently it is :" + CL_StringHelp::float_to_text(blur) );
font.draw_text(gc, 10, 64, text);
window.flip();
CL_System::sleep(10);
CL_KeepAlive::process();
}
return 0;
}