1
0
mirror of https://github.com/blawar/GLideN64.git synced 2024-07-07 03:13:49 +00:00

Fix MupenPlus port: Use MupenPlus style Video initialization.

This commit is contained in:
Sergey Lipskiy 2014-05-22 17:50:05 +07:00
parent aba7a97594
commit d29c149515
2 changed files with 83 additions and 5 deletions

View File

@ -133,6 +133,19 @@ EXPORT void CALL ReadScreen (void **dest, long *width, long *height)
ptr_ConfigGetSharedDataFilepath ConfigGetSharedDataFilepath = NULL;
ptr_ConfigGetUserConfigPath ConfigGetUserConfigPath = NULL;
/* definitions of pointers to Core video extension functions */
ptr_VidExt_Init CoreVideo_Init = NULL;
ptr_VidExt_Quit CoreVideo_Quit = NULL;
ptr_VidExt_ListFullscreenModes CoreVideo_ListFullscreenModes = NULL;
ptr_VidExt_SetVideoMode CoreVideo_SetVideoMode = NULL;
ptr_VidExt_SetCaption CoreVideo_SetCaption = NULL;
ptr_VidExt_ToggleFullScreen CoreVideo_ToggleFullScreen = NULL;
ptr_VidExt_ResizeWindow CoreVideo_ResizeWindow = NULL;
ptr_VidExt_GL_GetProcAddress CoreVideo_GL_GetProcAddress = NULL;
ptr_VidExt_GL_SetAttribute CoreVideo_GL_SetAttribute = NULL;
ptr_VidExt_GL_GetAttribute CoreVideo_GL_GetAttribute = NULL;
ptr_VidExt_GL_SwapBuffers CoreVideo_GL_SwapBuffers = NULL;
void (*CheckInterrupts)( void );
void (*renderCallback)() = NULL;
@ -142,6 +155,20 @@ EXPORT m64p_error CALL PluginStartup(m64p_dynlib_handle CoreLibHandle, void *Con
{
ConfigGetSharedDataFilepath = (ptr_ConfigGetSharedDataFilepath) DLSYM(CoreLibHandle, "ConfigGetSharedDataFilepath");
ConfigGetUserConfigPath = (ptr_ConfigGetUserConfigPath) DLSYM(CoreLibHandle, "ConfigGetUserConfigPath");
/* Get the core Video Extension function pointers from the library handle */
CoreVideo_Init = (ptr_VidExt_Init) DLSYM(CoreLibHandle, "VidExt_Init");
CoreVideo_Quit = (ptr_VidExt_Quit) DLSYM(CoreLibHandle, "VidExt_Quit");
CoreVideo_ListFullscreenModes = (ptr_VidExt_ListFullscreenModes) DLSYM(CoreLibHandle, "VidExt_ListFullscreenModes");
CoreVideo_SetVideoMode = (ptr_VidExt_SetVideoMode) DLSYM(CoreLibHandle, "VidExt_SetVideoMode");
CoreVideo_SetCaption = (ptr_VidExt_SetCaption) DLSYM(CoreLibHandle, "VidExt_SetCaption");
CoreVideo_ToggleFullScreen = (ptr_VidExt_ToggleFullScreen) DLSYM(CoreLibHandle, "VidExt_ToggleFullScreen");
CoreVideo_ResizeWindow = (ptr_VidExt_ResizeWindow) DLSYM(CoreLibHandle, "VidExt_ResizeWindow");
CoreVideo_GL_GetProcAddress = (ptr_VidExt_GL_GetProcAddress) DLSYM(CoreLibHandle, "VidExt_GL_GetProcAddress");
CoreVideo_GL_SetAttribute = (ptr_VidExt_GL_SetAttribute) DLSYM(CoreLibHandle, "VidExt_GL_SetAttribute");
CoreVideo_GL_GetAttribute = (ptr_VidExt_GL_GetAttribute) DLSYM(CoreLibHandle, "VidExt_GL_GetAttribute");
CoreVideo_GL_SwapBuffers = (ptr_VidExt_GL_SwapBuffers) DLSYM(CoreLibHandle, "VidExt_GL_SwapBuffers");
return M64ERR_SUCCESS;
}

View File

@ -238,7 +238,7 @@ void OGL_UpdateScale()
void OGL_ResizeWindow()
{
#ifdef _WINDOWS
#if defined(_WINDOWS) && !defined(MUPENPLUSAPI)
RECT windowRect, statusRect, toolRect;
if (OGL.fullscreen)
@ -348,6 +348,7 @@ bool OGL_SDL_Start()
bool OGL_Start()
{
#ifndef MUPENPLUSAPI
#ifdef _WINDOWS
int pixelFormat;
@ -372,6 +373,9 @@ bool OGL_Start()
0, 0, 0 // layer masks ignored
};
if ((HWND)hWnd == NULL)
hWnd = GetActiveWindow();
if ((OGL.hDC = GetDC( hWnd )) == NULL)
{
MessageBox( hWnd, "Error while getting a device context!", pluginName, MB_ICONERROR | MB_OK );
@ -421,7 +425,6 @@ bool OGL_Start()
OGL.height = config.video.windowedHeight;
}
#ifndef GLES2
/* Initialize SDL */
printf( "[glN64]: (II) Initializing SDL video subsystem...\n" );
if (SDL_InitSubSystem( SDL_INIT_VIDEO ) == -1)
@ -466,11 +469,44 @@ bool OGL_Start()
}
SDL_WM_SetCaption( pluginName, pluginName );
#endif // USE_SDL
#else // MUPENPLUSAPI
if (OGL.fullscreen){
OGL.width = config.video.fullscreenWidth;
OGL.height = config.video.fullscreenHeight;
} else {
OGL.width = config.video.windowedWidth;
OGL.height = config.video.windowedHeight;
}
#ifndef GLES2
CoreVideo_Init();
CoreVideo_GL_SetAttribute(M64P_GL_DOUBLEBUFFER, 1);
CoreVideo_GL_SetAttribute(M64P_GL_SWAP_CONTROL, 1);
CoreVideo_GL_SetAttribute(M64P_GL_BUFFER_SIZE, 16);
CoreVideo_GL_SetAttribute(M64P_GL_DEPTH_SIZE, 16);
printf("(II) Setting video mode %dx%d...\n", OGL.width, OGL.height);
if (CoreVideo_SetVideoMode(OGL.width, OGL.height, 0, OGL.fullscreen ? M64VIDEO_FULLSCREEN : M64VIDEO_WINDOWED, (m64p_video_flags) 0) != M64ERR_SUCCESS) {
printf("(EE) Error setting videomode %dx%d\n", OGL.width, OGL.height);
CoreVideo_Quit();
return false;
}
char caption[500];
# ifdef _DEBUG
sprintf(caption, "GLideN64 debug");
# else // _DEBUG
sprintf(caption, "GLideN64");
# endif // _DEBUG
CoreVideo_SetCaption(caption);
#else // GLES2
if (!OGL_SDL_Start())
return false;
#endif // GLES2
#endif // USE_SDL
#endif // MUPENPLUSAPI
OGL_InitExtensions();
OGL_InitStates();
@ -503,6 +539,7 @@ void OGL_Stop()
TextureCache_Destroy();
OGL.renderState = GLInfo::rsNone;
#ifndef MUPENPLUSAPI
#ifdef _WINDOWS
wglMakeCurrent( NULL, NULL );
@ -521,6 +558,16 @@ void OGL_Stop()
SDL_QuitSubSystem( SDL_INIT_VIDEO );
OGL.hScreen = NULL;
#endif // _WINDOWS
#else // MUPENPLUSAPI
#ifndef GLES2
CoreVideo_Quit();
#else
#if defined(USE_SDL)
SDL_QuitSubSystem( SDL_INIT_VIDEO );
OGL.hScreen = NULL;
#endif
#endif // GLES2
#endif // MUPENPLUSAPI
}
void OGL_UpdateCullFace()
@ -1267,6 +1314,7 @@ void OGL_ReadScreen( void **dest, long *width, long *height )
void OGL_SwapBuffers()
{
#ifndef MUPENPLUSAPI
#ifdef _WINDOWS
if (OGL.hDC == NULL)
SwapBuffers( wglGetCurrentDC() );
@ -1274,7 +1322,6 @@ void OGL_SwapBuffers()
SwapBuffers( OGL.hDC );
#endif // _WINDOWS
#if defined(USE_SDL)
#ifndef GLES2
static int frames[5] = { 0, 0, 0, 0, 0 };
static int framesIndex = 0;
static Uint32 lastTicks = 0;
@ -1295,10 +1342,14 @@ void OGL_SwapBuffers()
lastTicks = ticks;
}
SDL_GL_SwapBuffers();
#endif // USE_SDL
#else // MUPENPLUSAPI
#ifndef GLES2
CoreVideo_GL_SwapBuffers();
#else
Android_JNI_SwapWindow(); // paulscode, fix for black-screen bug
#endif // GLES2
#endif // USE_SDL
#endif // MUPENPLUSAPI
}
bool checkFBO() {