Window* Scheduler_getWindow() { static Window* window = NULL; if(window) return window; window = Window_new("Running Commands", &updateWindow); Window_setSize(window, 40, 17); return window; }
/** * Initializes game modules. * * Mostly what this function does is link up the various game modules. */ void initialize_game() { int window_id; // Seed the random number generator srand( time(NULL) ); /* Initialize windowing and rendering */ window_id = Window_new(PROJECT_TITLE); // Create a new game new_game(); // TODO: show main menu instead of immediately starting the game /* Initialize the game mechanics module */ //mechanics_init( GET_CURRENT_TIME() ); Window_registerReshapeEventHandler( window_id, window_resized ); /* Initialize input */ input_init(window_id); render_init(); /* Register the game loop */ glutIdleFunc(game_loop); }
/** * `eld` runs a copy of this function within each thread. The * function opens the input file, which gives the thread its own input * buffer so that it can move around in the file without locking it. * Then it examines pairs of SNPs within a window that slides across * the SNPs it is responsible for, placing the results into an object * of type Tabulation. * * @param varg A void pointer to an object of type ThreadArg. */ void *threadfun(void *varg) { long i; ThreadArg *targ = (ThreadArg *) varg; FILE *ifp = fopen(targ->ifname, "r"); if(ifp == NULL) { fprintf(stderr, "threadfun: can't open file \"%s\"\n", targ->ifname); pthread_exit(NULL); } /* set up sliding window */ Window *window = Window_new(targ->window_cm, ifp, targ->sampling_interval, targ->ploidy); /* populate window */ fseek(ifp, ThreadBounds_seekpos_initial(targ->tb), SEEK_SET); for(i = ThreadBounds_ndx_initial(targ->tb); i < ThreadBounds_ndx_1stFocal(targ->tb); ++i) { Window_nextSNP(window, targ->boot); } /* slide window */ for(i = ThreadBounds_ndx_1stFocal(targ->tb); i <= ThreadBounds_ndx_lastFocal(targ->tb); ++i) { int status = Window_advance(window, targ->tab, targ->spectab, targ->boot, i); if(Tabulation_overflow(targ->tab)) { targ->overflow = 1; break; } if(status == EOF) break; #if 0 if(i % 10000 == 0) fprintf(stderr, "threadfun SNP #%8ld\n", i); #endif } /* Give calling function access to the number of genotypes. */ targ->nGtype = Window_nGtype(window); fclose(ifp); Window_free(window); pthread_exit(NULL); }
NBody* NBody_new() { NBody* self = calloc(1, sizeof(NBody)); self->window = Window_new(); if (self->window == NULL) { goto error; } self->player = Player_new(); self->player->position = Vector_init(0.0f, 0.0f, 5.0f); // Turn on alpha blending for transparency glEnable(GL_BLEND); // Turn Blending On glEnable(GL_TEXTURE_2D); // Turn on textures glDisable(GL_DEPTH_TEST); // Turn Depth Testing Off glBlendFunc(GL_SRC_ALPHA, GL_ONE); // Load up star texture glGenTextures(1, &self->star_texture); glBindTexture(GL_TEXTURE_2D, self->star_texture); float* pixels = load_star_texture(); glTexImage2D( GL_TEXTURE_2D, // target 0, // level GL_ALPHA, // internalFormat STAR_TEXTURE_SIZE, // width STAR_TEXTURE_SIZE, // height 0, // border GL_ALPHA, // format GL_FLOAT, // type pixels // data ); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); free(pixels); for (size_t i = 0; i < NUM_STARS; ++i) { self->stars[i] = Star_random(); } return self; error: NBody_destroy(self); return NULL; }