surface_resize

Resize a previously created surface.

Syntax:

GML Code Example

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 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:

GML Code 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.





No Examples Submitted

Does this page need better examples? Be the first to Submit

No Edits Suggested

Is this page unclear or not descriptive enough? Suggest an edit to the page and with enough upvotes your changes will be made.

No Questions Have Been Ask

Do you have a question about this page? Ask it Here