本文整理汇总了C++中CL_GraphicContext::get_size方法的典型用法代码示例。如果您正苦于以下问题:C++ CL_GraphicContext::get_size方法的具体用法?C++ CL_GraphicContext::get_size怎么用?C++ CL_GraphicContext::get_size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CL_GraphicContext
的用法示例。
在下文中一共展示了CL_GraphicContext::get_size方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
GraphicStore::GraphicStore(CL_GraphicContext &gc) : shader_color_geometry(gc)
{
// Create a depth buffer
framebuffer_depth = CL_FrameBuffer(gc);
texture_depth = CL_Texture(gc, gc.get_size(), cl_depth_component);
texture_depth.set_wrap_mode(cl_wrap_clamp_to_edge, cl_wrap_clamp_to_edge, cl_wrap_clamp_to_edge);
framebuffer_depth.attach_depth_buffer(texture_depth);
// Load graphics
texture_alpha_ball = CL_Texture(gc, "Resources/alpha_ball2.png");
//texture_alpha_ball = CL_Texture(gc, "Resources/alpha_ball.png");
texture_alpha_ball.set_wrap_mode(cl_wrap_clamp_to_edge, cl_wrap_clamp_to_edge, cl_wrap_clamp_to_edge);
}
示例2: start
// The start of the Application
int App::start(const std::vector<CL_String> &args)
{
CL_DisplayWindowDescription win_desc;
win_desc.set_allow_resize(true);
win_desc.set_stencil_size(8);
// For simplicity this example does not use the depth components
//win_desc.set_depth_size(16);
win_desc.set_title("Stencil Example");
win_desc.set_size(CL_Size( 900, 570 ), false);
CL_DisplayWindow window(win_desc);
CL_Slot slot_quit = window.sig_window_close().connect(this, &App::on_window_close);
CL_Slot slot_input_up = (window.get_ic().get_keyboard()).sig_key_up().connect(this, &App::on_input_up);
CL_String theme;
if (CL_FileHelp::file_exists("../../../Resources/GUIThemeAero/theme.css"))
theme = "../../../Resources/GUIThemeAero";
else if (CL_FileHelp::file_exists("../../../Resources/GUIThemeBasic/theme.css"))
theme = "../../../Resources/GUIThemeBasic";
else
throw CL_Exception("No themes found");
CL_GUIWindowManagerTexture wm(window);
CL_GUIManager gui(wm, theme);
CL_GraphicContext gc = window.get_gc();
// Deleted automatically by the GUI
Options *options = new Options(gui, CL_Rect(0, 0, gc.get_size()));
CL_Image image_grid(gc, "../Blend/Resources/grid.png");
CL_Image image_ball(gc, "../Blend/Resources/ball.png");
grid_space = (float) (image_grid.get_width() - image_ball.get_width());
setup_balls();
CL_BufferControl buffer_control;
CL_BufferControl default_buffer_control;
options->request_repaint();
CL_Font font(gc, "Tahoma", 24);
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_balls = options->num_balls;
if (num_balls > max_balls)
num_balls = max_balls;
if (options->is_moveballs_set)
move_balls(time_diff, num_balls);
gc.clear_stencil(0);
// Draw the grid
const float grid_xpos = 10.0f;
const float grid_ypos = 10.0f;
image_grid.draw(gc, grid_xpos, grid_ypos);
// Draw the circle onto the stencil
if (options->is_circle_set)
{
buffer_control.enable_logic_op(false);
buffer_control.enable_stencil_test(true);
buffer_control.set_stencil_compare_func(cl_comparefunc_always, cl_comparefunc_always);
buffer_control.set_stencil_fail(cl_stencil_incr_wrap, cl_stencil_incr_wrap);
buffer_control.set_stencil_pass_depth_fail(cl_stencil_incr_wrap, cl_stencil_incr_wrap);
buffer_control.set_stencil_pass_depth_pass(cl_stencil_incr_wrap, cl_stencil_incr_wrap);
buffer_control.enable_color_write(false);
buffer_control.enable_depth_write(false);
buffer_control.enable_depth_test(false);
gc.set_buffer_control(buffer_control);
CL_Draw::circle(gc, grid_xpos + image_grid.get_width()/2, grid_ypos + image_grid.get_height()/2, 100, CL_Colorf::white);
}
buffer_control.enable_color_write(true);
buffer_control.enable_logic_op(false);
buffer_control.enable_stencil_test(true);
buffer_control.set_stencil_compare_func(options->compare_function, options->compare_function);
buffer_control.set_stencil_compare_reference(options->compare_reference, options->compare_reference);
buffer_control.set_stencil_write_mask(255, 255);
buffer_control.set_stencil_compare_mask(255, 255);
buffer_control.set_stencil_fail(options->stencil_fail, options->stencil_fail);;
// Note, depth testing disabled for this example
buffer_control.set_stencil_pass_depth_fail(options->stencil_pass, options->stencil_pass);
buffer_control.set_stencil_pass_depth_pass(options->stencil_pass, options->stencil_pass);
//.........这里部分代码省略.........
示例3: start
// The start of the Application
int App::start(const std::vector<CL_String> &args)
{
CL_OpenGLWindowDescription win_desc;
//win_desc.set_version(3, 2, false);
win_desc.set_allow_resize(true);
win_desc.set_title("Point Sprite Example");
win_desc.set_size(CL_Size( 800, 480 ), false);
CL_DisplayWindow window(win_desc);
CL_Slot slot_quit = window.sig_window_close().connect(this, &App::on_window_close);
CL_Slot slot_input_up = (window.get_ic().get_keyboard()).sig_key_up().connect(this, &App::on_input_up);
CL_String theme;
if (CL_FileHelp::file_exists("../../../Resources/GUIThemeAero/theme.css"))
theme = "../../../Resources/GUIThemeAero";
else if (CL_FileHelp::file_exists("../../../Resources/GUIThemeBasic/theme.css"))
theme = "../../../Resources/GUIThemeBasic";
else
throw CL_Exception("No themes found");
CL_GUIWindowManagerTexture wm(window);
CL_GUIManager gui(wm, theme);
CL_GraphicContext gc = window.get_gc();
// Deleted automatically by the GUI
Options *options = new Options(gui, CL_Rect(0, 0, gc.get_size()));
CL_Image image_grid(gc, "../Blend/Resources/grid.png");
CL_Texture texture_particle(gc, "Resources/particle.png");
float grid_width = (float) image_grid.get_width();
float grid_height = (float) image_grid.get_height();
grid_space = (float) (image_grid.get_width());
setup_particles();
CL_ShaderObject vertex_shader(gc, cl_shadertype_vertex, text_shader_vertex);
if(!vertex_shader.compile())
{
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;
//.........这里部分代码省略.........
示例4: start
// The start of the Application
int App::start(const std::vector<CL_String> &args)
{
CL_DisplayWindowDescription win_desc;
win_desc.set_allow_resize(true);
win_desc.set_title("MapMode Example");
win_desc.set_size(CL_Size( 800, 480 ), false);
CL_DisplayWindow window(win_desc);
CL_Slot slot_quit = window.sig_window_close().connect(this, &App::on_window_close);
CL_Slot slot_input_up = (window.get_ic().get_keyboard()).sig_key_up().connect(this, &App::on_input_up);
CL_String theme;
if (CL_FileHelp::file_exists("../../../Resources/GUIThemeAero/theme.css"))
theme = "../../../Resources/GUIThemeAero";
else if (CL_FileHelp::file_exists("../../../Resources/GUIThemeBasic/theme.css"))
theme = "../../../Resources/GUIThemeBasic";
else
throw CL_Exception("No themes found");
CL_GUIWindowManagerTexture wm(window);
CL_GUIManager gui(wm, theme);
CL_GraphicContext gc = window.get_gc();
// Deleted automatically by the GUI
Options *options = new Options(gui, CL_Rect(0, 0, gc.get_size()));
CL_Image image_grid(gc, "../Blend/Resources/grid.png");
CL_Image image_ball(gc, "../Blend/Resources/ball.png");
float grid_width = (float) image_grid.get_width();
float grid_height = (float) image_grid.get_height();
grid_space = (float) (image_grid.get_width() - image_ball.get_width());
setup_balls();
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_balls = options->num_balls;
if (num_balls > max_balls)
num_balls = max_balls;
if (options->is_moveballs_set)
move_balls(time_diff, num_balls);
gc.set_map_mode(options->current_mapmode);
const float grid_xpos = 10.0f;
const float grid_ypos = 10.0f;
if (options->current_mapmode == cl_user_projection)
{
CL_Sizef area_size(grid_width + (grid_xpos * 2.0f), grid_height + (grid_ypos * 2.0f));
set_user_projection(gc, area_size, options);
}
// Draw the grid
image_grid.draw(gc, grid_xpos, grid_ypos);
gc.flush_batcher(); // <--- Fix me, this should not be required for cl_user_projection
for (int cnt=0; cnt<num_balls; cnt++)
{
image_ball.draw(gc, grid_xpos + balls[cnt].xpos, grid_ypos + balls[cnt].ypos);
}
gc.set_modelview(CL_Mat4f::identity());
gc.set_projection(CL_Mat4f::identity());
gc.set_map_mode(cl_map_2d_upper_left);
window.flip(1);
CL_KeepAlive::process();
}
return 0;
}