Create interface classes for stereo displays and head mounted displays, see #43
--HG-- branch : multipass-stereohg/feature/sound
parent
bf16ccd320
commit
5f229667bc
@ -0,0 +1,139 @@
|
||||
/**
|
||||
* \file stereo_display.h
|
||||
* \brief IStereoDisplay
|
||||
* \date 2013-06-27 16:29GMT
|
||||
* \author Jan Boon (Kaetemi)
|
||||
* IStereoDisplay
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2013 by authors
|
||||
*
|
||||
* This file is part of NL3D.
|
||||
* NL3D is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* NL3D is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General
|
||||
* Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public
|
||||
* License along with NL3D. If not, see
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef NL3D_STEREO_DISPLAY_H
|
||||
#define NL3D_STEREO_DISPLAY_H
|
||||
#include <nel/misc/types_nl.h>
|
||||
|
||||
// STL includes
|
||||
|
||||
// NeL includes
|
||||
#include <nel/misc/smart_ptr.h>
|
||||
|
||||
// Project includes
|
||||
|
||||
namespace NL3D {
|
||||
|
||||
class UCamera;
|
||||
class CViewport;
|
||||
class CFrustum;
|
||||
class IStereoDisplay;
|
||||
|
||||
class IStereoDeviceFactory : public NLMISC::CRefCount
|
||||
{
|
||||
public:
|
||||
IStereoDeviceFactory() { }
|
||||
virtual ~IStereoDeviceFactory() { }
|
||||
virtual IStereoDisplay *createDevice() const = 0;
|
||||
};
|
||||
|
||||
struct CStereoDeviceInfo
|
||||
{
|
||||
public:
|
||||
enum TStereoDeviceClass
|
||||
{
|
||||
StereoDisplay,
|
||||
StereoHMD,
|
||||
};
|
||||
|
||||
enum TStereoDeviceLibrary
|
||||
{
|
||||
NeL3D,
|
||||
OVR,
|
||||
LibVR,
|
||||
OpenHMD,
|
||||
};
|
||||
|
||||
NLMISC::CSmartPtr<IStereoDeviceFactory> Factory;
|
||||
|
||||
TStereoDeviceLibrary Library;
|
||||
TStereoDeviceClass Class;
|
||||
std::string Manufacturer;
|
||||
std::string ProductName;
|
||||
std::string Serial; // A unique device identifier
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief IStereoDisplay
|
||||
* \date 2013-06-27 16:29GMT
|
||||
* \author Jan Boon (Kaetemi)
|
||||
* IStereoDisplay
|
||||
*/
|
||||
class IStereoDisplay
|
||||
{
|
||||
public:
|
||||
IStereoDisplay();
|
||||
virtual ~IStereoDisplay();
|
||||
|
||||
/// Gets the required screen resolution for this device
|
||||
virtual void getScreenResolution(uint &width, uint &height) = 0;
|
||||
/// Set latest camera position etcetera
|
||||
virtual void updateCamera(uint cid, const NL3D::UCamera *camera) = 0;
|
||||
/// Get the frustum to use for clipping
|
||||
virtual void getClippingFrustum(uint cid, NL3D::UCamera *camera) const = 0;
|
||||
|
||||
/// Is there a next pass
|
||||
virtual bool nextPass() = 0;
|
||||
/// Gets the current viewport
|
||||
virtual const NL3D::CViewport &getCurrentViewport() const = 0;
|
||||
/// Gets the current camera frustum
|
||||
virtual const NL3D::CFrustum &getCurrentFrustum(uint cid) const = 0;
|
||||
/// Gets the current camera frustum
|
||||
virtual void getCurrentFrustum(uint cid, NL3D::UCamera *camera) const = 0;
|
||||
/// Gets the current camera matrix
|
||||
virtual void getCurrentMatrix(uint cid, NL3D::UCamera *camera) const = 0;
|
||||
|
||||
/// At the start of a new render target
|
||||
virtual bool beginClear() = 0;
|
||||
// virtual void *getRenderTarget() const;
|
||||
virtual void endClear() = 0;
|
||||
|
||||
/// The 3D scene
|
||||
virtual bool beginScene() = 0;
|
||||
virtual void endScene() = 0;
|
||||
|
||||
/// Interface within the 3D scene
|
||||
virtual bool beginInterface3D() = 0;
|
||||
virtual void endInterface3D() = 0;
|
||||
|
||||
/// 2D Interface
|
||||
virtual bool beginInterface2D() = 0;
|
||||
virtual void endInterface2D() = 0;
|
||||
|
||||
static const char *getLibraryName(CStereoDeviceInfo::TStereoDeviceLibrary library);
|
||||
static void listDevices(std::vector<CStereoDeviceInfo> &devicesOut);
|
||||
static IStereoDisplay *createDevice(const CStereoDeviceInfo &deviceInfo);
|
||||
static void releaseUnusedLibraries();
|
||||
static void releaseAllLibraries();
|
||||
|
||||
}; /* class IStereoDisplay */
|
||||
|
||||
} /* namespace NL3D */
|
||||
|
||||
#endif /* #ifndef NL3D_STEREO_DISPLAY_H */
|
||||
|
||||
/* end of file */
|
@ -0,0 +1,69 @@
|
||||
/**
|
||||
* \file stereo_hmd.h
|
||||
* \brief IStereoHMD
|
||||
* \date 2013-06-27 16:30GMT
|
||||
* \author Jan Boon (Kaetemi)
|
||||
* IStereoHMD
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2013 by authors
|
||||
*
|
||||
* This file is part of NL3D.
|
||||
* NL3D is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* NL3D is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General
|
||||
* Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public
|
||||
* License along with NL3D. If not, see
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef NL3D_STEREO_HMD_H
|
||||
#define NL3D_STEREO_HMD_H
|
||||
#include <nel/misc/types_nl.h>
|
||||
|
||||
// STL includes
|
||||
|
||||
// NeL includes
|
||||
|
||||
// Project includes
|
||||
#include <nel/3d/stereo_display.h>
|
||||
|
||||
namespace NL3D {
|
||||
|
||||
/**
|
||||
* \brief IStereoHMD
|
||||
* \date 2013-06-27 16:30GMT
|
||||
* \author Jan Boon (Kaetemi)
|
||||
* IStereoHMD
|
||||
*/
|
||||
class IStereoHMD : public IStereoDisplay
|
||||
{
|
||||
public:
|
||||
IStereoHMD();
|
||||
virtual ~IStereoHMD();
|
||||
|
||||
/// Get the HMD orientation
|
||||
virtual NLMISC::CQuat getOrientation() const = 0;
|
||||
|
||||
/// Set the head model, eye position relative to orientation point
|
||||
// virtual void setEyePosition(const NLMISC::CVector &v) = 0;
|
||||
/// Get the head model, eye position relative to orientation point
|
||||
// virtual const NLMISC::CVector &getEyePosition() const = 0;
|
||||
/// Get GUI center (1 = width, 1 = height, 0 = center)
|
||||
virtual void getInterface2DShift(uint cid, float &x, float &y, float distance) const = 0;
|
||||
|
||||
}; /* class IStereoHMD */
|
||||
|
||||
} /* namespace NL3D */
|
||||
|
||||
#endif /* #ifndef NL3D_STEREO_HMD_H */
|
||||
|
||||
/* end of file */
|
@ -0,0 +1,98 @@
|
||||
/**
|
||||
* \file stereo_display.cpp
|
||||
* \brief IStereoDisplay
|
||||
* \date 2013-06-27 16:29GMT
|
||||
* \author Jan Boon (Kaetemi)
|
||||
* IStereoDisplay
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2013 by authors
|
||||
*
|
||||
* This file is part of NL3D.
|
||||
* NL3D is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* NL3D is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General
|
||||
* Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public
|
||||
* License along with NL3D. If not, see
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <nel/misc/types_nl.h>
|
||||
#include <nel/3d/stereo_display.h>
|
||||
|
||||
// STL includes
|
||||
|
||||
// NeL includes
|
||||
// #include <nel/misc/debug.h>
|
||||
|
||||
// Project includes
|
||||
#include <nel/3d/stereo_ovr.h>
|
||||
|
||||
using namespace std;
|
||||
// using namespace NLMISC;
|
||||
|
||||
namespace NL3D {
|
||||
|
||||
IStereoDisplay::IStereoDisplay()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
IStereoDisplay::~IStereoDisplay()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
const char *IStereoDisplay::getLibraryName(CStereoDeviceInfo::TStereoDeviceLibrary library)
|
||||
{
|
||||
static const char *nel3dName = "NeL 3D";
|
||||
static const char *ovrName = "Oculus SDK";
|
||||
static const char *libvrName = "LibVR";
|
||||
static const char *openhmdName = "OpenHMD";
|
||||
switch (library)
|
||||
{
|
||||
case CStereoDeviceInfo::NeL3D:
|
||||
return nel3dName;
|
||||
case CStereoDeviceInfo::OVR:
|
||||
return ovrName;
|
||||
case CStereoDeviceInfo::LibVR:
|
||||
return libvrName;
|
||||
case CStereoDeviceInfo::OpenHMD:
|
||||
return openhmdName;
|
||||
}
|
||||
nlerror("Invalid device library specified");
|
||||
return "<InvalidDeviceLibrary>";
|
||||
}
|
||||
|
||||
void IStereoDisplay::listDevices(std::vector<CStereoDeviceInfo> &devicesOut)
|
||||
{
|
||||
CStereoOVR::listDevices(devicesOut);
|
||||
}
|
||||
|
||||
IStereoDisplay *IStereoDisplay::createDevice(const CStereoDeviceInfo &deviceInfo)
|
||||
{
|
||||
return deviceInfo.Factory->createDevice();
|
||||
}
|
||||
|
||||
void IStereoDisplay::releaseUnusedLibraries()
|
||||
{
|
||||
if (!CStereoOVR::isLibraryInUse())
|
||||
CStereoOVR::releaseLibrary();
|
||||
}
|
||||
|
||||
void IStereoDisplay::releaseAllLibraries()
|
||||
{
|
||||
CStereoOVR::releaseLibrary();
|
||||
}
|
||||
|
||||
} /* namespace NL3D */
|
||||
|
||||
/* end of file */
|
@ -0,0 +1,55 @@
|
||||
/**
|
||||
* \file stereo_hmd.cpp
|
||||
* \brief IStereoHMD
|
||||
* \date 2013-06-27 16:30GMT
|
||||
* \author Jan Boon (Kaetemi)
|
||||
* IStereoHMD
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2013 by authors
|
||||
*
|
||||
* This file is part of NL3D.
|
||||
* NL3D is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* NL3D is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General
|
||||
* Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public
|
||||
* License along with NL3D. If not, see
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <nel/misc/types_nl.h>
|
||||
#include <nel/3d/stereo_hmd.h>
|
||||
|
||||
// STL includes
|
||||
|
||||
// NeL includes
|
||||
// #include <nel/misc/debug.h>
|
||||
|
||||
// Project includes
|
||||
|
||||
using namespace std;
|
||||
// using namespace NLMISC;
|
||||
|
||||
namespace NL3D {
|
||||
|
||||
IStereoHMD::IStereoHMD()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
IStereoHMD::~IStereoHMD()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
} /* namespace NL3D */
|
||||
|
||||
/* end of file */
|
Loading…
Reference in New Issue