surface_resize


Syntax:

surface_resize(surface_id, w, h);

Argument Description
surface_id The ID of the surface to change.
w The width of the new surface.
h The height of the new surface.


Returns:

N/A


Description

This function will resize a surface to the given dimensions (in pixels). The surface_id is that of a surface you have created previously, or the application_suface, and the function will resize that surface. Note that this will neither crop nor stretch the contents of the surface, but rather it destroys the current surface and recreates it with the same handle (surface_id) with the new dimensions, meaning that it will need to be cleared and drawn to again (unless it is the application_surface in which case GameMaker Studio 2 will do this automatically).

NOTE: If you are resizing the application surface, these changes will not be registered until the start of the next draw frame, meaning that calling the surface_get_width() or surface_get_height() functions in the same event or step will return the previous values.


Example:

if view_wport[0] != surface_get_width(application_surface) || view_hport[0] != surface_get_height(application_surface)
   {
   surface_resize(application_surface, view_wport[0],view_hport[0]);
   }

The above code will check the view port size against that of the surface "aplication_surface" and if it is different, the surface is re-sized.