本文整理汇总了C++中safe_ptr::attach方法的典型用法代码示例。如果您正苦于以下问题:C++ safe_ptr::attach方法的具体用法?C++ safe_ptr::attach怎么用?C++ safe_ptr::attach使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类safe_ptr
的用法示例。
在下文中一共展示了safe_ptr::attach方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: post_process
void post_process(
const safe_ptr<device_buffer>& background, bool straighten_alpha)
{
bool should_post_process =
supports_texture_barrier_
&& straighten_alpha
&& post_processing_;
if (!should_post_process)
return;
if (!blend_modes_)
ogl_->disable(GL_BLEND);
ogl_->disable(GL_POLYGON_STIPPLE);
ogl_->attach(*background);
background->bind(texture_id::background);
ogl_->use(*shader_);
shader_->set("background", texture_id::background);
shader_->set("post_processing", should_post_process);
shader_->set("straighten_alpha", straighten_alpha);
ogl_->viewport(0, 0, background->width(), background->height());
glBegin(GL_QUADS);
glMultiTexCoord2d(GL_TEXTURE0, 0.0, 0.0); glVertex2d(-1.0, -1.0);
glMultiTexCoord2d(GL_TEXTURE0, 1.0, 0.0); glVertex2d( 1.0, -1.0);
glMultiTexCoord2d(GL_TEXTURE0, 1.0, 1.0); glVertex2d( 1.0, 1.0);
glMultiTexCoord2d(GL_TEXTURE0, 0.0, 1.0); glVertex2d(-1.0, 1.0);
glEnd();
glTextureBarrierNV();
if (!blend_modes_)
ogl_->enable(GL_BLEND);
}
示例2: draw
//.........这里部分代码省略.........
}
// Setup image-adjustements
if(params.transform.levels.min_input > epsilon ||
params.transform.levels.max_input < 1.0-epsilon ||
params.transform.levels.min_output > epsilon ||
params.transform.levels.max_output < 1.0-epsilon ||
std::abs(params.transform.levels.gamma - 1.0) > epsilon)
{
shader_->set("levels", true);
shader_->set("min_input", params.transform.levels.min_input);
shader_->set("max_input", params.transform.levels.max_input);
shader_->set("min_output", params.transform.levels.min_output);
shader_->set("max_output", params.transform.levels.max_output);
shader_->set("gamma", params.transform.levels.gamma);
}
else
shader_->set("levels", false);
if(std::abs(params.transform.brightness - 1.0) > epsilon ||
std::abs(params.transform.saturation - 1.0) > epsilon ||
std::abs(params.transform.contrast - 1.0) > epsilon)
{
shader_->set("csb", true);
shader_->set("brt", params.transform.brightness);
shader_->set("sat", params.transform.saturation);
shader_->set("con", params.transform.contrast);
}
else
shader_->set("csb", false);
// Setup interlacing
if(params.transform.field_mode == core::field_mode::progressive)
ogl_->disable(GL_POLYGON_STIPPLE);
else
{
ogl_->enable(GL_POLYGON_STIPPLE);
if(params.transform.field_mode == core::field_mode::upper)
ogl_->stipple_pattern(upper_pattern);
else if(params.transform.field_mode == core::field_mode::lower)
ogl_->stipple_pattern(lower_pattern);
}
// Setup drawing area
ogl_->viewport(0, 0, params.background->width(), params.background->height());
auto m_p = params.transform.clip_translation;
auto m_s = params.transform.clip_scale;
bool scissor = m_p[0] > std::numeric_limits<double>::epsilon() || m_p[1] > std::numeric_limits<double>::epsilon() ||
m_s[0] < (1.0 - std::numeric_limits<double>::epsilon()) || m_s[1] < (1.0 - std::numeric_limits<double>::epsilon());
if(scissor)
{
double w = static_cast<double>(params.background->width());
double h = static_cast<double>(params.background->height());
ogl_->enable(GL_SCISSOR_TEST);
ogl_->scissor(static_cast<size_t>(m_p[0]*w), static_cast<size_t>(m_p[1]*h), static_cast<size_t>(m_s[0]*w), static_cast<size_t>(m_s[1]*h));
}
auto f_p = params.transform.fill_translation;
auto f_s = params.transform.fill_scale;
// Set render target
ogl_->attach(*params.background);
// Draw
/*
GL_TEXTURE0 are texture coordinates to the source material, what will be rendered with this call. These are always set to the whole thing.
GL_TEXTURE1 are texture coordinates to background- / key-material, that which will have to be taken in consideration when blending. These are set to the rectangle over which the source will be rendered
*/
glBegin(GL_QUADS);
glMultiTexCoord2d(GL_TEXTURE0, 0.0, 0.0); glMultiTexCoord2d(GL_TEXTURE1, f_p[0] , f_p[1] ); glVertex2d( f_p[0] *2.0-1.0, f_p[1] *2.0-1.0);
glMultiTexCoord2d(GL_TEXTURE0, 1.0, 0.0); glMultiTexCoord2d(GL_TEXTURE1, (f_p[0]+f_s[0]), f_p[1] ); glVertex2d((f_p[0]+f_s[0])*2.0-1.0, f_p[1] *2.0-1.0);
glMultiTexCoord2d(GL_TEXTURE0, 1.0, 1.0); glMultiTexCoord2d(GL_TEXTURE1, (f_p[0]+f_s[0]), (f_p[1]+f_s[1])); glVertex2d((f_p[0]+f_s[0])*2.0-1.0, (f_p[1]+f_s[1])*2.0-1.0);
glMultiTexCoord2d(GL_TEXTURE0, 0.0, 1.0); glMultiTexCoord2d(GL_TEXTURE1, f_p[0] , (f_p[1]+f_s[1])); glVertex2d( f_p[0] *2.0-1.0, (f_p[1]+f_s[1])*2.0-1.0);
glEnd();
// Cleanup
ogl_->disable(GL_SCISSOR_TEST);
params.textures.clear();
ogl_->yield(); // Return resources to pool as early as possible.
if(blend_modes_)
{
// http://www.opengl.org/registry/specs/NV/texture_barrier.txt
// This allows us to use framebuffer (background) both as source and target while blending.
glTextureBarrierNV();
}
}