//returns a pointer to FONT (char *aFilename) and shows //error message on failure FONT *makeFont(char *aFilename) { FONT *fontPointer; if (!(fontPointer = load_font(aFilename, palette, NULL))) { set_gfx_mode(GFX_TEXT, 1024,768,0,0); allegro_message("Error! Could not find the file \"%s\"!", aFilename); exit(1); } return(fontPointer); }
//returns a pointer to SAMPLE (char *aFilename) and shows //error message on failure SAMPLE *makeSample(char *aFilename) { SAMPLE *samplePointer; if (!(samplePointer = load_sample(aFilename))) { set_gfx_mode(GFX_TEXT, 1024,768,0,0); allegro_message("Error! Could not find the file \"%s\"!", aFilename); exit(1); } return(samplePointer); }
BITMAP *makeBitmap(char *aFilename) { BITMAP *bitmapPointer; if (!(bitmapPointer = load_bitmap(aFilename, NULL))) { set_gfx_mode(GFX_TEXT, 1024,768,0,0); allegro_message("Error! Could not find the file \"%s\"!", aFilename); exit(1); } return(bitmapPointer); }
void tui_init(void) { set_gfx_mode(GFX_TEXT, 80, 25, 0, 0); /* FIXME: this should be made more flexible, to handle other screen modes automatically. */ _set_screen_lines(25); gettextinfo(&text_mode_info); /* _setcursortype(_NOCURSOR); */ }
int main( void ) { int depth; /* represents color depth */ /* first, set up Allegro and the graphics mode */ allegro_init(); /* initialize Allegro */ install_keyboard(); /* install the keyboard for Allegro to use */ install_sound( DIGI_AUTODETECT, MIDI_AUTODETECT, NULL ); depth = desktop_color_depth(); /* find out what color depth is on our computer */ if (depth == 0) depth = 32; set_color_depth( depth ); /* set the color depth to depth used by our computer */ set_gfx_mode( GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0 ); /* set graphics mode */ ball = load_bitmap( "ball.bmp", NULL ); /* load the ball bitmap */ bar = load_bitmap( "bar.bmp", NULL); /* load the bar bitmap */ buffer = create_bitmap(SCREEN_W, SCREEN_H);/* create buffer */ boing = load_sample( "boing.wav" ); /* load the sound file */ pongFont = load_font( "pongfont.pcx", NULL, NULL ); /* load the font */ ball_x = SCREEN_W / 2; /* give the ball its initial x-coordinate */ ball_y = SCREEN_H / 2; /* give the ball its initial y-coordinate */ barL_y = SCREEN_H / 2; /* give left paddle its initial y-coordinate */ barR_y = SCREEN_H / 2; /* give right paddle its initial y-coordinate */ scoreL = 0; /* set left player’s score to 0 */ scoreR = 0; /* set right player’s score to 0 */ srand( time( NULL ) ); /* seed the random function ... */ direction = rand() % 4; /* and then make a random initial direction */ while ( !key[KEY_ESC] )/* until the escape key is pressed ... */ { moveBall(); /* move the ball */ respondToKeyboard(); /* respond to keyboard input */ /* now, perform double buffering */ clear_to_color( buffer, makecol( 255, 255, 255 ) ); blit( ball, buffer, 0, 0, ball_x, ball_y, ball->w, ball->h ); blit( bar, buffer, 0, 0, 0, barL_y, bar->w, bar->h ); blit( bar, buffer, 0, 0, 620, barR_y, bar->w, bar->h ); /* draw text onto the buffer */ textprintf_ex( buffer, pongFont, 75, 0, makecol( 0, 0, 0 ), -1, "Left Player Score: %d", scoreL ); textprintf_ex( buffer, pongFont, 400, 0, makecol( 0, 0, 0 ), -1, "Right Player Score: %d", scoreR ); blit( buffer, screen, 0, 0, 0, 0, buffer->w, buffer->h ); clear_bitmap( buffer ); } /* end while */ destroy_bitmap( ball ); /* destroy the ball bitmap */ destroy_bitmap( bar ); /* destroy the bar bitmap */ destroy_bitmap( buffer ); /* destroy the buffer bitmap */ destroy_sample( boing ); /* destroy the boing sound file */ destroy_font( pongFont ); /* destroy the font */ return 0; } /* end function main */
void Game::privChangeResolution( bool aWindowed ) { myWindowed = aWindowed; int driver; if (myWindowed) { driver = GFX_AUTODETECT_WINDOWED; myResolutionWidth = 640; myResolutionHeight = 480; } else { driver = GFX_AUTODETECT_FULLSCREEN; if (myWideScreen) { myResolutionWidth = 1280; myResolutionHeight = 720; } else { myResolutionWidth = 640; myResolutionHeight = 480; } } set_color_depth(32); if (set_gfx_mode(driver, myResolutionWidth, myResolutionHeight, 0, 0) < 0) { set_color_depth(24); if (set_gfx_mode(driver, myResolutionWidth, myResolutionHeight, 0, 0) < 0) { set_color_depth(16); if (set_gfx_mode(driver, myResolutionWidth, myResolutionHeight, 0, 0) < 0) { set_color_depth(15); if (set_gfx_mode(driver, myResolutionWidth, myResolutionHeight, 0, 0) < 0) { throw std::string("Unable to set graphics mode."); } } } } }
void memverify_str(void *pointer, char *str) { if(!pointer) { set_gfx_mode(GFX_TEXT, 0, 0, 0, 0); if(str) allegro_message("The program that you are running has run out of memory, and cannot continue. %s ", str); else allegro_message("The program that you are running has run out of memory, and cannot continue."); exit(EXIT_FAILURE); } }
//contrutor int ControleGrafico::IniciaAllegro() { //inicia o allegro allegro_init(); //..o teclado install_keyboard(); // .. 16 bits de cores set_color_depth(16); // (set_gfx_mode(GFX_AUTODETECT_FULLSCREEN, 800, 600, 0, 0) != 0) //.. se criar a janela do jogo no tamanho de 640x480 if (set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0) != 0) { //.. sei la set alguma coisa set_gfx_mode(GFX_TEXT, 0, 0, 0, 0); //fala pro usuario que deu merda .. allegro_message("Nao foi possivel selecionar modo grafico algum.\n%s\n", allegro_error); return 0; } return 1; }
// Construct state init::init(){ // Get graphics resolution int width; int height; get_desktop_resolution( &width, &height); // Set graphics mode set_gfx_mode( GFX_AUTODETECT_WINDOWED, 640, 640, 0, 0); // Title set_window_title( "Minesweeper - A.D.S. Games"); }
/* shutdown_gfx: * Used by allegro_exit() to return the system to text mode. */ static void shutdown_gfx(void) { if (gfx_driver) set_gfx_mode(GFX_TEXT, 0, 0, 0, 0); if (system_driver->restore_console_state) system_driver->restore_console_state(); _remove_exit_func(shutdown_gfx); gfx_virgin = TRUE; }
int initialize(){ allegro_init(); install_timer(); install_keyboard(); set_color_depth(16); set_gfx_mode(MODE,WIDTH,HEIGHT,0,0); srand(time(NULL)); buffer=create_bitmap(SCREEN_W,SCREEN_H); clear(buffer); if(install_sound(DIGI_AUTODETECT,MIDI_AUTODETECT,"")!=0){ allegro_message("Error initializing sound system"); return 0; } welcome=load_bitmap("welcome.bmp",NULL); instruction1=load_bitmap("instruction1.bmp",NULL); instruction2=load_bitmap("instruction2.bmp",NULL); instruction3=load_bitmap("instruction3.bmp",NULL); gameoverscreen=load_bitmap("gameover.bmp",NULL); if(!welcome || !instruction2 || ! instruction3 || !instruction1 || ! gameoverscreen){ set_gfx_mode(GFX_TEXT,0,0,0,0); allegro_message("WELCOME BMPS MISSING"); return 0; } //level1=load_sample("stage1.wav"); /*if(!level1){ allegro_message("No sound file"); return 0; }*/ if(MapLoad("level1.fmp")){ set_gfx_mode(GFX_TEXT,0,0,0,0); allegro_message("Can't find level1.fmp"); return 0; } LOCK_FUNCTION(timer1); LOCK_VARIABLE(ticks); LOCK_VARIABLE(framerate); LOCK_VARIABLE(counter); install_int(timer1,100); return 1; }
int change_resolution(int fullscreen, int ResIndex) { int screen_mode; if(!IsInstalled) { return install(fullscreen,800,480,32); //Security mesure } KillTextures(); allegro_gl_set(AGL_COLOR_DEPTH, Resolutions->mode[ResIndex].bpp); if(fullscreen) screen_mode=GFX_OPENGL_FULLSCREEN; else screen_mode=GFX_OPENGL_WINDOWED; if (set_gfx_mode(screen_mode, Resolutions->mode[ResIndex].width,Resolutions->mode[ResIndex].height, 0, 0)) { set_gfx_mode(GFX_TEXT, 0, 0, 0, 0); allegro_message("Unable to set graphic mode\n%s\n", allegro_error); return 1; } SetOpenGL2D(); RefreshGLTextures(); AspectRatio=(float)SCREEN_W/(float)SCREEN_H; Fullscreen=fullscreen; Width=Resolutions->mode[ResIndex].width; Height=Resolutions->mode[ResIndex].height; depth=Resolutions->mode[ResIndex].bpp; ResolutionIndex=ResIndex; set_config_file("Resources/Setting.cfg"); set_config_int("graphics","Fullscreen",Fullscreen); set_config_int("graphics","Width",Width); set_config_int("graphics","Height",Height); set_config_int("graphics","depth",depth); set_config_int("graphics","ResolutionIndex",ResIndex); flush_config_file(); LoadSavegame(); return 0; }
int main(int argc, char **argv) { allegro_init(); set_color_depth(32); set_gfx_mode(GFX_AUTODETECT_WINDOWED, SCRW, SCRH, 0, 0); install_keyboard(); install_mouse(); install_timer(); LOCK_VARIABLE(timer); LOCK_FUNCTION(timerupdate); install_int_ex(timerupdate, BPS_TO_TIMER(TIMER_BPS)); srand((unsigned)time(NULL)); set_window_title("Skat"); LOCK_FUNCTION(close_handler); set_close_button_callback(close_handler); cards = load_bitmap("images/cards.tga", NULL); game.p[0] = &human; game.p[1] = &cpu1; game.p[2] = &cpu2; human.choose_card = human_choose_card; cpu1.choose_card = cpu_choose_card; cpu2.choose_card = cpu_choose_card; human.choose_game = human_choose_game; cpu1.choose_game = cpu_choose_game; cpu2.choose_game = cpu_choose_game; human.reizen = human_reizen; cpu1.reizen = cpu_reizen; cpu2.reizen = cpu_reizen; human.schieben = human_schieben; cpu1.schieben = cpu_schieben; cpu2.schieben = cpu_schieben; human.kontra = human_kontra; cpu1.kontra = cpu_kontra; cpu2.kontra = cpu_kontra; human.name = "Stefan"; cpu1.name = "Robert"; cpu2.name = "Thomas"; human.rtext = cpu1.rtext = cpu2.rtext = NULL; human.total_points = 0; cpu1.total_points = 0; cpu2.total_points = 0; enable_hardware_cursor(); show_mouse(screen); buffered_do_dialog(main_dlg, -1); destroy_bitmap(cards); }
int main(void) { if (allegro_init() != 0) return 1; install_keyboard(); set_color_depth(32); if (set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0) != 0) { set_gfx_mode(GFX_TEXT, 0, 0, 0, 0); allegro_message("Unable to set a 640x480x32 windowed mode\n%s\n", allegro_error); return 1; } memread_test(); stdio_read_test(); stdio_seek_test(); stdio_write_test(); return 0; }
int main() { // programı ilklendir allegro_init(); set_color_depth(16); set_gfx_mode(GFX_AUTODETECT_FULLSCREEN, 640, 480, 0, 0); install_keyboard(); while(!key[KEY_ESC]) { } allegro_exit(); }
int main(int argc, char *argv[]) { BITMAP *buffer; allegro_init(); install_keyboard(); install_timer(); int buttons = install_mouse(); set_color_depth(32); if (set_gfx_mode(GFX_AUTODETECT, 640, 480, 0, 0) != 0) { set_gfx_mode(GFX_TEXT, 0, 0, 0, 0); allegro_message("Unable to set gfx mode\n%s\n", allegro_error); return 1; } uclock_t start; buffer = create_bitmap(SCREEN_W, SCREEN_H); zelda::image::Image *img = new zelda::image::Image; img->load_pcx("./pics/test3.pcx"); while (!key[KEY_ESC]) { blit(buffer, screen, 0, 0, 0, 0, SCREEN_W, SCREEN_H); blit(img->get_bmp(), screen, 0, 0, 0, 0, SCREEN_W, SCREEN_H); start = uclock(); while (uclock() < start + UCLOCKS_PER_SEC / 1500) ; //usleep(50000); } destroy_bitmap(buffer); return 0; }
void init() { int depth, res; allegro_init(); depth = desktop_color_depth(); if (depth == 0) depth = 32; set_color_depth(depth); res = set_gfx_mode(GFX_AUTODETECT_WINDOWED, 960, 600, 0, 0); if (res != 0) { allegro_message(allegro_error); exit(-1); } install_keyboard(); }
void graphics_init() { if (set_gfx_mode(GFX_AUTODETECT, 320, 200, 0, 0)) { fprintf(stderr, "Error setting screen mode:\n"); fprintf(stderr, allegro_error); exit(-1); } if ((gBuff = create_bitmap(SCREEN_W, SCREEN_H)) == NULL) { fprintf(stderr, "Could not allocate memory for a screen buffer."); exit(-1); } clear(gBuff); }
void InitDoubleBuffering(){//init grafickeho rezimu // obrazovy buffer buffer = create_bitmap(SCR_W,SCR_H); // Pokud se buffer navytvoøí ,vypíšeme hlášku a ukonèíme program if(buffer == NULL) { set_gfx_mode(GFX_TEXT,0,0,0,0); allegro_message("Could not create buffer!"); exit(EXIT_FAILURE); } }
void init() { int depth, res; allegro_init(); depth = desktop_color_depth(); if (depth == 0) depth = 32; set_color_depth(depth); res = set_gfx_mode(GFX_AUTODETECT, 1440, 900, 0, 0); if (res != 0) { allegro_message(allegro_error); exit(-1);} install_timer(); install_keyboard(); install_mouse(); }
int main(int argc, char *argv[]) { PALETTE my_palette; BITMAP *scr_buffer; char pcx_name[256]; if (allegro_init() != 0) return 1; install_keyboard(); if (set_gfx_mode(GFX_AUTODETECT, 640, 480, 0, 0) != 0) { if (set_gfx_mode(GFX_SAFE, 640, 480, 0, 0) != 0) { set_gfx_mode(GFX_TEXT, 0, 0, 0, 0); allegro_message("Unable to set any graphic mode\n%s\n", allegro_error); return 1; } } replace_filename(pcx_name, argv[0], "mysha.pcx", sizeof(pcx_name)); scr_buffer = load_pcx(pcx_name, my_palette); if (!scr_buffer) { set_gfx_mode(GFX_TEXT, 0, 0, 0, 0); allegro_message("Error loading %s!\n", pcx_name); return 1; } set_palette(my_palette); blit(scr_buffer, screen, 0, 0, 0, 0, scr_buffer->w, scr_buffer->h); while (!keypressed()) { stretch_blit(scr_buffer, screen, 0, 0, AL_RAND()%scr_buffer->w, AL_RAND()%scr_buffer->h, AL_RAND()%SCREEN_W, AL_RAND()%SCREEN_H, AL_RAND()%SCREEN_W, AL_RAND()%SCREEN_H); vsync(); } destroy_bitmap(scr_buffer); return 0; }
void init() { allegro_init(); install_mouse(); install_keyboard(); set_color_depth(32); set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0); buffer = create_bitmap(SCREEN_W, SCREEN_H); srand(time(NULL)); }
Init::Init() { // Set window title set_window_title("Error"); int width; int height; get_desktop_resolution(&width,&height); set_gfx_mode( GFX_AUTODETECT, width,height , 0, 0); set_window_title("Tile Engine"); }
static int setgfxmode(int fullscreen) { if (!fullscreen && set_gfx_mode(GFX_AUTODETECT_WINDOWED, 512, 400, 0, 0) == 0) { term_width = 64; set_display_switch_mode(SWITCH_BACKGROUND); set_display_switch_callback(SWITCH_OUT, lost_focus); return 1; } if (set_gfx_mode(GFX_AUTODETECT, 640, 480, 0, 0) == 0) { term_width = 80; set_display_switch_mode(SWITCH_PAUSE); return 1; } if (get_color_depth() != 8) { set_color_depth(8); return setgfxmode(fullscreen); } set_gfx_mode(GFX_TEXT, 0, 0, 0, 0); allegro_message("Unable to set any graphics mode:\n" "%s\n", allegro_error); return 0; }
int main (int argc, char **argv) { image *img; printf ("start\n"); allegro_init (); set_gfx_mode (GFX_VESA1,640,480,640,480); setup_palette (); img=open_pcx (argv[1]); convert_scr7 (img); getch (); erase_image (img); allegro_exit (); return 0; }
void GameInit(void) { allegro_init(); install_keyboard(); install_timer(); install_mouse(); clear_keybuf(); set_gfx_mode(GFX_AUTODETECT, 320, 240, 0, 0); set_pallete(desktop_pallete); return; }
/* * fatal_error() * Displays a fatal error and aborts the application * (printf() format) */ void fatal_error(const char *fmt, ...) { char buf[2048]; va_list args; va_start(args, fmt); vsprintf(buf, fmt, args); va_end(args); logfile_message(buf); set_gfx_mode(GFX_TEXT, 0, 0, 0, 0); allegro_message("%s", buf); exit(1); }
/***************************************************************************** Function: osd_gfx_init_scanline_mode Description: Initialize screen for use with the scanline displaying Parameters: none Return: nothing *****************************************************************************/ int osd_gfx_init_scanline_mode(void) { if (!(set_gfx_mode(GFX_SVGALIB,640,480,0,0))) { vwidth=640; vheight=480; blit_x=(320-io.screen_w); blit_y=(240-io.screen_h); screen_blit_x=((WIDTH-io.screen_h) >> 1); screen_blit_y=((HEIGHT-io.screen_w) >> 1); SetPalette(); return 1; }
Alleg4Display(int width, int height, int scale) : m_surface(NULL) , m_scale(0) { unique_display = this; if (install_mouse() < 0) throw DisplayCreationException(allegro_error); if (install_keyboard() < 0) throw DisplayCreationException(allegro_error); #ifdef FULLSCREEN_PLATFORM set_color_depth(16); // TODO Try all color depths for fullscreen platforms #else set_color_depth(desktop_color_depth()); #endif if (set_gfx_mode( #ifdef FULLSCREEN_PLATFORM GFX_AUTODETECT_FULLSCREEN, #else GFX_AUTODETECT_WINDOWED, #endif width, height, 0, 0) < 0) throw DisplayCreationException(allegro_error); setScale(scale); m_queue = new Alleg4EventQueue(); // Copy the initial queue to the display queue { base::scoped_lock hold(unique_display_mutex); Event ev; while (initial_queue.try_pop(ev)) m_queue->queueEvent(ev); } // Add a hook to display-switch so when the user returns to the // screen it's completelly refreshed/redrawn. LOCK_VARIABLE(display_flags); LOCK_FUNCTION(display_switch_in_callback); set_display_switch_callback(SWITCH_IN, display_switch_in_callback); #ifdef ALLEGRO4_WITH_RESIZE_PATCH // Setup the handler for window-resize events set_resize_callback(resize_callback); #endif #if WIN32 subclass_hwnd((HWND)nativeHandle()); #endif }
void allegro_video_init() { int c; set_color_depth(32); set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0); video_blit_memtoscreen = allegro_blit_memtoscreen; video_blit_memtoscreen_8 = allegro_blit_memtoscreen_8; for (c = 0; c < 256; c++) pal_lookup[c] = makecol(cgapal[c].r << 2, cgapal[c].g << 2, cgapal[c].b << 2); buffer32_vscale = create_bitmap(2048, 2048); }