mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-05 19:19:39 -06:00
Cleaning up abuffer classes
Make ABuffer type selectable in openspace.cfg
This commit is contained in:
@@ -33,19 +33,19 @@ class ABufferFixed: public ABuffer {
|
||||
public:
|
||||
|
||||
ABufferFixed();
|
||||
virtual ~ABufferFixed();
|
||||
virtual bool initialize();
|
||||
~ABufferFixed();
|
||||
bool initialize() override;
|
||||
|
||||
virtual void clear();
|
||||
virtual void preRender();
|
||||
virtual void postRender();
|
||||
void clear() override;
|
||||
void preRender() override;
|
||||
void postRender() override;
|
||||
|
||||
std::vector<fragmentData> pixelData() override;
|
||||
|
||||
std::vector<fragmentData> pixelData();
|
||||
protected:
|
||||
virtual bool reinitializeInternal();
|
||||
virtual bool reinitializeInternal() override;
|
||||
|
||||
private:
|
||||
|
||||
GLuint *_data;
|
||||
GLuint _anchorPointerTexture;
|
||||
GLuint _anchorPointerTextureInitializer;
|
||||
@@ -53,11 +53,8 @@ private:
|
||||
GLuint _atomicCounterTexture;
|
||||
GLuint _fragmentBuffer;
|
||||
GLuint _fragmentTexture;
|
||||
|
||||
|
||||
|
||||
|
||||
}; // ABufferFixed
|
||||
|
||||
} // openspace
|
||||
|
||||
#endif // __ABUFFERFIXED_H__
|
||||
@@ -51,7 +51,7 @@ public:
|
||||
RenderEngine();
|
||||
~RenderEngine();
|
||||
|
||||
bool initialize();
|
||||
bool initialize(const std::string& renderingMethod);
|
||||
|
||||
void setSceneGraph(Scene* sceneGraph);
|
||||
Scene* scene();
|
||||
@@ -113,6 +113,7 @@ private:
|
||||
Camera* _mainCamera;
|
||||
Scene* _sceneGraph;
|
||||
ABuffer* _abuffer;
|
||||
int _abufferImplementation;
|
||||
ScreenLog* _log;
|
||||
|
||||
bool _showInfo;
|
||||
|
||||
@@ -1,26 +1,36 @@
|
||||
return {
|
||||
Paths = {
|
||||
SGCT = "${BASE_PATH}/config/sgct",
|
||||
SCRIPTS = "${BASE_PATH}/scripts",
|
||||
SHADERS = "${BASE_PATH}/shaders",
|
||||
SHADERS_GENERATED = "${SHADERS}/generated",
|
||||
OPENSPACE_DATA = "${BASE_PATH}/openspace-data",
|
||||
TESTDIR = "${BASE_PATH}/tests",
|
||||
CONFIG = "${BASE_PATH}/config",
|
||||
CACHE = "${BASE_PATH}/cache",
|
||||
FONTS = "${OPENSPACE_DATA}/fonts",
|
||||
PLUTO_KERNELS = "${OPENSPACE_DATA}/spice/Pluto",
|
||||
JP_KERNELS = "${OPENSPACE_DATA}/spice/JP_KERNELS"
|
||||
},
|
||||
SpiceKernel = {
|
||||
Time = "${OPENSPACE_DATA}/spice/naif0010.tls",
|
||||
LeapSecond = "${OPENSPACE_DATA}/spice/pck00010.tpc",
|
||||
NewHorizons = "${OPENSPACE_DATA}/spice/nhmeta.tm"
|
||||
},
|
||||
Fonts = {
|
||||
Mono = "${FONTS}/Droid_Sans_Mono/DroidSansMono.ttf",
|
||||
Light = "${FONTS}/Roboto/Roboto-Regular.ttf"
|
||||
},
|
||||
-- Determines which SGCT configuration file is loaded, that is, if there rendering
|
||||
-- occurs in a single window, a fisheye projection, or a dome cluster system
|
||||
SGCTConfig = "${SGCT}/single.xml",
|
||||
--SGCTConfig = "${SGCT}/single_fisheye.xml",
|
||||
--SGCTConfig = "${SGCT}/two_nodes.xml",
|
||||
|
||||
-- Sets the scene that is to be loaded by OpenSpace. A scene file is a description
|
||||
-- of all entities that will be visible during an instance of OpenSpace
|
||||
Scene = "${OPENSPACE_DATA}/scene/default_nh.scene",
|
||||
|
||||
Paths = {
|
||||
SGCT = "${BASE_PATH}/config/sgct",
|
||||
SCRIPTS = "${BASE_PATH}/scripts",
|
||||
SHADERS = "${BASE_PATH}/shaders",
|
||||
SHADERS_GENERATED = "${SHADERS}/generated",
|
||||
OPENSPACE_DATA = "${BASE_PATH}/openspace-data",
|
||||
TESTDIR = "${BASE_PATH}/tests",
|
||||
CONFIG = "${BASE_PATH}/config",
|
||||
CACHE = "${BASE_PATH}/cache",
|
||||
FONTS = "${OPENSPACE_DATA}/fonts",
|
||||
PLUTO_KERNELS = "${OPENSPACE_DATA}/spice/Pluto",
|
||||
JP_KERNELS = "${OPENSPACE_DATA}/spice/JP_KERNELS"
|
||||
},
|
||||
SpiceKernel = {
|
||||
Time = "${OPENSPACE_DATA}/spice/naif0010.tls",
|
||||
LeapSecond = "${OPENSPACE_DATA}/spice/pck00010.tpc",
|
||||
NewHorizons = "${OPENSPACE_DATA}/spice/nhmeta.tm"
|
||||
},
|
||||
Fonts = {
|
||||
Mono = "${FONTS}/Droid_Sans_Mono/DroidSansMono.ttf",
|
||||
Light = "${FONTS}/Roboto/Roboto-Regular.ttf"
|
||||
},
|
||||
StartupScripts = {
|
||||
"${SCRIPTS}/default_startup.lua"
|
||||
},
|
||||
@@ -39,11 +49,9 @@ return {
|
||||
File = "${BASE_PATH}/LuaScripting.txt"
|
||||
},
|
||||
PropertyDocumentationFile = {
|
||||
Type = "text",
|
||||
File = "${BASE_PATH}/Properties.txt"
|
||||
Type = "text",
|
||||
File = "${BASE_PATH}/Properties.txt"
|
||||
},
|
||||
SGCTConfig = "${SGCT}/single.xml",
|
||||
--SGCTConfig = "${SGCT}/single_fisheye.xml",
|
||||
--SGCTConfig = "${SGCT}/two_nodes.xml",
|
||||
Scene = "${OPENSPACE_DATA}/scene/default_nh.scene",
|
||||
RenderingMethod = "ABufferSingleLinked" -- On Windows and Unix
|
||||
-- RenderingMethod = "ABufferFrameBuffer" -- On Mac due to OpenGL 4.1 restrictions
|
||||
}
|
||||
@@ -68,12 +68,17 @@ bool ABufferSingleLinked::initialize() {
|
||||
// BUFFERS
|
||||
// ============================
|
||||
glGenTextures(1, &_anchorPointerTexture);
|
||||
LDEBUG("AnchorPointerTexture ID: " << _anchorPointerTexture);
|
||||
glGenBuffers(1, &_anchorPointerTextureInitializer);
|
||||
LDEBUG("AnchorPointerTextureInitializer ID: " << _anchorPointerTextureInitializer);
|
||||
glGenBuffers(1, &_atomicCounterBuffer);
|
||||
LDEBUG("AtomicCounterBuffer ID: " << _atomicCounterBuffer);
|
||||
glBindBuffer(GL_ATOMIC_COUNTER_BUFFER, _atomicCounterBuffer);
|
||||
glBufferData(GL_ATOMIC_COUNTER_BUFFER, sizeof(GLuint), NULL, GL_DYNAMIC_COPY);
|
||||
glGenBuffers(1, &_fragmentBuffer);
|
||||
LDEBUG("FragmentBuffer ID: " << _fragmentBuffer);
|
||||
glGenTextures(1, &_fragmentTexture);
|
||||
LDEBUG("FragmentTexture ID: " << _fragmentTexture);
|
||||
|
||||
reinitialize();
|
||||
|
||||
|
||||
@@ -188,5 +188,4 @@ std::vector<ABuffer::fragmentData> ABufferFixed::pixelData() {
|
||||
return d;
|
||||
}
|
||||
|
||||
|
||||
} // openspace
|
||||
} // openspace
|
||||
|
||||
@@ -75,6 +75,9 @@ namespace {
|
||||
|
||||
const std::string _sgctConfigArgumentCommand = "-config";
|
||||
|
||||
const std::string KeyRenderingMethod = "RenderingMethod";
|
||||
const std::string DefaultRenderingMethod = "ABufferSingleLinked";
|
||||
|
||||
const std::string DefaultOpenGlVersion = "4.3";
|
||||
|
||||
struct {
|
||||
@@ -319,7 +322,11 @@ bool OpenSpaceEngine::initialize() {
|
||||
_renderEngine->setSceneGraph(sceneGraph);
|
||||
|
||||
// initialize the RenderEngine
|
||||
_renderEngine->initialize();
|
||||
if (_configurationManager->hasKeyAndValue<std::string>(KeyRenderingMethod))
|
||||
_renderEngine->initialize(_configurationManager->value<std::string>(KeyRenderingMethod));
|
||||
else
|
||||
_renderEngine->initialize(DefaultRenderingMethod);
|
||||
|
||||
sceneGraph->initialize();
|
||||
|
||||
std::string sceneDescriptionPath;
|
||||
|
||||
@@ -70,14 +70,21 @@
|
||||
#define ABUFFER_FIXED 2
|
||||
#define ABUFFER_DYNAMIC 3
|
||||
|
||||
#ifdef __APPLE__
|
||||
#define ABUFFER_IMPLEMENTATION ABUFFER_FRAMEBUFFER
|
||||
#else
|
||||
#define ABUFFER_IMPLEMENTATION ABUFFER_SINGLE_LINKED
|
||||
#endif
|
||||
//#ifdef __APPLE__
|
||||
//#define ABUFFER_IMPLEMENTATION ABUFFER_FRAMEBUFFER
|
||||
//#else
|
||||
//#define ABUFFER_IMPLEMENTATION ABUFFER_SINGLE_LINKED
|
||||
//#endif
|
||||
|
||||
namespace {
|
||||
const std::string _loggerCat = "RenderEngine";
|
||||
|
||||
const std::map<std::string, int> RenderingMethods = {
|
||||
{ "ABufferFrameBuffer", ABUFFER_FRAMEBUFFER},
|
||||
{ "ABufferSingleLinked", ABUFFER_SINGLE_LINKED },
|
||||
{ "ABufferFixed", ABUFFER_FIXED },
|
||||
{ "ABufferDynamic", ABUFFER_DYNAMIC }
|
||||
};
|
||||
}
|
||||
|
||||
namespace openspace {
|
||||
@@ -216,6 +223,7 @@ RenderEngine::RenderEngine()
|
||||
: _mainCamera(nullptr)
|
||||
, _sceneGraph(nullptr)
|
||||
, _abuffer(nullptr)
|
||||
, _abufferImplementation(-1)
|
||||
, _log(nullptr)
|
||||
, _showInfo(true)
|
||||
, _showScreenLog(true)
|
||||
@@ -252,7 +260,35 @@ RenderEngine::~RenderEngine() {
|
||||
ghoul::SharedMemory::remove(PerformanceMeasurementSharedData);
|
||||
}
|
||||
|
||||
bool RenderEngine::initialize() {
|
||||
bool RenderEngine::initialize(const std::string& renderingMethod) {
|
||||
auto it = RenderingMethods.find(renderingMethod);
|
||||
if (it == RenderingMethods.end()) {
|
||||
LFATAL("Rendering method '" << renderingMethod << "' not among the available "
|
||||
<< "rendering methods");
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
_abufferImplementation = it->second;
|
||||
switch (_abufferImplementation) {
|
||||
case ABUFFER_FRAMEBUFFER:
|
||||
LINFO("Creating ABufferFramebuffer implementation");
|
||||
_abuffer = new ABufferFramebuffer;
|
||||
break;
|
||||
case ABUFFER_SINGLE_LINKED:
|
||||
LINFO("Creating ABufferSingleLinked implementation");
|
||||
_abuffer = new ABufferSingleLinked();
|
||||
break;
|
||||
case ABUFFER_FIXED:
|
||||
LINFO("Creating ABufferFixed implementation");
|
||||
_abuffer = new ABufferFixed();
|
||||
break;
|
||||
case ABUFFER_DYNAMIC:
|
||||
LINFO("Creating ABufferDynamic implementation");
|
||||
_abuffer = new ABufferDynamic();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
generateGlslConfig();
|
||||
|
||||
// init camera and set temporary position and scaling
|
||||
@@ -270,15 +306,6 @@ bool RenderEngine::initialize() {
|
||||
|
||||
ghoul::io::TextureReader::ref().addReader(new ghoul::io::impl::TextureReaderCMAP);
|
||||
|
||||
#if ABUFFER_IMPLEMENTATION == ABUFFER_FRAMEBUFFER
|
||||
_abuffer = new ABufferFramebuffer();
|
||||
#elif ABUFFER_IMPLEMENTATION == ABUFFER_SINGLE_LINKED
|
||||
_abuffer = new ABufferSingleLinked();
|
||||
#elif ABUFFER_IMPLEMENTATION == ABUFFER_FIXED
|
||||
_abuffer = new ABufferFixed();
|
||||
#elif ABUFFER_IMPLEMENTATION == ABUFFER_DYNAMIC
|
||||
_abuffer = new ABufferDynamic();
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -788,6 +815,7 @@ void RenderEngine::startFading(int direction, float fadeDuration) {
|
||||
}
|
||||
|
||||
void RenderEngine::generateGlslConfig() {
|
||||
ghoul_assert(_abuffer != nullptr, "ABuffer not initialized");
|
||||
LDEBUG("Generating GLSLS config, expect shader recompilation");
|
||||
int xSize = sgct::Engine::instance()->getActiveWindowPtr()->getXFramebufferResolution();;
|
||||
int ySize = sgct::Engine::instance()->getActiveWindowPtr()->getYFramebufferResolution();;
|
||||
@@ -805,7 +833,7 @@ void RenderEngine::generateGlslConfig() {
|
||||
<< "#define ABUFFER_SINGLE_LINKED " << ABUFFER_SINGLE_LINKED << "\n"
|
||||
<< "#define ABUFFER_FIXED " << ABUFFER_FIXED << "\n"
|
||||
<< "#define ABUFFER_DYNAMIC " << ABUFFER_DYNAMIC << "\n"
|
||||
<< "#define ABUFFER_IMPLEMENTATION " << ABUFFER_IMPLEMENTATION << "\n";
|
||||
<< "#define ABUFFER_IMPLEMENTATION " << _abufferImplementation << "\n";
|
||||
// System specific
|
||||
#ifdef WIN32
|
||||
os << "#define WIN32\n";
|
||||
|
||||
Reference in New Issue
Block a user