static void cmdHandler(struct android_app* app, int32_t cmd) { switch (cmd) { case APP_CMD_SAVE_STATE: break; case APP_CMD_INIT_WINDOW: // The window is being shown, get it ready. if (GlobalData::getInstance()->app->window != NULL) { ContextControllerEGL::getInstance()->startDisplay(); init_resources(); engine_draw_frame(); running = true; } break; case APP_CMD_TERM_WINDOW: // The window is being hidden or closed, clean it up. free_resources(); ContextControllerEGL::getInstance()->endDisplay(); break; case APP_CMD_GAINED_FOCUS: // When our app gains focus, we start monitoring the accelerometer. break; case APP_CMD_LOST_FOCUS: logInf("APP_CMD_LOST_FOCUS"); free_resources(); ContextControllerEGL::getInstance()->endDisplay(); break; } }
int main(int argc, const char * argv[]) { int exclude = 0; if (load_resources() == -1) {fprintf(stderr, "Chyba systemovych volani.\n"); free_resources(); exit(2);} if (parse(argc, argv) == -1) {fprintf(stderr,"Nespravne zadane parametre.\n"); free_resources(); exit(1);} srand(time(NULL)); vars->oxygen = 0; vars->hydrogen = 0; vars->global_count = 1; vars->barrier_count = 0; vars->count = 0; pid_t childPID; vars->h2o = fopen("h2o.out", "w+"); //hydrogen_maker childPID = fork(); if (childPID == 0) { exclude = 1; hydrogen_maker(); } else if (childPID == -1) { fprintf(stderr, "Chyba systemovych volani.\n"); free_resources(); exit(2); } //oxygen_maker childPID = fork(); if (childPID == 0 && exclude != 1) { oxygen_maker(); } else if (childPID == -1) { fprintf(stderr, "Chyba systemovych volani.\n"); free_resources(); exit(2); } fclose(vars->h2o); free_resources(); exit(EXIT_SUCCESS); }
int main(int argc, char *argv[]) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_RGBA|GLUT_ALPHA|GLUT_DOUBLE|GLUT_DEPTH);//added alpha. glutInitWindowSize(800,600); glutCreateWindow("My First Triangle"); GLenum glew_status = glewInit(); if (glew_status != GLEW_OK) { fprintf(stderr, "Error: %s\n", glewGetErrorString(glew_status)); return 1; } if (init_resources()) { glutDisplayFunc(display); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glutMainLoop(); //and that is all the changes for this iteration. give it a go. the next bits of commentary //will be in the shader source files. so head on over to those files and take a look! } free_resources(); return 0; }
int main(int argc, char* argv[]) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_RGBA|GLUT_ALPHA|GLUT_DOUBLE|GLUT_DEPTH); glutInitWindowSize(x_resolution, y_resolution); glutCreateWindow("Mandelbrot"); GLenum glew_status = glewInit(); if (glew_status != GLEW_OK) { fprintf(stderr, "Error: %s\n", glewGetErrorString(glew_status)); return 1; } if (!GLEW_VERSION_2_0) { fprintf(stderr, "Error: your graphic card does not support OpenGL 2.0\n"); return 1; } if (init_resources()) { glutDisplayFunc(onDisplay); glutReshapeFunc(onReshape); glutKeyboardFunc(keyboardCallback); glutSpecialFunc(SpecialInput); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glutMainLoop(); } free_resources(); return 0; }
int main (int argc, char* argv[]) { glutInit (&argc, argv); glutInitDisplayMode (GLUT_RGBA|GLUT_ALPHA|GLUT_DOUBLE|GLUT_DEPTH); glutInitWindowSize (WINDOW_WIDTH, WINDOW_HEIGHT); glutCreateWindow ("triangle3"); /* Init glew */ GLenum glew_status = glewInit(); if (glew_status != GLEW_OK) { fprintf (stderr, "Error: %s\n", glewGetErrorString (glew_status)); exit (EXIT_FAILURE); } /* Check version of OpenGL */ if (!GLEW_VERSION_2_0) { fprintf (stderr, "Error: your graphics card does not support OpenGL 2.0\n"); exit (EXIT_FAILURE); } if (1 == init_resources() ) { glutDisplayFunc (onDisplay); glutIdleFunc (idle); glutKeyboardFunc(keyboard_char); glEnable (GL_BLEND); glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glutMainLoop (); } free_resources (); exit (EXIT_SUCCESS); }
int main(int argc, char *argv[]) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE); glutInitWindowSize(800,600); glutCreateWindow("My First Triangle"); //these 4 don't change. GLenum glew_status = glewInit(); if (glew_status != GLEW_OK) {//this is added in to init GLEW, just nod. fprintf(stderr, "Error: %s\n", glewGetErrorString(glew_status)); return 1; } if (init_resources()) {//we don't want to display unless the resources are actually initialized. //this conditional makes sure of such. glutDisplayFunc(display);//and these 2 don't really change glutMainLoop(); } free_resources(); //lastly add this bit to free up the resouces and we're done. return 0; }
int main(int argc, char* argv[]) { glutInit(&argc, argv); glutInitContextVersion(2,0); glutInitDisplayMode(GLUT_RGBA|GLUT_ALPHA|GLUT_DOUBLE|GLUT_DEPTH); glutInitWindowSize(640, 480); glutCreateWindow("My Transformed Triangle"); GLenum glew_status = glewInit(); if (glew_status != GLEW_OK) { fprintf(stderr, "Error: %s\n", glewGetErrorString(glew_status)); return 1; } if (!GLEW_VERSION_2_0) { fprintf(stderr, "Error: your graphic card does not support OpenGL 2.0\n"); return 1; } if (init_resources()) { glutDisplayFunc(onDisplay); glutIdleFunc(onIdle); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glutMainLoop(); } free_resources(); return 0; }
void keyboard(unsigned char key, int x, int y) { switch(key) { case 'q': case 'Q': case 27: free_resources(); exit(EXIT_SUCCESS); case ' ': active =! active; break; case '+': amplitude *= 1.5; setupTexture(); break; case '-': amplitude /= 1.5; setupTexture(); break; case 'z': camera_distance /= 1.1; break; case 'Z': camera_distance *= 1.1; break; case 'g': if(grid < N-10) grid += 10; setupTexture(); break; case 'G': if(grid > 10) grid -= 10; setupTexture(); break; } }
static status_t free_hook (void* cookie) { dp83815_properties_t *data = (dp83815_properties_t *) cookie; TRACE(( kDevName " free_hook()\n" )); while ( data->Tx.Lock ); /* wait for any current writes to finish */ while ( data->Rx.Lock ); /* wait for any current reads to finish */ //Remove interrupt handler remove_io_interrupt_handler( data->pcii->u.h0.interrupt_line , dp83815_interrupt_hook , cookie ); m_openmask &= ~(1L << data->device_id); free_resources(data); /* unblock waiting threads */ //Finally, free the cookie free( data ); //Put the pci module put_module( B_PCI_MODULE_NAME ); return B_OK; }
int main(int argc, char *argv[]) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_RGBA|GLUT_ALPHA|GLUT_DOUBLE|GLUT_DEPTH); glutInitWindowSize(screen_width,screen_height); glutCreateWindow("Spinny cube!"); glutIdleFunc(idle); glutReshapeFunc(reshape); //got to let glut know about the function. glEnable(GL_DEPTH_TEST); GLenum glew_status = glewInit(); if (glew_status != GLEW_OK) { fprintf(stderr, "Error: %s\n", glewGetErrorString(glew_status)); return 1; } if (init_resources()) { glutDisplayFunc(display); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glutMainLoop(); } free_resources(); return 0; }
static int __init hysdn_init(void) { char tmp[50]; strcpy(tmp, hysdn_init_revision); printk(KERN_NOTICE "HYSDN: module Rev: %s loaded\n", hysdn_getrev(tmp)); strcpy(tmp, hysdn_net_revision); printk(KERN_NOTICE "HYSDN: network interface Rev: %s \n", hysdn_getrev(tmp)); search_cards(); printk(KERN_INFO "HYSDN: %d card(s) found.\n", cardmax); if (hysdn_procconf_init()) { free_resources(); /* proc file_sys not created */ return (-1); } #ifdef CONFIG_HYSDN_CAPI if(cardmax > 0) { if(hycapi_init()) { printk(KERN_ERR "HYCAPI: init failed\n"); return(-1); } } #endif /* CONFIG_HYSDN_CAPI */ return (0); /* no error */ } /* init_module */
int main(int argc, char* argv[]) { /* Glut-related initialising functions */ glutInit(&argc, argv); glutInitDisplayMode(GLUT_RGBA|GLUT_DOUBLE|GLUT_DEPTH); glutInitWindowSize(640, 480); glutCreateWindow("My First Triangle"); /* Extension wrangler initialising */ // GLenum glew_status = glewInit(); // if (glew_status != GLEW_OK) // { // fprintf(stderr, "Error: %s\n", glewGetErrorString(glew_status)); // return EXIT_FAILURE; // } /* When all init functions run without errors, the program can initialise the resources */ if (1 == init_resources()) { /* We can display it if everything goes OK */ glutDisplayFunc(onDisplay); glutMainLoop(); } /* If the program exits in the usual way, free resources and exit with a success */ free_resources(); return EXIT_SUCCESS; }
int main(int argc, char **argv){ glutInit(&argc, argv); glutInitDisplayMode(GLUT_RGBA|GLUT_ALPHA|GLUT_DOUBLE|GLUT_DEPTH); glutInitWindowSize(screen_width, screen_height); glutCreateWindow("Cube"); GLenum glew_status = glewInit(); if(glew_status != GLEW_OK) { fprintf(stderr, "Error: %s\n", glewGetErrorString(glew_status)); return(EXIT_FAILURE); } if(1 == init_resources()) { glutDisplayFunc(onDisplay); //glutReshapeFunc(onReshape); glutIdleFunc(tut_idle); glutReshapeFunc(onReshape); glEnable(GL_BLEND); glEnable(GL_DEPTH_TEST); //glDepthFunc(GL_LESS); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glutMainLoop(); } free_resources(); return(EXIT_SUCCESS); }
/* ---------------------------------------------------------------------[<]- Function: init_resources Synopsis: stores needed parameters for the service and application - bin_name and appl_version will be used for display only. Can be NULL - init_fct: a function starting all the SMT agents needed for the service - term_fct: a function disposing resources allocated by init_fct Returns: 0 is everything is OK, negative error code otherwise ---------------------------------------------------------------------[>]-*/ static int init_resources( const char *binary_name, const char *appl_version, SMT_AGENTS_INIT_FCT *init_fct, SMT_AGENTS_TERM_FCT *term_fct) { if (!binary_name) return 1; application_name = mem_strdup (binary_name); if (application_name) strip_file_path (application_name); application_version = mem_strdup (appl_version ? appl_version : "???"); application_config = service_get_config_filename (application_name); smt_agents_init_fct = init_fct; smt_agents_term_fct = term_fct; if (!application_name || !application_config || !application_version) { free_resources(); return 1; } return 0; }
int main(int argc, char *argv[]) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_RGBA|GLUT_ALPHA|GLUT_DOUBLE|GLUT_DEPTH); glutInitWindowSize(800,600); glutCreateWindow("My First Triangle"); glutIdleFunc(idle); GLenum glew_status = glewInit(); if (glew_status != GLEW_OK) { fprintf(stderr, "Error: %s\n", glewGetErrorString(glew_status)); return 1; } if (init_resources()) { glutDisplayFunc(display); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glutMainLoop(); } free_resources(); return 0; }
int main(int argc, char* argv[]) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_RGBA|GLUT_ALPHA|GLUT_DOUBLE|GLUT_DEPTH); glutInitWindowSize(screen_width, screen_height); glutCreateWindow("My Rotating Cube"); GLenum glew_status = glewInit(); if (glew_status != GLEW_OK) { fprintf(stderr, "Error: %s\n", glewGetErrorString(glew_status)); return 1; } if (!GLEW_VERSION_2_0) { fprintf(stderr, "Error: your graphic card does not support OpenGL 2.0\n"); return 1; } if (init_resources()) { glutDisplayFunc(onDisplay); glutReshapeFunc(onReshape); glutIdleFunc(onIdle); glEnable(GL_BLEND); glEnable(GL_DEPTH_TEST); //glDepthFunc(GL_LESS); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glutMainLoop(); } free_resources(); return 0; }
int main(int argc, char *argv[]) { init(argc, argv); run(); TwTerminate(); free_resources(); return 0; }
void fz_decouple_type3_font(fz_context *ctx, fz_font *font, void *t3doc) { if (!ctx || !font || !t3doc || font->t3doc == NULL) return; if (font->t3doc != t3doc) fz_throw(ctx, FZ_ERROR_GENERIC, "can't decouple type3 font from a different doc"); font->t3doc = NULL; free_resources(ctx, font); }
int main(int argc, char* argv[]) { /* Glut-related initialising functions */ glutInit(&argc, argv); glutInitDisplayMode(GLUT_RGBA|GLUT_ALPHA|GLUT_DOUBLE|GLUT_DEPTH); glutInitWindowSize(screen_width, screen_height); glutCreateWindow(title.c_str()); /* Extension wrangler initialising */ GLenum glew_status = glewInit(); if (glew_status != GLEW_OK) { fprintf(stderr, "Error: %s\n", glewGetErrorString(glew_status)); return EXIT_FAILURE; } if (!GLEW_VERSION_2_0) { fprintf(stderr, "Error: your graphic card does not support OpenGL 2.0\n"); return 1; } /* When all init functions runs without errors, the program can initialise the resources */ if (init_resources() == 1) { /* And then we can display it if everything goes OK */ if(isFullscreen) glutFullScreen(); //glEnable(GL_CULL_FACE); glutSetCursor(GLUT_CURSOR_NONE); glEnable(GL_BLEND); glEnable(GL_DEPTH_TEST); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glutIdleFunc(idle); glutReshapeFunc(onReshape); glutDisplayFunc(onDisplay); glutPassiveMotionFunc(onMouseMove); glutMotionFunc(onMouseMove); glutKeyboardFunc(onKeyDown); glutKeyboardUpFunc(onKeyUp); glutSpecialFunc(onKeyDownSpecial); glutSpecialUpFunc(onKeyUpSpecial); glutTimerFunc(250, threadFunc, 4); glutMainLoop(); } /* If the program exits in the usual way, free resources and exit with a success */ free_resources(); return EXIT_SUCCESS; }
int main(int argc, char *argv[]) { SDL_Init(SDL_INIT_VIDEO); SDL_Window *window = SDL_CreateWindow("My Graph", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 640, 480, SDL_WINDOW_RESIZABLE | SDL_WINDOW_OPENGL); SDL_GLContext context = SDL_GL_CreateContext(window); SDL_GL_SetSwapInterval(1); GLenum glew_status = glewInit(); if (GLEW_OK != glew_status) { fprintf(stderr, "Error: %s\n", glewGetErrorString(glew_status)); return 1; } if (!GLEW_VERSION_2_0) { fprintf(stderr, "No support for OpenGL 2.0 found\n"); return 1; } GLint max_units; glGetIntegerv(GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS, &max_units); if (max_units < 1) { fprintf(stderr, "Your GPU does not have any vertex texture image units\n"); return 1; } printf("Use left/right/up/down to move.\n"); printf("Use pageup/pagedown to change the horizontal scale.\n"); printf("Press home to reset the position and scale.\n"); printf("Press F1 to toggle interpolation.\n"); printf("Press F2 to toggle clamping.\n"); printf("Press F3 to toggle rotation.\n"); printf("Press F4 to toggle polygon offset.\n"); if (!init_resources()) return EXIT_FAILURE; mainLoop(window); free_resources(); SDL_GL_DeleteContext(context); SDL_DestroyWindow(window); SDL_Quit(); return EXIT_SUCCESS; }
void huffman_decoder::decode_file(std::istream & ins, std::ostream & outs) { inbs = new ibstream(ins); chars_count = (((size_t)ins.get()) << 8) | ((size_t)ins.get()); if (chars_count == 0) { return; } read_tree(ins); decode_and_write(outs); free_resources(); }
int main(/*int argc, char *argv[]*/){ screen = {1920,1080}; SDL_Init(SDL_INIT_VIDEO); // Select an OpenGL 2.1 profile. //SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1); SDL_Window *window = SDL_CreateWindow("Voxel Engine", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, screen.x, screen.y, SDL_WINDOW_RESIZABLE | SDL_WINDOW_OPENGL); SDL_GLContext context = SDL_GL_CreateContext(window); GLenum err; glewExperimental = GL_TRUE; if((err=glewInit()) != GLEW_OK){ std::cout << "GLEW was not able to initialize! Error: " << glewGetErrorString(err) << std::endl; return -1; } // Set relative mouse mode, this will grab the cursor. SDL_SetRelativeMouseMode(SDL_TRUE); SDL_GL_SetSwapInterval(0); ui::reshape(window, screen.x, screen.y); print_opengl_info(); if (!init_resources()) return EXIT_FAILURE; glEnable(GL_BLEND); glEnable(GL_DEPTH_TEST); //glDepthFunc(GL_LESS); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); mainLoop(window); free_resources(); SDL_GL_DeleteContext(context); SDL_DestroyWindow(window); SDL_Quit(); return 0; // Calls everything passed to atexit }
int main(int argc, char* argv[]) { /* Glut-related initialising functions */ glutInit(&argc, argv); //glutInitContextVersion(4, 0); //glutInitContextFlags(GLUT_FORWARD_COMPATIBLE); glutInitContextProfile(GLUT_CORE_PROFILE); glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_CONTINUE_EXECUTION); //alternative GLUT_ACTION_GLUTMAINLOOP_RETURNS glutInitDisplayMode(GLUT_RGBA | GLUT_ALPHA | GLUT_DOUBLE | GLUT_DEPTH); glutInitWindowSize(640, 480); glutCreateWindow("Tetris"); /* Extension wrangler initialising */ GLenum glew_status = glewInit(); if (glew_status != GLEW_OK) { fprintf(stderr, "Error: %s\n", glewGetErrorString(glew_status)); return EXIT_FAILURE; } /* When all init functions run without errors, the program can initialise the resources */ if (1 == init_resources()) { /* We can display it if everything goes OK */ glutDisplayFunc(onDisplay); glutReshapeFunc(onReshape); glutKeyboardFunc(onKeyPressed); glutSpecialFunc(specialKeyPressed); glutMouseFunc(onMouse); glutMotionFunc(onMotion); glutMouseWheelFunc(onMouseWheel); glEnable(GL_BLEND); glEnable(GL_DEPTH_TEST); glutTimerFunc(0, timerCallBack, 0); //glDepthFunc(GL_LESS); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glutMainLoop(); } /* If the program exits in the usual way, free resources and exit with a success */ free_resources(); return EXIT_SUCCESS; }
int main(int argc, char *argv[]) { char *filename = NULL, *pattern = NULL; int lines = 0,n_Proc; parse_argv(argc, argv, &filename, &pattern, &lines,&n_Proc); install_signal_handler(); init_process_table(&n_Proc,lines); create_processes(lines, n_Proc, filename, pattern); wait_processes(); printf("\n[MANAGER] Program termination (all the processes terminated).\n"); free_resources(); return EXIT_SUCCESS; }
int hpx_main() { // List of currently available resources hpx::lcos::channel<locality_id_t> free_resources(hpx::find_here()); std::size_t os_thread_count = hpx::get_os_thread_count(); // At the beginning all threads on all localities are free for (locality_id_t id : hpx::find_all_localities()) { for (std::size_t i = 0; i != os_thread_count; ++i) { free_resources.set(id); ++count; } } for (int i = 0; i < 1000; ++i) { // Ask for resources hpx::shared_future<locality_id_t> target = free_resources.get(); // Do some work, once we have acquired resources hpx::shared_future<int> result = target.then( [](hpx::shared_future<locality_id_t> t) -> hpx::shared_future<int> { --count; return hpx::make_ready_future(0); }); // Free resources result.then( [free_resources, target](hpx::shared_future<int>) mutable { ++count; free_resources.set(target.get()); }); result.get(); } std::size_t remaining_count = free_resources.close(true); HPX_TEST_EQ(remaining_count, count.load()); return hpx::finalize(); }
void oxygen_maker() { int oxy_pid; //creates N oxygen atom processes for (int i = 0; i < vars->N; i++) { oxy_pid = fork(); if (oxy_pid == 0) { usleep((rand() % vars->GO*1000 + 1)); oxygen(i+1); } } free_resources(); _Exit(0); }
void hydrogen_maker() { int hydro_pid; //creates 2N hydrogen atom processes for (int i = 0; i < (vars->N)*2; i++) { hydro_pid = fork(); if (hydro_pid == 0) { usleep((rand() % vars->GH*1000 + 1)); hydrogen(i+1); } } free_resources(); _Exit(0); }
static event_response_t finish_readfile(drakvuf_t drakvuf, drakvuf_trap_info_t* info, vmi_instance_t vmi, bool is_success) { if (!is_success) { wrapper_t* injector = (wrapper_t*)info->trap->data; filedelete* f = injector->f; grab_file_by_handle(f, drakvuf, vmi, info, injector->handle); } wrapper_t* injector = (wrapper_t*)info->trap->data; filedelete* f = injector->f; auto filename = f->files[std::make_pair(info->proc_data.pid, injector->handle)]; print_filedelete_information(f, drakvuf, info, filename.c_str(), injector->ntreadfile_info.bytes_read, injector->fo_flags); free_resources(drakvuf, info); return VMI_EVENT_RESPONSE_SET_REGISTERS; }
static void bail_out(int exitcode, const char *fmt, ...){ va_list ap; (void) fprintf(stderr, "%s: ", progname); if (fmt != NULL) { va_start(ap, fmt); (void) vfprintf(stderr, fmt, ap); va_end(ap); } if (errno != 0) { (void) fprintf(stderr, ": %s", strerror(errno)); } (void) fprintf(stderr, "\n"); free_resources(); exit(exitcode); }
static void __exit hysdn_exit(void) { #ifdef CONFIG_HYSDN_CAPI hysdn_card *card; #endif /* CONFIG_HYSDN_CAPI */ stop_cards(); #ifdef CONFIG_HYSDN_CAPI card = card_root; /* first in chain */ while (card) { hycapi_capi_release(card); card = card->next; /* remove card from chain */ } /* while card */ hycapi_cleanup(); #endif /* CONFIG_HYSDN_CAPI */ hysdn_procconf_release(); free_resources(); printk(KERN_NOTICE "HYSDN: module unloaded\n"); } /* cleanup_module */