From 1266d1d5a48f55994709180feaf0b7e9cdb5966d Mon Sep 17 00:00:00 2001 From: kervala Date: Thu, 24 Feb 2011 18:42:09 +0100 Subject: [PATCH] Fixed: #1251 NeL can't find selected drivers in CMake --- code/nel/src/3d/driver_user.cpp | 14 ++++++++++---- code/nel/src/3d/dru.cpp | 15 +++++++++++++-- code/nel/src/3d/nelu.cpp | 21 ++++++++++++++++++--- 3 files changed, 41 insertions(+), 9 deletions(-) diff --git a/code/nel/src/3d/driver_user.cpp b/code/nel/src/3d/driver_user.cpp index 6d2bdcb53..5f1b48a1f 100644 --- a/code/nel/src/3d/driver_user.cpp +++ b/code/nel/src/3d/driver_user.cpp @@ -36,6 +36,9 @@ #include "nel/misc/hierarchical_timer.h" #include "nel/misc/event_emitter.h" +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif // HAVE_CONFIG_H using namespace NLMISC; @@ -131,14 +134,17 @@ CDriverUser::CDriverUser (uint windowIcon, bool direct3d, emptyProc exitFunc) CScene::registerBasics(); } + _Driver = NULL; + // Create/Init Driver. -#ifdef NL_OS_WINDOWS +#if defined(NL_OS_WINDOWS) && defined(NL_DIRECT3D_AVAILABLE) if (direct3d) _Driver= CDRU::createD3DDriver(); - else +#endif + +#ifdef NL_OPENGL_AVAILABLE + if (!_Driver) _Driver= CDRU::createGlDriver(); -#else - _Driver= CDRU::createGlDriver(); #endif nlassert(_Driver); diff --git a/code/nel/src/3d/dru.cpp b/code/nel/src/3d/dru.cpp index 290a51124..6b8f8f6a2 100644 --- a/code/nel/src/3d/dru.cpp +++ b/code/nel/src/3d/dru.cpp @@ -50,9 +50,12 @@ typedef uint32 (*IDRV_VERSION_PROC)(void); const char *IDRV_VERSION_PROC_NAME = "NL3D_interfaceVersion"; #ifdef NL_STATIC -extern IDriver* createGlDriverInstance (); -#ifdef NL_OS_WINDOWS +#ifdef NL_OPENGL_AVAILABLE +extern IDriver* createGlDriverInstance (); +#endif + +#if defined(NL_OS_WINDOWS) && defined(NL_DIRECT3D_AVAILABLE) extern IDriver* createD3DDriverInstance (); #endif @@ -63,7 +66,11 @@ IDriver *CDRU::createGlDriver() throw (EDru) { #ifdef NL_STATIC +#ifdef NL_OPENGL_AVAILABLE return createGlDriverInstance (); +#else + return NULL; +#endif // NL_OPENGL_AVAILABLE #else @@ -158,7 +165,11 @@ IDriver *CDRU::createD3DDriver() throw (EDru) { #ifdef NL_STATIC +#ifdef NL_DIRECT3D_AVAILABLE return createD3DDriverInstance (); +#else + return NULL; +#endif // NL_DIRECT3D_AVAILABLE #else diff --git a/code/nel/src/3d/nelu.cpp b/code/nel/src/3d/nelu.cpp index 535e80b70..73ff049ed 100644 --- a/code/nel/src/3d/nelu.cpp +++ b/code/nel/src/3d/nelu.cpp @@ -26,6 +26,11 @@ #include "nel/3d/init_3d.h" #include "nel/3d/vertex_stream_manager.h" #include "nel/misc/debug.h" + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif // HAVE_CONFIG_H + using namespace std; using namespace NLMISC; @@ -54,18 +59,28 @@ bool CNELU::initDriver (uint w, uint h, uint bpp, bool windowed, nlWindow syst ShapeBank = new CShapeBank; + CNELU::Driver = NULL; + // Init driver. -#ifdef NL_OS_WINDOWS +#if defined(NL_OS_WINDOWS) && defined(NL_DIRECT3D_AVAILABLE) if (direct3d) { CNELU::Driver= CDRU::createD3DDriver(); } - else -#endif // NL_OS_WINDOWS +#endif + +#ifdef NL_OPENGL_AVAILABLE + if (!CNELU::Driver) { CNELU::Driver= CDRU::createGlDriver(); } +#endif + if (!CNELU::Driver) + { + nlwarning ("CNELU::initDriver: no driver found"); + return false; + } if (!CNELU::Driver->init()) { nlwarning ("CNELU::initDriver: init() failed");