int main(){ initializeScreen(SCREEN_WIDTH,SCREEN_HEIGHT); initializeOpenGl(SCREEN_WIDTH,SCREEN_HEIGHT); mesh *malha = NULL; malha = New_Mesh(); mesh malha2; malha2 = Load_Mesh(malha,"bun_zipper.off"); malha = &malha2; calculaDeltas(malha); Resize_Mesh(malha,3); centralizaMesh(malha); while(1){ processEvents(); Render_Mesh(malha,TRIANGLES); SDL_Delay(500); } Del_Mesh(malha); return 0; }
int main(int argc, char** argv) { // used to set execution rate to 60hz clock_t prevtime; clock_t curtime; int delay = 0; // initialize graphics WINDOW *scrn; // pointer to screen object for ncurse (not sure if required) scrn = initscr(); // initalized the screen clear(); // clears the screen timeout(3); // sets getch() to wait 50ms srand(time(NULL)); // need random generator for one of the opcodes implemented chip8 myChip8; // initalize myChip8 initializeMyChip(&myChip8); initializeScreen(&myChip8); // load program into memory, exit if not loaded correctly if(loadProgram(&myChip8, "./ROMS/PONG") == 1){ return 0; } noecho(); // curses function, turns off echo of keyboard input cbreak(); // curses, reports keystrokes without waiting for return key // should probably come up with a better end condition but loops until pc == 0 while(myChip8.pc != 0){ prevtime = clock(); // stores the time at start of execution cycle executeCycle(&myChip8); // execute one cycle // Checks if draw flag is set to 1, if not no changes need to be drawn if(myChip8.draw != 0){ draw(&myChip8); myChip8.draw = 0; } // gets any changes to input getInput(&myChip8); // slows down execution to 60hz curtime = clock(); // gets clock at end of execution cycle // if execution time was greater than 17 ms (1sec/60) than continue if less // sleep so delay + execution time is equal to 17 ms if(((curtime * 1000 / CLOCKS_PER_SEC) - (prevtime * 1000 / CLOCKS_PER_SEC)) < 17){ delay = 17 - ((curtime * 1000 / CLOCKS_PER_SEC) - (prevtime * 1000 / CLOCKS_PER_SEC)); usleep(delay ); } } }
int constructScreenDriver (char **parameters) { initializeScreen(); if (mainScreen.processParameters(parameters)) { if (mainScreen.construct()) { return 1; } else { logMessage(LOG_DEBUG, "screen driver initialization failed: %s", screen->definition.code); } mainScreen.releaseParameters(); } return 0; }
void QDirectFbIntegration::initialize() { initializeDirectFB(); initializeScreen(); initializeInput(); }
void setNoScreen (void) { screen = &noScreen; initializeScreen(); }
int main(int argc, char *argv[]) { //Check arguments if(argc < 2 || argc > 4) { fprintf(stderr, "Usage: %s NAME [SERVERIP] [PORT]\n", argv[0]); fprintf(stderr, "By default SERVERIP=%s and PORT=%u.\n", DEFAULTIP, DEFAULTPORT); exit(1); } //Make sure we don't mess up the terminal signal(SIGINT, cleanup); signal(SIGTERM, cleanup); signal(SIGABRT, cleanup); #ifndef WIN32 signal(SIGSTOP, cleanup); signal(SIGTSTP, cleanup); #endif unsigned short port = DEFAULTPORT; //p for current players unsigned char i, n, players, bombs, id, mines, p; int sock; struct data *pData = NULL; #ifdef WIN32 WSADATA wsaData; if(WSAStartup(MAKEWORD(2, 0), &wsaData)) { fprintf(stderr, "WSAStartup() failed.\n"); exit(10); } #endif //Validate port if(argc == 4 && !(port = strtoul(argv[3], NULL, 0))) { fprintf(stderr, "Invalid port.\n"); exit(2); } //Check if it's a 7 bit name for(i = 0; argv[1][i]; i++) { if(argv[1][i] < 32 || argv[1][i] > 127) { fprintf(stderr, "Invalid name, only 7-bit characters are allowed.\n"); exit(9); } } //Initialize curses initscr(); noecho(); //Check if it is big enough if(LINES < MINLINES || COLS < MINCOLS ) { endwin(); fprintf(stderr, "Your terminal has to be, at least, %ux%u.\n", MINCOLS, MINLINES); exit(3); } //Try to connect i = startSocket(&sock, argc >= 3? argv[2] : DEFAULTIP, port); if(i) { endwin(); switch(i) { case 1: fprintf(stderr, "The socket could not be created.\n"); exit(4); case 2: fprintf(stderr, "Unable to resolv %s.\n", argc >= 3? argv[2] : DEFAULTIP); exit(5); default: fprintf(stderr, "Unable to connect to %s.\n", argc >= 3? argv[2] : DEFAULTIP); exit(6); } } //Send name and retrieve basic info from the server p = exchangeBasics(sock, &players, &bombs, &mines, &id, argv[1], &pData); //Lost connection if(!p) { endwin(); fprintf(stderr, "Lost connection to the server.\n"); exit(7); } //Copy own name for(i = 0; argv[1][i] && i < 16; i++) { pData[id].name[i] = argv[1][i]; } pData[id].name[i] = 0; //Update own stats pData[id].stats = 1; //Initialize the field unsigned char field[16][16]; for(i = 0; i < 16; i++) { for(n = 0; n < 16; n++) { field[i][n] = 10; } } //Draw the basic interface WINDOW *left, *middle, *right, *bottom, *textBox; if(initializeScreen(&left, &middle, &right, &bottom, &textBox)) { fprintf(stderr, "Out of memory.\n"); exit(8); } drawMiddle(middle, field); drawLeft(left, players, id, bombs, mines, pData); drawRight(right); refresh(); wrefresh(left); wrefresh(middle); wrefresh(right); wrefresh(bottom); wrefresh(textBox); //Play p = game(left, bottom, textBox, middle, sock, id, players, bombs, mines, pData, field); shutdown(sock, 2); #ifdef WIN32 closesocket(sock); #else close(sock); #endif if(!p) { showWinner(bottom, players, pData); } //Close curses endwin(); if(p) { fprintf(stderr, "Lost connection to the server.\n"); } //Close curses delwin(left); delwin(middle); delwin(right); delwin(bottom); delwin(textBox); //Free the memory free(pData); return 0; }