这次我们以一个自制的顶点源与椭圆组合作为渲染对象,用宝蓝色的实色渲染器进行渲染;
#include <agg_ellipse.h>
//................
class triangle_path {
public:
triangle_path()
{
unsigned tmp_array[4][3]={
{0 , 250, agg::path_cmd_move_to},
{500, 250, agg::path_cmd_line_to},
{250, 500, agg::path_cmd_line_to},
{0 , 0, agg::path_cmd_stop}
};
memcpy(m_points[0], tmp_array[0], sizeof(m_points));
}
unsigned vertex(double *x, double* y)
{
*x = m_points[m_step][0];
*y = m_points[m_step][1];
unsigned r = m_points[m_step][2];
m_step++;
return r;
}
void rewind(int)
{
m_step = 0;
}
private:
int m_step;
unsigned m_points[4][3];
};
//...... in class the_application
void on_draw()
{
ren_bas.reset_clipping(true);
ren_bas.clear(agg::rgba8(255, 255, 255));
agg::ellipse ellipse(250, 125, 125, 125);
triangle_path triangle;
rasterizer.reset();
rasterizer.add_path(triangle);
rasterizer.add_path(ellipse);
agg::render_scanlines_aa_solid(rasterizer, scanline, ren_bas,
agg::rgba8(45, 108, 155)); //注意:函数名中的scanline是复数!!
}