Changeset 2310


Ignore:
Timestamp:
Feb 1, 2013, 3:48:46 PM (7 years ago)
Author:
sam
Message:

ps3: add support for resolution selection.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/platform/ps3/ps3app.cpp

    r2222 r2310  
    22// Lol Engine
    33//
    4 // Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net>
     4// Copyright: (c) 2010-2013 Sam Hocevar <sam@hocevar.net>
    55//   This program is free software; you can redistribute it and/or
    66//   modify it under the terms of the Do What The Fuck You Want To
     
    8888#endif
    8989
    90     PSGLdevice* psgl = psglCreateDeviceAuto(GL_ARGB_SCE, GL_DEPTH_COMPONENT24,
    91                                        GL_MULTISAMPLING_4X_SQUARE_ROTATED_SCE);
     90    PSGLdeviceParameters psgldp =
     91    {
     92        enable: PSGL_DEVICE_PARAMETERS_COLOR_FORMAT
     93              | PSGL_DEVICE_PARAMETERS_DEPTH_FORMAT
     94              | PSGL_DEVICE_PARAMETERS_MULTISAMPLING_MODE
     95              | PSGL_DEVICE_PARAMETERS_WIDTH_HEIGHT,
     96        colorFormat: GL_ARGB_SCE, /* can also be GL_RGBA16F_ARB */
     97        depthFormat: GL_DEPTH_COMPONENT16, /* can also be 24-bit */
     98        multisamplingMode: GL_MULTISAMPLING_4X_SQUARE_ROTATED_SCE,
     99        width: 720,
     100        height: 480,
     101    };
     102
     103    /* Find closest valid resolution */
     104    ivec2 const valid_resolutions[8] =
     105    {
     106        ivec2( 720,  480),
     107        ivec2( 720,  576),
     108        ivec2(1280,  720),
     109        ivec2(1920, 1080),
     110        ivec2( 960, 1080),
     111        ivec2(1280, 1080),
     112        ivec2(1440, 1080),
     113        ivec2(1600, 1080),
     114    };
     115
     116    for (int i = 0; i < 8; ++i)
     117    {
     118        ivec2 cur(psgldp.width, psgldp.height);
     119        if (sqlength(valid_resolutions[i] - res) < sqlength(cur - res))
     120        {
     121            psgldp.width = valid_resolutions[i].x;
     122            psgldp.height = valid_resolutions[i].y;
     123        }
     124    }
     125
     126    /* Create graphics device */
     127    PSGLdevice* psgl = psglCreateDeviceExtended(&psgldp);
     128    if (!psgl)
     129        Log::Error("could not create PSGL device; expect imminent crash\n");
     130
    92131    GLuint w, h;
    93132    psglGetDeviceDimensions(psgl, &w, &h);
    94     res = ivec2(w, h);
     133    ivec2 newres(w, h);
     134    Log::Debug("resolution asked %d×%d, closest valid %d×%d, final %d×%d\n",
     135               res.x, res.y, psgldp.width, psgldp.height, newres.x, newres.y);
    95136
    96137    PSGLcontext *ctx = psglCreateContext();
     
    102143    /* Initialise everything */
    103144    Ticker::Setup(fps);
    104     Video::Setup(res);
     145    Video::Setup(newres);
    105146    Audio::Setup(2);
    106147
Note: See TracChangeset for help on using the changeset viewer.