本文整理汇总了C++中clan::Canvas::flush方法的典型用法代码示例。如果您正苦于以下问题:C++ Canvas::flush方法的具体用法?C++ Canvas::flush怎么用?C++ Canvas::flush使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类clan::Canvas
的用法示例。
在下文中一共展示了Canvas::flush方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: render_bloom_combine
void App::render_bloom_combine(clan::Canvas &canvas, clan::Texture2D &tex_base, clan::Texture2D &tex_bloom, clan::ProgramObject &program_object)
{
canvas.flush();
clan::GraphicContext gc = canvas.get_gc();
gc.set_texture(0, tex_base);
gc.set_texture(1, tex_bloom);
gc.set_program_object(program_object);
program_object.set_uniform1i(("BaseTexture"), 0);
program_object.set_uniform1f(("BaseIntensity"), base_intensity);
program_object.set_uniform1f(("BaseSaturation"), base_saturation);
program_object.set_uniform1i(("BloomTexture"), 1);
program_object.set_uniform1f(("BloomIntensity"), bloom_intensity);
program_object.set_uniform1f(("BloomSaturation"), bloom_saturation);
program_object.set_uniform_matrix("cl_ModelViewProjectionMatrix", canvas.get_projection() * canvas.get_transform());
draw_texture(gc, clan::Rectf(0,0,canvas.get_width(),canvas.get_height()), clan::Rectf(0.0f, 0.0f, 1.0f, 1.0f));
gc.reset_program_object();
gc.reset_texture(0);
gc.reset_texture(1);
}
示例2: get_stencil
clan::Image App::get_stencil(clan::Canvas &canvas, clan::Rect rect)
{
canvas.flush();
// For an unknown reason, stencil reads should be a multiple of 32
rect.left = 32 * ((rect.left + 31) / 32);
rect.top = 32 * ((rect.top + 31) / 32);
rect.right = 32 * ((rect.right + 31) / 32);
rect.bottom = 32 * ((rect.bottom + 31) / 32);
int rect_width = rect.get_width();
int rect_height = rect.get_height();
std::vector<unsigned char> buffer;
buffer.resize(rect_width * rect_height);
glPixelStorei(GL_PACK_ALIGNMENT, 1);
glPixelStorei(GL_PACK_ROW_LENGTH, rect_width);
glPixelStorei(GL_PACK_SKIP_PIXELS, 0);
glPixelStorei(GL_PACK_SKIP_ROWS, 0);
glReadBuffer(GL_BACK);
if (glClampColor)
{
#ifdef GL_CLAMP_READ_COLOR
glClampColor(GL_CLAMP_READ_COLOR, GL_FALSE);
#else
glClampColor(clan::GL_CLAMP_READ_COLOR, GL_FALSE);
#endif
}
glReadPixels(rect.left, canvas.get_height()- rect.bottom, rect_width, rect_height, GL_STENCIL_INDEX, GL_UNSIGNED_BYTE, &buffer[0]);
clan::PixelBuffer pbuf(rect_width, rect_height, clan::tf_rgba8);
unsigned int *pdata = (unsigned int *) pbuf.get_data();
unsigned char *rdata = &buffer[0];
for (int ycnt=0; ycnt < rect_height; ycnt++)
{
for (int xcnt=0; xcnt < rect_width; xcnt++)
{
int value = *(rdata++);
if (value == 0)
{
*(pdata++) = 0xFF005500;
}
else
{
value = value * 16;
value = 0xFF000000 | value | (value << 8) | (value << 16);
*(pdata++) = value;
}
}
}
pbuf.flip_vertical();
return clan::Image(canvas, pbuf, pbuf.get_size());
}
示例3: render_gaussian_blur
void App::render_gaussian_blur(clan::Canvas &canvas, float blur_amount, clan::Texture2D &source_texture, clan::ProgramObject &program_object, float dx, float dy)
{
uniforms.sample[0].weight = compute_gaussian(0, blur_amount);
uniforms.sample[0].offset_x = 0.0f;
uniforms.sample[0].offset_y = 0.0f;
float totalWeights = uniforms.sample[0].weight;
for (int i = 0; i < sampleCount / 2; i++)
{
float weight = compute_gaussian(i + 1.0f, blur_amount);
uniforms.sample[i * 2 + 1].weight = weight;
uniforms.sample[i * 2 + 2].weight = weight;
totalWeights += weight * 2;
float sampleOffset = i * 2 + 1.5f;
clan::Vec2f delta(dx * sampleOffset, dy * sampleOffset);
uniforms.sample[i * 2 + 1].offset_x = delta.x;
uniforms.sample[i * 2 + 1].offset_y = delta.y;
uniforms.sample[i * 2 + 2].offset_x = -delta.x;
uniforms.sample[i * 2 + 2].offset_y = -delta.y;
}
for (int i = 0; i < sampleCount; i++)
{
uniforms.sample[i].weight /= totalWeights;
}
canvas.flush();
clan::GraphicContext gc = canvas.get_gc();
gc.set_texture(0, source_texture);
gc.set_program_object(program_object);
uniforms.cl_ModelViewProjectionMatrix = canvas.get_projection() * canvas.get_transform();
gpu_uniforms.upload_data(gc, &uniforms, 1);
gc.set_uniform_buffer(0, gpu_uniforms);
draw_texture(gc, clan::Rectf(0,0,canvas.get_width(),canvas.get_height()), clan::Rectf(0.0f, 0.0f, 1.0f, 1.0f));
gc.reset_program_object();
gc.reset_texture(0);
}
示例4: render_shockwave
void App::render_shockwave(clan::Canvas &canvas, clan::Texture2D &source_texture, clan::ProgramObject &program_object)
{
canvas.flush();
clan::GraphicContext gc = canvas.get_gc();
gc.set_texture(0, source_texture);
gc.set_program_object(program_object);
uniforms.cl_ModelViewProjectionMatrix = canvas.get_projection() * canvas.get_modelview();
gpu_uniforms.upload_data(gc, &uniforms, 1);
gc.set_uniform_buffer(0, gpu_uniforms);
draw_texture(gc, clan::Rectf(0,0,canvas.get_width(),canvas.get_height()), clan::Rectf(0.0f, 0.0f, 1.0f, 1.0f));
gc.reset_program_object();
gc.reset_texture(0);
}
示例5: render_extract_highlights
void App::render_extract_highlights(clan::Canvas &canvas, clan::Texture2D &source_texture, clan::ProgramObject &program_object)
{
canvas.flush();
clan::GraphicContext gc = canvas.get_gc();
gc.set_texture(0, source_texture);
gc.set_program_object(program_object);
program_object.set_uniform1i(("SourceTexture"), 0);
program_object.set_uniform1f(("Threshold"), highlight_threshold);
program_object.set_uniform_matrix("cl_ModelViewProjectionMatrix", canvas.get_projection() * canvas.get_transform());
draw_texture(gc, clan::Rectf(0,0,canvas.get_width(),canvas.get_height()), clan::Rectf(0.0f, 0.0f, 1.0f, 1.0f));
gc.reset_program_object();
gc.reset_texture(0);
}