int main( int argc, char** argv ) { // Create the hidden program options (required args) boost::program_options::options_description hidden( "Hidden options" ); hidden.add_options() ("image", boost::program_options::value<std::string>(), "the image (with path) that will be used\n"); // Create the positional (required) args boost::program_options::positional_options_description pd; pd.add("image", 1 ); // Create the optional arguments boost::program_options::options_description generic( "Allowed options" ); generic.add_options() ("help,h", "produce help message"); // Create the command-line argument parser boost::program_options::options_description cmdline_options( "Allowed options" ); cmdline_options.add(generic).add(hidden); boost::program_options::variables_map vm; boost::program_options::store( boost::program_options::command_line_parser(argc, argv).options(cmdline_options).positional(pd).run(), vm ); boost::program_options::notify( vm ); // Check if the help message was requested if( vm.count( "help" ) ) { std::cerr << generic << std::endl; return 1; } // Store the image name std::string image_name; if( vm.count( "image" ) ) image_name = vm["image"].as<std::string>(); // Initialize the window if( !initialize() ) return 1; else { // Load the bitmap if( !loadMedia( image_name )) return 1; else { bool quit = false; // Event SDL_Event event; // Main application loop while( !quit ) { while( SDL_PollEvent( &event ) != 0 ) { if( event.type == SDL_QUIT ) quit = true; } // Clear the screen SDL_SetRenderDrawColor( g_renderer, 0xFF, 0xFF, 0xFF, 0xFF ); SDL_RenderClear( g_renderer ); // Set the viewport to the top left corner SDL_Rect top_left_viewport; top_left_viewport.x = 0; top_left_viewport.y = 0; top_left_viewport.w = screen_width_height[0]/2; top_left_viewport.h = screen_width_height[1]/2; SDL_RenderSetViewport( g_renderer, &top_left_viewport ); // Render texture to the screen SDL_RenderCopy( g_renderer, g_texture, NULL, NULL ); // Set the viewport to the top right corner SDL_Rect top_right_viewport; top_right_viewport.x = screen_width_height[0]/2; top_right_viewport.y = 0; top_right_viewport.w = screen_width_height[0]/2; top_right_viewport.h = screen_width_height[1]/2; SDL_RenderSetViewport( g_renderer, &top_right_viewport ); // Render texture to screen SDL_RenderCopy( g_renderer, g_texture, NULL, NULL ); // Set the viewport to the bottom SDL_Rect bottom_viewport; bottom_viewport.x = 0; bottom_viewport.y = screen_width_height[0]/2; bottom_viewport.w = screen_width_height[0]; bottom_viewport.h = screen_width_height[1]/2; SDL_RenderSetViewport( g_renderer, &bottom_viewport ); // Render texture to screen SDL_RenderCopy( g_renderer, g_texture, NULL, NULL ); // Update the screen SDL_RenderPresent( g_renderer ); } } } // Close program close(); return 0; }
void statement(int loop, Swtch swp, int lev) { float ref = refinc; if (Aflag >= 2 && lev == 15) warning("more than 15 levels of nested statements\n"); switch (t) { case IF: ifstmt(genlabel(2), loop, swp, lev + 1); break; case WHILE: whilestmt(genlabel(3), swp, lev + 1); break; case DO: dostmt(genlabel(3), swp, lev + 1); expect(';'); break; case FOR: forstmt(genlabel(4), swp, lev + 1); break; case BREAK: walk(NULL, 0, 0); definept(NULL); if (swp && swp->lab > loop) branch(swp->lab + 1); else if (loop) branch(loop + 2); else error("illegal break statement\n"); t = gettok(); expect(';'); break; case CONTINUE: walk(NULL, 0, 0); definept(NULL); if (loop) branch(loop + 1); else error("illegal continue statement\n"); t = gettok(); expect(';'); break; case SWITCH: swstmt(loop, genlabel(2), lev + 1); break; case CASE: { int lab = genlabel(1); if (swp == NULL) error("illegal case label\n"); definelab(lab); while (t == CASE) { static char stop[] = { IF, ID, 0 }; Tree p; t = gettok(); p = constexpr(0); if (generic(p->op) == CNST && isint(p->type)) { if (swp) { needconst++; p = cast(p, swp->sym->type); if (p->type->op == UNSIGNED) p->u.v.i = extend(p->u.v.u, p->type); needconst--; caselabel(swp, p->u.v.i, lab); } } else error("case label must be a constant integer expression\n"); test(':', stop); } statement(loop, swp, lev); } break; case DEFAULT: if (swp == NULL) error("illegal default label\n"); else if (swp->deflab) error("extra default label\n"); else { swp->deflab = findlabel(swp->lab); definelab(swp->deflab->u.l.label); } t = gettok(); expect(':'); statement(loop, swp, lev); break; case RETURN: { Type rty = freturn(cfunc->type); t = gettok(); definept(NULL); if (t != ';') if (rty == voidtype) { error("extraneous return value\n"); expr(0); retcode(NULL); } else retcode(expr(0)); else { if (rty != voidtype) { warning("missing return value\n"); retcode(cnsttree(inttype, 0L)); } else retcode(NULL); } branch(cfunc->u.f.label); } expect(';'); break; case '{': compound(loop, swp, lev + 1); break; case ';': definept(NULL); t = gettok(); break; case GOTO: walk(NULL, 0, 0); definept(NULL); t = gettok(); if (t == ID) { Symbol p = lookup(token, stmtlabs); if (p == NULL) { p = install(token, &stmtlabs, 0, FUNC); p->scope = LABELS; p->u.l.label = genlabel(1); p->src = src; } use(p, src); branch(p->u.l.label); t = gettok(); } else error("missing label in goto\n"); expect(';'); break; case ID: if (getchr() == ':') { stmtlabel(); statement(loop, swp, lev); break; } default: definept(NULL); if (kind[t] != ID) { error("unrecognized statement\n"); t = gettok(); } else { Tree e = expr0(0); listnodes(e, 0, 0); if (nodecount == 0 || nodecount > 200) walk(NULL, 0, 0); else if (glevel) walk(NULL, 0, 0); deallocate(STMT); } expect(';'); break; } if (kind[t] != IF && kind[t] != ID && t != '}' && t != EOI) { static char stop[] = { IF, ID, '}', 0 }; error("illegal statement termination\n"); skipto(0, stop); } refinc = ref; }
int main(int argc, char* argv[]) { string cfgFile; try{ namespace po = boost::program_options; po::options_description generic("Generic options"); generic.add_options() ("version,v", "print version string") ("help,h", "help message") ("about,a", "about me") ; po::options_description config("Configuration"); config.add_options() ("config,c",po::value<string>(&cfgFile)->default_value("moreobs.cfg"),"config file") ; po::options_description cmdline_options; cmdline_options.add(generic).add(config); po::variables_map vm; po::store(po::parse_command_line(argc, argv, cmdline_options),vm); po::notify(vm); if (vm.count("help")) { cout << cmdline_options << "\n"; return 1; } if (vm.count("version")) { cout << "Version: " << "0.2.1079" << "\n"; return 1; } if (vm.count("about")) { cout<< "Waaagh!TV Client Simulation Server (personal)"<<endl; cout<< "Author: binux@CN" <<endl <<"Version: " <<"0.2.1079" <<endl << "Build: 2010-7-9"<<endl <<"This program is based on Waaagh!TV. All information about the protocol is guessing by looking at the network traffic. Thanks to guys for your useful programs."<<endl; return 1; } if (cfgFile!="moreobs.cfg" && vm.count("config")) { cout << "Using config file :" << cfgFile << endl; } } catch(boost::system::system_error& e) { DEBUG_Print(string("[MAIN]") + e.what() , DEBUG_LEVEL_ERROR); return 1; } //============================================================================================================ CConfig cfg; cfg.Read(cfgFile); debug_level = cfg.GetInt( "debug_level" , 99 ); gLogFile = cfg.GetString( "log", string( ) ); gLogMethod = cfg.GetInt( "logmethod", 1 ); if( !gLogFile.empty( ) ) { if( gLogMethod == 1 ) { // log method 1: open, append, and close the log for every message // this works well on Linux but poorly on Windows, particularly as the log file grows in size // the log file can be edited/moved/deleted while GHost++ is running } else if( gLogMethod == 2 ) { // log method 2: open the log on startup, flush the log for every message, close the log on shutdown // the log file CANNOT be edited/moved/deleted while GHost++ is running gLog = new ofstream( ); gLog->open( gLogFile.c_str( ), ios :: app ); } } CONSOLE_Print( "[MAIN] starting up" ); if( !gLogFile.empty( ) ) { if( gLogMethod == 1 ) CONSOLE_Print( "[MAIN] using log method 1, logging is enabled and [" + gLogFile + "] will not be locked" , DEBUG_LEVEL_MESSAGE ); else if( gLogMethod == 2 ) { if( gLog->fail( ) ) CONSOLE_Print( "[MAIN] using log method 2 but unable to open [" + gLogFile + "] for appending, logging is disabled" , DEBUG_LEVEL_WARN ); else CONSOLE_Print( "[MAIN] using log method 2, logging is enabled and [" + gLogFile + "] is now locked" , DEBUG_LEVEL_MESSAGE ); } } else CONSOLE_Print( "[MAIN] no log file specified, logging is disabled" , DEBUG_LEVEL_WARN); gMoreObs = new CMoreObs( &cfg ); //runing gMoreObs->Run(); //shutdown CONSOLE_Print( "[MAIN] shutting down", DEBUG_LEVEL_MESSAGE ); delete gMoreObs; gMoreObs = NULL; if( gLog ) { if( !gLog->fail( ) ) gLog->close( ); delete gLog; } return 0; }
int main( int ac, char* av[] ) { try { std::cout << "FE analysis of Ducati steel trellis frame using FELyX\n"; // PROGRAM OPTIONS // --------------- // Declare a group of options that will be allowed only on command line po::options_description generic( "Generic options" ); unsigned noise; generic.add_options() ( "version,v", "Print version string" ) ( "help,h", "Produce help message" ) ( "noise,n", po::value<unsigned>( &noise ) ->default_value( 2 ), "Verbosity level (0-2)" ) ; // Declare groups of options that will be allowed both on command line and in config file po::options_description solution( "Solution strategies" ); std::string bwalgo, solver; solution.add_options() #ifdef HAVE_PARDISO ( "bwalgo", po::value<std::string>( &bwalgo ) ->default_value( "mmd" ), "Bandwidth algorithm (mmd, sloan, reverse_sloan, cuthill_mckee, reverse_cuthill_mckee)" ) ( "solver", po::value<std::string>( &solver ) ->default_value( "pardiso" ), "Solver (pardiso, skyline)" ) #else ( "bwalgo", po::value<std::string>( &bwalgo ) ->default_value( "sloan" ), "Bandwidth algorithm (sloan, reverse_sloan, cuthill_mckee, reverse_cuthill_mckee)" ) ( "solver", po::value<std::string>( &solver ) ->default_value( "skyline" ), "Solver (pardiso, skyline)" ) #endif ; // Files to manage po::options_description files( "Files" ); files.add_options() ( "model-path", po::value<std::string>() ->default_value( "DucatiFrameFEModel.ansys" ), "Finite Element model to be used" ) ( "res-path", po::value<std::string>() ->default_value( "DucatiFrame.objectives" ), "Path to result file where objective values are stored" ) ( "param-format", po::value<std::string>() ->default_value( "DoubleList" ), "Format of param file to read" ) ( "param-path", po::value<std::string>() ->default_value( "DoubleList.params" ), "Path to parameter file") ; // Put the different option containers together po::options_description options( "\nFELyX usage: program [options] model_path \nAllowed options" ); options.add( generic ).add( solution ).add( files ); // Store options in variables_map po::variables_map vm; store( po::parse_command_line( ac, av, options ), vm ); notify( vm ); // Define reactions for the different options if ( vm.count( "help" ) ) { std::cout << options << "\n"; return 0; } if ( vm.count( "version" ) ) { std::cout << "\nFELyX " << VERSION << " - The Finite Element LibrarY eXperiment \n\n"; return 0; } fs::path ModelPath( vm[ "model-path" ].as<std::string>(), fs::native ); fs::path ResPath ( vm[ "res-path" ].as<std::string>(), fs::native ); std::string ParamFormat = vm[ "param-format" ].as<std::string>(); fs::path ParamPath( vm[ "param-path" ].as<std::string>(), fs::native ); // RUN FEA ANALYSIS //StructObject FEM(ModelPath.leaf(), fs::complete(ModelPath).branch_path().native_file_string(),noise ); DucFelyxObject FEM( noise, 15, ModelPath ); FEM.NodesReordering( bwalgo ); FEM.updateTubeProperties(ParamPath,ParamFormat); // Save new model, if needed // FEM.SaveAnsysModel(); FEM.ApplyTorsionLoadcase(); if ( solver == "skyline" ) FEM.DirectSolver(); else if ( solver == "pardiso" ) FEM.SparseSolver(); else std::cerr << "WARNING: No valid solver type specified, evaluating nothing!\n "; double Stiffness= FEM.EvalTorsionStiffness(); FEM.ApplyBrakingLoadcase(); if ( solver == "skyline" ) FEM.DirectSolver(); else if ( solver == "pardiso" ) FEM.SparseSolver(); else std::cerr << "WARNING: No valid solver type specified, evaluating nothing!\n "; double MaxStress= FEM.EvalMaxStress( 1, 2 ) ; double Mass= FEM.EvalMass(1,2); exportObjectives( ResPath, Mass, Stiffness, MaxStress); } // Catch exceptions catch ( std::exception & e ) { cerr << e.what() << endl; return 1; } std::cout << "FELyX analysis done\n"; return 0; }
void GlobalData::read_parameters (int ac, char* av[]) { std::string input_file; std::string output_file; // Variables that will store parsed values for quarks. std::vector<std::string> quark_configs; // Variables that will store parsed values for operators. std::vector<std::string> operator_list_configs; // Variables that will store parsed values for correlators. std::vector<std::string> correlator_list_configs; // Declare a group of options that will be allowed only on command line po::options_description generic("Command line options"); generic.add_options()("help,h", "produce help message")("version,v", "print version string")("verbose", "does additional tests and prints more details")("input,i", po::value<std::string>(&input_file)->default_value("LapHs.in"), "name of input file.")("output,o", po::value<std::string>(&output_file)->default_value("LapHs.out"), "name of output file."); // Declare a group of options that will be // allowed both on command line and in input file po::options_description config("Input file options"); // parallelisation options config.add_options() ("nb_omp_threads", po::value<size_t>(&nb_omp_threads)->default_value(1), "nb_omp_threads: number of openMP threads") ("nb_eigen_threads", po::value<size_t>(&nb_eigen_threads)->default_value(1), "nb_eigen_threads: number of threads Eigen uses internally"); // lattice options config.add_options() ("output_path", po::value<std::string>(&path_output)-> default_value("../../contractions"), "path for output") ("overwrite_old", po::value<std::string>(&overwrite)->default_value("no"), "shall old correlator files be overwritten, yes or no") ("config_path", po::value<std::string>(&path_config)->default_value("../../configs"), "path for configurations") ("lattice", po::value<std::string>(&name_lattice)-> default_value("lattice"), "Codename of the lattice") ("Lt", po::value<int>(&Lt)->default_value(0), "Lt: temporal lattice extend") ("Lx", po::value<int>(&Lx)->default_value(0), "Lx: lattice extend in x direction") ("Ly", po::value<int>(&Ly)->default_value(0), "Ly: lattice extend in y direction") ("Lz", po::value<int>(&Lz)->default_value(0), "Lz: lattice extend in z direction"); // eigenvector options config.add_options() ("number_of_eigen_vec", po::value<int>(&number_of_eigen_vec)->default_value(0), "Number of eigen vectors") ("path_eigenvectors", po::value<std::string>(&path_eigenvectors)->default_value("."), "directory of eigenvectors") ("name_eigenvectors", po::value<std::string>(&name_eigenvectors)-> default_value("eigenvector"), "name of eigenvectors\nThe full name is internally created to:\n" "\"name_of_eigenvectors.eigenvector\n. time slice.configuration\""); // quark options config.add_options() ("quarks.quark", make_value(&quark_configs), "quark input, must be of type:\n" "quark = \n type:number of rnd. vec.:\n" " dil type time:number of dil time:\n" " dil type ev:number of dil ev:\n" " dil type Dirac:number of dil Dirac:\n" " path of the perambulators for these quarks"); // operator list options config.add_options() ("operator_lists.operator_list", make_value(&operator_list_configs), "operator input is rather complicated - see documentation!!"); // correlator list options config.add_options() ("correlator_lists.correlator_list", make_value(&correlator_list_configs), "correlator input is rather complicated - see documentation!!"); // configuration options config.add_options() ("start_config", po::value<int>(&start_config)->default_value(-1), "First configuration") ("end_config", po::value<int>(&end_config)->default_value(0), "Last configuration") ("delta_config", po::value<int>(&delta_config)->default_value(0), "Stepsize between two configurations"); po::options_description cmdline_options; cmdline_options.add(generic).add(config); po::options_description input_file_options; input_file_options.add(config); po::options_description visible("Allowed options"); visible.add(generic).add(config); po::positional_options_description p; p.add("input-file", -1); po::variables_map vm; po::store(po::command_line_parser(ac, av).options(cmdline_options). positional(p).run(), vm); po::notify(vm); // ************************************************************************* // command line options **************************************************** if(vm.count("help")){ std::cout << visible << "\n"; exit(0); } if(vm.count("verbose")){ verbose = 1; } else verbose = 0; if(vm.count("version")){ std::cout << "Contraction code for LapHs perambulators. Version 0.1. \n"; exit(0); } std::ifstream ifs(input_file.c_str()); if(!ifs){ std::cout << "CANNOT open input file: " << input_file << "\n"; exit(0); } else{ po::store(parse_config_file(ifs, input_file_options), vm); po::notify(vm); } ifs.close(); // reading input file options input_handling(quark_configs, operator_list_configs, correlator_list_configs); // setting the lookup tables for all needed quantum numbers to calculate // the wanted correlators init_lookup_tables(); // TODO: should be put in a separate function // setting the sizes and numbers of random vectors and perambulators rnd_vec_construct.nb_entities = 0; for(const auto& q: quarks) rnd_vec_construct.nb_entities += q.number_of_rnd_vec; rnd_vec_construct.length = Lt * 4 * number_of_eigen_vec; peram_construct.nb_entities = rnd_vec_construct.nb_entities; for(const auto& q: quarks){ for(size_t r = 0; r < q.number_of_rnd_vec; r++){ peram_construct.size_rows.push_back(rnd_vec_construct.length); peram_construct.size_cols.push_back((Lt / q.number_of_dilution_T) * q.number_of_dilution_E * q.number_of_dilution_D); } } }
/* * Command parser. */ static void cmdscanner(void) { register struct cmd *c; static EditLine *el; static History *hist; HistEvent he; size_t len; int num; const char *bp; num = 0; bp = NULL; el = NULL; hist = NULL; for (;;) { if (fromatty) { if (!el) { el = el_init("lpc", stdin, stdout, stderr); hist = history_init(); history(hist, &he, H_SETSIZE, 100); el_set(el, EL_HIST, history, hist); el_set(el, EL_EDITOR, "emacs"); el_set(el, EL_PROMPT, lpc_prompt); el_set(el, EL_SIGNAL, 1); el_source(el, NULL); /* * EditLine init may call 'cgetset()' to set a * capability-db meant for termcap (eg: to set * terminal type 'xterm'). Reset that now, or * that same db-information will be used for * printcap (giving us an "xterm" printer, with * all kinds of invalid capabilities...). */ cgetset(NULL); } if ((bp = el_gets(el, &num)) == NULL || num == 0) quit(0, NULL); len = (num > MAX_CMDLINE - 1) ? MAX_CMDLINE - 1 : num; memcpy(cmdline, bp, len); cmdline[len] = 0; history(hist, &he, H_ENTER, bp); } else { if (fgets(cmdline, MAX_CMDLINE, stdin) == NULL) quit(0, NULL); if (cmdline[0] == 0 || cmdline[0] == '\n') break; } makeargv(); if (margc == 0) continue; if (el != NULL && el_parse(el, margc, margv) != -1) continue; c = getcmd(margv[0]); if (c == (struct cmd *)-1) { printf("?Ambiguous command\n"); continue; } if (c == 0) { printf("?Invalid command\n"); continue; } if ((c->c_opts & LPC_PRIVCMD) && getuid() && ingroup(LPR_OPER) == 0) { printf("?Privileged command\n"); continue; } /* * Two different commands might have the same generic rtn * (eg: "clean" and "tclean"), and just use different * handler routines for distinct command-setup. The handler * routine might also be set on a generic routine for * initial parameter processing. */ if (c->c_generic != 0) generic(c->c_generic, c->c_opts, c->c_handler, margc, margv); else (*c->c_handler)(margc, margv); } }
static Tree root1(Tree p) { if (p == NULL) return p; if (p->type == voidtype) warn++; switch (generic(p->op)) { case COND: { Tree q = p->kids[1]; assert(q && q->op == RIGHT); if (p->u.sym && q->kids[0] && generic(q->kids[0]->op) == ASGN) q->kids[0] = root1(q->kids[0]->kids[1]); else q->kids[0] = root1(q->kids[0]); if (p->u.sym && q->kids[1] && generic(q->kids[1]->op) == ASGN) q->kids[1] = root1(q->kids[1]->kids[1]); else q->kids[1] = root1(q->kids[1]); p->u.sym = 0; if (q->kids[0] == 0 && q->kids[1] == 0) p = root1(p->kids[0]); } break; case AND: case OR: if ((p->kids[1] = root1(p->kids[1])) == 0) p = root1(p->kids[0]); break; case NOT: if (warn++ == 0) warning("expression with no effect elided\n"); return root1(p->kids[0]); case RIGHT: if (p->kids[1] == 0) return root1(p->kids[0]); if (p->kids[0] && p->kids[0]->op == CALL + B && p->kids[1] && p->kids[1]->op == INDIR + B) /* avoid premature release of the CALL+B temporary */ return p->kids[0]; if (p->kids[0] && p->kids[0]->op == RIGHT && p->kids[1] == p->kids[0]->kids[0]) /* de-construct e++ construction */ return p->kids[0]->kids[1]; p = tree(RIGHT, p->type, root1(p->kids[0]), root1(p->kids[1])); return p->kids[0] || p->kids[1] ? p : (Tree)0; case EQ: case NE: case GT: case GE: case LE: case LT: case ADD: case SUB: case MUL: case DIV: case MOD: case LSH: case RSH: case BAND: case BOR: case BXOR: if (warn++ == 0) warning("expression with no effect elided\n"); p = tree(RIGHT, p->type, root1(p->kids[0]), root1(p->kids[1])); return p->kids[0] || p->kids[1] ? p : (Tree)0; case INDIR: if (p->type->size == 0 && unqual(p->type) != voidtype) warning("reference to `%t' elided\n", p->type); if (isptr(p->kids[0]->type) && isvolatile(p->kids[0]->type->type)) warning("reference to `volatile %t' elided\n", p->type); /* fall thru */ case CVI: case CVF: case CVU: case CVP: case NEG: case BCOM: case FIELD: if (warn++ == 0) warning("expression with no effect elided\n"); return root1(p->kids[0]); case ADDRL: case ADDRG: case ADDRF: case CNST: if (needconst) return p; if (warn++ == 0) warning("expression with no effect elided\n"); return NULL; case ARG: case ASGN: case CALL: case JUMP: case LABEL: break; default: assert(0); } return p; }
int main( int argc, char** argv ) { // Create the hidden program options (required args) boost::program_options::options_description hidden( "Hidden options" ); hidden.add_options() ("sprite_sheet", boost::program_options::value<std::string>(), "the sprite sheet (with path) that will be used\n"); // Create the positional (required) args boost::program_options::positional_options_description pd; pd.add("sprite_sheet", 1 ); // Create the optional arguments boost::program_options::options_description generic( "Allowed options" ); generic.add_options() ("help,h", "produce help message"); // Create the command-line argument parser boost::program_options::options_description cmdline_options( "Allowed options" ); cmdline_options.add(generic).add(hidden); boost::program_options::variables_map vm; boost::program_options::store( boost::program_options::command_line_parser(argc, argv).options(cmdline_options).positional(pd).run(), vm ); boost::program_options::notify( vm ); // Check if the help message was requested if( vm.count( "help" ) ) { std::cerr << cmdline_options << std::endl; return 1; } // Store the image name std::string sprite_sheet_name; if( vm.count( "sprite_sheet" ) ) sprite_sheet_name = vm["sprite_sheet"].as<std::string>(); else { std::cerr << "The sprite sheet (with path) must be specified." << std::endl; return 1; } // Initialize the window if( !initialize() ) return 1; else { // Load the bitmap if( !loadMedia( sprite_sheet_name ) ) return 1; else { bool quit = false; // Event SDL_Event event; // Main application loop while( !quit ) { while( SDL_PollEvent( &event ) != 0 ) { if( event.type == SDL_QUIT ) quit = true; } // Clear the screen SDL_SetRenderDrawColor( g_renderer, 0xFF, 0xFF, 0xFF, 0xFF ); SDL_RenderClear( g_renderer ); // Render the top left sprite g_sprite_sheet_texture.render( 0, 0, &g_sprite_clips[0] ); // Render the top right sprite g_sprite_sheet_texture.render( screen_width_height[0] - g_sprite_clips[1].w, 0, &g_sprite_clips[1] ); // Render the bottom left sprite g_sprite_sheet_texture.render( 0, screen_width_height[1] - g_sprite_clips[2].h, &g_sprite_clips[2] ); // Render the bottom right sprite g_sprite_sheet_texture.render( screen_width_height[0] - g_sprite_clips[3].w, screen_width_height[1] - g_sprite_clips[3].h, &g_sprite_clips[3] ); // Update the screen SDL_RenderPresent( g_renderer ); } } } // Close program close(); return 0; }