mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-02-22 12:59:07 -06:00
Cleanup of license headers
Cleanup of include guards in modules
This commit is contained in:
@@ -41,220 +41,233 @@ namespace {
|
||||
|
||||
namespace openspace {
|
||||
|
||||
DebugRenderer* DebugRenderer::_reference = nullptr;
|
||||
DebugRenderer* DebugRenderer::_reference = nullptr;
|
||||
|
||||
DebugRenderer::DebugRenderer() {
|
||||
_programObject = OsEng.renderEngine().buildRenderProgram(
|
||||
"BasicDebugShader",
|
||||
"${MODULE_DEBUGGING}/rendering/debugshader_vs.glsl",
|
||||
"${MODULE_DEBUGGING}/rendering/debugshader_fs.glsl"
|
||||
);
|
||||
}
|
||||
DebugRenderer::DebugRenderer() {
|
||||
_programObject = OsEng.renderEngine().buildRenderProgram(
|
||||
"BasicDebugShader",
|
||||
"${MODULE_DEBUGGING}/rendering/debugshader_vs.glsl",
|
||||
"${MODULE_DEBUGGING}/rendering/debugshader_fs.glsl"
|
||||
);
|
||||
}
|
||||
|
||||
DebugRenderer::DebugRenderer(std::unique_ptr<ProgramObject> programObject)
|
||||
: _programObject(std::move(programObject))
|
||||
{
|
||||
// nothing to do
|
||||
}
|
||||
DebugRenderer::DebugRenderer(std::unique_ptr<ghoul::opengl::ProgramObject> programObject)
|
||||
: _programObject(std::move(programObject))
|
||||
{
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
DebugRenderer::~DebugRenderer()
|
||||
{
|
||||
// nothing to do
|
||||
}
|
||||
DebugRenderer::~DebugRenderer()
|
||||
{
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
|
||||
|
||||
const DebugRenderer& DebugRenderer::ref() {
|
||||
if (_reference == nullptr) {
|
||||
try {
|
||||
_reference = new DebugRenderer();
|
||||
}
|
||||
catch (const ShaderObject::ShaderCompileError& e) {
|
||||
LERROR(e.what());
|
||||
}
|
||||
const DebugRenderer& DebugRenderer::ref() {
|
||||
if (_reference == nullptr) {
|
||||
try {
|
||||
_reference = new DebugRenderer();
|
||||
}
|
||||
return *_reference;
|
||||
catch (const ghoul::opengl::ShaderObject::ShaderCompileError& e) {
|
||||
LERROR(e.what());
|
||||
}
|
||||
}
|
||||
return *_reference;
|
||||
}
|
||||
|
||||
void DebugRenderer::renderVertices(const Vertices& clippingSpacePoints, GLenum mode,
|
||||
RGBA rgba) const
|
||||
{
|
||||
if (clippingSpacePoints.size() == 0) {
|
||||
// nothing to render
|
||||
return;
|
||||
}
|
||||
|
||||
void DebugRenderer::renderVertices(const Vertices& clippingSpacePoints, GLenum mode, RGBA rgba) const {
|
||||
if (clippingSpacePoints.size() == 0) {
|
||||
// nothing to render
|
||||
return;
|
||||
}
|
||||
// Generate a vao, vertex array object (keeping track of pointers to vbo)
|
||||
GLuint _vaoID;
|
||||
glGenVertexArrays(1, &_vaoID);
|
||||
ghoul_assert(_vaoID != 0, "Could not generate vertex arrays");
|
||||
|
||||
// Generate a vao, vertex array object (keeping track of pointers to vbo)
|
||||
GLuint _vaoID;
|
||||
glGenVertexArrays(1, &_vaoID);
|
||||
ghoul_assert(_vaoID != 0, "Could not generate vertex arrays");
|
||||
// Generate a vbo, vertex buffer object (storeing actual data)
|
||||
GLuint _vertexBufferID;
|
||||
glGenBuffers(1, &_vertexBufferID);
|
||||
ghoul_assert(_vertexBufferID != 0, "Could not create vertex buffer");
|
||||
|
||||
// Generate a vbo, vertex buffer object (storeing actual data)
|
||||
GLuint _vertexBufferID;
|
||||
glGenBuffers(1, &_vertexBufferID);
|
||||
ghoul_assert(_vertexBufferID != 0, "Could not create vertex buffer");
|
||||
// Activate the shader program and set the uniform color within the shader
|
||||
_programObject->activate();
|
||||
_programObject->setUniform("color", rgba);
|
||||
|
||||
// Activate the shader program and set the uniform color within the shader
|
||||
_programObject->activate();
|
||||
_programObject->setUniform("color", rgba);
|
||||
|
||||
glBindVertexArray(_vaoID);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, _vertexBufferID);
|
||||
glBufferData(
|
||||
GL_ARRAY_BUFFER,
|
||||
clippingSpacePoints.size() * sizeof(clippingSpacePoints[0]),
|
||||
&clippingSpacePoints[0],
|
||||
GL_STATIC_DRAW);
|
||||
glBindVertexArray(_vaoID);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, _vertexBufferID);
|
||||
glBufferData(
|
||||
GL_ARRAY_BUFFER,
|
||||
clippingSpacePoints.size() * sizeof(clippingSpacePoints[0]),
|
||||
&clippingSpacePoints[0],
|
||||
GL_STATIC_DRAW);
|
||||
|
||||
|
||||
glEnableVertexAttribArray(0);
|
||||
glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, sizeof(clippingSpacePoints[0]), 0);
|
||||
glEnableVertexAttribArray(0);
|
||||
glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, sizeof(clippingSpacePoints[0]), 0);
|
||||
|
||||
// Draw the vertices
|
||||
glDrawArrays(mode, 0, clippingSpacePoints.size());
|
||||
// Draw the vertices
|
||||
glDrawArrays(mode, 0, clippingSpacePoints.size());
|
||||
|
||||
// Check for errors
|
||||
GLenum error = glGetError();
|
||||
if (error != GL_NO_ERROR) {
|
||||
// Commenting this line. It causes errors to be printed. However
|
||||
// the errors are not caused by DebugRenderer!!
|
||||
//LERROR(error);
|
||||
}
|
||||
// Check for errors
|
||||
GLenum error = glGetError();
|
||||
if (error != GL_NO_ERROR) {
|
||||
// Commenting this line. It causes errors to be printed. However
|
||||
// the errors are not caused by DebugRenderer!!
|
||||
//LERROR(error);
|
||||
}
|
||||
|
||||
// Clean up after the draw call was made
|
||||
glBindVertexArray(0);
|
||||
glDeleteVertexArrays(1, &_vaoID);
|
||||
glDeleteBuffers(1, &_vertexBufferID);
|
||||
_programObject->deactivate();
|
||||
}
|
||||
// Clean up after the draw call was made
|
||||
glBindVertexArray(0);
|
||||
glDeleteVertexArrays(1, &_vaoID);
|
||||
glDeleteBuffers(1, &_vertexBufferID);
|
||||
_programObject->deactivate();
|
||||
}
|
||||
|
||||
|
||||
void DebugRenderer::renderBoxFaces(const Vertices& clippingSpaceBoxCorners, RGBA rgba) const {
|
||||
ghoul_assert(clippingSpaceBoxCorners.size() == 8, "Box must have 8 vertices");
|
||||
const Vertices& V = clippingSpaceBoxCorners;
|
||||
void DebugRenderer::renderBoxFaces(const Vertices& clippingSpaceBoxCorners,
|
||||
RGBA rgba) const
|
||||
{
|
||||
ghoul_assert(clippingSpaceBoxCorners.size() == 8, "Box must have 8 vertices");
|
||||
const Vertices& V = clippingSpaceBoxCorners;
|
||||
|
||||
std::vector<glm::vec4> T;
|
||||
std::vector<glm::vec4> T;
|
||||
|
||||
// add "sides"
|
||||
T.push_back(V[1]); T.push_back(V[0]); T.push_back(V[4]);
|
||||
T.push_back(V[4]); T.push_back(V[5]); T.push_back(V[1]);
|
||||
// add "sides"
|
||||
T.push_back(V[1]); T.push_back(V[0]); T.push_back(V[4]);
|
||||
T.push_back(V[4]); T.push_back(V[5]); T.push_back(V[1]);
|
||||
|
||||
|
||||
T.push_back(V[3]); T.push_back(V[1]); T.push_back(V[5]);
|
||||
T.push_back(V[5]); T.push_back(V[7]); T.push_back(V[3]);
|
||||
T.push_back(V[3]); T.push_back(V[1]); T.push_back(V[5]);
|
||||
T.push_back(V[5]); T.push_back(V[7]); T.push_back(V[3]);
|
||||
|
||||
T.push_back(V[6]); T.push_back(V[3]); T.push_back(V[7]);
|
||||
T.push_back(V[3]); T.push_back(V[6]); T.push_back(V[2]);
|
||||
T.push_back(V[6]); T.push_back(V[3]); T.push_back(V[7]);
|
||||
T.push_back(V[3]); T.push_back(V[6]); T.push_back(V[2]);
|
||||
|
||||
T.push_back(V[4]); T.push_back(V[2]); T.push_back(V[6]);
|
||||
T.push_back(V[2]); T.push_back(V[4]); T.push_back(V[0]);
|
||||
T.push_back(V[4]); T.push_back(V[2]); T.push_back(V[6]);
|
||||
T.push_back(V[2]); T.push_back(V[4]); T.push_back(V[0]);
|
||||
|
||||
// add "top"
|
||||
T.push_back(V[5]); T.push_back(V[6]); T.push_back(V[7]);
|
||||
T.push_back(V[6]); T.push_back(V[5]); T.push_back(V[4]);
|
||||
// add "top"
|
||||
T.push_back(V[5]); T.push_back(V[6]); T.push_back(V[7]);
|
||||
T.push_back(V[6]); T.push_back(V[5]); T.push_back(V[4]);
|
||||
|
||||
// add bottom
|
||||
T.push_back(V[0]); T.push_back(V[1]); T.push_back(V[2]);
|
||||
T.push_back(V[3]); T.push_back(V[2]); T.push_back(V[1]);
|
||||
// add bottom
|
||||
T.push_back(V[0]); T.push_back(V[1]); T.push_back(V[2]);
|
||||
T.push_back(V[3]); T.push_back(V[2]); T.push_back(V[1]);
|
||||
|
||||
renderVertices(T, GL_TRIANGLES, rgba);
|
||||
}
|
||||
renderVertices(T, GL_TRIANGLES, rgba);
|
||||
}
|
||||
|
||||
void DebugRenderer::renderBoxEdges(const Vertices& clippingSpaceBoxCorners, RGBA rgba) const {
|
||||
ghoul_assert(clippingSpaceBoxCorners.size() == 8, "Box must have 8 vertices");
|
||||
const Vertices& V = clippingSpaceBoxCorners;
|
||||
void DebugRenderer::renderBoxEdges(const Vertices& clippingSpaceBoxCorners,
|
||||
RGBA rgba) const
|
||||
{
|
||||
ghoul_assert(clippingSpaceBoxCorners.size() == 8, "Box must have 8 vertices");
|
||||
const Vertices& V = clippingSpaceBoxCorners;
|
||||
|
||||
std::vector<glm::vec4> lineVertices;
|
||||
std::vector<glm::vec4> lineVertices;
|
||||
|
||||
for (size_t i = 0; i < 4; i++) {
|
||||
lineVertices.push_back(V[2 * i]);
|
||||
lineVertices.push_back(V[2 * i + 1]);
|
||||
lineVertices.push_back(V[i]);
|
||||
lineVertices.push_back(V[i + 4]);
|
||||
for (size_t i = 0; i < 4; i++) {
|
||||
lineVertices.push_back(V[2 * i]);
|
||||
lineVertices.push_back(V[2 * i + 1]);
|
||||
lineVertices.push_back(V[i]);
|
||||
lineVertices.push_back(V[i + 4]);
|
||||
}
|
||||
lineVertices.push_back(V[0]); lineVertices.push_back(V[2]);
|
||||
lineVertices.push_back(V[1]); lineVertices.push_back(V[3]);
|
||||
lineVertices.push_back(V[4]); lineVertices.push_back(V[6]);
|
||||
lineVertices.push_back(V[5]); lineVertices.push_back(V[7]);
|
||||
|
||||
DebugRenderer::ref().renderVertices(lineVertices, GL_LINES, rgba);
|
||||
}
|
||||
|
||||
void DebugRenderer::renderNiceBox(const Vertices& clippingSpaceBoxCorners,
|
||||
RGBA rgba) const
|
||||
{
|
||||
renderBoxFaces(clippingSpaceBoxCorners, rgba);
|
||||
|
||||
glLineWidth(4.0f);
|
||||
DebugRenderer::ref().renderBoxEdges(clippingSpaceBoxCorners, rgba);
|
||||
|
||||
glPointSize(10.0f);
|
||||
DebugRenderer::ref().renderVertices(clippingSpaceBoxCorners, GL_POINTS, rgba);
|
||||
}
|
||||
|
||||
void DebugRenderer::renderCameraFrustum(const RenderData& data, const Camera& otherCamera,
|
||||
RGBA rgba) const
|
||||
{
|
||||
using namespace glm;
|
||||
dmat4 modelTransform = translate(dmat4(1), data.position.dvec3());
|
||||
dmat4 viewTransform = dmat4(data.camera.combinedViewMatrix());
|
||||
dmat4 vp = dmat4(data.camera.projectionMatrix()) * viewTransform;
|
||||
|
||||
dmat4 inverseSavedV = glm::inverse(otherCamera.combinedViewMatrix());
|
||||
dmat4 inverseSavedP = glm::inverse(otherCamera.projectionMatrix());
|
||||
Vertices clippingSpaceFrustumCorners(8);
|
||||
// loop through the corners of the saved camera frustum
|
||||
for (size_t i = 0; i < 8; i++) {
|
||||
bool cornerIsRight = i % 2 == 0;
|
||||
bool cornerIsUp = i > 3;
|
||||
bool cornerIsFar = (i / 2) % 2 == 1;
|
||||
|
||||
double x = cornerIsRight ? 1 : -1;
|
||||
double y = cornerIsUp ? 1 : -1;
|
||||
double z = cornerIsFar ? 1 : 0;
|
||||
|
||||
// p represents a corner in the frustum of the saved camera
|
||||
dvec4 pSavedClippingSpace(x, y, z, 1);
|
||||
dvec4 pSavedCameraSpace = inverseSavedP * pSavedClippingSpace;
|
||||
if (cornerIsFar) {
|
||||
pSavedCameraSpace.w *= 1e-7;
|
||||
}
|
||||
lineVertices.push_back(V[0]); lineVertices.push_back(V[2]);
|
||||
lineVertices.push_back(V[1]); lineVertices.push_back(V[3]);
|
||||
lineVertices.push_back(V[4]); lineVertices.push_back(V[6]);
|
||||
lineVertices.push_back(V[5]); lineVertices.push_back(V[7]);
|
||||
pSavedCameraSpace = glm::abs(1.0 / pSavedCameraSpace.w) * pSavedCameraSpace;
|
||||
|
||||
DebugRenderer::ref().renderVertices(lineVertices, GL_LINES, rgba);
|
||||
dvec4 pWorldSpace = inverseSavedV * pSavedCameraSpace;
|
||||
dvec4 pCurrentClippingSpace = vp * pWorldSpace;
|
||||
clippingSpaceFrustumCorners[i] = pCurrentClippingSpace;
|
||||
}
|
||||
|
||||
void DebugRenderer::renderNiceBox(const Vertices& clippingSpaceBoxCorners, RGBA rgba) const {
|
||||
renderBoxFaces(clippingSpaceBoxCorners, rgba);
|
||||
|
||||
glLineWidth(4.0f);
|
||||
DebugRenderer::ref().renderBoxEdges(clippingSpaceBoxCorners, rgba);
|
||||
|
||||
glPointSize(10.0f);
|
||||
DebugRenderer::ref().renderVertices(clippingSpaceBoxCorners, GL_POINTS, rgba);
|
||||
}
|
||||
|
||||
void DebugRenderer::renderCameraFrustum(const RenderData& data, const Camera& otherCamera, RGBA rgba) const {
|
||||
using namespace glm;
|
||||
dmat4 modelTransform = translate(dmat4(1), data.position.dvec3());
|
||||
dmat4 viewTransform = dmat4(data.camera.combinedViewMatrix());
|
||||
dmat4 vp = dmat4(data.camera.projectionMatrix()) * viewTransform;
|
||||
|
||||
dmat4 inverseSavedV = glm::inverse(otherCamera.combinedViewMatrix());
|
||||
dmat4 inverseSavedP = glm::inverse(otherCamera.projectionMatrix());
|
||||
Vertices clippingSpaceFrustumCorners(8);
|
||||
// loop through the corners of the saved camera frustum
|
||||
for (size_t i = 0; i < 8; i++) {
|
||||
bool cornerIsRight = i % 2 == 0;
|
||||
bool cornerIsUp = i > 3;
|
||||
bool cornerIsFar = (i / 2) % 2 == 1;
|
||||
|
||||
double x = cornerIsRight ? 1 : -1;
|
||||
double y = cornerIsUp ? 1 : -1;
|
||||
double z = cornerIsFar ? 1 : 0;
|
||||
|
||||
// p represents a corner in the frustum of the saved camera
|
||||
dvec4 pSavedClippingSpace(x, y, z, 1);
|
||||
dvec4 pSavedCameraSpace = inverseSavedP * pSavedClippingSpace;
|
||||
if (cornerIsFar) {
|
||||
pSavedCameraSpace.w *= 1e-7;
|
||||
}
|
||||
pSavedCameraSpace = glm::abs(1.0 / pSavedCameraSpace.w) * pSavedCameraSpace;
|
||||
|
||||
dvec4 pWorldSpace = inverseSavedV * pSavedCameraSpace;
|
||||
dvec4 pCurrentClippingSpace = vp * pWorldSpace;
|
||||
clippingSpaceFrustumCorners[i] = pCurrentClippingSpace;
|
||||
}
|
||||
|
||||
|
||||
glDisable(GL_CULL_FACE);
|
||||
renderNiceBox(clippingSpaceFrustumCorners, rgba);
|
||||
glEnable(GL_CULL_FACE);
|
||||
}
|
||||
glDisable(GL_CULL_FACE);
|
||||
renderNiceBox(clippingSpaceFrustumCorners, rgba);
|
||||
glEnable(GL_CULL_FACE);
|
||||
}
|
||||
|
||||
#ifdef OPENSPACE_MODULE_GLOBEBROWSING_ENABLED
|
||||
void DebugRenderer::renderAABB2(const globebrowsing::AABB2& screenSpaceAABB, RGBA rgba) const {
|
||||
Vertices vertices(4);
|
||||
vertices[0] = glm::vec4(screenSpaceAABB.min.x, screenSpaceAABB.min.y, 1, 1);
|
||||
vertices[1] = glm::vec4(screenSpaceAABB.min.x, screenSpaceAABB.max.y, 1, 1);
|
||||
vertices[2] = glm::vec4(screenSpaceAABB.max.x, screenSpaceAABB.min.y, 1, 1);
|
||||
vertices[3] = glm::vec4(screenSpaceAABB.max.x, screenSpaceAABB.max.y, 1, 1);
|
||||
void DebugRenderer::renderAABB2(const globebrowsing::AABB2& screenSpaceAABB,
|
||||
RGBA rgba) const
|
||||
{
|
||||
Vertices vertices(4);
|
||||
vertices[0] = glm::vec4(screenSpaceAABB.min.x, screenSpaceAABB.min.y, 1, 1);
|
||||
vertices[1] = glm::vec4(screenSpaceAABB.min.x, screenSpaceAABB.max.y, 1, 1);
|
||||
vertices[2] = glm::vec4(screenSpaceAABB.max.x, screenSpaceAABB.min.y, 1, 1);
|
||||
vertices[3] = glm::vec4(screenSpaceAABB.max.x, screenSpaceAABB.max.y, 1, 1);
|
||||
|
||||
renderVertices(vertices, GL_LINES, rgba);
|
||||
}
|
||||
renderVertices(vertices, GL_LINES, rgba);
|
||||
}
|
||||
#endif // OPENSPACE_MODULE_GLOBEBROWSING_ENABLED
|
||||
|
||||
#ifdef OPENSPACE_MODULE_GLOBEBROWSING_ENABLED
|
||||
const DebugRenderer::Vertices DebugRenderer::verticesFor(const globebrowsing::AABB3& screenSpaceAABB) const {
|
||||
Vertices vertices(8);
|
||||
for (size_t i = 0; i < 8; i++) {
|
||||
bool cornerIsRight = i % 2 == 0;
|
||||
bool cornerIsUp = i > 3;
|
||||
bool cornerIsFar = (i / 2) % 2 == 1;
|
||||
const DebugRenderer::Vertices DebugRenderer::verticesFor(
|
||||
const globebrowsing::AABB3& screenSpaceAABB) const
|
||||
{
|
||||
Vertices vertices(8);
|
||||
for (size_t i = 0; i < 8; i++) {
|
||||
bool cornerIsRight = i % 2 == 0;
|
||||
bool cornerIsUp = i > 3;
|
||||
bool cornerIsFar = (i / 2) % 2 == 1;
|
||||
|
||||
double x = cornerIsRight ? screenSpaceAABB.max.x : screenSpaceAABB.min.x;
|
||||
double y = cornerIsUp ? screenSpaceAABB.max.y : screenSpaceAABB.min.y;
|
||||
double z = cornerIsFar ? screenSpaceAABB.max.z : screenSpaceAABB.min.z;
|
||||
double x = cornerIsRight ? screenSpaceAABB.max.x : screenSpaceAABB.min.x;
|
||||
double y = cornerIsUp ? screenSpaceAABB.max.y : screenSpaceAABB.min.y;
|
||||
double z = cornerIsFar ? screenSpaceAABB.max.z : screenSpaceAABB.min.z;
|
||||
|
||||
vertices[i] = glm::vec4(x, y, z, 1);
|
||||
}
|
||||
return std::move(vertices);
|
||||
vertices[i] = glm::vec4(x, y, z, 1);
|
||||
}
|
||||
return std::move(vertices);
|
||||
}
|
||||
#endif // OPENSPACE_MODULE_GLOBEBROWSING_ENABLED
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
|
||||
@@ -22,8 +22,8 @@
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#ifndef __DEBUG_RENDERER_H__
|
||||
#define __DEBUG_RENDERER_H__
|
||||
#ifndef __OPENSPACE_MODULE_BASE___DEBUGRENDERER___H__
|
||||
#define __OPENSPACE_MODULE_BASE___DEBUGRENDERER___H__
|
||||
|
||||
#include <ghoul/opengl/ghoul_gl.h>
|
||||
#include <ghoul/opengl/programobject.h>
|
||||
@@ -36,126 +36,130 @@
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
|
||||
|
||||
#include <ghoul/misc/assert.h>
|
||||
|
||||
namespace openspace {
|
||||
using namespace ghoul::opengl;
|
||||
|
||||
/**
|
||||
* A helper class for quick rendering of vertices IN clipping space.
|
||||
* The class is practically stateless. It only stores a ghoul::opengl::ProgramObject
|
||||
* which can be reused despite the fact that rendering calls are invoked from different
|
||||
* callers. Therefore a static reference is provided for convenience which is accessed
|
||||
* through ref(). Note: That constructors are still public and the class is not a strict
|
||||
* singleton.
|
||||
*/
|
||||
class DebugRenderer {
|
||||
public:
|
||||
typedef std::vector<glm::vec4> Vertices;
|
||||
typedef glm::vec4 RGBA;
|
||||
|
||||
/**
|
||||
A helper class for quick rendering of vertices IN clipping space.
|
||||
* Consider using ref() before creating a new default instance!
|
||||
*/
|
||||
DebugRenderer();
|
||||
|
||||
The class is practically stateless. It only stores a ghoul::opengl::ProgramObject
|
||||
which can be reused despite the fact that rendering calls are invoked from different callers.
|
||||
Therefor a static reference is provided for convenience which is accessed through ref(). Note:
|
||||
That constructors are still public and the class is not a strict singleton.
|
||||
*/
|
||||
class DebugRenderer {
|
||||
public:
|
||||
typedef std::vector<glm::vec4> Vertices;
|
||||
typedef glm::vec4 RGBA;
|
||||
/**
|
||||
* Instantiate a new DebugRenderer with a custom shader program
|
||||
*/
|
||||
DebugRenderer(std::unique_ptr<ghoul::opengl::ProgramObject> programObject);
|
||||
~DebugRenderer();
|
||||
|
||||
/**
|
||||
* Consider using ref() before creating a new default instance!
|
||||
*/
|
||||
DebugRenderer();
|
||||
/**
|
||||
* Access the static reference
|
||||
*/
|
||||
static const DebugRenderer& ref();
|
||||
|
||||
/**
|
||||
* Instantiate a new DebugRenderer with a custom shader program
|
||||
*/
|
||||
DebugRenderer(std::unique_ptr<ProgramObject> programObject);
|
||||
~DebugRenderer();
|
||||
/**
|
||||
* Render the vector of clipping space points in the specified mode and color.
|
||||
*/
|
||||
void renderVertices(const Vertices& clippingSpacePoints, GLenum mode,
|
||||
RGBA color = {1, 0, 0, 1}) const;
|
||||
|
||||
/**
|
||||
* Access the static reference
|
||||
*/
|
||||
static const DebugRenderer& ref();
|
||||
|
||||
/**
|
||||
* Render the vector of clipping space points in the specified mode and color.
|
||||
*/
|
||||
void renderVertices(const Vertices& clippingSpacePoints, GLenum mode, RGBA = {1, 0, 0, 1}) const;
|
||||
|
||||
/**
|
||||
* Takes a vector of exactly 8 vertices, i.e. corner points in a box.
|
||||
* The box corners should be ordered from smaller to larger,
|
||||
* first by x, the, y and finally z.
|
||||
*
|
||||
* 6-------7
|
||||
* |\ |\
|
||||
* | 2-------3
|
||||
* 4 | - - 5 |
|
||||
* \| \|
|
||||
* 0-------1
|
||||
*
|
||||
*/
|
||||
void renderBoxFaces(const Vertices& clippingSpaceBoxCorners, RGBA rgba = { 1, 0, 0, 1 }) const;
|
||||
/**
|
||||
* Takes a vector of exactly 8 vertices, i.e. corner points in a box.
|
||||
* The box corners should be ordered from smaller to larger,
|
||||
* first by x, the, y and finally z.
|
||||
*
|
||||
* 6-------7
|
||||
* |\ |\
|
||||
* | 2-------3
|
||||
* 4 | - - 5 |
|
||||
* \| \|
|
||||
* 0-------1
|
||||
*
|
||||
*/
|
||||
void renderBoxFaces(const Vertices& clippingSpaceBoxCorners,
|
||||
RGBA rgba = { 1, 0, 0, 1 }) const;
|
||||
|
||||
/**
|
||||
* Takes a vector of exactly 8 vertices, i.e. corner points in a box.
|
||||
* The box corners should be ordered from smaller to larger,
|
||||
* first by x, the, y and finally z.
|
||||
*
|
||||
* 6-------7
|
||||
* |\ |\
|
||||
* | 2-------3
|
||||
* 4 | - - 5 |
|
||||
* \| \|
|
||||
* 0-------1
|
||||
*
|
||||
*/
|
||||
void renderBoxEdges(const Vertices& clippingSpaceBoxCorners, RGBA rgba = { 1, 0, 0, 1 }) const;
|
||||
/**
|
||||
* Takes a vector of exactly 8 vertices, i.e. corner points in a box.
|
||||
* The box corners should be ordered from smaller to larger,
|
||||
* first by x, the, y and finally z.
|
||||
*
|
||||
* 6-------7
|
||||
* |\ |\
|
||||
* | 2-------3
|
||||
* 4 | - - 5 |
|
||||
* \| \|
|
||||
* 0-------1
|
||||
*
|
||||
*/
|
||||
void renderBoxEdges(const Vertices& clippingSpaceBoxCorners,
|
||||
RGBA rgba = { 1, 0, 0, 1 }) const;
|
||||
|
||||
/**
|
||||
* Takes a vector of exactly 8 vertices, i.e. corner points in a box.
|
||||
* The box corners should be ordered from smaller to larger,
|
||||
* first by x, the, y and finally z.
|
||||
*
|
||||
* 6-------7
|
||||
* |\ |\
|
||||
* | 2-------3
|
||||
* 4 | - - 5 |
|
||||
* \| \|
|
||||
* 0-------1
|
||||
*
|
||||
*/
|
||||
void renderNiceBox(const Vertices& clippingSpaceBoxCorners, RGBA rgba = { 1, 0, 0, 0.3 }) const;
|
||||
/**
|
||||
* Takes a vector of exactly 8 vertices, i.e. corner points in a box.
|
||||
* The box corners should be ordered from smaller to larger,
|
||||
* first by x, the, y and finally z.
|
||||
*
|
||||
* 6-------7
|
||||
* |\ |\
|
||||
* | 2-------3
|
||||
* 4 | - - 5 |
|
||||
* \| \|
|
||||
* 0-------1
|
||||
*
|
||||
*/
|
||||
void renderNiceBox(const Vertices& clippingSpaceBoxCorners,
|
||||
RGBA rgba = { 1, 0, 0, 0.3 }) const;
|
||||
|
||||
/**
|
||||
* Input arguments:
|
||||
* 1. const RenderData& data: defines position and camera that we will see the
|
||||
* other cameras view frustum from
|
||||
* 2. const Camera& otherCamera: The camera who's view frustum is to be rendered
|
||||
* 3. RGBA rgba Color to draw the view frustum with
|
||||
*/
|
||||
void renderCameraFrustum(const RenderData& data, const Camera& otherCamera, RGBA rgba = { 1, 1, 1, 0.3 }) const;
|
||||
/**
|
||||
* Input arguments:
|
||||
* 1. const RenderData& data: defines position and camera that we will see the
|
||||
* other cameras view frustum from
|
||||
* 2. const Camera& otherCamera: The camera who's view frustum is to be rendered
|
||||
* 3. RGBA rgba Color to draw the view frustum with
|
||||
*/
|
||||
void renderCameraFrustum(const RenderData& data, const Camera& otherCamera,
|
||||
RGBA rgba = { 1, 1, 1, 0.3 }) const;
|
||||
|
||||
#ifdef OPENSPACE_MODULE_GLOBEBROWSING_ENABLED
|
||||
/**
|
||||
* Renders a screen space AABB2 to the screen with the provided color
|
||||
*/
|
||||
void renderAABB2(const globebrowsing::AABB2& screenSpaceAABB, RGBA rgba = { 1, 1, 1, 0.3 }) const;
|
||||
/**
|
||||
* Renders a screen space AABB2 to the screen with the provided color
|
||||
*/
|
||||
void renderAABB2(const globebrowsing::AABB2& screenSpaceAABB,
|
||||
RGBA rgba = { 1, 1, 1, 0.3 }) const;
|
||||
#endif // OPENSPACE_MODULE_GLOBEBROWSING_ENABLED
|
||||
|
||||
|
||||
#ifdef OPENSPACE_MODULE_GLOBEBROWSING_ENABLED
|
||||
/**
|
||||
* Takes a AABB3 in screen space and returns vertices representing the corner points
|
||||
* of the AABB. The ordering of the corner points is compatible with the box rendering
|
||||
* methods in this class.
|
||||
*/
|
||||
const Vertices verticesFor(const globebrowsing::AABB3& screenSpaceAABB) const;
|
||||
/**
|
||||
* Takes a AABB3 in screen space and returns vertices representing the corner points
|
||||
* of the AABB. The ordering of the corner points is compatible with the box
|
||||
* rendering methods in this class.
|
||||
*/
|
||||
const Vertices verticesFor(const globebrowsing::AABB3& screenSpaceAABB) const;
|
||||
#endif // OPENSPACE_MODULE_GLOBEBROWSING_ENABLED
|
||||
|
||||
protected:
|
||||
std::unique_ptr<ProgramObject> _programObject;
|
||||
protected:
|
||||
std::unique_ptr<ghoul::opengl::ProgramObject> _programObject;
|
||||
|
||||
|
||||
// A raw pointer for the reason that it should not be deleted by the static
|
||||
// destructor and the normal destructor. This class has ownership
|
||||
static DebugRenderer* _reference;
|
||||
};
|
||||
// A raw pointer for the reason that it should not be deleted by the static
|
||||
// destructor and the normal destructor. This class has ownership
|
||||
static DebugRenderer* _reference;
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
#endif // __DEBUG_RENDERER_H__
|
||||
|
||||
#endif // __OPENSPACE_MODULE_BASE___DEBUGRENDERER___H__
|
||||
|
||||
@@ -22,8 +22,8 @@
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#ifndef __RENDERABLEDEBUGPLANE_H__
|
||||
#define __RENDERABLEDEBUGPLANE_H__
|
||||
#ifndef __OPENSPACE_MODULE_BASE___RENDERABLEDEBUGPLANE___H__
|
||||
#define __OPENSPACE_MODULE_BASE___RENDERABLEDEBUGPLANE___H__
|
||||
|
||||
#include <openspace/rendering/renderable.h>
|
||||
|
||||
@@ -82,4 +82,4 @@ private:
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
#endif // __RENDERABLEDEBUGPLANE_H__
|
||||
#endif // __OPENSPACE_MODULE_BASE___RENDERABLEDEBUGPLANE___H__
|
||||
|
||||
Reference in New Issue
Block a user