GL3 driver can now be instantiated.

--HG--
branch : gsoc2013-dfighter
hg/feature/gsoc2013-dfighter
dfighter1985 11 years ago
parent 7f0ae42a40
commit 8f45e49fa0

@ -27,10 +27,12 @@
#ifdef NL_OS_WINDOWS
# define NL3D_GL_DLL_NAME "nel_drv_opengl_win"
# define NL3D_GL3_DLL_NAME "nel_drv_opengl3_win"
# define NL3D_GLES_DLL_NAME "nel_drv_opengles_win"
# define NL3D_D3D_DLL_NAME "nel_drv_direct3d_win"
#elif defined (NL_OS_UNIX)
# define NL3D_GL_DLL_NAME "nel_drv_opengl"
# define NL3D_GL3_DLL_NAME "nel_drv_opengl3"
# define NL3D_GLES_DLL_NAME "nel_drv_opengles"
#else
# error "Unknown system"
@ -71,6 +73,32 @@ struct EDruOpenglDriverCantCreateDriver : public EDru
EDruOpenglDriverCantCreateDriver() : EDru( NL3D_GL_DLL_NAME " can't create driver" ) {}
};
// OpenGL 3
struct EDruOpengl3DriverNotFound : public EDru
{
EDruOpengl3DriverNotFound() : EDru( NL3D_GL3_DLL_NAME " not found" ) {}
};
struct EDruOpengl3DriverCorrupted : public EDru
{
EDruOpengl3DriverCorrupted() : EDru( "Can't get NL3D_createIDriverInstance from " NL3D_GL3_DLL_NAME " (Bad dll?)" ) {}
};
struct EDruOpengl3DriverOldVersion : public EDru
{
EDruOpengl3DriverOldVersion() : EDru( NL3D_GL3_DLL_NAME " is a too old version. Ask for a more recent file" ) {}
};
struct EDruOpengl3DriverUnknownVersion : public EDru
{
EDruOpengl3DriverUnknownVersion() : EDru( NL3D_GL3_DLL_NAME " is more recent than the application" ) {}
};
struct EDruOpengl3DriverCantCreateDriver : public EDru
{
EDruOpengl3DriverCantCreateDriver() : EDru( NL3D_GL3_DLL_NAME " can't create driver" ) {}
};
// OpenGL ES
struct EDruOpenglEsDriverNotFound : public EDru
{
@ -133,6 +161,9 @@ public:
/// Portable Function which create a GL Driver (using gl dll...).
static IDriver *createGlDriver() throw(EDru);
/// Portable Function which create a GL3 Driver (using gl dll...).
static IDriver *createGl3Driver() throw(EDru);
/// Portable Function which create a GL ES Driver (using gl dll...).
static IDriver *createGlEsDriver() throw(EDru);

@ -140,7 +140,7 @@ public:
enum TStencilFunc { never = 0, less, lessequal, equal, notequal, greaterequal, greater, always};
// Existing drivers
enum TDriver { Direct3d = 0, OpenGl, OpenGlEs };
enum TDriver { Direct3d = 0, OpenGl, OpenGlEs, OpenGl3 };
public:
/// The EventServer of this driver. Init after setDisplay()!!

@ -77,7 +77,7 @@ namespace NL3D {
#ifdef NL_STATIC
IDriver* createGlDriverInstance ()
IDriver* createGl3DriverInstance ()
{
return new NLDRIVERGL::CDriverGL3;
}

@ -147,6 +147,9 @@ CDriverUser::CDriverUser (uint windowIcon, TDriver driver, emptyProc exitFunc)
if (!_Driver && driver == OpenGlEs)
_Driver= CDRU::createGlEsDriver();
if( !_Driver && driver == OpenGl3 )
_Driver = CDRU::createGl3Driver();
nlassert(_Driver);
_Driver->init (windowIcon, exitFunc);

@ -58,6 +58,7 @@ const char *IDRV_VERSION_PROC_NAME = "NL3D_interfaceVersion";
#ifdef NL_OPENGL_AVAILABLE
extern IDriver* createGlDriverInstance ();
extern IDriver* createGl3DriverInstance ();
#endif
#if defined(NL_OS_WINDOWS) && defined(NL_DIRECT3D_AVAILABLE)
@ -124,6 +125,60 @@ IDriver *CDRU::createGlDriver() throw (EDru)
#endif
}
// ***************************************************************************
IDriver *CDRU::createGl3Driver() throw (EDru)
{
#ifdef NL_STATIC
#ifdef NL_OPENGL_AVAILABLE
return createGl3DriverInstance ();
#else
return NULL;
#endif // NL_OPENGL_AVAILABLE
#else
IDRV_CREATE_PROC createDriver = NULL;
IDRV_VERSION_PROC versionDriver = NULL;
CLibrary driverLib;
#if defined(NL_OS_UNIX) && defined(NL_DRIVER_PREFIX)
driverLib.addLibPath(NL_DRIVER_PREFIX);
#endif
if (!driverLib.loadLibrary(NL3D_GL3_DLL_NAME, true, true, false))
{
throw EDruOpengl3DriverNotFound();
}
nlinfo ("Using the library '"NL3D_GL3_DLL_NAME"' that is in the directory: '%s'", driverLib.getLibFileName().c_str());
createDriver = (IDRV_CREATE_PROC) driverLib.getSymbolAddress(IDRV_CREATE_PROC_NAME);
if (createDriver == NULL)
{
throw EDruOpengl3DriverCorrupted();
}
versionDriver = (IDRV_VERSION_PROC) driverLib.getSymbolAddress(IDRV_VERSION_PROC_NAME);
if (versionDriver != NULL)
{
if (versionDriver()<IDriver::InterfaceVersion)
throw EDruOpengl3DriverOldVersion();
else if (versionDriver()>IDriver::InterfaceVersion)
throw EDruOpengl3DriverUnknownVersion();
}
IDriver *ret= createDriver();
if (ret == NULL)
{
throw EDruOpengl3DriverCantCreateDriver();
}
return ret;
#endif
}
// ***************************************************************************
IDriver *CDRU::createGlEsDriver() throw (EDru)
{

@ -397,7 +397,8 @@ namespace MaterialEditor
void CNel3DInterface::initViewPort( unsigned long wnd, unsigned long w, unsigned long h )
{
driver = NL3D::UDriver::createDriver( 0, false, 0 );
//driver = NL3D::UDriver::createDriver( 0, false, 0 );
driver = NL3D::UDriver::createDriver( 0, NL3D::UDriver::OpenGl3, 0 );
nlassert( driver != NULL );
driver->setDisplay( (nlWindow)wnd, NL3D::UDriver::CMode( w, h, 32 ) );

Loading…
Cancel
Save