Cheap trick to speed up your games.
:: Forumrr Chat Room :: Tutorials
Page 1 of 1
Cheap trick to speed up your games.
GM VERSION: GM STUDIO
Target Platforms: Unknown, but probably all of them.
Download and Links: N/A
Summation: A cheap trick to give you a 20-50% performance optimization in your game.
Tutorial:
Go in the Room Editor and disable "Clear Display Buffer With Window Color".
Create a new object called "ortho".
Set it's depth to -1000.
Put in it's Create Event:
Code:
application_surface_draw_enable(false);
inc=0;
EDIT:
Put in it's Step Event:
Code:
// toggle inc between true and false each step
inc=!inc
if (inc) draw_enable_drawevent(1);
else
draw_enable_drawevent(0);
Put in it's Draw Gui Event:
Code:
draw_surface(application_surface, 0, 0)
draw_set_color(c_white);
Also remember to disable fog and lighting before the draw, and reenable it afterwards if you are in 3D. Also remember that game critical code, if it is in the Draw Event, is skipped for one frame.
This code works by only rendering half of the frames. The application surface is the default surface that GM renders the scene to. Normally it is enabled by default but in this code we want to control when we draw it ourselves. This is analogous to the old function in GM8 called set_automatic_draw.
Clear Display Buffer must be disabled, because if you enable it, it fills the screen with a solid color eliminating the afterimage effect.
This is a neat trick that skips the rendering of a frame but tricks the human eye into thinking it's smooth, because there is a transparent afterimage left over from the last frame allowing the eye to interpolate the frames like in movies.
Even without the frame boost, the afterimage looks kind of neat, and professional.
This is not the end of the tutorial. The tutorial continues onward, with you.
This topic is dedicated to posting optimization tips to the new GM Studio.
Last edited: Jul 14, 2016
Target Platforms: Unknown, but probably all of them.
Download and Links: N/A
Summation: A cheap trick to give you a 20-50% performance optimization in your game.
Tutorial:
Go in the Room Editor and disable "Clear Display Buffer With Window Color".
Create a new object called "ortho".
Set it's depth to -1000.
Put in it's Create Event:
Code:
application_surface_draw_enable(false);
inc=0;
EDIT:
Put in it's Step Event:
Code:
// toggle inc between true and false each step
inc=!inc
if (inc) draw_enable_drawevent(1);
else
draw_enable_drawevent(0);
Put in it's Draw Gui Event:
Code:
draw_surface(application_surface, 0, 0)
draw_set_color(c_white);
Also remember to disable fog and lighting before the draw, and reenable it afterwards if you are in 3D. Also remember that game critical code, if it is in the Draw Event, is skipped for one frame.
This code works by only rendering half of the frames. The application surface is the default surface that GM renders the scene to. Normally it is enabled by default but in this code we want to control when we draw it ourselves. This is analogous to the old function in GM8 called set_automatic_draw.
Clear Display Buffer must be disabled, because if you enable it, it fills the screen with a solid color eliminating the afterimage effect.
This is a neat trick that skips the rendering of a frame but tricks the human eye into thinking it's smooth, because there is a transparent afterimage left over from the last frame allowing the eye to interpolate the frames like in movies.
Even without the frame boost, the afterimage looks kind of neat, and professional.
This is not the end of the tutorial. The tutorial continues onward, with you.
This topic is dedicated to posting optimization tips to the new GM Studio.
Last edited: Jul 14, 2016
:: Forumrr Chat Room :: Tutorials
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
|
|