int wt_init(char *pszWorldFile, int width, int height) { FILE *fp; if ((fp = fopen(pszWorldFile, "r")) == NULL) { perror(pszWorldFile); exit(EXIT_FAILURE); } w = read_world_file(fp); fclose(fp); init_graphics(); init_renderer(width, height); init_input_devices(); /* setup view */ view = new_view(fixdiv(FIXED_2PI, INT_TO_FIXED(4))); view->x = FIXED_ZERO; view->y = FIXED_ZERO; view->height = FIXED_ONE; view->angle = FIXED_ZERO; frames = 0; return EXIT_SUCCESS; }
void init() { allegro_init(); set_color_depth(32); if(set_gfx_mode(GFX_AUTODETECT_WINDOWED, GFX_W, GFX_H, 0, 0)) { allegro_message("Error: %s.", allegro_error); exit(1); } install_keyboard(); install_mouse(); buffer = create_bitmap(SCREEN_W, SCREEN_H); zbuffer = create_bitmap_ex(32, SCREEN_W, SCREEN_H); texture = load_bitmap("data/wall.bmp", NULL); skin = load_bitmap("data/babe_skin.bmp", NULL); texture2 = load_bitmap("data/color.bmp", NULL); setup_projection(90.0, -1.333, 1.333, -1.0, 1.0, -1.0, 200.0); init_renderer(GFX_H); bind_color_buffer(buffer); bind_zbuffer(zbuffer); bind_texture(texture); }
static void rb_redcarpet__setup_render(VALUE ruby_obj, struct mkd_renderer *rnd) { unsigned int flags = RENDER_EXPAND_TABS; /* smart */ if (rb_funcall(ruby_obj, rb_intern("smart"), 0) == Qtrue) flags |= RENDER_SMARTYPANTS; /* filter_html */ if (rb_funcall(ruby_obj, rb_intern("filter_html"), 0) == Qtrue) flags |= RENDER_SKIP_HTML; /* no_image */ if (rb_funcall(ruby_obj, rb_intern("no_image"), 0) == Qtrue) flags |= RENDER_SKIP_IMAGES; /* no_links */ if (rb_funcall(ruby_obj, rb_intern("no_links"), 0) == Qtrue) flags |= RENDER_SKIP_LINKS; /* filter_style */ if (rb_funcall(ruby_obj, rb_intern("filter_styles"), 0) == Qtrue) flags |= RENDER_SKIP_STYLE; /* autolink */ if (rb_funcall(ruby_obj, rb_intern("autolink"), 0) == Qtrue) flags |= RENDER_AUTOLINK; /* safelink */ if (rb_funcall(ruby_obj, rb_intern("safelink"), 0) == Qtrue) flags |= RENDER_SAFELINK; init_renderer(rnd, flags); }
int main (int argc, char *argv[]) { finished=FALSE; closed=FALSE; /* mutex=SDL_CreateMutex(); */ /* FIXME check if there is MMX support here */ init_renderer(); renderer(); return 0; }
file_t * create_file(char * where, char * filename) { file_t * file = malloc(sizeof(file_t)); file->term = init_term(); file->buff = init_buff(); file->modbuff = init_buff(); file->rend = init_renderer(); file->path = where; file->filename = filename; file->size = 0; file->is_modal = 0; init_keys(); init_func(file); return file; }
static rtems_task gui_task(rtems_task_argument argument) { init_fb_mtk(sysconfig_get_autostart_mode() == SC_AUTOSTART_FILE); sysconfig_set_mtk_language(); sysconfig_set_mtk_wallpaper(); init_input(); input_add_callback(mtk_input); init_shortcuts(); init_osc(); init_messagebox(); init_performance(); init_renderer(); init_cp(); init_keyboard(); init_ir(); init_audio(); init_midi(); init_oscsettings(); init_dmxspy(); init_dmxdesk(); init_dmx(); init_videoin(); init_rsswall(); init_patcheditor(); init_monitor(); init_firstpatch(); init_filemanager(); #ifdef WITH_PDF init_pdfreader(); #endif init_sysettings(); init_about(); init_flash(); init_shutdown(); cp_autostart(); if(sysconfig_is_rescue()) messagebox("Rescue mode", "You have booted in rescue mode.\n" "Your system will function as usual, using back-up software.\n" "From there, you can update the main software or perform\nother actions to fix the problem.\n"); /* FIXME: work around "black screen" bug in MTK */ mtk_cmd(1, "screen.refresh()"); input_eventloop(); }
void init(void) { int ship, bull; ship = init_program(4, "vshader.glsl", GL_VERTEX_SHADER,"fshader.glsl", GL_FRAGMENT_SHADER); if (ship < 0) { fprintf(stderr,"Error: could not initialize program, bailing...\n"); exit(1); } bull = init_program(4, "vbullets.glsl", GL_VERTEX_SHADER, "fbullets.glsl", GL_FRAGMENT_SHADER); if (bull < 0) { fprintf(stderr,"Error: could not initialize program, bailing...\n"); exit(1); } init_renderer(ship, bull); players[0] = genShip(); players[1] = genShip(); // Set player colors players[0]->color[0] = 1.0f; players[0]->color[1] = 0.0f; players[0]->color[2] = 0.0f; players[0]->color[3] = 1.0f; players[1]->color[0] = 0.0f; players[1]->color[1] = 1.0f; players[1]->color[2] = 0.0f; players[1]->color[3] = 1.0f; // Set intial positions players[0]->pos = {-WINDOW_X/2,WINDOW_Y/2}; players[1]->pos = {-WINDOW_X/2,-WINDOW_Y/2}; }
int main(int argc, char **argv) { int ixs=832, iys=624; int player_number = 1; scene *current_scene = NULL; srand(time(NULL)); if(argc == 2 && (!strcmp(argv[1], "--fullscreen"))) { fullscreen_mode = 1; ixs = 1024; iys = 768; } if(!init_renderer(ixs, iys)) { fprintf(stderr, "Renderer failed to initialize!\n"); exit(1); } init_scenes(); while(!user_quit) { current_scene = get_current_scene(); if(!render_scene(current_scene, player_number)) { fprintf(stderr, "Render of scene failed!\n"); exit(1); } if(!input_process(current_scene, player_number)) { fprintf(stderr, "Input processing failed!\n"); exit(1); } } exit(0); return 0; }
int main(int argc, char *argv[]) { World *w; FILE *fp; Boolean quit = False; Intent *intent; fixed v = FIXED_ZERO; double vx = 0.0, vy = 0.0, va = 0.0; #ifdef MSDOS long frames; time_t starttime, endtime; #endif if (argc != 2) { fprintf(stderr, "Usage: wt <world file>\n"); exit(EXIT_FAILURE); } if ((fp = fopen(argv[1], "r")) == NULL) { perror(argv[1]); exit(EXIT_FAILURE); } w = read_world_file(fp); fclose(fp); init_graphics(); init_renderer(SCREEN_WIDTH, SCREEN_HEIGHT); init_input_devices(); /* setup view */ view = new_view(fixdiv(FIXED_2PI, INT_TO_FIXED(4))); view->x = FIXED_ZERO; view->y = FIXED_ZERO; view->height = FIXED_ONE; view->angle = FIXED_ZERO; #ifdef MSDOS starttime = time(NULL); frames = 0; #endif while (!quit) { double sin_facing, cos_facing; render(w, view); #ifdef MSDOS frames++; #endif intent = read_input_devices(); /* This block code is a hack to do acceleration and deceleration. */ if (fabs(vx) > fabs(intent->force_x)) { if (vx < 0.0) vx = MIN(vx + 0.1, intent->force_x); else vx = MAX(vx - 0.1, intent->force_x); } else if (fabs(vx) < fabs(intent->force_x)) { vx += intent->force_x / 5.0; if (fabs(vx) > fabs(intent->force_x)) vx = intent->force_x; } if (fabs(vy) > fabs(intent->force_y)) { if (vy < 0.0) vy = MIN(vy + 0.1, intent->force_y); else vy = MAX(vy - 0.1, intent->force_y); } else if (fabs(vy) < fabs(intent->force_y)) { vy += intent->force_y / 5.0; if (fabs(vy) > fabs(intent->force_y)) vy = intent->force_y; } if (fabs(vy) > fabs(intent->force_y)) { if (vy < 0.0) vy = MIN(vy + 0.1, intent->force_y); else vy = MAX(vy - 0.1, intent->force_y); } else if (fabs(vy) < fabs(intent->force_y)) { vy += intent->force_y / 5.0; if (fabs(vy) > fabs(intent->force_y)) vy = intent->force_y; } /* Angular deceleration here is weird and unrealistic, but it feels ** right to me. */ if (fabs(va) > fabs(intent->force_rotate)) va *= 0.6; else if (fabs(va) < fabs(intent->force_rotate)) { va += intent->force_rotate / 8.0; if (fabs(va) > fabs(intent->force_rotate)) va = intent->force_rotate; } view->angle += FLOAT_TO_FIXED(0.3 * va); sin_facing = sin(FIXED_TO_FLOAT(view->angle)); cos_facing = cos(FIXED_TO_FLOAT(view->angle)); view->x += FLOAT_TO_FIXED(0.8 * vx * cos_facing); view->y += FLOAT_TO_FIXED(0.8 * vx * sin_facing); view->x += FLOAT_TO_FIXED(0.8 * vy * -sin_facing); view->y += FLOAT_TO_FIXED(0.8 * vy * cos_facing); if (view->height > FIXED_ONE) v -= FIXED_ONE / 16; view->height += v; if (view->height < FIXED_ONE) { v = FIXED_ZERO; view->height = FIXED_ONE; } while (intent->n_special--) { if (intent->special[intent->n_special] == INTENT_END_GAME) quit = True; else v = FIXED_ONE / 2; } } #ifdef MSDOS endtime = time(NULL); #endif end_input_devices(); end_graphics(); #ifdef MSDOS printf("%li frames in %lu seconds - %.2f frames per second", (long) frames, (long) endtime - starttime, (float) frames / (float) (endtime-starttime)); #endif return EXIT_SUCCESS; }
void wt_reinit(int width,int height) { init_renderer(width, height); //so far, I think that's all I have to do. }
Renderer::Renderer(Shader new_shader, int screen_width, int screen_height) :shader(new_shader), SCREEN_WIDTH(screen_width), SCREEN_HEIGHT(screen_height){ init_renderer(); }
int main(int argc, char *argv[]) { World *w; View *view; Intent *intent; Graphics_info *ginfo; Tcl_Interp *interp; Object *me; Boolean quit = False; #if PROFILE int fps_count = 0; double total_time = 0.0; double start_time; #endif interp = Tcl_CreateInterp(); updater = updater_create(interp); if (argc != 2) { fprintf(stderr, "Usage: %s <world file>\n", argv[0]); exit(EXIT_FAILURE); } ginfo = init_graphics(); #define TRUECOLOR #ifdef TRUECOLOR set_texture_trans(32, ginfo->palette.color_lookup); #else set_texture_trans(ginfo->palette.rgb_cube_size, ginfo->palette.color_lookup); #endif init_renderer(ginfo->width, ginfo->height); init_input_devices(); /* Initialize the view */ view = new_view(FLOAT_TO_FIXED(3.14159265 / 2.0)); w = new_world(); parser_init(interp, w); if (Tcl_EvalFile(interp, WT_INIT_FILENAME) != TCL_OK) { fprintf(stderr, "%s\n", Tcl_GetVar(interp, "errorCode", 0)); fprintf(stderr, "%s\n", Tcl_GetVar(interp, "errorInfo", 0)); exit(1); } if (Tcl_EvalFile(interp, argv[1]) != TCL_OK) { fprintf(stderr, "%s\n", Tcl_GetVar(interp, "errorCode", 0)); fprintf(stderr, "%s\n", Tcl_GetVar(interp, "errorInfo", 0)); exit(1); } while (!quit) { double sin_facing, cos_facing; double fx, fy, fz, torque; Framebuffer *fb; int i; start_time = current_time(); intent = read_input_devices(); me = get_controlled_object(); if (me == NULL) fatal_error("No controlled object"); for (i = 0; i < intent->n_special; i++) { switch (intent->special[i]) { case INTENT_END_GAME: quit = True; (void) Tcl_Eval(interp, "action_quit"); break; case INTENT_JUMP: (void) Tcl_Eval(interp, "action_jump"); break; case INTENT_ACTION1: (void) Tcl_Eval(interp, "action_1"); break; case INTENT_ACTION2: (void) Tcl_Eval(interp, "action_2"); break; case INTENT_ACTION3: (void) Tcl_Eval(interp, "action_3"); break; case INTENT_ACTION4: (void) (Tcl_Eval(interp, "action_4") != TCL_OK); break; case INTENT_ACTION5: (void) Tcl_Eval(interp, "action_5"); break; default: break; } } /* Determine forces on viewer. */ sin_facing = sin(me->angle); cos_facing = cos(me->angle); fx = cos_facing * intent->force_x - sin_facing * intent->force_y; fy = sin_facing * intent->force_x + cos_facing * intent->force_y; fz = -0.05 * me->mass; /* gravity */ torque = intent->force_rotate; /* Apply the forces. */ object_apply_force(me, fx, fy, fz); object_apply_torque(me, torque); object_update(me); if (me->z <= 0.0 && me->dz <= 0.0) { me->z = 0.0; me->dz = 0.0; } /* Determine the view. */ me = get_viewpoint_object(); if (me == NULL) fatal_error("No viewpoint object"); object_view(me, view); updater_run(updater); /* Display the world. */ fb = render(w, view); update_screen(fb); #if PROFILE fps_count++; total_time += current_time() - start_time; if (fps_count == 100) { printf("fps = %3.2f\n", (double) fps_count / total_time); fps_count = 0; total_time = 0.0; } #endif } end_input_devices(); end_graphics(); return EXIT_SUCCESS; }