[Gambas-user] gb3: Draw method with same source and destination image
Kevin Fishburne
kevinfishburne at ...1887...
Fri Feb 4 19:26:42 CET 2011
On 02/02/2011 08:14 PM, Benoît Minisini wrote:
> Maybe you can speed up things a little by intelligently using the X11 design.
>
> In Gambas 3, if you use a DrawingArea with the Cached property set, the
> DrawingArea maintains a pixmap on the X11 server that is used as the
> background pixmap of the X11 window. That means that the DrawingArea is
> automatically refreshed by the X11 server.
>
> Then, if you put a big DrawingArea inside a smaller Panel (or another
> DrawingArea, because you can ensure that it will not drawing anything), you
> can create the scrolling of the center cell just by moving it with the Move()
> method. The X11 server will do all the display, without any processing in your
> application.
>
> Of course, when you reach one extremity of the inner DrawingArea, you must
> then do a real scrolling and update its contents.
>
> I don't know if you do that already. But if you didn't, it may speed things
> up.
That's a good idea, but unfortunately for me I'm compositing several
layers with alpha such as water, atmospheric effects, the player, other
players, vegetation, etc. I may also implement full-screen rotation as
well, though this may require porting the code to OpenGL. It would be
difficult to implement multiple DrawingAreas in my case since they'd be
treated as separate images.
What I discovered yesterday however is that the new gb.image.imlib
library is incredibly fast compared to gb.image. You might want to
compare code and steal a little from it. I wrote a test app which shows
frame rates copying one image to another for ten seconds.
Public Sub Form_Open()
Dim image1 As Image
Dim image2 As Image
Dim t As Float
Dim frames As Integer
Dim width As Integer
Dim height As Integer
width = 512
height = 512
image1 = New Image(width, height, Color.RGB(127, 127, 127, 127))
image2 = New Image(width, height, Color.RGB(127, 127, 127, 127))
t = Timer
Do
image1.Draw(image2, 0, 0)
Inc frames
Loop Until Timer - t >= 10
Print Fix(frames / 10) & " frames per second."
Print Fix(frames * width * height / 10 / 1000) & " pixels per
millisecond."
End
Running that code with gb.image results in:
51 frames per second.
13474 pixels per millisecond.
Running the same code with the gb.image.imlib component I get:
432 frames per second.
113455 pixels per millisecond.
imlib is 8.5 times faster, which is amazing. What's not amazing is that
even though my test program works, my game repeatedly gives me the
error, "The source image and the destination image must have the same
format." Just crazy...
Sadly when I check their properties they are the same format, Standard
(not Multiplicative). I'm currently trying to understand why it's saying
that, as I want my 8.5x framerate boost.
--
Kevin Fishburne
Eight Virtues
www: http://sales.eightvirtues.com
e-mail: sales at ...1887...
phone: (770) 853-6271
More information about the User
mailing list