void Game::cleanup() { //delete the timers delete mpLoopTimer; mpLoopTimer = NULL; delete mpMasterTimer; mpMasterTimer = NULL; //delete the graphics system delete mpGraphicsSystem; mpGraphicsSystem = NULL; delete mpGraphicsBufferManager; mpGraphicsBufferManager = NULL; delete mpSpriteManager; mpSpriteManager = NULL; al_destroy_font(mpFont); mpFont = NULL; //shutdown components al_uninstall_audio(); al_shutdown_image_addon(); al_shutdown_font_addon(); al_shutdown_ttf_addon(); al_uninstall_keyboard(); al_uninstall_mouse(); al_shutdown_primitives_addon(); }
InputManager::~InputManager() { delete mpKeyboardState; delete mpMouseState; al_uninstall_keyboard(); al_uninstall_mouse(); }
void uninit() { if (this->event_queue_) al_destroy_event_queue(this->event_queue_); if (this->timer_) al_destroy_timer(this->timer_); al_uninstall_keyboard(); al_uninstall_mouse(); }
void Mouse::Deinit() { al_destroy_mouse_cursor(_cursor); delete _image; _image = nullptr; al_uninstall_mouse(); }
void shutdown() { al_shutdown_image_addon(); al_shutdown_ttf_addon(); al_shutdown_font_addon(); al_shutdown_primitives_addon(); al_uninstall_keyboard(); al_uninstall_mouse(); al_uninstall_audio(); al_uninstall_system(); }
int initializeAllegro(void){ if(!al_init()){ fprintf(stderr,"No se pudo inicializar Allegro\n"); return ERROR; } if(!al_install_mouse()){ fprintf(stderr,"No se pudo inicializar el mouse.\n"); al_uninstall_system(); return ERROR; } if(!al_init_primitives_addon()){ fprintf(stderr,"No se pudo inicializar el mouse.\n"); al_uninstall_system(); al_uninstall_mouse(); return ERROR; } al_init_font_addon(); //esta funcion en su declaracion dice que devuelve VOID, por eso no puedo hacer el chequeo if(!al_init_ttf_addon()){ fprintf(stderr,"No se pudo inicializar el mouse.\n"); al_uninstall_system(); al_uninstall_mouse(); al_shutdown_primitives_addon; al_shutdown_font_addon(); return ERROR; } if(!al_init_image_addon()){ fprintf(stderr,"No se inicializo el addon de imagenes\n"); fprintf(stderr,"No se pudo inicializar el mouse.\n"); al_uninstall_system(); al_uninstall_mouse(); al_shutdown_primitives_addon; al_shutdown_font_addon(); al_shutdown_ttf_addon(); return ERROR; } return 0; }
bool System::shutdownSharedSystem() { if (al_is_joystick_installed()) al_uninstall_joystick(); if (al_is_mouse_installed()) al_uninstall_mouse(); if (al_is_keyboard_installed()) al_uninstall_keyboard(); al_shutdown_image_addon(); if (al_is_system_installed()) al_uninstall_system(); return true; }
void closeAllegro(void){ al_uninstall_system(); al_uninstall_mouse(); al_shutdown_primitives_addon; al_shutdown_font_addon(); al_shutdown_ttf_addon(); al_shutdown_image_addon(); al_uninstall_system(); }
virtual ~Core() { if (_optionParser) delete _optionParser; if (_slideshowDisplay) delete _slideshowDisplay; if (_captureDisplay) delete _captureDisplay; if (_captureListener) delete _captureListener; if (_cameraContext) delete _cameraContext; if (_eventQueue) al_destroy_event_queue(_eventQueue); if (_timer) al_destroy_timer(_timer); al_uninstall_mouse(); al_uninstall_keyboard(); al_shutdown_image_addon(); al_uninstall_system(); }
void main_close_allegro_library() { regular_message("shutdown primitive addon"); al_shutdown_primitives_addon(); regular_message("shutdown native dialog addon"); al_shutdown_native_dialog_addon(); regular_message("shutdown image addon"); al_shutdown_image_addon(); regular_message("uninstall audio"); al_uninstall_audio(); regular_message("uninstall keyboard"); al_uninstall_keyboard(); regular_message("uinstall mouse"); al_uninstall_mouse(); regular_message("uninstll allegro system"); al_uninstall_system(); }
Framework::~Framework() { Settings->Save( "settings.cfg" ); #ifdef WRITE_LOG printf( "Framework: Shutdown\n" ); #endif al_destroy_event_queue( eventQueue ); al_destroy_display( displaySurface ); al_destroy_mutex( extraEventsMutex ); delete imageMgr; delete audioMgr; delete fontMgr; delete networkMgr; delete downloadMgr; // Shutdown Allegro if( mixer != 0 ) { al_destroy_mixer( mixer ); } if( voice != 0 ) { al_destroy_voice( voice ); } al_uninstall_keyboard(); al_uninstall_mouse(); al_shutdown_primitives_addon(); al_shutdown_ttf_addon(); al_shutdown_image_addon(); al_shutdown_font_addon(); al_uninstall_audio(); al_uninstall_joystick(); }
void finalize_mouse (void) { al_uninstall_mouse (); }
int main( int argc, char* argv[] ) { ALLEGRO_EVENT e; ALLEGRO_TIMER* t; int64_t framesToUpdate = 0; if( !al_init() ) { return -1; } al_init_font_addon(); if( !al_install_keyboard() || !al_install_mouse() || !al_init_primitives_addon() || !al_init_ttf_addon() || !al_init_image_addon() ) { return -1; } #if NETWORK_SUPPORT != 0 if( !install_network() ) { return -1; } #endif #if HTTP_SUPPORT if( !install_http() ) { return -1; } #ifdef PANDORA Downloads = new HttpManager(2); #else Downloads = new HttpManager(6); #endif #endif #if EXIT_IF_NO_AUDIO != 0 if( !al_install_audio() || !al_init_acodec_addon() ) { return -1; } voice = al_create_voice(44100, ALLEGRO_AUDIO_DEPTH_INT16, ALLEGRO_CHANNEL_CONF_2); if (!voice) return 1; mixer = al_create_mixer(44100, ALLEGRO_AUDIO_DEPTH_FLOAT32, ALLEGRO_CHANNEL_CONF_2); if (!mixer) return 1; if (!al_attach_mixer_to_voice(mixer, voice)) return 1; #else if( al_install_audio() ) { if( al_init_acodec_addon() ) { voice = al_create_voice(44100, ALLEGRO_AUDIO_DEPTH_INT16, ALLEGRO_CHANNEL_CONF_2); if( voice != 0 ) { mixer = al_create_mixer(44100, ALLEGRO_AUDIO_DEPTH_FLOAT32, ALLEGRO_CHANNEL_CONF_2); if( mixer != 0 ) al_attach_mixer_to_voice(mixer, voice); } } } #endif // EXIT_IF_NO_AUDIO // Random number is guarenteed to be random srand( 5 ); GameStack = new StageStack(); CurrentConfiguration = new Configuration(); if( CurrentConfiguration->FullScreen ) al_set_new_display_flags( ALLEGRO_FULLSCREEN_WINDOW ); al_set_new_display_option(ALLEGRO_VSYNC, 1, ALLEGRO_SUGGEST); bool foundMode = false; int fallbackW = 640; int fallbackH = 480; if( CurrentConfiguration->ForceResolution ) { foundMode = true; } else { for( int modeIdx = 0; modeIdx < al_get_num_display_modes(); modeIdx++ ) { if( al_get_display_mode( modeIdx, &ScreenMode ) != NULL ) { if( ScreenMode.width == CurrentConfiguration->ScreenWidth && ScreenMode.height == CurrentConfiguration->ScreenHeight ) { foundMode = true; } else { fallbackW = ScreenMode.width; fallbackH = ScreenMode.height; } } if( foundMode ) break; } } if( foundMode ) { Screen = al_create_display( CurrentConfiguration->ScreenWidth, CurrentConfiguration->ScreenHeight ); } else { Screen = al_create_display( fallbackW, fallbackH ); CurrentConfiguration->ScreenWidth = fallbackW; CurrentConfiguration->ScreenHeight = fallbackH; } al_hide_mouse_cursor( Screen ); t = al_create_timer( 1.0 / SCREEN_FPS ); if( t == NULL ) Quit = true; al_start_timer( t ); EventQueue = al_create_event_queue(); al_register_event_source( EventQueue, al_get_display_event_source( Screen ) ); al_register_event_source( EventQueue, al_get_keyboard_event_source() ); al_register_event_source( EventQueue, al_get_mouse_event_source() ); al_register_event_source( EventQueue, al_get_timer_event_source( t ) ); #if NETWORK_SUPPORT != 0 al_register_event_source( EventQueue, get_network_event_source() ); #endif #if HTTP_SUPPORT Downloads->urlDownloads = CurrentConfiguration->MaxConcurrentDownloads; al_register_event_source( EventQueue, get_http_event_source() ); #endif Fonts = new FontManager(); Images = new ImageManager(); Audio = new SoundManager(); al_set_blender( ALLEGRO_ADD, ALLEGRO_ALPHA, ALLEGRO_INVERSE_ALPHA ); GameStack->Push( (Stage*)new BootUp() ); while( !Quit ) { if( GameStack->IsEmpty() ) { Quit = true; } else { while( al_get_next_event( EventQueue, &e ) ) { #if HTTP_SUPPORT Downloads->Event( &e ); #endif switch( e.type ) { case ALLEGRO_EVENT_DISPLAY_CLOSE: Quit = true; break; case ALLEGRO_EVENT_JOYSTICK_CONFIGURATION: al_reconfigure_joysticks(); break; case ALLEGRO_EVENT_TIMER: if( e.timer.source == t ) framesToUpdate++; else if( !GameStack->IsEmpty() ) GameStack->Current()->Event( &e ); break; default: if( !GameStack->IsEmpty() ) GameStack->Current()->Event( &e ); switch( e.type ) { #if HTTP_SUPPORT case ALLEGRO_EVENT_HTTP: #endif #if NETWORK_SUPPORT case ALLEGRO_EVENT_NETWORK_CONNECTION: case ALLEGRO_EVENT_NETWORK_RECEIVEPACKET: case ALLEGRO_EVENT_NETWORK_DISCONNECTION: #endif case ALLEGRO_EVENT_BUTTON_CLICK: case ALLEGRO_EVENT_MOUSEEX_MOVE: case ALLEGRO_EVENT_MOUSEEX_DOWN: case ALLEGRO_EVENT_MOUSEEX_UP: case ALLEGRO_EVENT_MOUSEEX_CLICK: case ALLEGRO_EVENT_MOUSEEX_DOUBLECLICK: case ALLEGRO_EVENT_MOUSEEX_BOXED: case ALLEGRO_EVENT_MOUSEEX_WHEEL: al_unref_user_event( &e.user ); break; } break; } } if( framesToUpdate > 0 ) { for( int frmUp = 0; frmUp < framesToUpdate; frmUp++ ) { if( !GameStack->IsEmpty() ) GameStack->Current()->Update(); } framesToUpdate = 0; } al_clear_to_color( al_map_rgb( 128, 128, 128 ) ); if( !GameStack->IsEmpty() ) GameStack->Current()->Render(); al_flip_display(); Images->Tidy(); Fonts->Tidy(); Audio->Tidy(); } } while( !GameStack->IsEmpty() ) { GameStack->Pop(); } delete Downloads; delete Fonts; delete Images; delete Audio; al_destroy_event_queue( EventQueue ); al_destroy_display( Screen ); #if HTTP_SUPPORT uninstall_http(); #endif #if NETWORK_SUPPORT != 0 uninstall_network(); #endif al_uninstall_keyboard(); al_uninstall_mouse(); al_shutdown_primitives_addon(); al_shutdown_ttf_addon(); al_shutdown_image_addon(); al_uninstall_audio(); al_shutdown_font_addon(); return 0; }
VALUE rbal_mouse_done(VALUE rself) { al_uninstall_mouse(); return rself; }
/*metodo principal, gerencia a janela*/ int main(int argc, char argv[]) { /*janela principal*/ ALLEGRO_DISPLAY *janela = NULL; /*fila de eventos*/ ALLEGRO_EVENT_QUEUE *filaEvento = NULL; /*evento atual*/ ALLEGRO_EVENT evento; ALLEGRO_BITMAP *botao_gravar = NULL, *botao_carregar = NULL, *botao_girar_horario = NULL, *botao_girar_antihorario = NULL; /*ponteiro para um arquivo no dico*/ FILE *arquivo; /*definicoes do arquivo*/ int altura = 0,//altura da imagem largura = 0, //largura da imagem maxCor = 0;//inteiro que representa tonalidade de cor maxima char tipo[3];//tipo de PGM /*estrutura para armazenar os bits do arquivo*/ unsigned char **data = NULL; /*sinaliza fechamento da janela*/ bool fechaJanela = false; /*sinaliza existencia de arquivo aberto*/ bool arquivoAberto = false; /*inicializa bibliotecas*/ if(!(al_init() && al_install_mouse()&& al_init_image_addon()&& al_install_keyboard()&& al_init_primitives_addon()&& (filaEvento = al_create_event_queue()))){ printf("Erro ao inicializar biblioteca(s)!\n"); return 0; } // Alocamos o botão para fechar a aplicação criaBotao(botoes[0], "carregar.bmp"); botao_carregar = al_load_bitmap("carregar.bmp"); if (!botao_carregar) { fprintf(stderr, "Falha ao criar botão de carregar a imagem.\n"); al_destroy_display(janela); return -1; } // Alocamos o botão para fechar a aplicação botao_gravar = al_load_bitmap("salvar.bmp"); if (!botao_gravar) { fprintf(stderr, "Falha ao criar botão de salvar a imagem.\n"); al_destroy_bitmap(botao_carregar); al_destroy_display(janela); return -1; } // Alocamos o botão para fechar a aplicação botao_girar_horario = al_load_bitmap("girar_horario.bmp"); if (!botao_girar_horario) { fprintf(stderr, "Falha ao criar botão de girar a imagem 90º sentido horario.\n"); al_destroy_bitmap(botao_carregar); al_destroy_bitmap(botao_gravar); al_destroy_display(janela); return -1; } // Alocamos o botão para fechar a aplicação botao_girar_antihorario = al_load_bitmap("girar_anti.bmp"); if (!botao_girar_antihorario) { fprintf(stderr, "Falha ao criar botão de girar a imagem 90º sentido anti-horario.\n"); al_destroy_bitmap(botao_carregar); al_destroy_bitmap(botao_gravar); al_destroy_bitmap(botao_girar_horario); al_destroy_display(janela); return -1; } /*cria uma janela 640x480*/ janela = al_create_display(640, 50); /*registra os eventos*/ al_register_event_source(filaEvento, al_get_display_event_source(janela)); al_register_event_source(filaEvento, al_get_mouse_event_source()); al_register_event_source(filaEvento, al_get_keyboard_event_source()); /*preenche a janela com a cor branca*/ al_clear_to_color(al_map_rgb(255, 255, 255)); /*atualiza tela*/ al_flip_display(); /*fluxo principal da janela*/ while(fechaJanela == false){ /*pega evento da fila*/ al_wait_for_event(filaEvento, &evento); switch (evento.type) { /*fecha a janela (termina aplicacao)*/ case ALLEGRO_EVENT_DISPLAY_CLOSE: fechaJanela = true; break; /*carrega imagem em mostra na tela*/ case ALLEGRO_EVENT_MOUSE_BUTTON_UP: if (evento.mouse.x >= 0 && evento.mouse.x <= 70 && evento.mouse.y <= 50 && evento.mouse.y >= 0) { /*caso algum arquivo estiver aberto, limpa dados*/ if(arquivoAberto==true) { desalocaMatriz(data, altura); altura =0; largura =0; maxCor =0; arquivoAberto = false; } if(arquivoAberto==false) { /*carrega imagem na matriz*/ if(carregaImagem (janela, &altura,&largura, &maxCor, tipo, &data)==-1) { printf("Erro ao desenhar imagem!\n"); break; } /*sinaliza como arquivo aberto*/ arquivoAberto = true; /*desenha a imagem na janela*/ desenha(janela, data, altura, largura); } } if (evento.mouse.x >= 71 && evento.mouse.x <= 140 && evento.mouse.y <= 50 && evento.mouse.y >= 0 && arquivoAberto== true){ if(arquivoAberto == true) { if(gravaImagem(janela, tipo, altura, largura, maxCor, data)==-1) { printf("Erro ao salvar imagem!\n"); break; } } else { printf("Nenhum arquivo aberto!\n"); } } if (evento.mouse.x >= 141 && evento.mouse.x <= 210 && evento.mouse.y <= 50 && evento.mouse.y >= 0 && arquivoAberto== true) { data = rotacao(data, &altura, &largura, 'D'); desenha(janela, data, altura, largura); } if (evento.mouse.x >= 211 && evento.mouse.x <= 280 && evento.mouse.y <= 50 && evento.mouse.y >= 0 && arquivoAberto== true){ data = rotacao(data, &altura, &largura, 'E'); desenha(janela, data, altura, largura); } break; case ALLEGRO_EVENT_KEY_DOWN: switch(evento.keyboard.keycode) { case ALLEGRO_KEY_ENTER: if(arquivoAberto == true) { if(gravaImagem(janela, tipo, altura, largura, maxCor, data)==-1) { printf("Erro ao salvar imagem!\n"); break; } } else { printf("Nenhum arquivo aberto!\n"); } break; case ALLEGRO_KEY_SPACE: data = rotacao(data, &altura, &largura, 'D'); desenha(janela, data, altura, largura); break; } default: break; } al_set_target_bitmap(botao_gravar); al_set_target_bitmap(botao_carregar); al_set_target_bitmap(botao_girar_horario); al_set_target_bitmap(botao_girar_antihorario); al_set_target_bitmap(al_get_backbuffer(janela)); al_draw_bitmap(botao_carregar, 0,0, 0); al_draw_bitmap(botao_gravar, 71,0, 0); al_draw_bitmap(botao_girar_horario, 141,0, 0); al_draw_bitmap(botao_girar_antihorario, 211,0, 0); /*atualiza tela*/ al_flip_display(); } /*limpeza*/ if(data!=NULL && arquivoAberto == true){ desalocaMatriz(data, altura); } al_destroy_event_queue(filaEvento); al_uninstall_mouse(); al_uninstall_keyboard(); al_destroy_bitmap(botao_carregar); al_destroy_bitmap(botao_gravar); al_destroy_bitmap(botao_girar_horario); al_destroy_bitmap(botao_girar_antihorario); al_destroy_display(janela); return 0; }
static int allua_mouse_uninstall(lua_State * L) { al_uninstall_mouse(); return 0; }