Merged with feature/ABuffer

This commit is contained in:
Hans-Christian Helltegen
2014-06-27 15:49:49 -04:00
54 changed files with 2550 additions and 585 deletions

View File

@@ -0,0 +1,90 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014 *
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
* software and associated documentation files (the "Software"), to deal in the Software *
* without restriction, including without limitation the rights to use, copy, modify, *
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
* permit persons to whom the Software is furnished to do so, subject to the following *
* conditions: *
* *
* The above copyright notice and this permission notice shall be included in all copies *
* or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#ifndef __ABUFFER_H__
#define __ABUFFER_H__
#include <openspace/abuffer/abuffer_i.h>
#include <ghoul/opengl/ghoul_gl.h>
#include <ghoul/glm.h>
#include <ghoul/opengl/programobject.h>
#include <ghoul/filesystem/file.h>
namespace ghoul {
namespace opengl {
class Texture;
}
}
namespace openspace {
class ABuffer: public ABuffer_I {
public:
ABuffer();
virtual ~ABuffer();
virtual void resolve();
void addVolume(const std::string& tag,ghoul::opengl::Texture* volume);
void addTransferFunction(const std::string& tag,ghoul::opengl::Texture* transferFunction);
int addSamplerfile(const std::string& filename);
protected:
virtual std::string settings() = 0;
bool initializeABuffer();
void generateShaderSource();
bool updateShader();
std::string openspaceHeaders();
std::string openspaceSamplerCalls();
std::string openspaceSamplers();
unsigned int _width, _height, _totalPixels;
private:
GLuint _screenQuad;
bool _validShader;
std::string _fragmentShaderPath;
ghoul::filesystem::File* _fragmentShaderFile;
ghoul::opengl::ProgramObject* _resolveShader;
std::vector<std::pair<std::string,ghoul::opengl::Texture*> > _volumes;
std::vector<std::pair<std::string,ghoul::opengl::Texture*> > _transferFunctions;
std::vector<ghoul::filesystem::File*> _samplerFiles;
std::vector<std::string> _samplers;
// Development functionality to update shader for changes in several files
std::vector<ghoul::filesystem::File*> _shaderFiles;
}; // ABuffer
} // openspace
#endif // __ABUFFER_H__

View File

@@ -0,0 +1,60 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014 *
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
* software and associated documentation files (the "Software"), to deal in the Software *
* without restriction, including without limitation the rights to use, copy, modify, *
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
* permit persons to whom the Software is furnished to do so, subject to the following *
* conditions: *
* *
* The above copyright notice and this permission notice shall be included in all copies *
* or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#ifndef __ABUFFERSINGLELINKED_H__
#define __ABUFFERSINGLELINKED_H__
#include <openspace/abuffer/abuffer.h>
namespace openspace {
class ABufferSingleLinked: public ABuffer {
public:
ABufferSingleLinked();
virtual ~ABufferSingleLinked();
virtual bool initialize();
virtual void clear();
virtual void preRender();
virtual void postRender();
virtual std::string settings();
private:
GLuint *_data;
GLuint _anchorPointerTexture;
GLuint _anchorPointerTextureInitializer;
GLuint _atomicCounterBuffer;
GLuint _fragmentBuffer;
GLuint _fragmentTexture;
}; // ABuffer_I
} // openspace
#endif // __ABUFFERSINGLELINKED_H__

View File

@@ -0,0 +1,43 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014 *
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
* software and associated documentation files (the "Software"), to deal in the Software *
* without restriction, including without limitation the rights to use, copy, modify, *
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
* permit persons to whom the Software is furnished to do so, subject to the following *
* conditions: *
* *
* The above copyright notice and this permission notice shall be included in all copies *
* or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#ifndef __ABUFFER_I_H__
#define __ABUFFER_I_H__
namespace openspace {
class ABuffer_I {
public:
virtual ~ABuffer_I() {};
virtual bool initialize() = 0;
virtual void clear() = 0;
virtual void preRender() = 0;
virtual void postRender() = 0;
virtual void resolve() = 0;
}; // ABuffer_I
} // openspace
#endif // __ABUFFER_I_H__

View File

@@ -34,6 +34,8 @@
#include <ghoul/opencl/clprogram.h>
#include <ghoul/opencl/clkernel.h>
//#define FLARE_ONLY
#include <openspace/flare/flare.h>
namespace openspace {
@@ -81,6 +83,9 @@ private:
ghoul::Dictionary* _configurationManager;
InteractionHandler* _interactionHandler;
RenderEngine* _renderEngine;
#ifdef FLARE_ONLY
Flare* _flare;
#endif
// ScriptEngine* _scriptEngine;
ghoul::opencl::CLContext _context;

View File

@@ -53,6 +53,7 @@ public:
void keyboard(int key, int action);
void mouse(int button, int action);
void preSync();
void postSyncPreDraw();
void postDraw();
void encode();
void decode();

View File

@@ -32,12 +32,6 @@
#include <ghoul/opengl/programobject.h>
#include <ghoul/filesystem/file.h>
#ifdef __APPLE__
#include <memory>
#else
#include <mutex>
#endif
namespace openspace {
class RenderableFieldlines : public Renderable {
@@ -61,8 +55,6 @@ private:
ghoul::opengl::ProgramObject *_fieldlinesProgram;
GLuint _VAO, _seedpointVAO;
std::mutex* _shaderMutex;
ghoul::filesystem::File* _vertexSourceFile;
ghoul::filesystem::File* _fragmentSourceFile;
@@ -70,6 +62,7 @@ private:
std::vector<GLsizei> _lineCount;
bool _programUpdateOnSave;
bool _update;
void safeShaderCompilation();
};

View File

@@ -27,7 +27,6 @@
// open space includes
#include <openspace/rendering/renderablevolume.h>
#include <openspace/rendering/volumeraycasterbox.h>
// ghoul includes
#include <ghoul/opengl/programobject.h>
@@ -36,11 +35,9 @@
#include <ghoul/io/rawvolumereader.h>
#include <ghoul/filesystem/file.h>
#ifdef __APPLE__
#include <memory>
#else
#include <mutex>
#endif
namespace sgct_utils {
class SGCTBox;
}
namespace openspace {
@@ -58,22 +55,24 @@ public:
private:
ghoul::Dictionary _hintsDictionary;
std::string _filename;
float _stepSize;
ghoul::opengl::Texture* _volume;
ghoul::opengl::ProgramObject* _twopassProgram;
GLuint _screenQuad;
VolumeRaycasterBox* _colorBoxRenderer;
std::string _filename;
std::string _transferFunctionPath;
std::string _samplerFilename;
ghoul::filesystem::File* _transferFunctionFile;
ghoul::opengl::Texture* _volume;
ghoul::opengl::Texture* _transferFunction;
GLuint _boxArray;
ghoul::opengl::ProgramObject *_boxProgram;
sgct_utils::SGCTBox* _box;
glm::vec3 _boxScaling;
GLint _MVPLocation, _modelTransformLocation, _typeLocation;
std::mutex* _shaderMutex;
ghoul::filesystem::File* _vertexSourceFile;
ghoul::filesystem::File* _fragmentSourceFile;
bool _programUpdateOnSave;
void safeShaderCompilation();
bool _updateTransferfunction;
int _id;
};
} // namespace openspace

View File

@@ -30,6 +30,8 @@
#include <memory>
#include <string>
#include <openspace/abuffer/abuffer.h>
namespace openspace {
class Camera;
@@ -45,6 +47,7 @@ public:
SceneGraph* sceneGraph();
Camera* camera() const;
ABuffer* abuffer() const;
// sgct wrapped functions
bool initializeGL();
@@ -58,6 +61,8 @@ public:
private:
Camera* _mainCamera;
SceneGraph* _sceneGraph;
ABuffer* _abuffer;
};
} // namespace openspace

View File

@@ -45,7 +45,7 @@ public:
VolumeRaycasterBox();
~VolumeRaycasterBox();
bool initialize();
void render(const glm::mat4& MVP);
void render(const glm::mat4& MVP, const glm::mat4& transform = glm::mat4(1.0), int type = 0);
ghoul::opengl::Texture* backFace();
ghoul::opengl::Texture* frontFace();
@@ -56,7 +56,7 @@ private:
ghoul::opengl::Texture *_backTexture, *_frontTexture;
ghoul::opengl::ProgramObject *_boxProgram;
sgct_utils::SGCTBox* _boundingBox;
GLint _MVPLocation;
GLint _MVPLocation, _modelTransformLocation, _typeLocation;
glm::size2_t _dimensions;
};

View File

@@ -70,6 +70,7 @@ public:
// bounding sphere
PowerScaledScalar calculateBoundingSphere();
PowerScaledScalar boundingSphere() const;
SceneGraphNode* get(const std::string& name);