Issue/518 (#529)

* Adding ScreenSpaceSpout object to display spout textures in screen space
 * Enable the clearing of option properties
 * Fix crash in ScreenSpaceImageLocal specification
 * Split RenderablePlane into RenderablePlaneImageLocal and RenderablePlaneImageOnline
 * Add RenderablePlane Spout
 * Rename Texture parameter in ScreenSpaceImageOnline into URL

Closes #518
This commit is contained in:
Alexander Bock
2018-02-23 13:24:35 -05:00
committed by GitHub
parent 9ad1d7e3ed
commit 58f79a8851
46 changed files with 1430 additions and 142 deletions
+8 -2
View File
@@ -75,12 +75,18 @@ void OptionProperty::addOptions(std::vector<std::pair<int, std::string>> options
}
}
void OptionProperty::clearOptions() {
_options.clear();
_value = 0;
}
void OptionProperty::setValue(int value) {
// Check if the passed value belongs to any option
for (const Option& o : _options) {
for (int i = 0; i < _options.size(); ++i) {
const Option& o = _options[i];
if (o.value == value) {
// If it does, set it by calling the superclasses setValue method
NumericalProperty::setValue(value);
NumericalProperty::setValue(i);
return;
}
}
+1
View File
@@ -101,6 +101,7 @@ int addScreenSpaceRenderable(lua_State* L) {
ghoul::Dictionary d;
try {
ghoul::lua::luaDictionaryFromState(L, d);
lua_settop(L, 0);
}
catch (const ghoul::lua::LuaFormatException& e) {
LERRORC("addScreenSpaceRenderable", e.what());
+14 -8
View File
@@ -33,6 +33,9 @@
#include <openspace/util/camera.h>
#include <openspace/util/factorymanager.h>
#include <ghoul/filesystem/filesystem.h>
#include <ghoul/misc/defer.h>
namespace {
const char* KeyType = "Type";
const char* KeyTag = "Tag";
@@ -214,7 +217,6 @@ ScreenSpaceRenderable::ScreenSpaceRenderable(const ghoul::Dictionary& dictionary
, _delete(DeleteInfo)
, _quad(0)
, _vertexPositionBuffer(0)
, _texture(nullptr)
, _shader(nullptr)
, _radius(PlaneDepth)
{
@@ -327,8 +329,6 @@ bool ScreenSpaceRenderable::deinitializeGL() {
glDeleteBuffers(1, &_vertexPositionBuffer);
_vertexPositionBuffer = 0;
_texture = nullptr;
RenderEngine& renderEngine = OsEng.renderEngine();
if (_shader) {
renderEngine.removeRenderProgram(_shader);
@@ -343,7 +343,7 @@ void ScreenSpaceRenderable::render() {
}
bool ScreenSpaceRenderable::isReady() const {
return _shader && _texture;
return _shader != nullptr;
}
void ScreenSpaceRenderable::update() {}
@@ -441,8 +441,8 @@ void ScreenSpaceRenderable::createShaders() {
dict.setValue("fragmentPath", "${MODULE_BASE}/shaders/screenspace_fs.glsl");
_shader = ghoul::opengl::ProgramObject::Build(
"ScreenSpaceProgram",
"${MODULE_BASE}/shaders/screenspace_vs.glsl",
"${SHADERS}/render.frag",
absPath("${MODULE_BASE}/shaders/screenspace_vs.glsl"),
absPath("${SHADERS}/render.frag"),
dict
);
@@ -459,7 +459,7 @@ glm::mat4 ScreenSpaceRenderable::scaleMatrix() {
//to scale the plane
float textureRatio =
static_cast<float>(_texture->height()) / static_cast<float>(_texture->width());
static_cast<float>(_objectSize.y) / static_cast<float>(_objectSize.x);
float scalingRatioX = _originalViewportSize.x / resolution.x;
float scalingRatioY = _originalViewportSize.y / resolution.y;
@@ -520,7 +520,8 @@ void ScreenSpaceRenderable::draw(glm::mat4 modelTransform) {
ghoul::opengl::TextureUnit unit;
unit.activate();
_texture->bind();
bindTexture();
defer { unbindTexture(); };
_shader->setUniform(_uniformCache.texture, unit);
glBindVertexArray(_quad);
@@ -531,4 +532,9 @@ void ScreenSpaceRenderable::draw(glm::mat4 modelTransform) {
_shader->deactivate();
}
void ScreenSpaceRenderable::bindTexture() {}
void ScreenSpaceRenderable::unbindTexture() {}
} // namespace openspace