Skip to content

Commit

Permalink
Using Panda's managed pointer for texture and buffers to avoid memory…
Browse files Browse the repository at this point in the history
… leaks
  • Loading branch information
SamFlt committed Sep 5, 2024
1 parent f025d37 commit 983d558
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
8 changes: 4 additions & 4 deletions modules/ar/include/visp3/ar/vpPanda3DGeometryRenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class VISP_EXPORT vpPanda3DGeometryRenderer : public vpPanda3DBaseRenderer
};

vpPanda3DGeometryRenderer(vpRenderType renderType);
~vpPanda3DGeometryRenderer() { }
~vpPanda3DGeometryRenderer() = default;

/**
* @brief Get render results into ViSP readable structures
Expand All @@ -85,7 +85,7 @@ class VISP_EXPORT vpPanda3DGeometryRenderer : public vpPanda3DBaseRenderer
*/
void getRender(vpImage<float> &depth) const;

GraphicsOutput *getMainOutputBuffer() VP_OVERRIDE { return m_normalDepthBuffer; }
GraphicsOutput *getMainOutputBuffer() VP_OVERRIDE { return (GraphicsOutput *)m_normalDepthBuffer; }


protected:
Expand All @@ -94,8 +94,8 @@ class VISP_EXPORT vpPanda3DGeometryRenderer : public vpPanda3DBaseRenderer

private:
vpRenderType m_renderType;
Texture *m_normalDepthTexture;
GraphicsOutput *m_normalDepthBuffer;
PointerTo<Texture> m_normalDepthTexture;
PointerTo<GraphicsOutput> m_normalDepthBuffer;

static const char *SHADER_VERT_NORMAL_AND_DEPTH_OBJECT;
static const char *SHADER_VERT_NORMAL_AND_DEPTH_CAMERA;
Expand Down
12 changes: 4 additions & 8 deletions modules/ar/include/visp3/ar/vpPanda3DPostProcessFilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,18 +62,14 @@ class VISP_EXPORT vpPanda3DPostProcessFilter : public vpPanda3DBaseRenderer
m_renderOrder = m_inputRenderer->getRenderOrder() + 1;
}

~vpPanda3DPostProcessFilter()
{
// delete m_texture;
// delete m_buffer;
}
virtual ~vpPanda3DPostProcessFilter() = default;

bool isRendering3DScene() const VP_OVERRIDE
{
return false;
}

GraphicsOutput *getMainOutputBuffer() VP_OVERRIDE { return m_buffer; }
GraphicsOutput *getMainOutputBuffer() VP_OVERRIDE { return (GraphicsOutput *)m_buffer; }

void afterFrameRendered() VP_OVERRIDE
{
Expand All @@ -100,8 +96,8 @@ class VISP_EXPORT vpPanda3DPostProcessFilter : public vpPanda3DBaseRenderer
bool m_isOutput; //! Whether this filter is an output to be used and should be copied to ram
std::string m_fragmentShader;
PointerTo<Shader> m_shader;
Texture *m_texture;
GraphicsOutput *m_buffer;
PointerTo<Texture> m_texture;
PointerTo<GraphicsOutput> m_buffer;

static const char *FILTER_VERTEX_SHADER;
};
Expand Down
14 changes: 9 additions & 5 deletions modules/ar/include/visp3/ar/vpPanda3DRGBRenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
#include <visp3/ar/vpPanda3DLight.h>
#include <visp3/core/vpImage.h>

#include "pointerTo.h"

BEGIN_VISP_NAMESPACE
/**
* \ingroup group_ar_renderer_panda3d_3d
Expand Down Expand Up @@ -78,6 +80,8 @@ class VISP_EXPORT vpPanda3DRGBRenderer : public vpPanda3DBaseRenderer, public vp
*/
vpPanda3DRGBRenderer(bool showSpeculars) : vpPanda3DBaseRenderer(showSpeculars ? "RGB" : "RGB-diffuse"), m_showSpeculars(showSpeculars) { }

virtual ~vpPanda3DRGBRenderer() = default;

/**
* @brief Store the render resulting from calling renderFrame() into a vpImage.
*
Expand All @@ -91,7 +95,7 @@ class VISP_EXPORT vpPanda3DRGBRenderer : public vpPanda3DBaseRenderer, public vp

void setBackgroundImage(const vpImage<vpRGBa> &background);

GraphicsOutput *getMainOutputBuffer() VP_OVERRIDE { return m_colorBuffer; }
GraphicsOutput *getMainOutputBuffer() VP_OVERRIDE { return (GraphicsOutput *)m_colorBuffer; }

bool isShowingSpeculars() const { return m_showSpeculars; }

Expand All @@ -103,14 +107,14 @@ class VISP_EXPORT vpPanda3DRGBRenderer : public vpPanda3DBaseRenderer, public vp

private:
bool m_showSpeculars;
Texture *m_colorTexture;
GraphicsOutput *m_colorBuffer;
PointerTo<Texture> m_colorTexture;
PointerTo<GraphicsOutput> m_colorBuffer;
static const char *COOK_TORRANCE_VERT;
static const char *COOK_TORRANCE_FRAG;

NodePath m_backgroundImage;
DisplayRegion *m_display2d;
Texture *m_backgroundTexture;
PointerTo<DisplayRegion> m_display2d;
PointerTo<Texture> m_backgroundTexture;
};

END_VISP_NAMESPACE
Expand Down

0 comments on commit 983d558

Please sign in to comment.