~ubuntu-branches/ubuntu/trusty/mupen64plus-video-rice/trusty

« back to all changes in this revision

Viewing changes to src/Video.cpp

  • Committer: Package Import Robot
  • Author(s): Sven Eckelmann
  • Date: 2013-07-05 22:53:25 UTC
  • mfrom: (1.2.2) (3.1.9 experimental)
  • Revision ID: package-import@ubuntu.com-20130705225325-k0fbb2m44xnrju66
Tags: 2.0-1
* New Upstream Version
* Upload to unstable
* debian/control:
  - Build-Depend on debhelper 9.20130604 for support of parameters when
    detecting targets in dh_auto_*
* debian/rules:
  - Work around new debhelper 9.20130624 dh_auto_{clean,test} behavior
    which is causing a FTBFS by adding an explicit
    override_dh_auto_{clean,test} rule
* debian/watch:
  - Verify new upstream versions using GPG key 954F81B094AA5BB226F5

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
 
23
23
#include <stdarg.h>
24
24
 
25
 
#include <SDL_opengl.h>
 
25
#include "osal_opengl.h"
26
26
 
27
27
#define M64P_PLUGIN_PROTOTYPES 1
28
28
#include "m64p_types.h"
95
95
ptr_VidExt_SetVideoMode          CoreVideo_SetVideoMode = NULL;
96
96
ptr_VidExt_SetCaption            CoreVideo_SetCaption = NULL;
97
97
ptr_VidExt_ToggleFullScreen      CoreVideo_ToggleFullScreen = NULL;
 
98
ptr_VidExt_ResizeWindow          CoreVideo_ResizeWindow = NULL;
98
99
ptr_VidExt_GL_GetProcAddress     CoreVideo_GL_GetProcAddress = NULL;
99
100
ptr_VidExt_GL_SetAttribute       CoreVideo_GL_SetAttribute = NULL;
100
101
ptr_VidExt_GL_GetAttribute       CoreVideo_GL_GetAttribute = NULL;
125
126
    status.ToToggleFullScreen = FALSE;
126
127
}
127
128
 
 
129
static void ResizeStep2(void)
 
130
{
 
131
    g_CritialSection.Lock();
 
132
 
 
133
    // Delete all OpenGL textures
 
134
    gTextureManager.CleanUp();
 
135
    RDP_Cleanup();
 
136
    // delete our opengl renderer
 
137
    CDeviceBuilder::GetBuilder()->DeleteRender();
 
138
 
 
139
    // call video extension function with updated width, height (this creates a new OpenGL context)
 
140
    windowSetting.uDisplayWidth = status.gNewResizeWidth;
 
141
    windowSetting.uDisplayHeight = status.gNewResizeHeight;
 
142
    CoreVideo_ResizeWindow(windowSetting.uDisplayWidth, windowSetting.uDisplayHeight);
 
143
 
 
144
    // re-initialize our OpenGL graphics context state
 
145
    bool res = CGraphicsContext::Get()->ResizeInitialize(windowSetting.uDisplayWidth, windowSetting.uDisplayHeight, !windowSetting.bDisplayFullscreen);
 
146
    if (res)
 
147
    {
 
148
        // re-create the OpenGL renderer
 
149
        CDeviceBuilder::GetBuilder()->CreateRender();
 
150
        CRender::GetRender()->Initialize();
 
151
        DLParser_Init();
 
152
    }
 
153
 
 
154
    g_CritialSection.Unlock();
 
155
    status.ToResize = false;
 
156
}
 
157
 
128
158
static void UpdateScreenStep2 (void)
129
159
{
130
160
    status.bVIOriginIsUpdated = false;
134
164
        ChangeWindowStep2();
135
165
        return;
136
166
    }
 
167
    if (status.ToResize && status.gDlistCount > 0)
 
168
    {
 
169
        ResizeStep2();
 
170
        return;
 
171
    }
137
172
 
138
173
    g_CritialSection.Lock();
139
174
    if( status.bHandleN64RenderTexture )
597
632
    CoreVideo_SetVideoMode = (ptr_VidExt_SetVideoMode) osal_dynlib_getproc(CoreLibHandle, "VidExt_SetVideoMode");
598
633
    CoreVideo_SetCaption = (ptr_VidExt_SetCaption) osal_dynlib_getproc(CoreLibHandle, "VidExt_SetCaption");
599
634
    CoreVideo_ToggleFullScreen = (ptr_VidExt_ToggleFullScreen) osal_dynlib_getproc(CoreLibHandle, "VidExt_ToggleFullScreen");
 
635
    CoreVideo_ResizeWindow = (ptr_VidExt_ResizeWindow) osal_dynlib_getproc(CoreLibHandle, "VidExt_ResizeWindow");
600
636
    CoreVideo_GL_GetProcAddress = (ptr_VidExt_GL_GetProcAddress) osal_dynlib_getproc(CoreLibHandle, "VidExt_GL_GetProcAddress");
601
637
    CoreVideo_GL_SetAttribute = (ptr_VidExt_GL_SetAttribute) osal_dynlib_getproc(CoreLibHandle, "VidExt_GL_SetAttribute");
602
638
    CoreVideo_GL_GetAttribute = (ptr_VidExt_GL_GetAttribute) osal_dynlib_getproc(CoreLibHandle, "VidExt_GL_GetAttribute");
603
639
    CoreVideo_GL_SwapBuffers = (ptr_VidExt_GL_SwapBuffers) osal_dynlib_getproc(CoreLibHandle, "VidExt_GL_SwapBuffers");
604
640
 
605
641
    if (!CoreVideo_Init || !CoreVideo_Quit || !CoreVideo_ListFullscreenModes || !CoreVideo_SetVideoMode ||
606
 
        !CoreVideo_SetCaption || !CoreVideo_ToggleFullScreen || !CoreVideo_GL_GetProcAddress ||
 
642
        !CoreVideo_ResizeWindow || !CoreVideo_SetCaption || !CoreVideo_ToggleFullScreen || !CoreVideo_GL_GetProcAddress ||
607
643
        !CoreVideo_GL_SetAttribute || !CoreVideo_GL_GetAttribute || !CoreVideo_GL_SwapBuffers)
608
644
    {
609
645
        DebugMessage(M64MSG_ERROR, "Couldn't connect to Core video extension functions");
771
807
    windowSetting.fViWidth = 320;
772
808
    windowSetting.fViHeight = 240;
773
809
    status.ToToggleFullScreen = FALSE;
 
810
    status.ToResize = false;
774
811
    status.bDisableFPS=false;
775
812
 
776
813
    if (!InitConfiguration())
785
822
    return(TRUE);
786
823
}
787
824
 
 
825
EXPORT void CALL ResizeVideoOutput(int width, int height)
 
826
{
 
827
    // save the new window resolution.  actual resizing operation is asynchronous (it happens later)
 
828
    status.gNewResizeWidth = width;
 
829
    status.gNewResizeHeight = height;
 
830
    status.ToResize = true;
 
831
}
 
832
 
788
833
//---------------------------------------------------------------------------------------
789
834
 
790
835
EXPORT void CALL ProcessRDPList(void)
924
969
 
925
970
    *width = windowSetting.uDisplayWidth;
926
971
    *height = windowSetting.uDisplayHeight;
927
 
   
 
972
 
928
973
    if (dest == NULL)
929
974
        return;
930
 
   
 
975
 
 
976
#if SDL_VIDEO_OPENGL
931
977
    GLint oldMode;
932
978
    glGetIntegerv( GL_READ_BUFFER, &oldMode );
933
979
    if (bFront)
937
983
    glReadPixels( 0, 0, windowSetting.uDisplayWidth, windowSetting.uDisplayHeight,
938
984
                 GL_RGB, GL_UNSIGNED_BYTE, dest );
939
985
    glReadBuffer( oldMode );
 
986
#endif
940
987
}
941
988
    
942
989