本文整理汇总了C++中CL_GraphicContext::set_buffer_control方法的典型用法代码示例。如果您正苦于以下问题:C++ CL_GraphicContext::set_buffer_control方法的具体用法?C++ CL_GraphicContext::set_buffer_control怎么用?C++ CL_GraphicContext::set_buffer_control使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CL_GraphicContext
的用法示例。
在下文中一共展示了CL_GraphicContext::set_buffer_control方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: render
void App::render(CL_GraphicContext &gc)
{
gc.clear(CL_Colorf(0.0f, 0.0f, 0.0f, 1.0f));
scene.gs->image_grid.draw(gc, 420.0f, 120.0f); // Draw a grid in the backgound
gc.set_map_mode(cl_user_projection);
CL_Rect viewport_rect(0, 0, CL_Size(gc.get_width(), gc.get_height()));
gc.set_viewport(viewport_rect);
gc.set_projection(scene.gs->camera_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(true);
gc.set_buffer_control(buffer_control);
gc.clear_depth(1.0f);
CL_Mat4f modelview_matrix = scene.gs->camera_modelview;
scene.Draw(modelview_matrix, gc);
gc.reset_program_object();
}
示例2: 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();
}
示例3: render_depth_buffer
void App::render_depth_buffer(CL_GraphicContext &gc)
{
gc.set_map_mode(cl_user_projection);
gc.set_viewport(scene.gs->texture_depth.get_size());
gc.set_projection(scene.gs->camera_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);
CL_Mat4f modelview_matrix = scene.gs->camera_modelview;
scene.Draw(modelview_matrix, gc);
gc.reset_program_object();
}
示例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_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);
//.........这里部分代码省略.........
示例5: start
// The start of the Application
int App::start(const std::vector<CL_String> &args)
{
quit = false;
CL_GL1WindowDescription desc;
desc.set_title("ClanLib Object 3D Example");
desc.set_size(CL_Size(640, 480), true);
desc.set_multisampling(4);
desc.set_depth_size(16);
CL_DisplayWindow window(desc);
#ifdef _DEBUG
//struct aiLogStream stream;
//stream = aiGetPredefinedLogStream(aiDefaultLogStream_STDOUT,NULL);
//aiAttachLogStream(&stream);
//stream = aiGetPredefinedLogStream(aiDefaultLogStream_FILE,"assimp_log.txt");
//aiAttachLogStream(&stream);
#endif
// Connect the Window close event
CL_Slot slot_quit = window.sig_window_close().connect(this, &App::on_window_close);
// Connect a keyboard handler to on_key_up()
CL_Slot slot_input_up = (window.get_ic().get_keyboard()).sig_key_up().connect(this, &App::on_input_up);
// Get the graphic context
CL_GraphicContext gc = window.get_gc();
#ifdef USE_OPENGL_1
CL_GraphicContext_GL1 gc_gl1 = gc;
#endif
// Prepare the display
gc.set_map_mode(cl_user_projection);
CL_PolygonRasterizer polygon_rasterizer;
polygon_rasterizer.set_culled(true);
polygon_rasterizer.set_face_cull_mode(cl_cull_back);
polygon_rasterizer.set_front_face(cl_face_side_clockwise);
gc.set_polygon_rasterizer(polygon_rasterizer);
CL_BufferControl buffer_control;
buffer_control.enable_depth_test(true);
buffer_control.set_depth_compare_function(cl_comparefunc_lequal);
buffer_control.enable_depth_write(true);
gc.set_buffer_control(buffer_control);
#ifdef USE_OPENGL_1
// Set the lights
CL_LightModel_GL1 light_model;
light_model.enable_lighting(true);
light_model.set_flat_shading(false);
light_model.set_scene_ambient_light(CL_Colorf(0.2f, 0.2f, 0.2f, 1.0f));
gc_gl1.set_light_model(light_model);
CL_LightSource_GL1 light_distant;
light_distant.set_spot_cutoff(180.0f);
light_distant.set_diffuse_intensity(CL_Colorf(1.0f, 1.0f, 1.0f, 1.0f));
light_distant.set_position(CL_Vec4f(0.0f, -2.0f, 30.0f, 0.0f).normalize3());
gc_gl1.set_light(0, light_distant);
cl1Enable(GL_NORMALIZE);
#endif
#ifdef USE_OPENGL_2
Shader shader(gc);
#endif
// Create the objects
aiSetImportPropertyFloat(AI_CONFIG_PP_GSN_MAX_SMOOTHING_ANGLE,89.53f);
const struct aiScene* scene_teapot = aiImportFile("../Clan3D/Resources/teapot.dae",aiProcessPreset_TargetRealtime_MaxQuality);
if (!scene_teapot)
throw CL_Exception("Cannot load the teapot model");
const struct aiScene* scene_clanlib = aiImportFile("../Clan3D/Resources/clanlib.dae",aiProcessPreset_TargetRealtime_MaxQuality);
if (!scene_clanlib)
throw CL_Exception("Cannot load the clanlib model");
const struct aiScene* scene_tuxball = aiImportFile("../Clan3D/Resources/tux_ball.dae",aiProcessPreset_TargetRealtime_MaxQuality | aiProcess_FlipUVs);
if (!scene_tuxball)
throw CL_Exception("Cannot load the tux ball model");
// Load the texture
CL_Texture tux(gc, "../Clan3D/Resources/tux.png");
float angle = 0.0f;
// Run until someone presses escape
while (!quit)
{
CL_Mat4f perp = CL_Mat4f::perspective(45.0f, ((float) gc.get_width()) / ((float) gc.get_height()), 0.1f, 1000.0f);
gc.set_projection(perp);
gc.clear(CL_Colorf::black);
gc.clear_depth(1.0f);
//.........这里部分代码省略.........
示例6: 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("Vertex Buffer Object Example");
win_desc.set_depth_size(16);
win_desc.set_size(CL_Size( 800, 600 ), 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_GraphicContext gc = window.get_gc();
Shader shader(gc);
// Prepare the display
gc.set_map_mode(cl_user_projection);
CL_PolygonRasterizer polygon_rasterizer;
polygon_rasterizer.set_culled(true);
polygon_rasterizer.set_face_cull_mode(cl_cull_back);
polygon_rasterizer.set_front_face(cl_face_side_clockwise);
gc.set_polygon_rasterizer(polygon_rasterizer);
CL_BufferControl buffer_control;
buffer_control.enable_depth_test(true);
buffer_control.set_depth_compare_function(cl_comparefunc_lequal);
buffer_control.enable_depth_write(true);
gc.set_buffer_control(buffer_control);
std::vector<CL_Vec3f> object_positions;
std::vector<CL_Vec3f> object_normals;
std::vector<CL_Vec4f> object_material_ambient;
const int num_cubes = 20000;
object_positions.reserve(num_cubes * 6 * 6); // 6 faces, and 6 vertices per face
object_normals.reserve(num_cubes * 6 * 6);
object_material_ambient.reserve(num_cubes * 6 * 6);
for (int cnt=0; cnt < num_cubes; cnt++)
{
create_cube(object_positions, object_normals, object_material_ambient);
}
CL_VertexArrayBuffer vb_positions(gc, &object_positions[0], sizeof(CL_Vec3f) * object_positions.size());
CL_VertexArrayBuffer vb_normals(gc, &object_normals[0], sizeof(CL_Vec3f) * object_normals.size());
CL_VertexArrayBuffer vb_material_ambient(gc, &object_material_ambient[0], sizeof(CL_Vec4f) * object_material_ambient.size());
// ** Note, at this point "object_positions, object_normals and object_material_ambient"
// ** can be destroyed. But for the purpose of this example, is it kept
CL_Font fps_font(gc, "tahoma", 20);
FramerateCounter frameratecounter;
unsigned int time_last = CL_System::get_time();
float angle = 0.0f;
is_vertex_buffer_on = true;
while (!quit)
{
unsigned int time_now = CL_System::get_time();
float time_diff = (float) (time_now - time_last);
time_last = time_now;
gc.clear(CL_Colorf(0.0f, 0.0f, 0.0f, 1.0f));
gc.clear_depth(1.0f);
gc.set_map_mode(cl_map_2d_upper_left);
CL_String fps = cl_format("%1 fps", frameratecounter.get_framerate());
fps_font.draw_text(gc, gc.get_width() - 100, 30, fps);
CL_String info = cl_format("%1 vertices", (int) object_positions.size());
fps_font.draw_text(gc, 30, 30, info);
fps_font.draw_text(gc, 30, gc.get_height() - 8, "Press any key to toggle the Vertex Buffer option");
if (is_vertex_buffer_on)
{
fps_font.draw_text(gc, 200, 30, "Vertex Buffer = ON");
}
else
{
fps_font.draw_text(gc, 200, 30, "Vertex Buffer = OFF");
}
gc.set_map_mode(cl_user_projection);
CL_Mat4f perp = CL_Mat4f::perspective(45.0f, ((float) gc.get_width()) / ((float) gc.get_height()), 0.1f, 100000.0f);
gc.set_projection(perp);
angle += time_diff / 20.0f;
if (angle >= 360.0f)
angle -= 360.0f;
gc.push_modelview();
gc.set_modelview(CL_Mat4f::identity());
gc.mult_scale(1.0f,1.0f, -1.0f); // So +'ve Z goes into the screen
gc.mult_translate(0.0f, 0.0f, 800.0f);
//.........这里部分代码省略.........