With this variable you can set the contents of a view port to draw to a surface. When working with surfaces, it is often required that capture the whole visible region of the screen to the surface, and so you would assign it to a view port using this function. This means that everything that is shown in the chosen port view will now be drawn to the assigned surface and the contents of that view port will no longer be displayed, meaning that you will need to either:

  • Enable a new view and draw the surface only in that view (using view_current to check which view is being drawn)

  • Draw the surface in the Draw GUI event of an instance, since the GUI layer is independent of views.

When using this function you give the view port index (from 0 to 7) and a surface index (either the application_surface or the unique index value returned by the function surface_create) or, if a surface has previously been assigned and you want to remove it, a value of -1. For further information on setting the view port to a surface see also the variable view_surface_id.


view_set_surface_id(view_port, surf)

Argument Description
view_port The view port to target (0 - 7)




if view_get_surface_id(0) == -1
    view_set_surface_id(0, global.vSurf);

The above code will check to see if a surface has been assigned to the view port[0] and if it has not then one is assigned.