paysages3d/src/render/software/SoftwareCanvasRenderer.h

87 lines
2.1 KiB
C
Raw Normal View History

#ifndef SOFTWARECANVASRENDERER_H
#define SOFTWARECANVASRENDERER_H
#include "software_global.h"
2014-06-12 15:45:59 +00:00
#include "SoftwareRenderer.h"
namespace paysages {
namespace software {
/**
* @brief Software rendering inside a Canvas surface.
*
* This class launches the rasterization process into canvas portions and
* redirects post processing to the software renderer.
*
* It tries to keep a canvas portion rasterized ahead of the post processing.
*/
2014-06-12 15:45:59 +00:00
class SOFTWARESHARED_EXPORT SoftwareCanvasRenderer: public SoftwareRenderer
{
public:
SoftwareCanvasRenderer();
2014-06-12 15:45:59 +00:00
virtual ~SoftwareCanvasRenderer();
inline const Canvas *getCanvas() const {return canvas;}
/**
* Set the renderer configuration.
*/
void setConfig(const RenderConfig &config);
/**
* @brief Set the rendering size in pixels.
*
* Set 'samples' to something bigger than 1 to allow for the multi-sampling of pixels.
*/
void setSize(int width, int height, int samples=1);
/**
* @brief Start the two-pass render process.
*/
void render();
/**
* @brief Interrupt the render process.
*/
void interrupt();
2014-08-19 07:18:55 +00:00
2014-08-18 10:17:16 +00:00
/**
* @brief Get the list of objects that can be rasterized to polygons on a canvas.
2014-06-12 15:45:59 +00:00
*/
virtual const std::vector<Rasterizer*> &getRasterizers() const;
2014-08-18 10:17:16 +00:00
/**
* Get a rasterizer by its client id.
*/
const Rasterizer &getRasterizer(int client_id) const;
protected:
/**
* @brief Rasterize the scenery into a canvas portion.
*
* If 'threaded' is true, the rasterization will take advantage of multiple CPU cores.
*/
2014-08-19 07:18:55 +00:00
void rasterize(CanvasPortion *portion, bool threaded=false);
/**
2014-08-19 07:18:55 +00:00
* @brief Apply pixel shader to fragments stored in the CanvasPortion.
*
2014-08-19 07:18:55 +00:00
* If 'threaded' is true, the shader will take advantage of multiple CPU cores.
*/
2014-08-19 07:18:55 +00:00
void applyPixelShader(CanvasPortion *portion, bool threaded=true);
private:
2014-08-19 07:18:55 +00:00
Canvas *canvas;
2014-06-12 15:45:59 +00:00
std::vector<Rasterizer*> rasterizers;
bool started;
bool interrupted;
2014-08-19 07:18:55 +00:00
ParallelWork *current_work;
};
}
}
#endif // SOFTWARECANVASRENDERER_H