AggPas as fast as possible lazarus / 39-Graphics ---------------------------------------------------------------------- cd · 2011-06-13 19:24 Hello all! I use aggpas to draw a map-like fullscreen gui. So the task is to increase fps as much as possible. Without real drawing - aggpas renders image into in-memory buffer at frame rate 150. But there is a huge loss of performance when i display the image on a form. I tried different ways of displaying - the best gives 13 fps which is not very good. A 30 fps would be much more appreciated (:. Here is the main code of the best result (13fps) Code: [Select]procedure TForm1.FormCreate(Sender: TObject); begin   AggLCLCanvas:=TAggLCLCanvas.Create;   with AggLCLCanvas do begin     Image.PixelFormat:=afpimRGBA32;     Image.SetSize(1024,768);   end; end; procedure TForm1.Draw; var     bmp: TBitmap; begin   with AggLCLCanvas do begin     AggClearAll(random(255),random(255),random(255),255);   end;   bmp:=TBitmap.Create;   bmp.LoadFromIntfImage(aggLCLCanvas.Image.IntfImg);   canvas.Draw(0,0,bmp);   bmp.Free; end; I also tried Code: [Select]procedure TForm1.Draw; begin   with AggLCLCanvas do begin     AggClearAll(random(255),random(255),random(255),255);   end;   image1.picture.bitmap.LoadFromIntfImage(aggLCLCanvas.Image.IntfImg); end;but this gives 10 fps. What i think i could still do to improve performance is to avoid any transfer of data, which occurs in Code: [Select]  bmp.LoadFromIntfImage(aggLCLCanvas.Image.IntfImg);   canvas.Draw(0,0,bmp); and even more in Code: [Select]  image1.picture.bitmap.LoadFromIntfImage(aggLCLCanvas.Image.IntfImg); To avoid data transfer one could share RawImage between aggLCLCanvas.Image.IntfImg and image1.picture.bitmap. The following code could be a solution Code: [Select]procedure TForm1.FormCreate(Sender: TObject); var     arawimage: TRawImage; begin   AggLCLCanvas:=TAggLCLCanvas.Create;   with AggLCLCanvas do begin     Image.PixelFormat:=afpimRGBA32;     Image.SetSize(1024,768);   end;   // get aggpas rawimage and pass it to image1's bitmap   AggLCLCanvas.Image.IntfImg.GetRawImage(arawimage,true);   image1.picture.Bitmap.LoadFromRawImage(arawimage,true); end; procedure TForm1.Draw; begin   with AggLCLCanvas do begin     AggClearAll(random(255),random(255),random(255),255);   end;   image1.Repaint; end; which promises about 40 fps, but unfortunately it does not draw anything. To make it draw i need to insert two additional lines Code: [Select]procedure TForm1.Draw; begin   with AggLCLCanvas do begin     AggClearAll(random(255),random(255),random(255),255);   end;   image1.Picture.Bitmap.BeginUpdate();   image1.Picture.Bitmap.EndUpdate(); end; which put to death all the performance: down to 5 fps. The question is: how can i avoid using these lines, which really do nothing useful but just some kind of invalidation of an image, because real image data which is in underlying RawImage is already there!? ---------------------------------------------------------------------- benohb · 2011-10-04 02:07 Operations in the libraries of graphics are not the cause The problem is to convert the image from the raw image to agree with the interface.. Quote image1.Picture.Bitmap.BeginUpdate();   image1.Picture.Bitmap.EndUpdate() I have tried the library aggpas... It is really rich..But QuoteC++ TEMPLATES  =============  Well, well, well. I was forced to remove the Maxim's template based  architecture and to replace it with the conventional one - object oriented,  because in Object Pascal there are no templates. Due to that there is a  speed penalty consequence. AggPas is in fact slower by 20 - 50%.  Despite the speed decrease, the AggPas is still a very usable super- trooper 2d  vector graphic library. Unless you are willing to make a real-time (30 fps >)  rendering, there is still a great benefit of incorporating it into your Pascal  based projects. Try to compile the demos and see for yourself ... This talk developer aggpas I have found cairo Library for lazarus lcl Quotehttp://code.google.com/p/luipack/source/browse/trunk/cairo/?r=276 I do not know about the project is active not , But the packages worked well and all tutorial In my test, i found it very fast than aggpas (rendering and Operations) > 80 fps photo  (1280x1024) usage (cpu p4 3.2 )  60% to 80% Photo double (layers or Interface in cairo ) + Transparency You can access the raw image (Meaning you can switch between formats or use IntfImage and Tbitmap) sys : linux gtk 32bit I did not understand how, but I looking in the code I come back aggpas,procedure  just like that is a problem Code: [Select]Bitmap1.LoadFromIntfImage(AggLCLCanvas.Image.IntfImg); ..I believe the solution Must deal directly with the interface ,Because Lazarus has the potential are known The same problems in all Development platforms, here comes the creativity of the developer ---------------------------------------------------------------------- User137 · 2011-10-04 04:02 Real problem is that TImage was never meant for games or least of all fullscreen animations. You are actually using just CPU for all the drawing while the massive power of graphics card stands idle. SDL has some ways to optimize software rendering alot, but going for OpenGL would be a huge boost.