// The start of the Application int App::start(const std::vector<CL_String> &args) { // Setup the window CL_DisplayWindowDescription win_desc; win_desc.set_allow_resize(true); win_desc.set_title("Input Example"); win_desc.set_size(CL_Size( 700, 700 ), false); window = CL_DisplayWindow(win_desc); // Connect the slots that we require CL_Slot slot_quit = window.sig_window_close().connect(this, &App::on_window_close); CL_Slot slot_input_down = (window.get_ic().get_keyboard()).sig_key_down().connect(this, &App::on_input_down); CL_Slot slot_mouse_down = (window.get_ic().get_mouse()).sig_key_down().connect(this, &App::on_mouse_down); CL_Slot slot_mouse_dblclick = (window.get_ic().get_mouse()).sig_key_dblclk().connect(this, &App::on_mouse_down); std::vector<CL_Slot> slot_joystick; int max_joysticks = window.get_ic().get_joystick_count(); for (int joystick_number=0; joystick_number < max_joysticks; joystick_number++) { CL_Slot current_joystick = window.get_ic().get_joystick(joystick_number).sig_key_down().connect(this, &App::on_joystick_down, joystick_number); slot_joystick.push_back(current_joystick); } CL_GraphicContext gc = window.get_gc(); font = CL_Font(gc, "tahoma", 16); vector_font = CL_Font_Vector("../../Game/DiceWar/Resources/bitstream_vera_sans/VeraBd.ttf", 256); calculate_matrix(gc); while(!quit) { gc.set_map_mode(cl_map_2d_upper_left); CL_Draw::gradient_fill(gc, CL_Rect(0, 0, gc.get_width(), gc.get_height()/2), CL_Gradient(CL_Colorf(0.2f, 0.2f, 0.8f, 1.0f), CL_Colorf(0.0f, 0.0f, 0.2f, 1.0f))); CL_Draw::gradient_fill(gc, CL_Rect(0, gc.get_height()/2, gc.get_width(), gc.get_height()), CL_Gradient(CL_Colorf(0.0f, 0.0f, 0.2f, 1.0f), CL_Colorf(0.2f, 0.2f, 0.8f, 1.0f))); font.draw_text(gc, 8, 20, "Press any key, mouse button or joystick button to fire text. Use mouse to control direction."); int yoffset = gc.get_height() - 20; const int y_gap = 20; // Draw Keyboard Information draw_keyboard_state(gc, yoffset); yoffset -= y_gap; // Draw Mouse Information draw_mouse_state(gc, yoffset); yoffset -= y_gap; // Draw Joysticks Information for (int joystick_number=0; joystick_number < max_joysticks; joystick_number++) { draw_joystick_state(gc, joystick_number, yoffset); yoffset -= y_gap; } // Draw Tablet Information int max_tablets = window.get_ic().get_tablet_count(); for (int tablet_number=0; tablet_number < max_tablets; tablet_number++) { draw_tablet_state(gc, tablet_number, yoffset); yoffset -= y_gap; } gc.set_map_mode(cl_user_projection); gc.set_projection(projection_matrix); gc.set_modelview(modelview_matrix); draw_text_shooter(gc); window.flip(1); CL_KeepAlive::process(); } return 0; }
// 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); angle += 1.0f; if (angle >= 360.0f) angle -= 360.0f; #ifdef USE_OPENGL_2 shader.Set(gc); shader.Use(gc); #else gc.set_program_object(cl_program_color_only); #endif CL_PrimitivesArray prim_array(gc); 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, 2.0f); gc.mult_rotate(CL_Angle(angle, cl_degrees), 0.0f, 1.0f, 0.0f, false); gc.push_modelview(); recursive_render(gc, scene_teapot, scene_teapot->mRootNode, false); gc.pop_modelview(); gc.push_modelview(); gc.mult_scale(0.5f, 0.5f, 0.5f); gc.mult_translate(0.0f, -0.5f, 0.0f); recursive_render(gc, scene_clanlib, scene_clanlib->mRootNode, false); gc.pop_modelview(); #ifdef USE_OPENGL_2 shader.Set(gc, 0); shader.Use(gc); #else gc.set_program_object(cl_program_single_texture); #endif gc.set_texture(0, tux); 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.7f, 0.5f, 2.0f); gc.mult_scale(0.05f, 0.05f, 0.05f); gc.mult_rotate(CL_Angle(angle * 4.0f, cl_degrees), 0.0f, 1.0f, 0.0f, false); recursive_render(gc, scene_tuxball, scene_tuxball->mRootNode, true); gc.reset_texture(0); gc.reset_program_object(); // Flip the display, showing on the screen what we have drawed // since last call to flip() window.flip(1); // This call processes user input and other events CL_KeepAlive::process(); } aiReleaseImport(scene_tuxball); aiReleaseImport(scene_clanlib); aiReleaseImport(scene_teapot); aiDetachAllLogStreams(); return 0; }
CL_Size CL_GUIComponent::get_preferred_size() const { throw CL_Exception("CL_GUIComponent::get_preferred_size shall not be called directly! Derived classes should override this function, if needed!"); return CL_Size(); }
// 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); gc.mult_rotate(CL_Angle(angle*2.0f, cl_degrees), 0.0f, 1.0f, 0.0f, false); gc.mult_rotate(CL_Angle(angle, cl_degrees), 1.0f, 0.0f, 0.0f, false); shader.Set(gc); shader.Use(gc); CL_PrimitivesArray prim_array(gc); if (is_vertex_buffer_on) { prim_array.set_attributes(0, vb_positions, 3, cl_type_float, (void *) 0); prim_array.set_attributes(1, vb_normals, 3, cl_type_float, (void *) 0); prim_array.set_attributes(2, vb_material_ambient, 4, cl_type_float, (void *) 0); } else { prim_array.set_attributes(0, &object_positions[0]); prim_array.set_attributes(1, &object_normals[0]); prim_array.set_attributes(2, &object_material_ambient[0]); } gc.draw_primitives(cl_triangles, object_positions.size(), prim_array); gc.pop_modelview(); gc.reset_program_object(); window.flip(0); frameratecounter.frame_shown(); CL_KeepAlive::process(); } return 0; }
CL_Size CL_GUIThemePart::get_preferred_size() const { return CL_Size(get_property_int(impl->prop_preferred_width), get_property_int(impl->prop_preferred_height)); }
// The start of the Application int Tetris::start(const std::vector<CL_String> &args) { quit = false; finish = false; // leftborderlist = new LeftBordeList(); // rightbordelist = new RightBordeList(); // Set the window CL_DisplayWindowDescription desc; desc.set_title("Tetris"); desc.set_size(CL_Size(320, 640), true); desc.set_allow_resize(true); CL_DisplayWindow window(desc); // Connect the Window close event CL_Slot slot_quit = window.sig_window_close().connect(this, &Tetris::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, &Tetris::on_input_up); // Get the graphic context CL_GraphicContext gc = window.get_gc(); // Load a sprite from a png-file //CL_Sprite spr_logo(gc, "Resources/logo.png"); float sin_count = 0.0f; float ypos = 0.0f; float ydir = 0.3f; unsigned int last_time = CL_System::get_time(); CL_Font font(gc, "Utopia", 40); linesRemoved = 0; // Run until someone presses escape while (!quit) { unsigned int current_time = CL_System::get_time(); float time_delta_ms = static_cast<float> (current_time - last_time); last_time = current_time; float shift = time_delta_ms/20; shift = 1.0f; //std::cout << "shift = " << shift << std::endl; // Clear the display in a dark blue nuance // The four arguments are red, green, blue and alpha gc.clear(CL_Colorf(25.0f,25.0f,25.0f)); std::string s; std::stringstream out; out << linesRemoved; s = out.str(); font.draw_text(gc, 250,40, s.c_str(), CL_Colorf::blue); int l = bottomborderlist.getLineNumberToDelete(); while (l != -1) { l = bottomborderlist.getLineNumberToDelete(); if (l!= -1) { if (!bottomborderlist.isFullHeight()) { linesRemoved++; } } bottomborderlist.removeLine(l); } if (!figlist.checkCollisionDown(bottomborderlist)) { figlist.moveDown(shift); } else { FigureList newfl = figlist; newfl.setStablePosition(); if (!finish) { bottomborderlist.addList(newfl.getFigureList()); if (figlist.checkCollisionDown(bottomborderlist)) { figlist.reset(); } else { figlist.reset(); figlist.clearFigureList(); } } if (figlist.checkCollisionDown(bottomborderlist)) { finish = true; } } leftborderlist.draw(gc); rightborderlist.draw(gc); bottomborderlist.draw(gc); if (finish == false && !figlist.checkCollisionDown(bottomborderlist)) { figlist.draw(gc); } else { if (linesRemoved < 5) { font.draw_text(gc, 10,40, "You Lost", CL_Colorf::black); } else { font.draw_text(gc, 10,40, "You Won", CL_Colorf::black); } } // Flip the display, showing on the screen what we have drawed // since last call to flip() window.flip(1); // This call processes user input and other events CL_KeepAlive::process(0); } return 0; }
// The start of the Application int App::start(const std::vector<CL_String> &args) { // Setup the window CL_DisplayWindowDescription win_desc; win_desc.set_allow_resize(true); win_desc.set_title("3D GUI Example"); win_desc.set_size(CL_Size( 700, 700 ), false); window = CL_DisplayWindow(win_desc); // Connect the slots that we require CL_Slot slot_quit = window.sig_window_close().connect(this, &App::on_window_close); CL_Slot slot_input_down = (window.get_ic().get_keyboard()).sig_key_down().connect(this, &App::on_input_down); CL_GraphicContext gc = window.get_gc(); CL_Font font = CL_Font(gc, "tahoma", 16); // Initialise the GUI system GUI gui(this); // NOTE: The GUI component positions are still in 2D world, therefore // be careful not to overlap windows, else unpredicted results may occur! window1 = new Window1(gui, CL_Rect(0,0, CL_Size(256, 256))); slider_1_xrotation = new Slider(gui, CL_Rect(0, 512, CL_Size(200, 17))); slider_1_xrotation->object_matrix.translate_self(0.0f, 0.8f, 3.0f); slider_1_xrotation->object_matrix.multiply(CL_Mat4f::rotate(CL_Angle(10, cl_degrees), 0.0f, 0.0f, 1.0f)); slider_1_yrotation = new Slider(gui, CL_Rect(256*1, 512, CL_Size(200, 17))); slider_1_yrotation->object_matrix.translate_self(0.0f, 0.7f, 3.0f); slider_1_yrotation->object_matrix.multiply(CL_Mat4f::rotate(CL_Angle(10, cl_degrees), 0.0f, 0.0f, 1.0f)); slider_1_zrotation = new Slider(gui, CL_Rect(256*2, 512, CL_Size(200, 17))); slider_1_zrotation->object_matrix.translate_self(0.0f, 0.6f, 3.0f); slider_1_zrotation->object_matrix.multiply(CL_Mat4f::rotate(CL_Angle(10, cl_degrees), 0.0f, 0.0f, 1.0f)); slider_1_xtranslation = new Slider(gui, CL_Rect(256*3, 512, CL_Size(200, 17))); slider_1_xtranslation->object_matrix.translate_self(0.0f, 0.5f, 3.0f); slider_1_xtranslation->object_matrix.multiply(CL_Mat4f::rotate(CL_Angle(10, cl_degrees), 0.0f, 0.0f, 1.0f)); slider_1_xtranslation->component->set_position(500); slider_1_ytranslation = new Slider(gui, CL_Rect(256*4, 512, CL_Size(200, 17))); slider_1_ytranslation->object_matrix.translate_self(0.0f, 0.4f, 3.0f); slider_1_ytranslation->object_matrix.multiply(CL_Mat4f::rotate(CL_Angle(10, cl_degrees), 0.0f, 0.0f, 1.0f)); slider_1_ytranslation->component->set_position(500); slider_1_ztranslation = new Slider(gui, CL_Rect(256*5, 512, CL_Size(200, 17))); slider_1_ztranslation->object_matrix.translate_self(0.0f, 0.3f, 3.0f); slider_1_ztranslation->object_matrix.multiply(CL_Mat4f::rotate(CL_Angle(10, cl_degrees), 0.0f, 0.0f, 1.0f)); slider_1_ztranslation->component->set_position(500); while(!quit) { calculate_matrix(); gc.set_modelview(CL_Mat4f::identity()); gc.set_map_mode(CL_MapMode(cl_map_2d_upper_left)); // Draw the gradient CL_Draw::gradient_fill(gc, CL_Rect(0, 0, gc.get_width(), gc.get_height()/2), CL_Gradient(CL_Colorf(0.2f, 0.2f, 0.8f, 1.0f), CL_Colorf(0.0f, 0.0f, 0.2f, 1.0f))); CL_Draw::gradient_fill(gc, CL_Rect(0, gc.get_height()/2, gc.get_width(), gc.get_height()), CL_Gradient(CL_Colorf(0.0f, 0.0f, 0.2f, 1.0f), CL_Colorf(0.2f, 0.2f, 0.8f, 1.0f))); font.draw_text(gc, 8, 20, "GUI3D"); int xoffset = 160; int yoffset = 70; const int ygap = 35; font.draw_text(gc, xoffset, yoffset, "X Rotation"); yoffset += ygap; font.draw_text(gc, xoffset, yoffset, "Y Rotation"); yoffset += ygap; font.draw_text(gc, xoffset, yoffset, "Z Rotation"); yoffset += ygap; font.draw_text(gc, xoffset, yoffset, "X Translation"); yoffset += ygap; font.draw_text(gc, xoffset, yoffset, "Y Translation"); yoffset += ygap; font.draw_text(gc, xoffset, yoffset, "Z Translation"); yoffset += ygap; if (!gui.run()) break; gc.set_map_mode(cl_user_projection); gc.set_projection(projection_matrix); gc.set_modelview(modelview_matrix); control_window(); gui.draw(); window.flip(1); CL_KeepAlive::process(); } return 0; }
CL_Size CL_GUIThemePart::get_maximum_size() const { return CL_Size(get_property_int(impl->prop_maximum_width), get_property_int(impl->prop_maximum_height)); }
// The start of the Application int App::start(const std::vector<CL_String> &args) { quit = false; CL_OpenGLWindowDescription desc; desc.set_title("ClanLib Shadow Example"); desc.set_size(CL_Size(640, 640), 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 aiSetImportPropertyFloat(AI_CONFIG_PP_GSN_MAX_SMOOTHING_ANGLE,89.53f); // 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(); GraphicStore graphic_store(gc); scene.gs = &graphic_store; // 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); create_scene(gc); CL_FrameBuffer framebuffer(gc); CL_Texture new_depth_texture(gc, CL_Size(1024, 1024), cl_depth_component); new_depth_texture.set_wrap_mode(cl_wrap_clamp_to_edge, cl_wrap_clamp_to_edge, cl_wrap_clamp_to_edge); framebuffer.attach_depth_buffer(new_depth_texture); scene.gs->texture_shadow = new_depth_texture; camera_angle = 0.0f; CL_Font font(gc, "tahoma", 24); FramerateCounter framerate_counter; unsigned int time_last = CL_System::get_time(); // Run until someone presses escape while (!quit) { framerate_counter.frame_shown(); unsigned int time_now = CL_System::get_time(); time_delta = time_now - time_last; time_last = time_now; rotate_teapot(); control_camera(); update_light(gc); calculate_matricies(gc); render_from_lightsource(gc, framebuffer); render_from_camera(gc, framebuffer); gc.set_modelview(CL_Mat4f::identity()); gc.set_map_mode(cl_map_2d_upper_left); CL_String fps(cl_format("%1 fps", framerate_counter.get_framerate())); font.draw_text(gc, 16-2, gc.get_height()-16-2, fps, CL_Colorf(0.0f, 0.0f, 0.0f, 1.0f)); font.draw_text(gc, 16, gc.get_height()-16-2, fps, CL_Colorf(1.0f, 1.0f, 1.0f, 1.0f)); // Use flip(1) to lock the fps window.flip(0); // This call processes user input and other events CL_KeepAlive::process(); } aiDetachAllLogStreams(); return 0; }
ortho() : pump_factor_(4) { // glVertexPointer(4, GL_FLOAT, 0, ptr); //glEnableClientState( GL_VERTEX_ARRAY ); // glColorPointer( //std::ifstream is( "cryistal-castle-hidden-ramp.txt" ); // std::ifstream is( "house1.txt" ); //std::ifstream is( "cryistal-castle-tree-wave.txt" ); // assert( is.good() ); // height_fields_ = crystal_bits::load_crystal(is, pump_factor_); // std::cout << "hf: " << height_fields_.size() << "\n"; // // // // scene_static_.init_solid(height_fields_); // // scene_static_.init_solid_from_crystal(is, pump_factor_); // scene_static_.init_planes(); // uint64_t scene_hash = scene_static_.hash(); // // try { // std::ifstream is( "ff.bin" ); // // // light_static_ = light_static( is, scene_hash ); // } catch( std::runtime_error x ) { // // std::cerr << "load failed. recreating. error:\n" << x.what() << std::endl; // // light_static_ = setup_formfactors(scene_static_.planes(), scene_static_.solid()); // } // // if( !false ) { // std::ofstream os( "ff.bin" ); // light_static_.write(os, scene_hash); // } // // // light_dynamic_ = light_dynamic(scene_static_.planes().size() ); CL_OpenGLWindowDescription desc; desc.set_size( CL_Size( 1024, 768 ), true ); desc.set_depth_size(16); //std::cout << "depth: " << desc.get_depth_size(); wnd_ = CL_DisplayWindow(desc); CL_GraphicContext_GL gc = wnd_.get_gc(); // //CL_Mat4f proj = CL_Mat4f::ortho( 0, 1024, 0, 768, 100, -100 ); gc.set_active(); #ifdef TEST_OPENCL try { init_opencl(); } catch( cl::Error x ) { // std::array<void*, 256> bt; // //void *bt[256]; // // size_t size = backtrace( bt.data(), bt.size() ); // char **strings = backtrace_symbols( bt.data(), size ); // std::cout << "backtrace: " << size << "\n"; // for( size_t i = 0; i < size; ++i ) { // std::cout << i << " " << strings[i] << "\n"; // } // free( strings ); std::cerr << "opencl initialization failed\ncall: " << x.what() << "\nerror code: " << cl_str_error( x.err() ) << "\n"; throw; } #endif // throw 0; glMatrixMode(GL_PROJECTION); //hello CL_Mat4f proj = CL_Mat4f::perspective( 60, 1.5, 2, 200 ); // CL_Mat4f proj = CL_Mat4f::ortho( -20.0 * pump_factor_, 20.0 * pump_factor_, -15.0 * pump_factor_, 15.0 * pump_factor_, 0, 200 ); //CL_Mat4f proj = CL_Mat4f::ortho( -40, 40, -30, 30, 0, 200 ); glLoadMatrixf( proj.matrix ); //CL_Texture tex(gc, 64, 64 ); struct texel { GLubyte col[3]; GLubyte alpha; texel() { col[0] = 128; col[1] = 128; col[2] = 128; alpha = 255; } }; std::array<texel,64 * 64> tex_data; glLightModelf(GL_LIGHT_MODEL_LOCAL_VIEWER, 0.0); // glGenTextures(1, &texName); // glBindTexture(GL_TEXTURE_2D, texName); // glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); // glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); // glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); // glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); // glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 64, 64, 0, GL_RGBA, GL_UNSIGNED_BYTE, tex_data.data()); // gc.set_map_mode(cl_user_projection); // gc.set_projection(proj); // // gc.flush_batcher(); // glMatrixMode(GL_PROJECTION); glMatrixMode(GL_MODELVIEW); glEnable(GL_DEPTH_TEST); glDepthMask(GL_TRUE); glDepthFunc(GL_LESS); glEnable(GL_TEXTURE_2D); glShadeModel(GL_FLAT); }
void Game::run() { //_________________________________________________________________ // V I D E O S E T T I N G S screen_x_res = 640; screen_y_res = 480; CL_DisplayWindowDescription desc; desc.set_title("Roadgeddon"); desc.set_size(CL_Size(screen_x_res, screen_y_res), true); desc.set_allow_resize(false); CL_DisplayWindow window(desc); CL_Slot slot_quit = window.sig_window_close() .connect(this,&Game::on_quit); CL_Slot slot_keyboard_key_down = (window.get_ic().get_keyboard()).sig_key_down() .connect(this,&Game::on_key_down); CL_Slot slot_keyboard_key_up = (window.get_ic().get_keyboard()).sig_key_up() .connect(this,&Game::on_key_up); CL_Slot slot_mouse_moved = (window.get_ic().get_mouse()).sig_pointer_move() .connect(this,&Game::on_pointer_move); CL_Slot slot_mouse_down = (window.get_ic().get_mouse()).sig_key_down() .connect(this,&Game::on_pointer_down); CL_Slot slot_mouse_up = (window.get_ic().get_mouse()).sig_key_up() .connect(this,&Game::on_pointer_up); gc = window.get_gc(); CL_ResourceManager resources("resources.xml"); resources_=&resources; int time_elapsed_ms = 0; int lastTime = 0; int currentTime = 0; currentTime = CL_System::get_time(); lastTime = CL_System::get_time(); //________________________________________________________________ // S O U N D S total_channels=3; current_channel=1; CL_SoundBuffer music("Music1",&resources); music.set_volume(0.3f); sound_session1.play(); sound_session2.play(); sound_session3.play(); total_samples = 6; samples.resize(total_samples); samples[0] = CL_SoundBuffer("Explosion1",&resources); samples[1] = CL_SoundBuffer("Explosion2",&resources); samples[2] = CL_SoundBuffer("Hurt1",&resources); samples[3] = CL_SoundBuffer("Hurt2",&resources); samples[4] = CL_SoundBuffer("Powerup1",&resources); samples[5] = CL_SoundBuffer("Shoot1",&resources); for(int i = 0; i<total_samples; i++) { samples[i].set_volume(0.3f); } CL_SoundBuffer_Session music_session = music.prepare(); music_session_ = &music_session; music_session.set_looping(true); music_session.play(); is_music_muted = false; //________________________________________________________________ // G A M E P R E P Map map(*this); Player player(*this); mapP = ↦ playerP = &player; time_elapsed_since_last_enemy=0; //________________________________________________________________ // O T H E R srand(CL_System::get_time()); while (!quit) { currentTime = CL_System::get_time(); time_elapsed_ms = currentTime - lastTime; lastTime = currentTime; update_game(time_elapsed_ms); update_signal.invoke(time_elapsed_ms); map.drawBackground(); draw_signal.invoke(); // Flip the display, showing on the screen what we have drawed since last call to flip() window.flip(1); // This call processes user input and other events CL_KeepAlive::process(0); // Sleep for a little while to avoid using too much of the CPU. CL_System::sleep(5); if(objects_for_deletion.size()>0) { std::list<Gameobject *>::iterator it; for(it=objects_for_deletion.begin(); it!= objects_for_deletion.end(); ++it) { delete (*it); } objects_for_deletion.clear(); } } }
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)"); image_texture.set_alignment(origin_top_center, 0, 8); image_texture.draw(gc, 700+offset, 500+offset); image_texture.set_alignment(origin_bottom_center, 0, -8); image_texture.draw(gc, 700+offset, 500+offset); image_texture.set_alignment(origin_center_left, 8, 0); image_texture.draw(gc, 700+offset, 500+offset); image_texture.set_alignment(origin_center_right, -8, 0); image_texture.draw(gc, 700+offset, 500+offset); CL_Draw::circle(gc, 700+offset, 500+offset, 4, CL_Colorf(1.0f, 1.0f, 1.0f, 0.9f)); small_font.draw_text(gc, 700, 160, "Image - Center Align (4 images with 64 pixel offset)"); small_font.draw_text(gc, 700, 175, "Also Includes a centered image (Without offset)"); small_font.draw_text(gc, 700, 190, "(Circle denotes the draw origin)"); const int center_image_offset = 64; image_texture.set_alignment(origin_center, 0, 0); image_texture.draw(gc, 700+offset, 200+offset); image_texture.set_alignment(origin_center, 0, center_image_offset); image_texture.draw(gc, 700+offset, 200+offset); image_texture.set_alignment(origin_center, 0, -center_image_offset); image_texture.draw(gc, 700+offset, 200+offset); image_texture.set_alignment(origin_center, center_image_offset, 0); image_texture.draw(gc, 700+offset, 200+offset); image_texture.set_alignment(origin_center, -center_image_offset, 0); image_texture.draw(gc, 700+offset, 200+offset); CL_Draw::circle(gc, 700+offset, 200+offset, 4, CL_Colorf(1.0f, 1.0f, 1.0f, 0.9f)); // Restore alignment image_texture.set_alignment(origin_top_left, 0, 0); dump_fps(); window.flip(1); CL_KeepAlive::process(); } return 0; } catch(CL_Exception error) { CL_Console::write_line("Exception caught:"); CL_Console::write_line(error.message); console.display_close_message(); return -1; } return 0; }
CL_Size CL_DisplayWindow_OpenGL::get_max_surface_size() const { CLint max_texture_size; clGetIntegerv(CL_MAX_TEXTURE_SIZE, &max_texture_size); return CL_Size(max_texture_size, max_texture_size); }
MenuBar::MenuBar(CL_GUIManager &manager, CL_ResourceManager &application_resources) : CL_Window(&manager, CL_GUITopLevelDescription("Menu Bar & Status Bar", CL_Rect(512 + 24, 256 + 16, CL_Size(256, 180)), false)) { tux_image = CL_ImageProviderFactory::load("../CommonCode/Resources/tux.png"); CL_GraphicContext gc = get_gc(); tux_head = CL_Image(gc, "tux_head", &application_resources); set_draggable(true); CL_Rect client_area = get_client_area(); menubar1 = new CL_MenuBar(this); menubar1->set_geometry(CL_Rect(client_area.left, client_area.top, client_area.right, client_area.top + 25)); menu_file.insert_item("New").func_clicked().set(this, &MenuBar::on_item_selected); menu_file.insert_item("Open").func_clicked().set(this, &MenuBar::on_item_selected); menu_file.insert_item("Save").func_clicked().set(this, &MenuBar::on_item_selected); CL_PopupMenuItem tux_item = menu_file.insert_item("Tux"); tux_item.func_clicked().set(this, &MenuBar::on_item_selected); tux_item.set_icon(tux_image); menu_file.insert_item("Exit").func_clicked().set(this, &MenuBar::on_item_selected); menubar1->add_menu("File", menu_file); menu_edit.insert_item("Undo").func_clicked().set(this, &MenuBar::on_item_selected); CL_PopupMenuItem redo_item = menu_edit.insert_item("Redo"); redo_item.func_clicked().set(this, &MenuBar::on_item_selected); redo_item.set_enabled(false); menu_edit.insert_separator(); menu_edit.insert_item("Cut").func_clicked().set(this, &MenuBar::on_item_selected); menu_edit.insert_item("Copy").func_clicked().set(this, &MenuBar::on_item_selected); menu_edit.insert_separator(); item_submenu = menu_edit.insert_item("Submenu"); item_submenu.func_clicked().set(this, &MenuBar::on_item_selected); menu_edit.insert_separator(); menu_edit.insert_item("Paste").func_clicked().set(this, &MenuBar::on_item_selected); menu_edit.insert_item("Delete").func_clicked().set(this, &MenuBar::on_item_selected); menu_edit.insert_separator(); menu_edit.insert_item("Select All").func_clicked().set(this, &MenuBar::on_item_selected); menu_submenu.insert_item("foo").func_clicked().set(this, &MenuBar::on_item_selected); menu_submenu.insert_item("bar").func_clicked().set(this, &MenuBar::on_item_selected); menu_submenu.insert_item("foobar").func_clicked().set(this, &MenuBar::on_item_selected); CL_PopupMenuItem check_item1 = menu_submenu.insert_item("Checkable 1"); check_item1.func_clicked().set(this, &MenuBar::on_item_selected); check_item1.set_checkable(true); check_item1.set_checked(true); CL_PopupMenuItem check_item2 = menu_submenu.insert_item("Checkable 2"); check_item2.func_clicked().set(this, &MenuBar::on_item_selected); check_item2.set_checkable(true); check_item2.set_checked(false); CL_PopupMenuItem check_item3 = menu_submenu.insert_item("Disabled Checkable 1"); check_item3.func_clicked().set(this, &MenuBar::on_item_selected); check_item3.set_checkable(true); check_item3.set_checked(true); check_item3.set_enabled(false); CL_PopupMenuItem check_item4 = menu_submenu.insert_item("Disabled Checkable 2"); check_item4.func_clicked().set(this, &MenuBar::on_item_selected); check_item4.set_checkable(true); check_item4.set_checked(false); check_item4.set_enabled(false); item_submenu.set_submenu(menu_submenu); menubar1->add_menu("Edit", menu_edit); int xoffset = client_area.left + 80; int yoffset = client_area.top + 30; const int gap = 16; CL_Size label_size(50, 15); info_item_selected = new Info(this); info_item_selected->set(xoffset, yoffset, "Item Selected"); yoffset += gap; statusbar1 = new CL_StatusBar(this); int statusbar_height = statusbar1->get_preferred_height(); CL_Rect statusbar_rect(0, client_area.get_height() - statusbar_height, CL_Size(client_area.get_width(), statusbar_height)); statusbar_rect.translate(client_area.left, client_area.top); statusbar1->set_geometry(statusbar_rect); statusbar1->set_status_text("Status bar"); statusbar1->show_size_grip(true); pushbutton1 = new CL_PushButton(statusbar1); pushbutton1->set_icon(tux_head); pushbutton1->func_clicked().set(this, &MenuBar::on_clicked, pushbutton1); statusbar1->add_part(0, 48, pushbutton1); statusbar1->func_part_double_clicked(0).set(this, &MenuBar::on_part_double_clicked_0, statusbar1); component1 = new CL_GUIComponent(statusbar1); statusbar1->add_part(1, 48, component1); statusbar1->set_part_text(1, "ClanTest"); statusbar1->func_part_double_clicked(1).set(this, &MenuBar::on_part_double_clicked_1, statusbar1); CL_GUIComponent *component2 = (new CL_GUIComponent(statusbar1)); statusbar1->add_part(2, 48, component2); statusbar1->set_part_text(2, tux_head, ""); statusbar1->func_part_double_clicked(2).set(this, &MenuBar::on_part_double_clicked_2, statusbar1); xoffset = client_area.left + 5; yoffset = client_area.top + 40; label_status = new CL_Label(this); label_status->set_geometry(CL_Rect(xoffset, yoffset, label_size)); label_status->set_text("Status Bar:"); yoffset += gap; checkbox_status_size_grip = new CL_CheckBox(this); checkbox_status_size_grip->set_geometry(CL_Rect(xoffset, yoffset, CL_Size(150, 15))); checkbox_status_size_grip->func_checked().set(this, &MenuBar::on_checked_status_size_grip, checkbox_status_size_grip); checkbox_status_size_grip->func_unchecked().set(this, &MenuBar::on_unchecked_status_size_grip, checkbox_status_size_grip); checkbox_status_size_grip->set_text("Show Size Grip"); checkbox_status_size_grip->set_checked(true); yoffset += gap; checkbox_status_text = new CL_CheckBox(this); checkbox_status_text->set_geometry(CL_Rect(xoffset, yoffset, CL_Size(150, 15))); checkbox_status_text->func_checked().set(this, &MenuBar::on_checked_status_text, checkbox_status_text); checkbox_status_text->func_unchecked().set(this, &MenuBar::on_unchecked_status_text, checkbox_status_text); checkbox_status_text->set_text("Change Status Text"); checkbox_status_text->set_checked(true); yoffset += gap; checkbox_status_show_clantest = new CL_CheckBox(this); checkbox_status_show_clantest->set_geometry(CL_Rect(xoffset, yoffset, CL_Size(150, 15))); checkbox_status_show_clantest->func_checked().set(this, &MenuBar::on_checked_show_clantest, checkbox_status_show_clantest); checkbox_status_show_clantest->func_unchecked().set(this, &MenuBar::on_unchecked_show_clantest, checkbox_status_show_clantest); checkbox_status_show_clantest->set_text("Show ClanTest"); checkbox_status_show_clantest->set_checked(true); yoffset += gap; checkbox_status_remove_clantest = new CL_CheckBox(this); checkbox_status_remove_clantest->set_geometry(CL_Rect(xoffset, yoffset, CL_Size(150, 15))); checkbox_status_remove_clantest->func_checked().set(this, &MenuBar::on_checked_remove_clantest, checkbox_status_remove_clantest); checkbox_status_remove_clantest->func_unchecked().set(this, &MenuBar::on_unchecked_remove_clantest, checkbox_status_remove_clantest); checkbox_status_remove_clantest->set_text("Remove ClanTest"); checkbox_status_remove_clantest->set_checked(false); yoffset += gap; xoffset = client_area.left + 110; yoffset -= (gap*2); info_clicked = new Info(this); info_clicked->set(xoffset, yoffset, "Push Button Clicked"); yoffset += gap; info_part_clicked = new Info(this); info_part_clicked->set(xoffset, yoffset, "Part Dbl Clicked"); }
// 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; }