I have started using GameMaker:Studio this year and, since my primary mobile target is Android, transition from 1.2 to 1.3 wasn’t the most pleasant experience. To be honest, it was probably the worst. I do like those 60FPS in my simple 2D games and watching them halve after running APK built with 1.3 was devastating.
While YoYo Games are surely improving their new surface-based drawing pipeline, as much as I Googled and browsed, I couldn’t get back the smoothness I needed. Article Optimising The Draw Pipeline had some solutions, but most of them had absolutely zero impact in my projects. You should check them out and experiment for yourself, but for me only bypassing default shader increased FPS in Galaxy 10.1 tablet (had no impact in Galaxy 7).
I wasted a shameful amount of time on this, since I’m not very attentive and searching through GMC forums is usually quite unpleasant experience, but the solution exists and it’s as easy as adding single line in Create event of some object created at the start of the game:
Basically, it makes all the fancy drawing logic disappear and sets you back to the good old times of 1.2, when people with older or economic-class Android devices were running your games smoothly. And the results made my eyes teary from joy – 60FPS in both Galaxy Tab 7 (from 25-30) and Galaxy Tab 10 (from 40-60*).
Now, I ashamed to admit that, but I did find it much earlier, but in an unlucky turn of events and brain farts I confused it with application_surface_draw_enable() and lived in an illusion that taking over drawing of surface to your hands was what I needed. That being said, my quest for FPS weren’t completely without loot, so I’m to share some things, which worked for me thus explaining bold “60” in previous paragraph.
Bypassing Default Shader
This, taken from the YoYo optimization article, had the biggest impact to me in Galaxy Tab 10 boosting FPS by 10-15 when still using 1.3 surfaces. Sadly, it seemed to have no impact in the older Tab 7 (different OpenGL versions? I’m no expert here and I might have been doing something wrong, so take my words with a grain of salt). The implementation is in the example projects listed in the before-mentioned article, but if you, like me, hate adding tutorial projects in to your workspace and you, like me, have no idea, where to put those shaders, just follow this…
What you should’ve done already, is resizing surface to match your view (preferably in the same place where you should be adapting view/port to the device screen) with surface_resize(application_surface, view_wview, view_hview); and taking surface drawing in to your own hands with application_surface_draw_enable(false);.
- Right click on “Shaders” and “Create Shader”
- In the object of your preference create a “Post Draw” event
- Drop a code action and Ctrl+vomit these lines:
draw_surface_stretched(application_surface, 0, 0, view_wport, view_hport);
Build, play, check the FPS. Hopefully, the result makes you at least a bit happy. The YoYo article mentions some changes in the shader you could make, but I only downloaded the final example project and couldn’t find any differences between shader0 & shader1. I would really like to see some comments in those examples…
Faster background drawing
Now, other thing, which significant amount of those sweet sweet FPS and which I kept even after disabling usage of surfaces, was drawing backgrounds manually, since, in my case, they’re usually large images without any transparency. That being said, this is not very useful with fancy foregrounds with alpha. So, to take your background away from the sticky hands of GameMaker, you should…
- Uncheck “Visible when room starts” in the “backgrounds” tab of your room.
- Add a “Draw begin” event in an object of your choice
draw_background(background1, 0, 0); // can use draw_background_tiled() or other related functions too!
Players with low-end devices are people too. Take care of them. Jokes aside, you’re most welcome to correct me, since shaders & surfaces are not really my area of expertise.I would have been much happier if I wouldn’t have been forced to dig through this stuff. In the end, I got my 60FPS, players are happy, so I’m happy too. Until I’ll need to use surfaces….