[Gambas-user] gb3 (rev. 3641) and SDL surfaces
Kevin Fishburne
kevinfishburne at ...1887...
Thu Mar 10 02:46:50 CET 2011
I've been experimenting with gb.sdl and found that I could achieve frame
rates higher than 380 fps at 1920x1080, including alpha channel. This
involves writing directly to the SDL window/surface with a 1920x1080
image loaded from a file, for example:
Public Screen As New Window As "Screen"
Public SomeImage As Image = Image.Load("someimage.png")
Public Sub Main()
' Create screen.
With Screen
.Width = 1920
.Height = 1080
.Framerate = 1000
.FullScreen = True
.Show()
End With
End
Public Sub Screen_Draw()
Draw.Image(SomeImage, 0, 0)
Draw.Text(Screen.Framerate & " FPS", 0, 0)
End
While this is awesome, there is a problem if images need to be
composited before being written to the SDL surface. For example, if I
wanted to do something like this:
Water.Draw(WaterRipples, 0, 0)
Water.Draw(SkyReflection, 0, 0)
Water.DrawAlpha(WaterDepth, 0, 0)
and then draw Water to the SDL window, not only is the imlib2 component
required (otherwise it states the .Draw method is unknown), it kills the
frame rate because the Draw method is done in software (imlib2) and only
the writes done directly to the SDL window are hardware accelerated.
Attempting to circumvent this I created a second SDL window, hoping I
could write the contents of window B to window A. The idea was to create
multiple secondary SDL windows, using them as image buffers, then write
the buffers as necessary to the main SDL window when its Draw event was
called. This didn't work at all and I don't think it's supported.
Is there a way to use the Draw method, or an equivalent, so that
image-to-image writes can be done entirely in SDL? I've already
converted my app to use the SDL component but too much of it currently
uses the .Draw and .DrawAlpha methods which bring the framerate to 21
fps at 1280x720. The framerate is only going to get worse from here, as
I'm just getting started.
--
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