Ignore:
Timestamp:
Jun 22, 2013, 11:23:40 PM (8 years ago)
Author:
sam
Message:

gpu: framebuffers now use the g_render object to restore viewport data.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/video.cpp

    r2761 r2768  
    4949
    5050private:
    51     static ivec2 saved_viewport;
    5251    static DebugRenderMode render_mode;
    5352#if defined USE_D3D9 || defined _XBOX
     
    6261};
    6362
    64 ivec2 VideoData::saved_viewport(0, 0);
    6563DebugRenderMode VideoData::render_mode = DebugRenderMode::Default;
    6664
     
    9694                                VideoMode.dwDisplayHeight);
    9795#   endif
    98     VideoData::saved_viewport = size;
    99 
    10096    D3DPRESENT_PARAMETERS d3dpp;
    10197    memset(&d3dpp, 0, sizeof(d3dpp));
     
    124120    g_d3ddevice = VideoData::d3d_dev;
    125121
    126     g_renderer = new Renderer();
     122    g_renderer = new Renderer(size);
    127123#else
    128124    /* Initialise OpenGL */
    129     g_renderer = new Renderer();
    130 
    131     glViewport(0, 0, size.x, size.y);
    132     VideoData::saved_viewport = size;
     125    g_renderer = new Renderer(size);
    133126#endif
    134127
    135128    /* Initialise reasonable scene default properties */
    136129    SetDebugRenderMode(DebugRenderMode::Default);
    137 }
    138 
    139 void Video::SetCustomSize(ivec2 size)
    140 {
    141     ivec4 current_size(0);
    142 #if defined USE_D3D9 || defined _XBOX
    143 #   define STR0(x) #x
    144 #   define STR(x) STR0(x)
    145 #   pragma message(__FILE__ "(" STR(__LINE__) "): warning: Video::SetSize() not implemented")
    146 #elif defined __CELLOS_LV2__
    147     // FIXME: use psglCreateDeviceAuto && psglGetDeviceDimensions
    148 #else
    149     glGetIntegerv(GL_VIEWPORT, (GLint*)&current_size);
    150     if (current_size.zw != size)
    151         glViewport(0, 0, size.x, size.y);
    152 #endif
    153 }
    154 
    155 void Video::RestoreSize()
    156 {
    157     ivec4 current_size(0);
    158 #if defined USE_D3D9 || defined _XBOX
    159 #   define STR0(x) #x
    160 #   define STR(x) STR0(x)
    161 #   pragma message(__FILE__ "(" STR(__LINE__) "): warning: Video::SetSize() not implemented")
    162 #elif defined __CELLOS_LV2__
    163     // FIXME: use psglCreateDeviceAuto && psglGetDeviceDimensions
    164 #else
    165     glGetIntegerv(GL_VIEWPORT, (GLint*)&current_size);
    166     if (current_size.zw != VideoData::saved_viewport)
    167         glViewport(0, 0, VideoData::saved_viewport.x, VideoData::saved_viewport.y);
    168 #endif
    169130}
    170131
     
    244205        Abort();
    245206#else
    246     /* FIXME: is this necessary here? */
    247     ivec2 size = GetSize();
    248     glViewport(0, 0, size.x, size.y);
    249 
    250207    GLbitfield mask = 0;
    251208    if (m & ClearMask::Color)
     
    303260ivec2 Video::GetSize()
    304261{
    305 #if defined USE_D3D9 || defined _XBOX
    306     return VideoData::saved_viewport;
    307 #elif 1
    308     /* GetSize() is called too often on the game thread; we cannot rely on
    309      * the GL context at this point */
    310     return VideoData::saved_viewport;
    311 #elif defined __CELLOS_LV2__
    312     // FIXME: use psglCreateDeviceAuto && psglGetDeviceDimensions
    313 #else
    314     GLint v[4];
    315     glGetIntegerv(GL_VIEWPORT, v);
    316     return ivec2(v[2], v[3]);
    317 #endif
     262    ibox2 viewport = g_renderer->GetViewport();
     263
     264    return viewport.B - viewport.A;
    318265}
    319266
Note: See TracChangeset for help on using the changeset viewer.