本文整理汇总了C++中CL_GraphicContext::set_blend_mode方法的典型用法代码示例。如果您正苦于以下问题:C++ CL_GraphicContext::set_blend_mode方法的具体用法?C++ CL_GraphicContext::set_blend_mode怎么用?C++ CL_GraphicContext::set_blend_mode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CL_GraphicContext
的用法示例。
在下文中一共展示了CL_GraphicContext::set_blend_mode方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: prim_array
void CL_RenderBatch3D::flush(CL_GraphicContext &gc)
{
if (position > 0)
{
gc.set_modelview(CL_Mat4f::identity());
gc.set_program_object(cl_program_sprite);
if (use_glyph_program)
{
CL_BlendMode old_blend_mode = gc.get_blend_mode();
CL_BlendMode blend_mode;
blend_mode.set_blend_color(constant_color);
blend_mode.set_blend_function(cl_blend_constant_color, cl_blend_one_minus_src_color, cl_blend_zero, cl_blend_one);
gc.set_blend_mode(blend_mode);
for (int i = 0; i < num_current_textures; i++)
gc.set_texture(i, current_textures[i]);
CL_PrimitivesArray prim_array(gc);
prim_array.set_attributes(0, &vertices[0].position, sizeof(SpriteVertex));
prim_array.set_attributes(1, &vertices[0].color, sizeof(SpriteVertex));
prim_array.set_attributes(2, &vertices[0].texcoord, sizeof(SpriteVertex));
prim_array.set_attributes(3, &vertices[0].texindex, sizeof(SpriteVertex));
gc.draw_primitives(cl_triangles, position, prim_array);
for (int i = 0; i < num_current_textures; i++)
gc.reset_texture(i);
gc.set_blend_mode(old_blend_mode);
}
else
{
for (int i = 0; i < num_current_textures; i++)
gc.set_texture(i, current_textures[i]);
CL_PrimitivesArray prim_array(gc);
prim_array.set_attributes(0, &vertices[0].position, sizeof(SpriteVertex));
prim_array.set_attributes(1, &vertices[0].color, sizeof(SpriteVertex));
prim_array.set_attributes(2, &vertices[0].texcoord, sizeof(SpriteVertex));
prim_array.set_attributes(3, &vertices[0].texindex, sizeof(SpriteVertex));
gc.draw_primitives(cl_triangles, position, prim_array);
for (int i = 0; i < num_current_textures; i++)
gc.reset_texture(i);
}
gc.reset_program_object();
gc.set_modelview(modelview);
position = 0;
for (int i = 0; i < num_current_textures; i++)
current_textures[i] = CL_Texture();
num_current_textures = 0;
}
}
示例2: on_render
void Options::on_render(CL_GraphicContext &gc, const CL_Rect &update_rect)
{
CL_BlendMode blendmode;
blendmode.enable_blending(false);
gc.set_blend_mode(blendmode);
CL_Draw::fill(gc, update_rect, CL_Colorf(0.4f, 0.4f, 0.6f, 0.0f));
gc.reset_blend_mode();
}
示例3: main
static int main(const std::vector<CL_String> &args)
{
try
{
CL_SetupCore setup_core;
CL_SetupDisplay setup_disp;
CL_SetupGL setup_gl;
CL_DisplayWindow window("Viewport Grid Test", 640, 480, false, true);
CL_GraphicContext gc = window.get_gc();
CL_BlendMode blend_mode1;
blend_mode1.enable_blending(true);
gc.set_blend_mode(blend_mode1);
gc.set_map_mode(cl_map_2d_upper_left);
while(!window.get_ic().get_keyboard().get_keycode(CL_KEY_ESCAPE))
{
gc.clear(CL_Colorf::white);
CL_Rect viewport = window.get_viewport();
for (int y = viewport.top; y < viewport.bottom; y+=2)
{
CL_Draw::line(gc, viewport.left, y, viewport.right, y, CL_Colorf::black);
}
for (int x = viewport.left; x < viewport.right; x+=2)
{
CL_Draw::line(gc, x, viewport.top, x, viewport.bottom, CL_Colorf::black);
}
window.flip(1);
CL_KeepAlive::process();
CL_System::sleep(10);
}
return 0;
}
catch(CL_Exception error)
{
CL_ConsoleWindow console("Console");
CL_Console::write_line("Exception caught:");
CL_Console::write_line(error.message);
console.display_close_message();
return -1;
}
return 0;
}
示例4: start
//.........这里部分代码省略.........
{
throw CL_Exception(cl_format("Unable to compile vertex shader object: %1", vertex_shader.get_info_log()));
}
CL_ShaderObject fragment_shader(gc, cl_shadertype_fragment, text_shader_fragment);
if(!fragment_shader.compile())
{
throw CL_Exception(cl_format("Unable to compile fragment shader object: %1", fragment_shader.get_info_log()));
}
CL_ProgramObject program_object(gc);
program_object.attach(vertex_shader);
program_object.attach(fragment_shader);
program_object.bind_attribute_location(0, "InPosition");
program_object.bind_attribute_location(1, "InColor");
if (!program_object.link())
{
throw CL_Exception(cl_format("Unable to link program object: %1", program_object.get_info_log()));
}
options->request_repaint();
unsigned int time_last = CL_System::get_time();
while (!quit)
{
unsigned int time_now = CL_System::get_time();
float time_diff = (float) (time_now - time_last);
time_last = time_now;
wm.process();
wm.draw_windows(gc);
int num_particles = options->num_particles;
if (num_particles > max_particles)
num_particles = max_particles;
move_particles(time_diff, num_particles);
const float grid_xpos = 10.0f;
const float grid_ypos = 10.0f;
// Draw the grid
image_grid.draw(gc, grid_xpos, grid_ypos);
if (num_particles > 0)
{
std::vector<CL_Vec2f> positions;
std::vector<CL_Vec4f> colors;
positions.resize(num_particles);
colors.resize(num_particles);
for (int cnt=0; cnt<num_particles; cnt++)
{
positions[cnt] = CL_Vec2f(grid_xpos + particles[cnt].xpos, grid_ypos + particles[cnt].ypos);
switch (cnt % 3)
{
case 0:
colors[cnt] = CL_Vec4f(1.0f, 0.0f, 0.0f, 1.0f);
break;
case 1:
colors[cnt] = CL_Vec4f(0.0f, 1.0f, 0.0f, 1.0f);
break;
case 2:
colors[cnt] = CL_Vec4f(0.0f, 0.0f, 1.0f, 1.0f);
break;
}
};
CL_BlendMode blend;
blend.enable_blending(true);
blend.set_blend_function(cl_blend_src_alpha, cl_blend_one, cl_blend_src_alpha, cl_blend_one);
gc.set_blend_mode(blend);
CL_Pen pen;
pen.enable_point_sprite(true);
pen.set_point_size(options->point_size);
pen.set_point_sprite_origin(cl_point_sprite_origin_upper_left);
gc.set_pen(pen);
program_object.set_uniform1i("Texture0", 0);
gc.set_texture(0, texture_particle);
CL_PrimitivesArray prim_array(gc);
prim_array.set_attributes(0, &positions[0]);
prim_array.set_attributes(1, &colors[0]);
gc.set_program_object(program_object);
gc.draw_primitives(cl_points, num_particles, prim_array);
gc.reset_program_object();
gc.reset_texture(0);
gc.reset_blend_mode();
gc.reset_pen();
}
window.flip(1);
CL_KeepAlive::process();
}
return 0;
}
示例5: start
int start(const std::vector<CL_String> &args)
{
CL_ConsoleWindow console("Console");
try
{
CL_DisplayWindow window("Image test", 1024, 768);
CL_GraphicContext gc = window.get_gc();
// Connect the Window close event
CL_Slot slot_quit = window.sig_window_close().connect(this, &App::on_window_close);
CL_BlendMode blend_mode1;
blend_mode1.enable_blending(true);
gc.set_blend_mode(blend_mode1);
quit = false;
CL_ResourceManager resources("resources.xml");
CL_Texture texture(gc, "Images/square.png");
CL_Image image_texture(gc, texture, CL_Rect(0, 0, texture.get_size()));
CL_Image image_loaded(gc, "Images/square.png");
CL_Image image_resources(gc, "entire_image", &resources);
CL_Image image_copy(image_texture);
CL_Image image_top_right(gc, "image_top_right", &resources);
CL_Image image_bottom_right(gc, "image_bottom_right", &resources);
CL_Image image_black(gc, "image_black", &resources);
CL_Font small_font = CL_Font(gc, "Tahoma", 12);
//CL_Console::write_line("Color: %1,%2,%3,%4", image_resources.get_color().r, image_resources.get_color().g, image_resources.get_color().b, image_resources.get_color().a);
//CL_Console::write_line("Scale: %1,%2", image_resources.get_scale_x(), image_resources.get_scale_y());
//CL_Console::write_line("Translation: %1,%2,%3", image_resources.get_alignment());
while((!quit) && (!window.get_ic().get_keyboard().get_keycode(CL_KEY_ESCAPE)))
{
gc.clear(CL_Colorf(0.5f,0.5f,0.5f));
small_font.draw_text(gc, 10, 40, "Image From Texture (10,60)");
image_texture.draw(gc, 10, 60);
small_font.draw_text(gc, 150, 40, "Image From Load (150,60)");
image_loaded.draw(gc, 150, 60);
small_font.draw_text(gc, 300, 40, "Image From Resources (300,60)");
image_resources.draw(gc, 300, 60);
small_font.draw_text(gc, 450, 40, "Image Copied (450,60)");
image_copy.draw(gc, 450, 60);
small_font.draw_text(gc, 10, 190, "Image - Top Right (10,200)");
image_top_right.draw(gc, 10, 200);
small_font.draw_text(gc, 150, 190, "Image - Top Right (150,200)");
image_texture.draw(gc, CL_Rect(32, 0, CL_Size(32, 32)), CL_Rect(150, 200, CL_Size(32, 32)));
small_font.draw_text(gc, 300, 190, "Image - Bottom Right (300,200)");
image_bottom_right.draw(gc, 300, 200);
small_font.draw_text(gc, 450, 190, "Image - Bottom Right (450,200)");
image_texture.draw(gc, CL_Rect(32, 32, CL_Size(32, 32)), CL_Rect(450, 200, CL_Size(32, 32)));
small_font.draw_text(gc, 10, 290, "700 Images (10,300)");
for(int i=0;i<700;i++)
image_texture.draw(gc, 10, 300);
small_font.draw_text(gc, 150, 290, "br image (150,400) Size(128,256)");
image_bottom_right.draw(gc, CL_Rect(150, 300, CL_Size(128, 256)));
small_font.draw_text(gc, 300, 290, "Image - black");
image_black.draw(gc, 300, 300);
small_font.draw_text(gc, 300, 490, "Image - Scale (1.5, 2.5)");
image_texture.set_scale(1.5f, 2.5f);
image_texture.draw(gc, 300, 500);
image_texture.set_scale(1.0f, 1.0f);
small_font.draw_text(gc, 450, 460, "Image - Alignment (4 images with 8 pixel offset)");
small_font.draw_text(gc, 450, 475, "(top left, top right, bottom left, bottom right)");
small_font.draw_text(gc, 450, 490, "(Circle denotes the draw origin)");
const int offset = 96;
image_texture.set_alignment(origin_top_left, 8, 8);
image_texture.draw(gc, 450+offset, 500+offset);
image_texture.set_alignment(origin_top_right, -8, 8);
image_texture.draw(gc, 450+offset, 500+offset);
image_texture.set_alignment(origin_bottom_left, 8, -8);
image_texture.draw(gc, 450+offset, 500+offset);
image_texture.set_alignment(origin_bottom_right, -8, -8);
image_texture.draw(gc, 450+offset, 500+offset);
CL_Draw::circle(gc, 450+offset, 500+offset, 4, CL_Colorf(1.0f, 1.0f, 1.0f, 0.9f));
small_font.draw_text(gc, 700, 460, "Image - Center Alignment (4 images with 8 pixel offset)");
small_font.draw_text(gc, 700, 475, "(top center, right center, bottom center, left center)");
small_font.draw_text(gc, 700, 490, "(Circle denotes the draw origin)");
//.........这里部分代码省略.........