SOLVED view_surface_id. draw view to surface or draw viewport to surface?

NastyMonk

Member
With this variable, you can set the contents of a given viewport to draw to a surface, or get the current surface id if one has been assigned to a viewport. When working with surfaces, it is often required that you capture the whole visible region of the screen to the surface, and so you would assign it to a viewport using this variable. This means that everything that is shown in the chosen view will now be drawn to the assigned surface. The view will now not be drawn to the screen, 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.
You can also read this variable to get the index of the surface that has been assigned to the chosen view or it will return -1 if no surface has been assigned, and generally, the surface used for this function should be the size of the view camera itself (not the viewport). The extended example below shows a basic setup for capturing a view and drawing it in the Draw GUI event, and for more information on surfaces see the section Surfaces.

Note that you can also set a viewport to a surface using the function view_set_surface_id().
Does this draw the content of view to surface or viewport to surface? If it draws the content of viewport to the surface, why does it say "generally the surface used for this function should be the size of the view camera itself (not the viewport)."?

What's the difference between draw view to surface or draw viewport to surface? My understanding is that there is a transformation between the content of view and the content of viewport.
 

TheouAegis

Member
you can test it yourself, but from my understanding it was the view itself, not the viewport. Basically what it does is instead of drawing The view camera to some hidden surface, it draws it to a surface you can manipulate yourself. normally that hidden surface will get scaled to fit the viewport, but since you will be drawing to a different surface, it doesn't get scaled.
 
Top