#include "agg_rendering_buffer.h" #include "agg_basics.h" #include "platform/agg_platform_support.h" #include "agg_pixfmt_rgb.h" enum { flip_y = true, }; template<class Ren> void draw_black_frame(Ren &ren) { agg::rgba8 c(0,0,0); unsigned i; for (i=0; i<ren.height(); ++i) { ren.copy_pixel(0, i, c); ren.copy_pixel(ren.width()-1, i, c); } for (i=0; i<ren.width(); ++i) { ren.copy_pixel(i, 0, c); ren.copy_pixel(i,ren.height()-1, c); } } class the_application : public agg::platform_support { public: the_application(agg::pix_format_e format, bool flip_y): agg::platform_support(format,flip_y) {} virtual ~the_application() { } virtual void on_init(){} virtual void on_draw() { agg::rendering_buffer rbuf = this->rbuf_window(); agg::pixfmt_rgb24 pixf(rbuf);//底层像素渲染对象,对渲染内存进行包装了 int w = pixf.width(); int h = pixf.height(); memset( rbuf.row_ptr(0), 255, w*h*3 );//绘制白色背景 agg::rgba8 c(127,200,98); unsigned i; for (i=0; i<h/2; ++i)//绘制对角线 { pixf.copy_pixel(i, i,c); } draw_black_frame(pixf); } }; int agg_main(int argc, char* argv[]) { the_application app(agg::pix_format_bgr24, flip_y); app.caption("My AGG Demo"); if(app.init(320, 200, agg::window_resize )) { app.run(); } return 1; }