31 #include <visp3/ar/vpPanda3DPostProcessFilter.h>
33 #if defined(VISP_HAVE_PANDA3D)
35 #include "lightRampAttrib.h"
36 #include "graphicsOutput.h"
37 #include "windowFramework.h"
38 #include "graphicsEngine.h"
43 "in vec4 p3d_Vertex;\n"
44 "uniform mat4 p3d_ModelViewProjectionMatrix;\n"
45 "in vec2 p3d_MultiTexCoord0;\n"
46 "out vec2 texcoords;\n"
50 " gl_Position = p3d_ModelViewProjectionMatrix * p3d_Vertex;\n"
51 " texcoords = p3d_MultiTexCoord0;\n"
57 cm.set_frame_fullscreen_quad();
62 if (buffer ==
nullptr) {
64 "Cannot add a postprocess filter to a renderer that does not define getMainOutputBuffer()");
66 m_shader = Shader::make(Shader::ShaderLanguage::SL_GLSL,
70 m_renderRoot.set_shader_input(
"dp", LVector2f(1.0 / buffer->get_texture()->get_x_size(), 1.0 / buffer->get_texture()->get_y_size()));
72 m_renderRoot.set_attrib(LightRampAttrib::make_identity());
79 PT(OrthographicLens) lens =
new OrthographicLens();
80 lens->set_film_size(2, 2);
81 lens->set_film_offset(0, 0);
82 lens->set_near_far(-1000, 1000);
95 WindowProperties win_prop;
99 int flags = GraphicsPipe::BF_refuse_window | GraphicsPipe::BF_resizeable;
100 GraphicsOutput *windowOutput =
m_window->get_graphics_output();
101 GraphicsEngine *engine = windowOutput->get_engine();
102 GraphicsStateGuardian *gsg = windowOutput->get_gsg();
103 GraphicsPipe *pipe = windowOutput->get_pipe();
106 fbp, win_prop, flags,
117 m_buffer->add_render_texture(
m_texture,
m_isOutput ? GraphicsOutput::RenderTextureMode::RTM_copy_texture : GraphicsOutput::RenderTextureMode::RTM_bind_or_copy);
118 m_buffer->set_clear_color(LColor(0.f));
119 m_buffer->set_clear_color_active(
true);
120 DisplayRegion *region =
m_buffer->make_display_region();
121 if (region ==
nullptr) {
125 region->set_clear_color(LColor(0.f));
136 m_renderRoot.set_shader_input(
"dp", LVector2f(1.0 / buffer->get_texture()->get_x_size(), 1.0 / buffer->get_texture()->get_y_size()));
139 for (GraphicsOutput *buffer:
m_buffers) {
141 GraphicsBuffer *buf =
dynamic_cast<GraphicsBuffer *
>(buffer);
142 if (buf ==
nullptr) {
159 const unsigned numComponents =
m_texture->get_num_components();
160 int rowIncrement = I.
getWidth() * numComponents;
161 unsigned char *data = (
unsigned char *)(&(
m_texture->get_ram_image().front()));
163 data += rowIncrement * (I.
getHeight() - 1);
164 rowIncrement = -rowIncrement;
166 for (
unsigned int i = 0; i < I.
getHeight(); ++i) {
167 unsigned char *colorRow = I[i];
168 for (
unsigned int j = 0; j < I.
getWidth(); ++j) {
169 colorRow[j] = data[j * numComponents];
171 data += rowIncrement;
182 const unsigned numComponents =
m_texture->get_num_components();
183 int rowIncrement = I.
getWidth() * numComponents;
184 float *data = (
float *)(&(
m_texture->get_ram_image().front()));
186 data += rowIncrement * (I.
getHeight() - 1);
187 rowIncrement = -rowIncrement;
189 for (
unsigned int i = 0; i < I.
getHeight(); ++i) {
191 for (
unsigned int j = 0; j < I.
getWidth(); ++j) {
192 colorRow[j].
B = data[j * numComponents];
193 colorRow[j].
G = data[j * numComponents + 1];
194 colorRow[j].
R = data[j * numComponents + 2];
196 data += rowIncrement;
202 #elif !defined(VISP_BUILD_SHARED_LIBS)
204 void dummy_vpPanda3DPostProcessFilter() { };
error that can be emitted by ViSP classes.
unsigned int getWidth() const
void resize(unsigned int h, unsigned int w)
resize the image : Image initialization
unsigned int getHeight() const
NodePath m_renderRoot
Rendering parameters.
PointerTo< Camera > m_camera
Node containing all the objects and the camera for this renderer.
std::string m_name
Inverse of VISP_T_PANDA.
std::vector< PointerTo< GraphicsOutput > > m_buffers
NodePath of the camera.
PointerTo< WindowFramework > m_window
Rendering priority for this renderer and its buffers. A lower value will be rendered first....
int m_renderOrder
name of the renderer
vpPanda3DRenderParameters m_renderParameters
Pointer to owning window, which can create buffers etc. It is not necessarily visible.
std::string m_fragmentShader
Whether this filter is an output to be used and should be copied to ram.
virtual FrameBufferProperties getBufferProperties() const =0
static const std::string FILTER_VERTEX_SHADER
void getRenderBasic(vpImage< unsigned char > &I) const
std::shared_ptr< vpPanda3DBaseRenderer > m_inputRenderer
PointerTo< GraphicsOutput > m_buffer
PointerTo< Shader > m_shader
virtual void setupScene() VP_OVERRIDE
Initialize the scene for this specific renderer.
void setRenderParameters(const vpPanda3DRenderParameters ¶ms) VP_OVERRIDE
Set new rendering parameters. If the scene has already been initialized, the renderer camera is updat...
void setupRenderTarget() VP_OVERRIDE
Initialize buffers and other objects that are required to save the render.
void setupCamera() VP_OVERRIDE
Initialize camera. Should be called when the scene root of this render has already been created.
PointerTo< Texture > m_texture
Rendering parameters for a panda3D simulation.
unsigned int getImageWidth() const
unsigned int getImageHeight() const