int main(int argc, char **argv) { int COLS, ROWS; if (GrOpen() < 0) { GrError("Cannot open graphics\n"); return 1; } COLS = 350; ROWS = 300; g_main = GrNewWindowEx(GR_WM_PROPS_APPWINDOW, "dashdemo", GR_ROOT_WINDOW_ID, 100, 50, COLS - 120, ROWS - 60, BLUE); GrSelectEvents(g_main, GR_EVENT_MASK_EXPOSURE|GR_EVENT_MASK_CLOSE_REQ); GrMapWindow(g_main); while (1) { GR_EVENT event; GrGetNextEvent(&event); switch (event.type) { case GR_EVENT_TYPE_EXPOSURE: draw_screen(); break; case GR_EVENT_TYPE_CLOSE_REQ: GrClose(); return 0; } } }
void loop(void) { static long lastMsg = 0; static int value = 0; char msg[50] = { '\0' }; draw_screen(); if (!client.connected()) { reconnect(); } client.loop(); long now = millis(); if (now - lastMsg > 2000) { lastMsg = now; ++value; sprintf(msg, "hello world #%ld", value); Serial.print("Publish message: "); Serial.println(msg); client.publish("outTopic", msg); } }
void help(editor_t *ed) { gotoxy(ed, 0, 0); clear_screen(ed); outstr(ed,"Editor Command Summary\r\n"); outstr(ed, "======================\r\n\r\n"); outstr(ed, "<up> Move one line up (*) \r\n"); outstr(ed, "<down> Move one line down (*) \r\n"); outstr(ed, "<left> Move one character left (*) Ctrl+S Save file\r\n"); outstr(ed, "<right> Move one character right (*) Ctrl+W Close file\r\n"); outstr(ed, "<pgup> Move one page up (*) Ctrl+Q Quit\r\n"); outstr(ed, "<pgdn> Move one page down (*) \r\n"); outstr(ed, "Ctrl+<left> Move to previous word (*) Ctrl+A Select all\r\n"); outstr(ed, "Ctrl+<right> Move to next word (*) Ctrl+C Copy selection to clipboard\r\n"); outstr(ed, "<home> Move to start of line (*) Ctrl+X Cut selection to clipboard\r\n"); outstr(ed, "<end> Move to end of line (*) Ctrl+V Paste from clipboard\r\n"); outstr(ed, "Ctrl+<home> Move to start of file (*) Ctrl+Z Undo\r\n"); outstr(ed, "Ctrl+<end> Move to end of file (*) Ctrl+R Redo\r\n"); outstr(ed, "<backspace> Delete previous character Ctrl+F Find text\r\n"); outstr(ed, "<delete> Delete current character Ctrl+G Find next\r\n"); outstr(ed, " Ctrl+L Goto line\r\n"); outstr(ed, "<tab> Indent selection F1 Help\r\n"); outstr(ed, "Shift+<tab> Unindent selection F3 Navigate to file\r\n"); outstr(ed, " F5 Redraw screen\r\n"); outstr(ed, "\r\n(*) Extends selection if combined with Shift"); outstr(ed, "\r\nPress any key to continue..."); getkey(ed); draw_screen(ed); draw_full_statusline(ed); }
void handle_expose(Display* display, GC gc, GC rev_gc, XExposeEvent* expose_event) { if (expose_event->count != 0) return; draw_screen(display, gc, rev_gc, expose_event->window); }
static inline int neo_interrupt(void) { /* static int fc; int skip_this_frame; */ pd4990a_addretrace(); // printf("neogeo_frame_counter_speed %d\n",neogeo_frame_counter_speed); if (!(irq2control & 0x8)) { if (fc >= neogeo_frame_counter_speed) { fc = 0; neogeo_frame_counter++; } fc++; } skip_this_frame = skip_next_frame; skip_next_frame = frame_skip(0); if (!skip_this_frame) { draw_screen(); } return 1; }
int main(void) { draw_screen(); // Main "game" loop while (1) { switch (joypad()) { case J_LEFT: _input1--; redraw_in1(); break; case J_RIGHT: _input1++; redraw_in1(); break; case J_UP: _input2++; redraw_in2(); break; case J_DOWN: _input2--; redraw_in2(); break; case J_START: calc_ans(); break; case J_SELECT: select_op(); break; } } return 0; }
int main( int argc, char* argv[] ) { if (argc > 1) { cout << "Retro Quake2 Model - W.P. van Paassen - 2002" << endl; return -1; } TDEC_init_video(); SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 5 ); SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 5 ); SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 5 ); SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 16 ); SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 ); if (!TDEC_set_video_GL(SCREEN_WIDTH, SCREEN_HEIGHT, 16, SDL_DOUBLEBUF | SDL_HWACCEL | SDL_HWSURFACE | SDL_HWPALETTE /*| SDL_FULLSCREEN*/)) quit(1); TDEC_init_timer(); SDL_WM_SetCaption("Retro Quake2 Model effect ", ""); WP_Init* wpcg = new WP_Init(argc, argv); wpcg->vSetViewPort(0, SCREEN_WIDTH, SCREEN_HEIGHT, 0); init(); Uint32 ntime, time = SDL_GetTicks(); Uint32 next = SDL_GetTicks() + TICK_INTERVAL; /* time based demo loop */ while( 1 ) { if ((ntime = SDL_GetTicks()) < next) { draw_screen(); if (ntime - time >= 1000) { rfps = fps;//(Uint32)(((float)fps / (ntime - time)) * 1000); fps = 0; time = SDL_GetTicks(); } else fps++; } else { process_events(); demon->setNewHeading(heading); weapon->setNewHeading(heading); heading += 0.6f; if (heading >= 360.0f) heading -= 360.0f; manager->updateAll(); next = SDL_GetTicks() + TICK_INTERVAL; } } return 0; /* never reached */ }
int main(int argc, char* argv[]) { // If intialising of SDL fails -> quit the program with error code 1 if (!init_SDL()) { quit_program(1); } // If intialising of OpenGL fails -> quit the program with error code 1 if (!init_OpenGL(default_width, default_height)) { quit_program(1); } // Repeat forever while(true) { // Draw your graphics draw_screen(); // Process any ocuring events process_events(); fflush(stdout); } // You shouldn't get here. Only if someone changes the while condition... quit_program(0); return 0; }
static inline int neo_interrupt(void) { /* static int fc; int skip_this_frame; */ pd4990a_addretrace(); // printf("neogeo_frame_counter_speed %d\n",neogeo_frame_counter_speed); if (!(irq2control & 0x8)) { if (fc >= neogeo_frame_counter_speed) { fc = 0; neogeo_frame_counter++; } fc++; } skip_this_frame = skip_next_frame; skip_next_frame = frame_skip(0); if (!skip_this_frame) { PROFILER_START(PROF_VIDEO); #ifdef DEBUG_VIDEO draw_screen_scanline(0, 256, 1); #else #ifdef FULL_GL fgl_drawscreen(); #else draw_screen(); #endif #endif PROFILER_STOP(PROF_VIDEO); } return 1; }
/* * initialises neccessary componenets so the game can be played, then * handles the playing of the game */ void Window::start_game() { start_ncurses(); snake.go(); // start snake off food.push_back(create_food()); // initial piece of food bool dead = false; while(!dead) // game loop { char input = getch(); if(input != ERR) // user pressed something handle_input(input); update_directions(); if(is_on_food()) { snake.grow(); food.push_back(create_food()); // create new food } if(snake.has_died()) dead = true; draw_screen(); } Game_Manager::game_over(); }
int main(int argc, char *args[]) { screen_t screen; struct timeb tb; struct tm *t; init(); while (1) { ftime(&tb); t = localtime(&tb.time); clear_clock(screen); doppelpunkt(2,screen); myclock(t->tm_hour,t->tm_min, screen); //putpixel(10,20,1,screen); draw_screen(screen); sleep(10); } clr(); return 0; }
int main(void){ // Game Ticks to manage FPS (This code is Windows only ) int next_game_tick = GetTickCount(); int sleep time = 0; int game_is_running = 1; start_game(); //system_func.h? while ( game_is_running = 1 ) { // Basic Game Loop handle_input(); update_game(); draw_screen(); next_game_tick += SKIP_TICKS; // Determine Sleep time (windows function!) sleep_time = next_game_tick - GetTickCount(); if( sleep_time >= 0 ) Sleep( sleep_time ); if( terminal_read() == TK_CLOSE) { // Some sort of Save/clean escape function? terminal_close(); printf("\n Clean Exit. \n"); return 0; } } }
void updatescreen(void) { /* update sound */ sound_frame_update(); /* if we're not skipping this frame, draw the screen */ if (!osd_skip_this_frame()) { profiler_mark(PROFILER_VIDEO); draw_screen(); profiler_mark(PROFILER_END); } /* the user interface must be called between vh_update() and osd_update_video_and_audio(), */ /* to allow it to overlay things on the game display. We must call it even */ /* if the frame is skipped, to keep a consistent timing. */ ui_update_and_render(artwork_get_ui_bitmap()); /* update our movie recording state */ if (!mame_is_paused()) record_movie_frame(scrbitmap[0]); /* blit to the screen */ update_video_and_audio(); /* call the end-of-frame callback */ if (Machine->drv->video_eof && !mame_is_paused()) { profiler_mark(PROFILER_VIDEO); (*Machine->drv->video_eof)(); profiler_mark(PROFILER_END); } }
int updatescreen(void) { /* update sound */ sound_update(); if (osd_skip_this_frame() == 0) { profiler_mark(PROFILER_VIDEO); if (need_to_clear_bitmap) { osd_clearbitmap(real_scrbitmap); need_to_clear_bitmap = 0; } draw_screen(bitmap_dirty); /* update screen */ bitmap_dirty = 0; profiler_mark(PROFILER_END); } /* the user interface must be called between vh_update() and osd_update_video_and_audio(), */ /* to allow it to overlay things on the game display. We must call it even */ /* if the frame is skipped, to keep a consistent timing. */ if (handle_user_interface(real_scrbitmap)) /* quit if the user asked to */ return 1; update_video_and_audio(); if (drv->vh_eof_callback) (*drv->vh_eof_callback)(); return 0; }
static inline void update_screen(void) { if (memory.vid.irq2control & 0x40) memory.vid.irq2start = (memory.vid.irq2pos + 3) / 0x180; /* ridhero gives 0x17d */ else memory.vid.irq2start = 1000; if (!skip_this_frame) { if (last_line < 21) { /* there was no IRQ2 while the beam was in the * visible area -> no need for scanline rendering */ draw_screen(); } else { draw_screen_scanline(last_line - 21, 262, 1); } } last_line = 0; pd4990a_addretrace(); if (fc >= neogeo_frame_counter_speed) { fc = 0; neogeo_frame_counter++; } fc++; //skip_this_frame = skip_next_frame; //skip_next_frame = frame_skip(0); }
/* intercept mouse input to move a point */ void mouse_move_input(int x, int y) { if (left_button_down) { points[current_point].x = x; points[current_point].y = SCREEN_HEIGHT - y; draw_screen(); } }
void do_idle(void) { int i, n, len; if (refresh_screen) { draw_screen(); refresh_screen = 0; } }
cleanupscreen() { /* alarm already turned off */ if (done_curses) { (void) wmove(scroll_w, SCROLL_Y - 1, 0); (void) wclrtoeol(scroll_w); draw_screen(); endwin(); } }
void newturn(void) { repaired = loaded = fired = changed = 0; movebuf[0] = '\0'; alarm(0); if (mf->readyL & R_LOADING) { if (mf->readyL & R_DOUBLE) mf->readyL = R_LOADING; else mf->readyL = R_LOADED; } if (mf->readyR & R_LOADING) { if (mf->readyR & R_DOUBLE) mf->readyR = R_LOADING; else mf->readyR = R_LOADED; } if (!hasdriver) Write(W_DDEAD, SHIP(0), 0, 0, 0, 0); if (sc_hasprompt) { wmove(scroll_w, sc_line, 0); wclrtoeol(scroll_w); } if (Sync() < 0) leave(LEAVE_SYNC); if (!hasdriver) leave(LEAVE_DRIVER); if (sc_hasprompt) wprintw(scroll_w, "%s%s", sc_prompt, sc_buf); if (turn % 50 == 0) Write(W_ALIVE, SHIP(0), 0, 0, 0, 0); if (mf->FS && (!mc->rig1 || windspeed == 6)) Write(W_FS, ms, 0, 0, 0, 0); if (mf->FS == 1) Write(W_FS, ms, 2, 0, 0, 0); if (mf->struck) leave(LEAVE_QUIT); if (mf->captured != 0) leave(LEAVE_CAPTURED); if (windspeed == 7) leave(LEAVE_HURRICAN); adjustview(); draw_screen(); signal(SIGALRM, (sig_t)newturn); alarm(7); }
void do_idle(void) { int i; struct timeval now; if (refresh_screen) { draw_screen(); refresh_screen = 0; gettimeofday(&last_busy, 0); } switch (state) { case AttractLoop: if (over_fps(2)) return; grab_video_in(); write_video_frame_zoom(video_r.min, video_in, VIDEO_ZOOM); break; case Live: if (over_fps(30)) return; grab_video_in(); memcpy(frames[0], video_in, sizeof(frames[0])); /* FALLTHROUGH */ case Frozen: for (i=0; i<nhist; i++) transform(history[i], frames[i], frames[i+1]); write_video_frame_zoom(video_r.min, &frames[nhist], VIDEO_ZOOM); gettimeofday(&now, 0); if (idletime > 0 && elapsed_time(last_busy, now) > idletime) { nhist = 0; unfreeze(); draw_screen(); state = AttractLoop; } if (fps_flag) show_fps(); break; } }
void main() #endif { game_t game; /* Initialize the front end */ fe_init(); /* Initialize the game */ /* Create the game */ memset(&game, 0, sizeof(game_t)); /* Create the paddle */ init_paddle(&game.paddle, SPECIAL_NONE, (SCREEN_WIDTH/2)-(PADDLE_WIDTH/2)); /* Init the balls (only one active) */ init_ball(&game.p_balls[0], game.paddle.x+(PADDLE_WIDTH/2), PADDLE_Y-PADDLE_HEIGHT, BALL_STATE_ACTIVE|BALL_STATE_HOLDING); game.nr_balls = 1; /* Init the specials */ game.lives = NR_LIVES; /* Set the numbe of levels */ if (fe_load_data(game.p_levels, 0, (FIELD_WIDTH+1)*FIELD_HEIGHT, "Zarkanoid")) fe_finalize(); /* Could not load the levels */ game.levels = (game.p_levels[0]-'0')*10+(game.p_levels[1]-'0'); /* Number of levels */ game.level = 5*((game.p_levels[3]-'0')*10+(game.p_levels[4]-'0')); /* Starting level (skip 5 levels at a time) */ #if defined(TARGET_SDL) /* Set the level to start at to the argument */ if (argc > 1) game.level = atoi(argv[1]); #endif /* Load the first level */ goto_level(&game); /* Draw the game screen */ draw_screen(&game); fe_sleep(100); /* Start the game */ do_game(&game); /* Clean up afterwards */ fe_finalize(); #if defined(TARGET_SDL) return 0; #endif }
static gint timeout (C2NetworkTraffic *nt) { gint current_recv, current_send, record; gint seconds_to_display; /* This is a dynamic value, the * SECONDS_TO_DISPLAY constant * is about how much we WISH to * display, not how much we WILL * display. */ GtkWidget *widget = GTK_WIDGET (nt); seconds_to_display = widget->allocation.width / PIXELS_PER_SECOND; current_recv = c2_net_speed_tracker_recv (); current_send = c2_net_speed_tracker_send (); if (g_slist_length (nt->recv) > seconds_to_display) nt->recv = g_slist_remove_link (nt->recv, g_slist_last (nt->recv)); nt->recv = g_slist_prepend (nt->recv, (gpointer) current_recv); if (g_slist_length (nt->send) > seconds_to_display) nt->send = g_slist_remove_link (nt->send, g_slist_last (nt->send)); nt->send = g_slist_prepend (nt->send, (gpointer) current_send); /* Update the maximum speed */ record = current_send > current_recv ? current_send : current_recv; if (record > nt->top_speed) nt->top_speed = record; else { GSList *l; nt->top_speed = 1024; for (l = nt->send; l; l = g_slist_next (l)) if (GPOINTER_TO_INT (l->data) > nt->top_speed) nt->top_speed = GPOINTER_TO_INT (l->data); for (l = nt->recv; l; l = g_slist_next (l)) if (GPOINTER_TO_INT (l->data) > nt->top_speed) nt->top_speed = GPOINTER_TO_INT (l->data); } /* Time to draw */ draw_background (nt); draw_top_speed (nt); draw_list (nt, nt->send); draw_list (nt, nt->recv); draw_screen (nt); return TRUE; }
int main(int argc, char *argv[]) { screen_t screen; int x, y; // int D=atoi(argv[1]); #define D 3 // try other values pthread_t ut; init(); memset(intensity, 0, LCD_ROWS*LCD_COLS*8); pthread_create(&ut, 0, update_thread, 0); for (y=0; y<65; y++) { for (x=0; x<120; x++) image[LCD_COLS*y+x]=0; } while (1) { int x, y, yy, pix; for (y=0; y<LCD_ROWS; y++) { for (x=0; x<LCD_COLS; x++) { pix = 0; for (yy=0; yy<8; yy++) { int off=(8*y+(7-yy))*LCD_COLS+x; int val, t=image[off]; if (intensity[off] < t) val=1; else val=0; pix = (pix<<1) + val; intensity[off]=(intensity[off])*(256-D)/256; intensity[off]+=val*D; } screen[y*LCD_COLS+x] = pix; } } draw_screen(screen); } clr(); return 0; }
int main (int argc, char **argv) { SDL_Surface *screen; SDL_Event event; (void)argc; (void)argv; /* Initialize SDL, open a screen */ screen = init_screen (640, 480, 32); /* Create a timer which will redraw the screen every 100 ms. */ SDL_AddTimer (100, timer_cb, NULL); while (SDL_WaitEvent (&event)) { switch (event.type) { case SDL_KEYDOWN: if (event.key.keysym.sym == SDLK_q) { goto done; } break; case SDL_QUIT: goto done; case SDL_VIDEORESIZE: screen = SDL_SetVideoMode (event.resize.w, event.resize.h, 32, SDL_HWSURFACE | SDL_RESIZABLE); /* fall-through */ case SDL_USEREVENT: draw_screen (screen); break; default: break; } } done: SDL_FreeSurface (screen); SDL_Quit (); return 0; }
void handle_button_down(Display* display, GC gc, GC rev_gc, XButtonEvent* button_event) { int x, y; struct CEventDescriptor event; event.Type = EVENT_TOUCHSCREEN; event.x = button_event->x; event.y = button_event->y; while (!ProcessGUIServer(&event)) ; event.Type = EVENT_NULL; while (!ProcessGUIServer(&event)) ; draw_screen(display, gc, rev_gc, button_event->window); }
struct client *client_create(int sock_fd) { struct client *client; ssize_t size; client = calloc(1, sizeof(struct client)); if (!client) error(1, errno, "cannot allocate memory"); client->d = display_create(); client->w = window_create(client->d); client->sock_fd = sock_fd; init_shaders(client); glViewport(0, 0, client->w->width, client->w->height); glClearColor(0.0, 1.0, 0.0, 0.0); glClear(GL_COLOR_BUFFER_BIT); eglSwapBuffers(client->d->x11.egl_display, client->w->x11.egl_surface); glUniform1i(client->tex_loc, 0); sleep(1); for (;;) { /* glClear(GL_COLOR_BUFFER_BIT); */ /* eglSwapBuffers(client->d->x11.egl_display, client->w->x11.egl_surface); */ struct cmd_buf buf; int myfd; size = sock_fd_read(client->sock_fd, &buf, sizeof(buf), &myfd); if (size <= 0) break; if (buf.type == CMD_TYPE_BUF) { add_texture(client, &buf, myfd); } else if (buf.type == CMD_TYPE_DIRT) { draw_screen(client); eglSwapBuffers(client->d->x11.egl_display, client->w->x11.egl_surface); } } return client; }
/* Called when the player finishes a level (move to next) */ static int handle_level_finished(game_t *p_game) { fe_clear_screen(); draw_screen(p_game); /* Move the paddle to starting place */ init_paddle(&p_game->paddle, PADDLE_NORMAL, (SCREEN_WIDTH/2)-(PADDLE_WIDTH/2)); /* Init the balls (only one active) */ memset(p_game->p_balls, 0, sizeof(ball_t)*MAX_BALLS); init_ball(&p_game->p_balls[0], p_game->paddle.x+(PADDLE_WIDTH/2), PADDLE_Y-PADDLE_HEIGHT, BALL_STATE_ACTIVE|BALL_STATE_HOLDING); p_game->nr_balls = 1; p_game->state = 0; /* Clear the specials */ memset(p_game->p_specials, 0, sizeof(special_t)*MAX_SPECIALS); p_game->level++; return goto_level(p_game); }
/* intercept mouse input */ void mouse_input(int button, int state, int x, int y) { if (button == GLUT_LEFT_BUTTON && state == GLUT_DOWN) { int point_found = update_point(x, SCREEN_HEIGHT - y); if (point_found) left_button_down = 1; if (!point_found && num_points < MAX_POINTS) { points[num_points].x = x; points[num_points].y = SCREEN_HEIGHT - y; current_point = num_points; num_points++; } } else if (button == GLUT_RIGHT_BUTTON && state == GLUT_DOWN) { remove_point(x, SCREEN_HEIGHT - y); } else if (button==GLUT_LEFT_BUTTON && state == GLUT_UP) { left_button_down = 0; } draw_screen(); }
void do_frame(int full) { /* Clear it out */ memset(playground, PLAYGROUND_EMPTY, XUNITS * YUNITS); /* Fill the matrix */ draw_border(); draw_snake(); draw_nibble(); /* Only draw the score if we need to */ /* draw_score(); */ /* Draw it to the offscreen buffer */ draw_screen(full); /* And finally, show it on the screen */ show_buffer(); }
int main(int argc, char* argv[]) { // SDL init SDL_Window *mainWindow; SDL_Init(SDL_INIT_VIDEO); mainWindow = SDL_CreateWindow("Tests OpenGL", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, WINDOW_WIDTH, WINDOW_HEIGHT, SDL_WINDOW_SHOWN); SDL_Surface* window_s = SDL_GetWindowSurface(mainWindow); int screen_bg_color = Graphic_base::Color::format32_rgb(100, 100, 100); Graphic_base::Surface windows_surf(window_s->pixels, window_s->w, window_s->h, screen_bg_color); // Initializing global variables init(); // Loop int quit = 0; SDL_Event event; while(!quit) { // Traitement des évènements if(SDL_WaitEvent(&event)) if(process_event(&event, windows_surf)) quit = 1; while(SDL_PollEvent(&event)) if(process_event(&event, windows_surf)) quit = 1; draw_screen(windows_surf); SDL_UpdateWindowSurface(mainWindow); SDL_Delay(10); } delete f; printf("Freeing done.\n"); SDL_DestroyWindow(mainWindow); SDL_Quit(); return 0; }