added NO_OGL switch

simplified fall back when initializing render API failed

git-svn-id: https://svn.code.sf.net/p/vbam/code/trunk@225 a31d4220-a93d-0410-bf67-fe4944624d44
This commit is contained in:
spacy51 2007-12-23 21:09:29 +00:00
parent 3821d13005
commit 4382e41696
3 changed files with 84 additions and 39 deletions

View File

@ -465,20 +465,28 @@ void MainWnd::OnOptionsVideoRendermethodDirect3d()
void MainWnd::OnUpdateOptionsVideoRendermethodDirect3d(CCmdUI* pCmdUI) void MainWnd::OnUpdateOptionsVideoRendermethodDirect3d(CCmdUI* pCmdUI)
{ {
#ifndef NO_D3D #ifndef NO_D3D
pCmdUI->SetCheck(theApp.renderMethod == DIRECT_3D); pCmdUI->SetCheck(theApp.renderMethod == DIRECT_3D);
#else
pCmdUI->Enable( FALSE );
#endif #endif
} }
void MainWnd::OnOptionsVideoRendermethodOpengl() void MainWnd::OnOptionsVideoRendermethodOpengl()
{ {
#ifndef NO_OGL
theApp.renderMethod = OPENGL; theApp.renderMethod = OPENGL;
theApp.updateRenderMethod(false); theApp.updateRenderMethod(false);
theApp.winAccelMgr.UpdateMenu(theApp.menu); theApp.winAccelMgr.UpdateMenu(theApp.menu);
#endif
} }
void MainWnd::OnUpdateOptionsVideoRendermethodOpengl(CCmdUI* pCmdUI) void MainWnd::OnUpdateOptionsVideoRendermethodOpengl(CCmdUI* pCmdUI)
{ {
pCmdUI->SetCheck(theApp.renderMethod == OPENGL); #ifndef NO_OGL
pCmdUI->SetCheck(theApp.renderMethod == OPENGL);
#else
pCmdUI->Enable( FALSE );
#endif
} }
@ -556,86 +564,122 @@ void MainWnd::OnUpdateOptionsVideoRenderoptionsD3dbilinear(CCmdUI* pCmdUI)
void MainWnd::OnOptionsVideoRenderoptionsGlnearest() void MainWnd::OnOptionsVideoRenderoptionsGlnearest()
{ {
#ifndef NO_OGL
theApp.glFilter = 0; theApp.glFilter = 0;
if( theApp.display ) { if( theApp.display ) {
theApp.display->setOption( _T("glFilter"), theApp.glFilter ); theApp.display->setOption( _T("glFilter"), theApp.glFilter );
} }
#endif
} }
void MainWnd::OnUpdateOptionsVideoRenderoptionsGlnearest(CCmdUI* pCmdUI) void MainWnd::OnUpdateOptionsVideoRenderoptionsGlnearest(CCmdUI* pCmdUI)
{ {
pCmdUI->SetCheck(theApp.glFilter == 0); #ifndef NO_OGL
pCmdUI->SetCheck(theApp.glFilter == 0);
#else
pCmdUI->Enable( FALSE );
#endif
} }
void MainWnd::OnOptionsVideoRenderoptionsGlbilinear() void MainWnd::OnOptionsVideoRenderoptionsGlbilinear()
{ {
#ifndef NO_OGL
theApp.glFilter = 1; theApp.glFilter = 1;
if( theApp.display ) { if( theApp.display ) {
theApp.display->setOption( _T("glFilter"), theApp.glFilter ); theApp.display->setOption( _T("glFilter"), theApp.glFilter );
} }
#endif
} }
void MainWnd::OnUpdateOptionsVideoRenderoptionsGlbilinear(CCmdUI* pCmdUI) void MainWnd::OnUpdateOptionsVideoRenderoptionsGlbilinear(CCmdUI* pCmdUI)
{ {
pCmdUI->SetCheck(theApp.glFilter == 1); #ifndef NO_OGL
pCmdUI->SetCheck(theApp.glFilter == 1);
#else
pCmdUI->Enable( FALSE );
#endif
} }
void MainWnd::OnOptionsVideoRenderoptionsGltriangle() void MainWnd::OnOptionsVideoRenderoptionsGltriangle()
{ {
#ifndef NO_OGL
theApp.glType = 0; theApp.glType = 0;
if( theApp.display ) { if( theApp.display ) {
theApp.display->setOption( _T("glType"), theApp.glType ); theApp.display->setOption( _T("glType"), theApp.glType );
} }
#endif
} }
void MainWnd::OnUpdateOptionsVideoRenderoptionsGltriangle(CCmdUI* pCmdUI) void MainWnd::OnUpdateOptionsVideoRenderoptionsGltriangle(CCmdUI* pCmdUI)
{ {
pCmdUI->SetCheck(theApp.glType == 0); #ifndef NO_OGL
pCmdUI->SetCheck(theApp.glType == 0);
#else
pCmdUI->Enable( FALSE );
#endif
} }
void MainWnd::OnOptionsVideoRenderoptionsGlquads() void MainWnd::OnOptionsVideoRenderoptionsGlquads()
{ {
#ifndef NO_OGL
theApp.glType = 1; theApp.glType = 1;
if( theApp.display ) { if( theApp.display ) {
theApp.display->setOption( _T("glType"), theApp.glType ); theApp.display->setOption( _T("glType"), theApp.glType );
} }
#endif
} }
void MainWnd::OnUpdateOptionsVideoRenderoptionsGlquads(CCmdUI* pCmdUI) void MainWnd::OnUpdateOptionsVideoRenderoptionsGlquads(CCmdUI* pCmdUI)
{ {
pCmdUI->SetCheck(theApp.glType == 1); #ifndef NO_OGL
pCmdUI->SetCheck(theApp.glType == 1);
#else
pCmdUI->Enable( FALSE );
#endif
} }
void MainWnd::OnOptionsVideoRenderoptionsGlpolygons() void MainWnd::OnOptionsVideoRenderoptionsGlpolygons()
{ {
#ifndef NO_OGL
theApp.glType = 2; theApp.glType = 2;
if( theApp.display ) { if( theApp.display ) {
theApp.display->setOption( _T("glType"), theApp.glType ); theApp.display->setOption( _T("glType"), theApp.glType );
} }
#endif
} }
void MainWnd::OnUpdateOptionsVideoRenderoptionsGlpolygons(CCmdUI* pCmdUI) void MainWnd::OnUpdateOptionsVideoRenderoptionsGlpolygons(CCmdUI* pCmdUI)
{ {
pCmdUI->SetCheck(theApp.glType == 2); #ifndef NO_OGL
pCmdUI->SetCheck(theApp.glType == 2);
#else
pCmdUI->Enable( FALSE );
#endif
} }
void MainWnd::OnUpdateOptionsVideoRenderingoptionsGLSLShaders(CCmdUI* pCmdUI) void MainWnd::OnUpdateOptionsVideoRenderingoptionsGLSLShaders(CCmdUI* pCmdUI)
{ {
pCmdUI->SetCheck(theApp.GLSLShaders); #ifndef NO_OGL
pCmdUI->SetCheck(theApp.GLSLShaders);
#else
pCmdUI->Enable( FALSE );
#endif
} }
void MainWnd::OnOptionsVideoRenderingoptionsGLSLShaders() void MainWnd::OnOptionsVideoRenderingoptionsGLSLShaders()
{ {
#ifndef NO_OGL
theApp.GLSLShaders = !theApp.GLSLShaders; theApp.GLSLShaders = !theApp.GLSLShaders;
if( theApp.GLSLShaders ) { if( theApp.GLSLShaders ) {
theApp.display->setOption( _T("GLSLShaders"), theApp.GLSLShaders ); theApp.display->setOption( _T("GLSLShaders"), theApp.GLSLShaders );
} }
#endif
} }
void MainWnd::OnOptionsEmulatorAssociate() void MainWnd::OnOptionsEmulatorAssociate()
@ -2000,6 +2044,8 @@ void MainWnd::OnUpdateOutputapiOpenal(CCmdUI *pCmdUI)
#ifndef NO_OAL #ifndef NO_OAL
pCmdUI->SetCheck( ( theApp.audioAPI == OPENAL_SOUND ) ? 1 : 0 ); pCmdUI->SetCheck( ( theApp.audioAPI == OPENAL_SOUND ) ? 1 : 0 );
pCmdUI->Enable(!theApp.aviRecording && !theApp.soundRecording); pCmdUI->Enable(!theApp.aviRecording && !theApp.soundRecording);
#else
pCmdUI->Enable( FALSE );
#endif #endif
} }
@ -2034,5 +2080,7 @@ void MainWnd::OnUpdateOutputapiOalconfiguration(CCmdUI *pCmdUI)
{ {
#ifndef NO_OAL #ifndef NO_OAL
pCmdUI->Enable(!theApp.aviRecording && !theApp.soundRecording); pCmdUI->Enable(!theApp.aviRecording && !theApp.soundRecording);
#else
pCmdUI->Enable( FALSE );
#endif #endif
} }

View File

@ -17,6 +17,8 @@
// along with this program; if not, write to the Free Software Foundation, // along with this program; if not, write to the Free Software Foundation,
// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef NO_OGL
#include "stdafx.h" #include "stdafx.h"
#include "MainWnd.h" #include "MainWnd.h"
@ -684,3 +686,5 @@ IDisplay *newOpenGLDisplay()
{ {
return new OpenGLDisplay(); return new OpenGLDisplay();
} }
#endif // #ifndef NO_OGL

View File

@ -101,7 +101,9 @@ extern void toolsLog(const char *);
extern IDisplay *newGDIDisplay(); extern IDisplay *newGDIDisplay();
extern IDisplay *newDirectDrawDisplay(); extern IDisplay *newDirectDrawDisplay();
#ifndef NO_OGL
extern IDisplay *newOpenGLDisplay(); extern IDisplay *newOpenGLDisplay();
#endif
#ifndef NO_D3D #ifndef NO_D3D
extern IDisplay *newDirect3DDisplay(); extern IDisplay *newDirect3DDisplay();
#endif #endif
@ -1445,7 +1447,10 @@ void VBA::loadSettings()
} }
renderMethod = (DISPLAY_TYPE)regQueryDwordValue("renderMethod", DIRECT_DRAW); renderMethod = (DISPLAY_TYPE)regQueryDwordValue("renderMethod", DIRECT_DRAW);
if( ( renderMethod != DIRECT_DRAW ) && ( renderMethod != OPENGL ) if( ( renderMethod != DIRECT_DRAW )
#ifndef NO_OGL
&& ( renderMethod != OPENGL )
#endif
#ifndef NO_D3D #ifndef NO_D3D
&& ( renderMethod != DIRECT_3D ) && ( renderMethod != DIRECT_3D )
#endif #endif
@ -2121,34 +2126,19 @@ bool VBA::preInitialize()
bool VBA::updateRenderMethod(bool force) bool VBA::updateRenderMethod(bool force)
{ {
Sm60FPS_Init(); bool ret = true;
bool res = updateRenderMethod0(force);
while(!res && renderMethod > 0) { Sm60FPS_Init();
if( fsAdapter > 0 ) {
fsAdapter = 0; if( !updateRenderMethod0( force ) ) {
} else { // fall back to safe configuration
if( videoOption > VIDEO_4X ) { renderMethod = DIRECT_DRAW;
videoOption = VIDEO_1X; fsAdapter = 0;
force = true; videoOption = VIDEO_1X;
} else { ret = updateRenderMethod( true );
if(renderMethod == OPENGL) {
#ifndef NO_D3D
renderMethod = DIRECT_3D;
} else {
if(renderMethod == DIRECT_3D) {
#endif
renderMethod = DIRECT_DRAW;
}
}
}
#ifndef NO_D3D
}
#endif
res = updateRenderMethod(force);
} }
return res; return ret;
} }
@ -2183,19 +2173,22 @@ bool VBA::updateRenderMethod0(bool force)
} }
if(display == NULL) { if(display == NULL) {
switch(renderMethod) { switch(renderMethod) {
case DIRECT_DRAW: #ifndef NO_OGL
pVideoDriverGUID = NULL;
ZeroMemory( &videoDriverGUID, sizeof( GUID ) );
display = newDirectDrawDisplay();
break;
case OPENGL: case OPENGL:
display = newOpenGLDisplay(); display = newOpenGLDisplay();
break; break;
#endif
#ifndef NO_D3D #ifndef NO_D3D
case DIRECT_3D: case DIRECT_3D:
display = newDirect3DDisplay(); display = newDirect3DDisplay();
break; break;
#endif #endif
case DIRECT_DRAW:
default:
pVideoDriverGUID = NULL;
ZeroMemory( &videoDriverGUID, sizeof( GUID ) );
display = newDirectDrawDisplay();
break;
} }
if( preInitialize() ) { if( preInitialize() ) {