Make debug plane a ScreenSpaceRenderable and add documentation (#3483)

* Add screenspace version of debug plane, and an example

* Remove the old renderable

* Apply suggestions from code review

Co-authored-by: Alexander Bock <alexander.bock@liu.se>

---------

Co-authored-by: Alexander Bock <alexander.bock@liu.se>
This commit is contained in:
Emma Broman
2025-01-17 13:47:37 +01:00
committed by GitHub
parent 16aa150f10
commit e643e8d653
5 changed files with 49 additions and 32 deletions

View File

@@ -26,16 +26,16 @@ include(${PROJECT_SOURCE_DIR}/support/cmake/module_definition.cmake)
set(HEADER_FILES
debuggingmodule.h
rendering/renderabledebugplane.h
rendering/debugrenderer.h
rendering/screenspacedebugplane.h
)
source_group("Header Files" FILES ${HEADER_FILES})
set(SOURCE_FILES
debuggingmodule.cpp
debuggingmodule_lua.inl
rendering/renderabledebugplane.cpp
rendering/debugrenderer.cpp
rendering/screenspacedebugplane.cpp
)
source_group("Source Files" FILES ${SOURCE_FILES})

View File

@@ -24,7 +24,7 @@
#include <modules/debugging/debuggingmodule.h>
#include <modules/debugging/rendering/renderabledebugplane.h>
#include <modules/debugging/rendering/screenspacedebugplane.h>
#include <openspace/documentation/documentation.h>
#include <openspace/engine/configuration.h>
#include <openspace/engine/globals.h>
@@ -136,11 +136,11 @@ DebuggingModule::DebuggingModule()
}
void DebuggingModule::internalInitialize(const ghoul::Dictionary&) {
ghoul::TemplateFactory<Renderable>* fRenderable =
FactoryManager::ref().factory<Renderable>();
ghoul_assert(fRenderable, "No renderable factory existed");
ghoul::TemplateFactory<ScreenSpaceRenderable>* fSsRenderable =
FactoryManager::ref().factory<ScreenSpaceRenderable>();
ghoul_assert(fSsRenderable, "ScreenSpaceRenderable factory was not created");
fRenderable->registerClass<RenderableDebugPlane>("RenderableDebugPlane");
fSsRenderable->registerClass<ScreenSpaceDebugPlane>("ScreenSpaceDebugPlane");
}
void DebuggingModule::internalInitializeGL() {
@@ -150,7 +150,7 @@ void DebuggingModule::internalInitializeGL() {
std::vector<documentation::Documentation> DebuggingModule::documentations() const {
return {
RenderableDebugPlane::Documentation()
ScreenSpaceDebugPlane::Documentation()
};
}

View File

@@ -22,7 +22,7 @@
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#include <modules/debugging/rendering/renderabledebugplane.h>
#include <modules/debugging/rendering/screenspacedebugplane.h>
#include <openspace/documentation/documentation.h>
@@ -34,37 +34,34 @@ namespace {
openspace::properties::Property::Visibility::AdvancedUser
};
struct [[codegen::Dictionary(RenderableDebugPlane)]] Parameters {
// This `ScreenSpaceRenderable` can be used for debugging OpenGL textures. It renders
// the content of an existing texture, based on a provided OpenGL texture name.
struct [[codegen::Dictionary(ScreenSpaceDebugPlane)]] Parameters {
// [[codegen::verbatim(TextureInfo.description)]]
std::optional<int> texture;
};
#include "renderabledebugplane_codegen.cpp"
#include "screenspacedebugplane_codegen.cpp"
} // namespace
namespace openspace {
documentation::Documentation RenderableDebugPlane::Documentation() {
return codegen::doc<Parameters>(
"debugging_renderable_debugplane",
RenderablePlane::Documentation()
);
documentation::Documentation ScreenSpaceDebugPlane::Documentation() {
return codegen::doc<Parameters>("debugging_screenspace_debugplane");
}
RenderableDebugPlane::RenderableDebugPlane(const ghoul::Dictionary& dictionary)
: RenderablePlane(dictionary)
, _texture(TextureInfo, -1, -1, 512)
ScreenSpaceDebugPlane::ScreenSpaceDebugPlane(const ghoul::Dictionary& dictionary)
: ScreenSpaceRenderable(dictionary)
, _texture(TextureInfo, -1, -1, 4096)
{
const Parameters p = codegen::bake<Parameters>(dictionary);
_texture = p.texture.value_or(_texture);
addProperty(_texture);
_objectSize = glm::ivec2(256);
}
bool RenderableDebugPlane::isReady() const {
return _texture >= 0 && RenderablePlane::isReady();
}
void RenderableDebugPlane::bindTexture() {
void ScreenSpaceDebugPlane::bindTexture() {
glBindTexture(GL_TEXTURE_2D, _texture);
}

View File

@@ -22,18 +22,18 @@
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#ifndef __OPENSPACE_MODULE_DEBUGGING___RENDERABLEDEBUGPLANE___H__
#define __OPENSPACE_MODULE_DEBUGGING___RENDERABLEDEBUGPLANE___H__
#ifndef __OPENSPACE_MODULE_DEBUGGING___SCREENSPACEDEBUGPLANE___H__
#define __OPENSPACE_MODULE_DEBUGGING___SCREENSPACEDEBUGPLANE___H__
#include <modules/base/rendering/renderableplane.h>
#include <openspace/rendering/screenspacerenderable.h>
#include <openspace/properties/scalar/intproperty.h>
namespace openspace {
class RenderableDebugPlane : public RenderablePlane {
class ScreenSpaceDebugPlane : public ScreenSpaceRenderable {
public:
RenderableDebugPlane(const ghoul::Dictionary& dictionary);
bool isReady() const override;
ScreenSpaceDebugPlane(const ghoul::Dictionary& dictionary);
static documentation::Documentation Documentation();
@@ -45,4 +45,4 @@ private:
} // namespace openspace
#endif // __OPENSPACE_MODULE_DEBUGGING___RENDERABLEDEBUGPLANE___H__
#endif // __OPENSPACE_MODULE_DEBUGGING___SCREENSPACEDEBUGPLANE___H__