示例#1
0
void precalc_render_screen_and_frame(const GameSizeDef &game_size, const ScreenSetup &setup,
                                     Size &screen_size, GameSizeDef &frame_size,
                                     const int color_depth, const bool windowed)
{
    Size device_size = get_max_display_size(windowed);

    // Set requested screen (window) size, depending on screen definition option
    switch (setup.SizeDef)
    {
    case kScreenDef_Explicit:
        // Use resolution from user config
        screen_size = setup.Size;
        if (screen_size.IsNull())
        {
            // If the configuration did not define proper screen size,
            // use the scaled game size instead
            set_game_frame_after_screen_size(game_size, device_size, setup.GameFrame, frame_size);
            if (screen_size.Width <= 0)
                screen_size.Width = frame_size.Box.Width;
            if (screen_size.Height <= 0)
                screen_size.Height = frame_size.Box.Height;
        }
        break;
    case kScreenDef_ByGameScaling:
        // Use game frame (scaled game) size
        set_game_frame_after_screen_size(game_size, device_size, setup.GameFrame, frame_size);
        screen_size = frame_size.Box;
        break;
    case kScreenDef_MaxDisplay:
        // Set as big as current device size
        screen_size = device_size;
        break;
    }
}
示例#2
0
int engine_init_gfx_filters(Size &game_size, Size &screen_size, const int color_depth)
{
    Out::FPrint("Initializing gfx filters");
    if (force_gfxfilter[0])
        GfxFilterRequest = force_gfxfilter;
    else
        GfxFilterRequest = usetup.gfxFilterID;
    Out::FPrint("Requested gfx filter: %s", GfxFilterRequest.GetCStr());

    String gfxfilter;
    if (GfxFilterRequest.CompareNoCase("max") != 0)
        gfxfilter = GfxFilterRequest;
    
    const Size base_size = game_size;
    const bool windowed = usetup.windowed != 0;
    const bool enable_sideborders = usetup.enable_side_borders != 0;
    const bool force_letterbox = game.options[OPT_LETTERBOX] != 0;

    int scaling_factor = 0;
    if (!gfxfilter.IsEmpty())
    {
        scaling_factor = get_scaling_from_filter_name(gfxfilter);
        Size found_screen_size;
        if (try_find_nearest_supported_mode(base_size, scaling_factor, found_screen_size, color_depth,
                windowed, enable_sideborders, force_letterbox))
            screen_size = found_screen_size;
    }

#if defined (WINDOWS_VERSION) || defined (LINUX_VERSION)
    if (screen_size.IsNull())
    {
        Size found_screen_size;
        scaling_factor = try_find_max_supported_uniform_scaling(base_size, found_screen_size, color_depth,
                            windowed, enable_sideborders, force_letterbox);
        if (scaling_factor > 0)
        {
            screen_size = found_screen_size;
            gfxfilter.Format(scaling_factor > 1 ? "StdScale%d" : "None", scaling_factor);
        }
    }
#endif

    if (gfxfilter.IsEmpty())
    {
        set_allegro_error("Failed to find acceptable graphics filter");
        return EXIT_NORMAL;
    }
    game_size.Width = screen_size.Width / scaling_factor;
    game_size.Height = screen_size.Height / scaling_factor;
    Out::FPrint("Chosen gfx resolution: %d x %d (%d bit), game frame: %d x %d",
        screen_size.Width, screen_size.Height, color_depth, game_size.Width, game_size.Height);
    if (initialize_graphics_filter(gfxfilter, base_size.Width, base_size.Height, color_depth))
    {
        return EXIT_NORMAL;
    }
    return RETURN_CONTINUE;
}
示例#3
0
void display_gfx_mode_error(const Size &game_size, const Size &screen_size)
{
    proper_exit=1;
    platform->FinishedUsingGraphicsMode();

    String main_error;
    if (screen_size.IsNull())
        main_error.Format("There was a problem finding appropriate graphics mode for game size %d x %d (%d-bit) and requested filter '%s'.",
            game_size.Width, game_size.Height, firstDepth, GfxFilterRequest.IsEmpty() ? "Undefined" : GfxFilterRequest.GetCStr());
    else
        main_error.Format("There was a problem initializing graphics mode %d x %d (%d-bit) with game size %d x %d and filter '%s'.",
            screen_size.Width, screen_size.Height, firstDepth, game_size.Width, game_size.Height, filter ? filter->GetFilterID() : "Undefined");

    platform->DisplayAlert("%s\n"
            "(Problem: '%s')\n"
            "Try to correct the problem, or seek help from the AGS homepage."
            "%s",
            main_error.GetCStr(), get_allegro_error(), platform->GetGraphicsTroubleshootingText());
}
示例#4
0
void display_gfx_mode_error(const Size &game_size, const Size &screen_size)
{
    proper_exit=1;
    platform->FinishedUsingGraphicsMode();

    String main_error;
    if (screen_size.IsNull())
        main_error.Format("There was a problem finding appropriate graphics mode for game size %d x %d (%d-bit) and requested filter '%s'.",
            game_size.Width, game_size.Height, firstDepth, GfxFilterRequest.IsEmpty() ? "Undefined" : GfxFilterRequest.GetCStr());
    else
        main_error.Format("There was a problem initializing graphics mode %d x %d (%d-bit) with game size %d x %d and filter '%s'.",
            screen_size.Width, screen_size.Height, firstDepth, game_size.Width, game_size.Height, filter ? filter->GetFilterID() : "Undefined");

    platform->DisplayAlert("%s\n"
            "(Problem: '%s')\n"
            "Try to correct the problem, or seek help from the AGS homepage.\n"
            "\nPossible causes:\n* your graphics card drivers do not support this resolution. "
            "Run the game setup program and try the other resolution.\n"
            "* the graphics driver you have selected does not work. Try switching between Direct3D and DirectDraw.\n"
            "* the graphics filter you have selected does not work. Try another filter.",
            main_error.GetCStr(), get_allegro_error());
}
示例#5
0
void engine_init_screen_settings(Size &game_size, Size &screen_size)
{
    Out::FPrint("Initializing screen settings");

    // default shifts for how we store the sprite data

#if defined(PSP_VERSION)
    // PSP: Switch b<>r for 15/16 bit.
    _rgb_r_shift_32 = 16;
    _rgb_g_shift_32 = 8;
    _rgb_b_shift_32 = 0;
    _rgb_b_shift_16 = 11;
    _rgb_g_shift_16 = 5;
    _rgb_r_shift_16 = 0;
    _rgb_b_shift_15 = 10;
    _rgb_g_shift_15 = 5;
    _rgb_r_shift_15 = 0;
#else
    _rgb_r_shift_32 = 16;
    _rgb_g_shift_32 = 8;
    _rgb_b_shift_32 = 0;
    _rgb_r_shift_16 = 11;
    _rgb_g_shift_16 = 5;
    _rgb_b_shift_16 = 0;
    _rgb_r_shift_15 = 10;
    _rgb_g_shift_15 = 5;
    _rgb_b_shift_15 = 0;
#endif

    GameSize = ResolutionTypeToSize(game.default_resolution);
    if (GameSize.IsNull())
        quit("Unable to define native game resolution, could be unsupported game format.");

    scrnwid = GameSize.Width;
    scrnhit = GameSize.Height;

    if (game.IsHiRes())
    {
        usetup.base_width = scrnwid / 2;
        usetup.base_height = scrnhit / 2;
        wtext_multiply = 2;
    }
    else
    {
        usetup.base_width = scrnwid;
        usetup.base_height = scrnhit;
        wtext_multiply = 1;
    }

    usetup.textheight = wgetfontheight(0) + 1;

    vesa_xres=scrnwid; vesa_yres=scrnhit;
    current_screen_resolution_multiplier = scrnwid / BASEWIDTH;

    if (game.IsHiRes() &&
        (game.options[OPT_NATIVECOORDINATES]))
    {
        usetup.base_width *= 2;
        usetup.base_height *= 2;
    }

    // don't allow them to force a 256-col game to hi-color
    if (game.color_depth < 2)
        usetup.force_hicolor_mode = false;

    firstDepth = 8, secondDepth = 8;
    if ((game.color_depth == 2) || (force_16bit) || (usetup.force_hicolor_mode)) {
        firstDepth = 16;
        secondDepth = 15;
    }
    else if (game.color_depth > 2) {
        firstDepth = 32;
        secondDepth = 24;
    }

    // The letterbox-by-design game property requests that game frame must
    // include black horizontal borders of fixed height.
    // If the letterbox option is disabled, then the game frame size will be
    // equal to native game size.
    LetterboxedGameSize = ResolutionTypeToSize(game.default_resolution, game.options[OPT_LETTERBOX] != 0);
    game_size = LetterboxedGameSize;
    screen_size = Size(0, 0);

    // Log out display information
    Size device_size;
    if (get_desktop_resolution(&device_size.Width, &device_size.Height) == 0)
        Out::FPrint("Device display resolution: %d x %d", device_size.Width, device_size.Height);
    else
        Out::FPrint("Unable to obtain device resolution");

    Out::FPrint("Game native resolution: %d x %d (%d bit)%s", scrnwid, scrnhit, firstDepth,
        game.options[OPT_LETTERBOX] == 0 ? "": " letterbox-by-design");
    Out::FPrint("Game settings: %s, letterbox %s, side borders %s",
        usetup.windowed ? "windowed" : "fullscreen",
        usetup.prefer_letterbox ? "acceptable" : "undesirable", usetup.prefer_sideborders ? "acceptable" : "undesirable");

    adjust_sizes_for_resolution(loaded_game_file_version);
}