mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-05 19:19:39 -06:00
More cleanup
This commit is contained in:
@@ -34,8 +34,6 @@ class RaycasterListener;
|
||||
|
||||
class RaycasterManager {
|
||||
public:
|
||||
RaycasterManager();
|
||||
~RaycasterManager();
|
||||
void attachRaycaster(VolumeRaycaster& raycaster);
|
||||
void detachRaycaster(VolumeRaycaster& raycaster);
|
||||
bool isAttached(VolumeRaycaster& raycaster);
|
||||
|
||||
@@ -153,7 +153,7 @@ void ABufferRenderer::initialize() {
|
||||
"${SHADERS}/abuffer/resolveabuffer.frag",
|
||||
dict
|
||||
);
|
||||
} catch (const ghoul::RuntimeErcomponent& e) {
|
||||
} catch (const ghoul::RuntimeError& e) {
|
||||
LERRORC(e.component, e.message);
|
||||
}
|
||||
|
||||
@@ -401,14 +401,23 @@ void ABufferRenderer::clear() {
|
||||
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, _anchorPointerTextureInitializer);
|
||||
glBindTexture(GL_TEXTURE_2D, _anchorPointerTexture);
|
||||
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_R32UI, _resolution.x, _resolution.y, 0, GL_RED_INTEGER, GL_UNSIGNED_INT, NULL);
|
||||
glTexImage2D(
|
||||
GL_TEXTURE_2D,
|
||||
0,
|
||||
GL_R32UI,
|
||||
_resolution.x,
|
||||
_resolution.y,
|
||||
0,
|
||||
GL_RED_INTEGER,
|
||||
GL_UNSIGNED_INT,
|
||||
nullptr
|
||||
);
|
||||
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
|
||||
|
||||
static const GLuint zero = 1;
|
||||
glBindBufferBase(GL_ATOMIC_COUNTER_BUFFER, 0, _atomicCounterBuffer);
|
||||
glBufferSubData(GL_ATOMIC_COUNTER_BUFFER, 0, sizeof(zero), &zero);
|
||||
glBindBufferBase(GL_ATOMIC_COUNTER_BUFFER, 0, 0);
|
||||
|
||||
}
|
||||
|
||||
void ABufferRenderer::updateResolution() {
|
||||
@@ -416,21 +425,43 @@ void ABufferRenderer::updateResolution() {
|
||||
|
||||
int totalPixels = _resolution.x * _resolution.y;
|
||||
glBindTexture(GL_TEXTURE_2D, _anchorPointerTexture);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_R32UI, _resolution.x, _resolution.y, 0, GL_RED_INTEGER, GL_UNSIGNED_INT, NULL);
|
||||
glTexImage2D(
|
||||
GL_TEXTURE_2D,
|
||||
0,
|
||||
GL_R32UI,
|
||||
_resolution.x,
|
||||
_resolution.y,
|
||||
0,
|
||||
GL_RED_INTEGER,
|
||||
GL_UNSIGNED_INT,
|
||||
nullptr
|
||||
);
|
||||
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
|
||||
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, _anchorPointerTextureInitializer);
|
||||
glBufferData(GL_PIXEL_UNPACK_BUFFER, totalPixels * sizeof(GLuint), NULL, GL_STATIC_DRAW);
|
||||
glBufferData(
|
||||
GL_PIXEL_UNPACK_BUFFER,
|
||||
totalPixels * sizeof(GLuint),
|
||||
nullptr,
|
||||
GL_STATIC_DRAW
|
||||
);
|
||||
|
||||
GLuint* data = (GLuint*)glMapBuffer(GL_PIXEL_UNPACK_BUFFER, GL_WRITE_ONLY);
|
||||
GLuint* data = reinterpret_cast<GLuint*>(
|
||||
glMapBuffer(GL_PIXEL_UNPACK_BUFFER, GL_WRITE_ONLY)
|
||||
);
|
||||
memset(data, 0x00, totalPixels * sizeof(GLuint));
|
||||
glUnmapBuffer(GL_PIXEL_UNPACK_BUFFER);
|
||||
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
|
||||
|
||||
glBindBuffer(GL_TEXTURE_BUFFER, _fragmentBuffer);
|
||||
glBufferData(GL_TEXTURE_BUFFER, MaxAverageLayers*totalPixels*sizeof(GLuint) * 4, NULL, GL_DYNAMIC_COPY);
|
||||
glBufferData(
|
||||
GL_TEXTURE_BUFFER,
|
||||
MaxAverageLayers*totalPixels * sizeof(GLuint) * 4,
|
||||
nullptr,
|
||||
GL_DYNAMIC_COPY
|
||||
);
|
||||
|
||||
glBindTexture(GL_TEXTURE_BUFFER, _fragmentTexture);
|
||||
glTexBuffer(GL_TEXTURE_BUFFER, GL_RGBA32UI, _fragmentBuffer);
|
||||
@@ -446,7 +477,8 @@ void ABufferRenderer::updateResolution() {
|
||||
GL_RGBA,
|
||||
GLsizei(_resolution.x),
|
||||
GLsizei(_resolution.y),
|
||||
true);
|
||||
true
|
||||
);
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, _mainDepthTexture);
|
||||
glTexImage2DMultisample(
|
||||
@@ -455,9 +487,9 @@ void ABufferRenderer::updateResolution() {
|
||||
GL_DEPTH_COMPONENT32F,
|
||||
GLsizei(_resolution.x),
|
||||
GLsizei(_resolution.y),
|
||||
true);
|
||||
true
|
||||
);
|
||||
|
||||
|
||||
_dirtyResolution = false;
|
||||
}
|
||||
|
||||
@@ -465,10 +497,9 @@ void ABufferRenderer::updateResolution() {
|
||||
|
||||
void ABufferRenderer::updateResolveDictionary() {
|
||||
ghoul::Dictionary dict;
|
||||
|
||||
ghoul::Dictionary raycastersDict;
|
||||
|
||||
for (const auto &raycastPair : _raycastData) {
|
||||
for (const auto& raycastPair : _raycastData) {
|
||||
ghoul::Dictionary innerDict;
|
||||
int id = raycastPair.second.id;
|
||||
std::string namespaceName = raycastPair.second.namespaceName;
|
||||
@@ -485,7 +516,7 @@ void ABufferRenderer::updateResolveDictionary() {
|
||||
dict.setValue("raycasters", raycastersDict);
|
||||
|
||||
ghoul::Dictionary helperPathsDict;
|
||||
for (int i = 0; i < _helperPaths.size(); i++) {
|
||||
for (int i = 0; i < _helperPaths.size(); ++i) {
|
||||
helperPathsDict.setValue(std::to_string(i), _helperPaths[i]);
|
||||
}
|
||||
|
||||
@@ -508,7 +539,8 @@ void ABufferRenderer::updateRaycastData() {
|
||||
_boundsPrograms.clear();
|
||||
_helperPaths.clear();
|
||||
|
||||
const std::vector<VolumeRaycaster*>& raycasters = OsEng.renderEngine().raycasterManager().raycasters();
|
||||
const std::vector<VolumeRaycaster*>& raycasters =
|
||||
OsEng.renderEngine().raycasterManager().raycasters();
|
||||
|
||||
std::map<std::string, int> namespaceIndices;
|
||||
int nextId = 0; // raycaster ids are positive integers starting at 0. (for raycasters, fragment type is id+1)
|
||||
@@ -517,7 +549,10 @@ void ABufferRenderer::updateRaycastData() {
|
||||
for (auto &raycaster : raycasters) {
|
||||
if (nextId > MaxRaycasters) {
|
||||
int nIgnored = MaxRaycasters - static_cast<int>(raycasters.size());
|
||||
LWARNING("ABufferRenderer does not support more than 32 raycasters. Ignoring " << nIgnored << " raycasters");
|
||||
LWARNING(
|
||||
"ABufferRenderer does not support more than 32 raycasters. " <<
|
||||
"Ignoring " << nIgnored << " raycasters"
|
||||
);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -557,19 +592,22 @@ void ABufferRenderer::updateRaycastData() {
|
||||
dict.setValue("fragmentPath", fsPath);
|
||||
dict.setValue("fragmentType", data.id + 1);
|
||||
try {
|
||||
_boundsPrograms[raycaster] = ghoul::opengl::ProgramObject::Build("Volume " + std::to_string(data.id) + " bounds", vsPath, BoundsFragmentShaderPath, dict);
|
||||
_boundsPrograms[raycaster] = ghoul::opengl::ProgramObject::Build(
|
||||
"Volume " + std::to_string(data.id) + " bounds",
|
||||
vsPath,
|
||||
BoundsFragmentShaderPath,
|
||||
dict
|
||||
);
|
||||
}
|
||||
catch (ghoul::RuntimeError& error) {
|
||||
LERROR(error.message);
|
||||
LERRORC(error.component, error.message);
|
||||
}
|
||||
}
|
||||
|
||||
_dirtyRaycastData = false;
|
||||
_dirtyResolveDictionary = true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
void ABufferRenderer::updateRendererData() {
|
||||
PerfMeasure("ABufferRenderer::updateRendererData");
|
||||
|
||||
|
||||
@@ -22,43 +22,42 @@
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#include <openspace/rendering/framebufferrenderer.h>
|
||||
|
||||
#include <openspace/engine/openspaceengine.h>
|
||||
#include <openspace/engine/wrapper/windowwrapper.h>
|
||||
#include <openspace/performance/performancemeasurement.h>
|
||||
#include <openspace/rendering/raycastermanager.h>
|
||||
#include <openspace/rendering/renderable.h>
|
||||
#include <openspace/rendering/renderengine.h>
|
||||
#include <openspace/rendering/framebufferrenderer.h>
|
||||
#include <string>
|
||||
#include <openspace/rendering/volumeraycaster.h>
|
||||
#include <openspace/scene/scene.h>
|
||||
#include <openspace/util/camera.h>
|
||||
#include <openspace/util/timemanager.h>
|
||||
#include <openspace/engine/openspaceengine.h>
|
||||
#include <openspace/rendering/renderable.h>
|
||||
#include <openspace/rendering/volumeraycaster.h>
|
||||
#include <openspace/rendering/raycastermanager.h>
|
||||
|
||||
#include <openspace/performance/performancemeasurement.h>
|
||||
|
||||
#include <ghoul/opengl/ghoul_gl.h>
|
||||
#include <ghoul/opengl/programobject.h>
|
||||
#include <ghoul/opengl/textureunit.h>
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <ghoul/opengl/programobject.h>
|
||||
|
||||
namespace {
|
||||
const std::string _loggerCat = "FramebufferRenderer";
|
||||
const std::string ExitFragmentShaderPath = "${SHADERS}/framebuffer/exitframebuffer.frag";
|
||||
const std::string RaycastFragmentShaderPath = "${SHADERS}/framebuffer/raycastframebuffer.frag";
|
||||
const std::string GetEntryInsidePath = "${SHADERS}/framebuffer/inside.glsl";
|
||||
const std::string GetEntryOutsidePath = "${SHADERS}/framebuffer/outside.glsl";
|
||||
const std::string RenderFragmentShaderPath = "${SHADERS}/framebuffer/renderframebuffer.frag";
|
||||
}
|
||||
const char* _loggerCat = "FramebufferRenderer";
|
||||
const char* ExitFragmentShaderPath = "${SHADERS}/framebuffer/exitframebuffer.frag";
|
||||
const char* RaycastFragmentShaderPath = "${SHADERS}/framebuffer/raycastframebuffer.frag";
|
||||
const char* GetEntryInsidePath = "${SHADERS}/framebuffer/inside.glsl";
|
||||
const char* GetEntryOutsidePath = "${SHADERS}/framebuffer/outside.glsl";
|
||||
const char* RenderFragmentShaderPath = "${SHADERS}/framebuffer/renderframebuffer.frag";
|
||||
} // namespace
|
||||
|
||||
namespace openspace {
|
||||
|
||||
FramebufferRenderer::FramebufferRenderer()
|
||||
: _camera(nullptr)
|
||||
, _scene(nullptr)
|
||||
, _resolution(glm::vec2(0)) {
|
||||
}
|
||||
, _resolution(glm::vec2(0))
|
||||
{}
|
||||
|
||||
FramebufferRenderer::~FramebufferRenderer() {}
|
||||
|
||||
@@ -83,7 +82,14 @@ void FramebufferRenderer::initialize() {
|
||||
glBindBuffer(GL_ARRAY_BUFFER, _vertexPositionBuffer);
|
||||
|
||||
glBufferData(GL_ARRAY_BUFFER, sizeof(vertex_data), vertex_data, GL_STATIC_DRAW);
|
||||
glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, sizeof(GLfloat)*4, reinterpret_cast<void*>(0));
|
||||
glVertexAttribPointer(
|
||||
0,
|
||||
4,
|
||||
GL_FLOAT,
|
||||
GL_FALSE,
|
||||
sizeof(GLfloat) * 4,
|
||||
reinterpret_cast<void*>(0)
|
||||
);
|
||||
glEnableVertexAttribArray(0);
|
||||
|
||||
GLint defaultFbo;
|
||||
@@ -104,12 +110,36 @@ void FramebufferRenderer::initialize() {
|
||||
updateRaycastData();
|
||||
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, _mainFramebuffer);
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D_MULTISAMPLE, _mainColorTexture, 0);
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D_MULTISAMPLE, _mainDepthTexture, 0);
|
||||
glFramebufferTexture2D(
|
||||
GL_FRAMEBUFFER,
|
||||
GL_COLOR_ATTACHMENT0,
|
||||
GL_TEXTURE_2D_MULTISAMPLE,
|
||||
_mainColorTexture,
|
||||
0
|
||||
);
|
||||
glFramebufferTexture2D(
|
||||
GL_FRAMEBUFFER,
|
||||
GL_DEPTH_ATTACHMENT,
|
||||
GL_TEXTURE_2D_MULTISAMPLE,
|
||||
_mainDepthTexture,
|
||||
0
|
||||
);
|
||||
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, _exitFramebuffer);
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, _exitColorTexture, 0);
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, _exitDepthTexture, 0);
|
||||
glFramebufferTexture2D(
|
||||
GL_FRAMEBUFFER,
|
||||
GL_COLOR_ATTACHMENT0,
|
||||
GL_TEXTURE_2D,
|
||||
_exitColorTexture,
|
||||
0
|
||||
);
|
||||
glFramebufferTexture2D(
|
||||
GL_FRAMEBUFFER,
|
||||
GL_DEPTH_ATTACHMENT,
|
||||
GL_TEXTURE_2D,
|
||||
_exitDepthTexture,
|
||||
0
|
||||
);
|
||||
|
||||
GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
|
||||
if (status != GL_FRAMEBUFFER_COMPLETE) {
|
||||
@@ -119,11 +149,13 @@ void FramebufferRenderer::initialize() {
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, defaultFbo);
|
||||
|
||||
try {
|
||||
_resolveProgram = ghoul::opengl::ProgramObject::Build("Framebuffer Resolve",
|
||||
_resolveProgram = ghoul::opengl::ProgramObject::Build(
|
||||
"Framebuffer Resolve",
|
||||
"${SHADERS}/framebuffer/resolveframebuffer.vert",
|
||||
"${SHADERS}/framebuffer/resolveframebuffer.frag");
|
||||
} catch (ghoul::RuntimeError e) {
|
||||
LERROR(e.message);
|
||||
"${SHADERS}/framebuffer/resolveframebuffer.frag"
|
||||
);
|
||||
} catch (const ghoul::RuntimeError& e) {
|
||||
LERRORC(e.component, e.message);
|
||||
}
|
||||
|
||||
OsEng.renderEngine().raycasterManager().addListener(*this);
|
||||
@@ -146,9 +178,7 @@ void FramebufferRenderer::deinitialize() {
|
||||
OsEng.renderEngine().raycasterManager().removeListener(*this);
|
||||
}
|
||||
|
||||
void FramebufferRenderer::raycastersChanged(VolumeRaycaster& raycaster, bool attached) {
|
||||
(void) raycaster;
|
||||
(void) attached;
|
||||
void FramebufferRenderer::raycastersChanged(VolumeRaycaster&, bool) {
|
||||
_dirtyRaycastData = true;
|
||||
}
|
||||
|
||||
@@ -166,38 +196,38 @@ void FramebufferRenderer::update() {
|
||||
if (_resolveProgram->isDirty()) {
|
||||
try {
|
||||
_resolveProgram->rebuildFromFile();
|
||||
} catch (ghoul::RuntimeError& error) {
|
||||
LERROR(error.message);
|
||||
} catch (const ghoul::RuntimeError& error) {
|
||||
LERRORC(error.component, error.message);
|
||||
}
|
||||
}
|
||||
|
||||
for (auto &program : _exitPrograms) {
|
||||
for (auto& program : _exitPrograms) {
|
||||
if (program.second->isDirty()) {
|
||||
try {
|
||||
program.second->rebuildFromFile();
|
||||
} catch (ghoul::RuntimeError e) {
|
||||
LERROR(e.message);
|
||||
} catch (const ghoul::RuntimeError& e) {
|
||||
LERRORC(e.component, e.message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (auto &program : _raycastPrograms) {
|
||||
for (auto& program : _raycastPrograms) {
|
||||
if (program.second->isDirty()) {
|
||||
try {
|
||||
program.second->rebuildFromFile();
|
||||
} catch (ghoul::RuntimeError e) {
|
||||
LERROR(e.message);
|
||||
} catch (const ghoul::RuntimeError& e) {
|
||||
LERRORC(e.component, e.message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (auto &program : _insideRaycastPrograms) {
|
||||
for (auto& program : _insideRaycastPrograms) {
|
||||
if (program.second->isDirty()) {
|
||||
try {
|
||||
program.second->rebuildFromFile();
|
||||
}
|
||||
catch (ghoul::RuntimeError e) {
|
||||
LERROR(e.message);
|
||||
catch (const ghoul::RuntimeError& e) {
|
||||
LERRORC(e.component, e.message);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -212,7 +242,8 @@ void FramebufferRenderer::updateResolution() {
|
||||
GL_RGBA,
|
||||
GLsizei(_resolution.x),
|
||||
GLsizei(_resolution.y),
|
||||
true);
|
||||
true
|
||||
);
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, _mainDepthTexture);
|
||||
glTexImage2DMultisample(
|
||||
@@ -221,7 +252,8 @@ void FramebufferRenderer::updateResolution() {
|
||||
GL_DEPTH_COMPONENT32F,
|
||||
GLsizei(_resolution.x),
|
||||
GLsizei(_resolution.y),
|
||||
true);
|
||||
true
|
||||
);
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, _exitColorTexture);
|
||||
glTexImage2D(
|
||||
@@ -233,7 +265,8 @@ void FramebufferRenderer::updateResolution() {
|
||||
0,
|
||||
GL_RGBA,
|
||||
GL_UNSIGNED_SHORT,
|
||||
nullptr);
|
||||
nullptr
|
||||
);
|
||||
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
@@ -249,7 +282,8 @@ void FramebufferRenderer::updateResolution() {
|
||||
0,
|
||||
GL_DEPTH_COMPONENT,
|
||||
GL_FLOAT,
|
||||
nullptr);
|
||||
nullptr
|
||||
);
|
||||
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
@@ -263,9 +297,10 @@ void FramebufferRenderer::updateRaycastData() {
|
||||
_raycastPrograms.clear();
|
||||
_insideRaycastPrograms.clear();
|
||||
|
||||
const std::vector<VolumeRaycaster*>& raycasters = OsEng.renderEngine().raycasterManager().raycasters();
|
||||
const std::vector<VolumeRaycaster*>& raycasters =
|
||||
OsEng.renderEngine().raycasterManager().raycasters();
|
||||
int nextId = 0;
|
||||
for (auto &raycaster : raycasters) {
|
||||
for (auto& raycaster : raycasters) {
|
||||
RaycastData data;
|
||||
data.id = nextId++;
|
||||
data.namespaceName = "HELPER";
|
||||
@@ -279,7 +314,7 @@ void FramebufferRenderer::updateRaycastData() {
|
||||
dict.setValue("id", data.id);
|
||||
std::string helperPath = raycaster->getHelperPath();
|
||||
ghoul::Dictionary helpersDict;
|
||||
if (helperPath != "") {
|
||||
if (!helperPath.empty()) {
|
||||
helpersDict.setValue("0", helperPath);
|
||||
}
|
||||
dict.setValue("helperPaths", helpersDict);
|
||||
@@ -288,7 +323,12 @@ void FramebufferRenderer::updateRaycastData() {
|
||||
_raycastData[raycaster] = data;
|
||||
|
||||
try {
|
||||
_exitPrograms[raycaster] = ghoul::opengl::ProgramObject::Build("Volume " + std::to_string(data.id) + " exit", vsPath, ExitFragmentShaderPath, dict);
|
||||
_exitPrograms[raycaster] = ghoul::opengl::ProgramObject::Build(
|
||||
"Volume " + std::to_string(data.id) + " exit",
|
||||
vsPath,
|
||||
ExitFragmentShaderPath,
|
||||
dict
|
||||
);
|
||||
} catch (ghoul::RuntimeError e) {
|
||||
LERROR(e.message);
|
||||
}
|
||||
@@ -299,7 +339,8 @@ void FramebufferRenderer::updateRaycastData() {
|
||||
"Volume " + std::to_string(data.id) + " raycast",
|
||||
vsPath,
|
||||
RaycastFragmentShaderPath,
|
||||
outsideDict);
|
||||
outsideDict
|
||||
);
|
||||
} catch (ghoul::RuntimeError e) {
|
||||
LERROR(e.message);
|
||||
}
|
||||
@@ -310,10 +351,11 @@ void FramebufferRenderer::updateRaycastData() {
|
||||
"Volume " + std::to_string(data.id) + " inside raycast",
|
||||
"${SHADERS}/framebuffer/resolveframebuffer.vert",
|
||||
RaycastFragmentShaderPath,
|
||||
insideDict);
|
||||
insideDict
|
||||
);
|
||||
}
|
||||
catch (ghoul::RuntimeError e) {
|
||||
LERROR(e.message);
|
||||
catch (const ghoul::RuntimeError& e) {
|
||||
LERRORC(e.component, e.message);
|
||||
}
|
||||
}
|
||||
_dirtyRaycastData = false;
|
||||
@@ -328,10 +370,9 @@ void FramebufferRenderer::render(float blackoutFactor, bool doPerformanceMeasure
|
||||
);
|
||||
}
|
||||
|
||||
if (!_scene)
|
||||
return;
|
||||
if (!_camera)
|
||||
if (!_scene || !_camera) {
|
||||
return;
|
||||
}
|
||||
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glEnable(GL_BLEND);
|
||||
@@ -373,7 +414,10 @@ void FramebufferRenderer::render(float blackoutFactor, bool doPerformanceMeasure
|
||||
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, _mainFramebuffer);
|
||||
glm::vec3 cameraPosition;
|
||||
bool cameraIsInside = raycaster->cameraIsInside(raycasterTask.renderData, cameraPosition);
|
||||
bool cameraIsInside = raycaster->cameraIsInside(
|
||||
raycasterTask.renderData,
|
||||
cameraPosition
|
||||
);
|
||||
ghoul::opengl::ProgramObject* raycastProgram = nullptr;
|
||||
|
||||
if (cameraIsInside) {
|
||||
@@ -423,8 +467,6 @@ void FramebufferRenderer::render(float blackoutFactor, bool doPerformanceMeasure
|
||||
glDepthMask(true);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
|
||||
|
||||
|
||||
raycaster->postRaycast(_raycastData[raycaster], *raycastProgram);
|
||||
raycastProgram->deactivate();
|
||||
} else {
|
||||
@@ -483,4 +525,4 @@ void FramebufferRenderer::updateRendererData() {
|
||||
OsEng.renderEngine().setRendererData(dict);
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace openspace
|
||||
|
||||
@@ -23,25 +23,19 @@
|
||||
****************************************************************************************/
|
||||
|
||||
#include <openspace/rendering/raycastermanager.h>
|
||||
|
||||
#include <openspace/rendering/raycasterlistener.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <string>
|
||||
|
||||
namespace {
|
||||
const std::string _loggerCat = "RaycasterManager";
|
||||
}
|
||||
|
||||
namespace openspace {
|
||||
|
||||
RaycasterManager::RaycasterManager() {}
|
||||
|
||||
RaycasterManager::~RaycasterManager() {}
|
||||
|
||||
void RaycasterManager::attachRaycaster(VolumeRaycaster& raycaster) {
|
||||
if (!isAttached(raycaster)) {
|
||||
_raycasters.push_back(&raycaster);
|
||||
}
|
||||
for (auto &listener : _listeners) {
|
||||
for (RaycasterListener* listener : _listeners) {
|
||||
listener->raycastersChanged(raycaster, true);
|
||||
}
|
||||
}
|
||||
@@ -51,18 +45,16 @@ bool RaycasterManager::isAttached(VolumeRaycaster& raycaster) {
|
||||
return it != _raycasters.end();
|
||||
}
|
||||
|
||||
|
||||
void RaycasterManager::detachRaycaster(VolumeRaycaster& raycaster) {
|
||||
auto it = std::find(_raycasters.begin(), _raycasters.end(), &raycaster);
|
||||
if (it != _raycasters.end()) {
|
||||
_raycasters.erase(it);
|
||||
for (auto &listener : _listeners) {
|
||||
for (RaycasterListener* listener : _listeners) {
|
||||
listener->raycastersChanged(raycaster, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void RaycasterManager::addListener(RaycasterListener& listener) {
|
||||
auto it = std::find(_listeners.begin(), _listeners.end(), &listener);
|
||||
if (it == _listeners.end()) {
|
||||
@@ -81,4 +73,4 @@ const std::vector<VolumeRaycaster*>& RaycasterManager::raycasters() {
|
||||
return _raycasters;
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace openspace
|
||||
|
||||
@@ -23,18 +23,18 @@
|
||||
****************************************************************************************/
|
||||
|
||||
#include <openspace/rendering/renderable.h>
|
||||
#include <openspace/util/factorymanager.h>
|
||||
#include <openspace/util/updatestructures.h>
|
||||
#include <openspace/util/spicemanager.h>
|
||||
#include <openspace/scene/scenegraphnode.h>
|
||||
|
||||
#include <openspace/documentation/documentation.h>
|
||||
#include <openspace/documentation/verifier.h>
|
||||
#include <openspace/scene/scenegraphnode.h>
|
||||
#include <openspace/util/factorymanager.h>
|
||||
#include <openspace/util/spicemanager.h>
|
||||
#include <openspace/util/updatestructures.h>
|
||||
|
||||
#include <ghoul/misc/dictionary.h>
|
||||
#include <ghoul/filesystem/filesystem.h>
|
||||
#include <ghoul/opengl/programobject.h>
|
||||
#include <ghoul/misc/assert.h>
|
||||
#include <ghoul/misc/dictionary.h>
|
||||
#include <ghoul/opengl/programobject.h>
|
||||
|
||||
namespace {
|
||||
const char* _loggerCat = "Renderable";
|
||||
@@ -42,7 +42,7 @@ namespace {
|
||||
const char* keyEnd = "EndTime";
|
||||
const char* KeyType = "Type";
|
||||
const char* KeyTag = "Tag";
|
||||
}
|
||||
} // namespace
|
||||
|
||||
namespace openspace {
|
||||
|
||||
@@ -81,6 +81,7 @@ std::unique_ptr<Renderable> Renderable::createFromDictionary(
|
||||
std::string renderableType = dictionary.value<std::string>(KeyType);
|
||||
|
||||
auto factory = FactoryManager::ref().factory<Renderable>();
|
||||
ghoul_assert(factory, "Renderable factory did not exist");
|
||||
std::unique_ptr<Renderable> result = factory->create(renderableType, dictionary);
|
||||
if (result == nullptr) {
|
||||
LERROR("Failed to create a Renderable object of type '" << renderableType << "'");
|
||||
@@ -117,16 +118,18 @@ Renderable::Renderable(const ghoul::Dictionary& dictionary)
|
||||
|
||||
if (dictionary.hasKeyAndValue<std::string>(KeyTag)) {
|
||||
std::string tagName = dictionary.value<std::string>(KeyTag);
|
||||
if (!tagName.empty())
|
||||
if (!tagName.empty()) {
|
||||
addTag(std::move(tagName));
|
||||
}
|
||||
} else if (dictionary.hasKeyAndValue<ghoul::Dictionary>(KeyTag)) {
|
||||
ghoul::Dictionary tagNames = dictionary.value<ghoul::Dictionary>(KeyTag);
|
||||
std::vector<std::string> keys = tagNames.keys();
|
||||
std::string tagName;
|
||||
for (const std::string& key : keys) {
|
||||
tagName = tagNames.value<std::string>(key);
|
||||
if (!tagName.empty())
|
||||
if (!tagName.empty()) {
|
||||
addTag(std::move(tagName));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -191,8 +194,9 @@ bool Renderable::getInterval(double& start, double& end) {
|
||||
end = SpiceManager::ref().ephemerisTimeFromDate(_endTime);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool Renderable::isReady() const {
|
||||
@@ -204,8 +208,8 @@ bool Renderable::isEnabled() const {
|
||||
}
|
||||
|
||||
void Renderable::onEnabledChange(std::function<void(bool)> callback) {
|
||||
_enabled.onChange([=] () {
|
||||
callback(isEnabled());
|
||||
_enabled.onChange([&] () {
|
||||
callback(isEnabled());
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -33,24 +33,21 @@
|
||||
#include <openspace/engine/openspaceengine.h>
|
||||
#include <openspace/engine/wrapper/windowwrapper.h>
|
||||
#include <openspace/interaction/interactionhandler.h>
|
||||
#include <openspace/interaction/luaconsole.h>
|
||||
#include <openspace/mission/missionmanager.h>
|
||||
#include <openspace/performance/performancemanager.h>
|
||||
#include <openspace/rendering/abufferrenderer.h>
|
||||
#include <openspace/rendering/framebufferrenderer.h>
|
||||
#include <openspace/rendering/raycastermanager.h>
|
||||
#include <openspace/scene/scene.h>
|
||||
#include <openspace/performance/performancemanager.h>
|
||||
#include <openspace/rendering/renderer.h>
|
||||
|
||||
#include <openspace/interaction/luaconsole.h>
|
||||
#include <openspace/rendering/screenspacerenderable.h>
|
||||
#include <openspace/scene/scene.h>
|
||||
#include <openspace/scripting/scriptengine.h>
|
||||
#include <openspace/util/camera.h>
|
||||
#include <openspace/util/time.h>
|
||||
#include <openspace/util/timemanager.h>
|
||||
#include <openspace/util/screenlog.h>
|
||||
#include <openspace/util/spicemanager.h>
|
||||
#include <openspace/rendering/raycastermanager.h>
|
||||
#include <openspace/rendering/screenspacerenderable.h>
|
||||
#include <openspace/scripting/scriptengine.h>
|
||||
|
||||
#include <ghoul/glm.h>
|
||||
#include <ghoul/font/font.h>
|
||||
|
||||
@@ -29,9 +29,9 @@
|
||||
#include <openspace/engine/openspaceengine.h>
|
||||
#include <openspace/engine/wrapper/windowwrapper.h>
|
||||
#include <openspace/rendering/renderengine.h>
|
||||
#include <openspace/scripting/scriptengine.h>
|
||||
#include <openspace/util/camera.h>
|
||||
#include <openspace/util/factorymanager.h>
|
||||
#include <openspace/scripting/scriptengine.h>
|
||||
|
||||
#ifdef WIN32
|
||||
#define _USE_MATH_DEFINES
|
||||
@@ -49,7 +49,7 @@ namespace {
|
||||
const char* KeyAlpha = "Alpha";
|
||||
const char* KeyTag = "Tag";
|
||||
const float PlaneDepth = -2.f;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
namespace openspace {
|
||||
|
||||
@@ -148,16 +148,18 @@ ScreenSpaceRenderable::ScreenSpaceRenderable(const ghoul::Dictionary& dictionary
|
||||
|
||||
if (dictionary.hasKeyAndValue<std::string>(KeyTag)) {
|
||||
std::string tagName = dictionary.value<std::string>(KeyTag);
|
||||
if (!tagName.empty())
|
||||
if (!tagName.empty()) {
|
||||
addTag(std::move(tagName));
|
||||
}
|
||||
} else if (dictionary.hasKeyAndValue<ghoul::Dictionary>(KeyTag)) {
|
||||
ghoul::Dictionary tagNames = dictionary.value<ghoul::Dictionary>(KeyTag);
|
||||
std::vector<std::string> keys = tagNames.keys();
|
||||
std::string tagName;
|
||||
for (const std::string& key : keys) {
|
||||
tagName = tagNames.value<std::string>(key);
|
||||
if (!tagName.empty())
|
||||
if (!tagName.empty()) {
|
||||
addTag(std::move(tagName));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -176,7 +178,10 @@ ScreenSpaceRenderable::ScreenSpaceRenderable(const ghoul::Dictionary& dictionary
|
||||
_delete.onChange([this](){
|
||||
std::string script =
|
||||
"openspace.unregisterScreenSpaceRenderable('" + name() + "');";
|
||||
OsEng.scriptEngine().queueScript(script, scripting::ScriptEngine::RemoteScripting::Yes);
|
||||
OsEng.scriptEngine().queueScript(
|
||||
script,
|
||||
scripting::ScriptEngine::RemoteScripting::Yes
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -22,24 +22,21 @@
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
// open space includes
|
||||
#include <openspace/rendering/transferfunction.h>
|
||||
|
||||
// ghoul includes
|
||||
#include <ghoul/opengl/texture.h>
|
||||
#include <ghoul/io/texture/texturereader.h>
|
||||
#include <ghoul/filesystem/filesystem.h>
|
||||
#include <ghoul/filesystem/cachemanager.h>
|
||||
|
||||
#include <ghoul/filesystem/filesystem.h>
|
||||
#include <ghoul/io/texture/texturereader.h>
|
||||
#include <ghoul/logging/logmanager.h>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <ghoul/opengl/texture.h>
|
||||
|
||||
#include <cstring>
|
||||
#include <iterator>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
|
||||
namespace {
|
||||
const std::string _loggerCat = "TransferFunction";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user