/** * Try to set the device to a given width & height */ static void GFraMe_set_screen_ratio() { int i_zoom; double d_zoom; d_zoom = GFraMe_screen_set_keep_ratio(0, 1); i_zoom = (int)d_zoom; if ((double)i_zoom != d_zoom) d_zoom = (double)GFraMe_screen_set_pixel_perfect(0, 1); if (d_zoom == 0) GFraMe_screen_set_maximize_double(1); }
int main(int argc, char *argv[]) { GFraMe_ret rv; GFraMe_save sv, *pSv; GFraMe_wndext ext; int zoom, lang; state st; ext.atlas = "atlas"; ext.atlasWidth = 256; ext.atlasHeight = 256; ext.flags = GFraMe_wndext_none; //ext.flags = GFraMe_wndext_scanline; rv = GFraMe_init ( SCR_W, SCR_H, WND_W, WND_H, ORG, NAME, GFraMe_window_none, // GFraMe_window_fullscreen &ext, FPS, 1, // Log to file 0 // Log append ); GFraMe_assertRet(rv == GFraMe_ret_ok, "Init failed", __ret); setIcon(); // Set the bg color GFraMe_set_bg_color(0x22, 0x20, 0x34, 0xff); // Set the actual game dimensions pSv = 0; rv = GFraMe_save_bind(&sv, CONFFILE); GFraMe_assertRet(rv == GFraMe_ret_ok, "Error opening file", __ret); pSv = &sv; rv = GFraMe_save_read_int(&sv, "zoom", &zoom); if (rv == GFraMe_ret_ok) { // Switch the resolution if (zoom != 0 && zoom != 2) { GFraMe_ret rv; rv = GFraMe_screen_set_window_size(SCR_W*zoom, SCR_H*zoom); if (rv == GFraMe_ret_ok) GFraMe_screen_set_pixel_perfect(0, 1); } else if (zoom == 0) { GFraMe_ret rv; rv = GFraMe_screen_setFullscreen(); if (rv == GFraMe_ret_ok) GFraMe_screen_set_pixel_perfect(0, 1); } } // Check if the language was stored (and load it) rv = GFraMe_save_read_int(&sv, "lang", &lang); if (rv == GFraMe_ret_ok) { if (lang == EN_US) { gl_lang = EN_US; } else if (lang == PT_BR) { gl_lang = PT_BR; } } else { gl_lang = EN_US; } GFraMe_save_close(&sv); pSv = 0; rv = GFraMe_audio_player_init(); GFraMe_assertRet(rv == GFraMe_ret_ok, "Audio player init failed", __ret); rv = gl_init(); GFraMe_assertRet(rv == GFraMe_ret_ok, "global init failed", __ret); GFraMe_controller_init(1); st = MENUSTATE; // st = CREDITS; while (gl_running) { switch (st) { case MENUSTATE: st = menustate(); break; case NEW_PLAYSTATE: st = playstate(0); break; case CNT_PLAYSTATE: st = playstate(1); break; case OPTIONS: st = options(); break; case DEMO: st = demo(); break; case CREDITS: st = credits(); break; default: rv = 123; GFraMe_assertRet(0, "Invalid state!", __ret); } } rv = 0; __ret: if (pSv) GFraMe_save_close(pSv); GFraMe_audio_player_pause(); GFraMe_audio_player_clear(); gl_clean(); GFraMe_controller_close(); GFraMe_quit(); return rv; }