View Issue Details

IDProjectCategoryView StatusLast Update
0028628RunnerFunctionsPublic2018-01-08 13:45
ReporterStewart BishopAssigned ToMike Dailly 
PriorityLowSeverityC - GeneralReproducibility100%
Status ResolvedResolutionWon't Fix 
Product Version 
Fixed in Version 
Summary0028628: Functions: matrix_view is corrupted after calling surface_reset_target
DescriptionIn GMS2 the surface_set_target function sets matrix_view to surface's local coordinates so if I call draw_point(0, 0) it will be drawn in the top-left corner of the surface and it doesn't matter what the current view coordinates are but it's possible to save the matrix_view in the beginning of Draw Event, and set it after the surface_set_target then call draw_point(0,0) and it will set a point it the top-left corner of the current view on the selected surface which seems to be fine.

However surface_reset_target corrupts the view matrix and all the other draw_* calls in Draw Events of any object are incorrect, all the elements are drawn in wrong places. I guess, surface_reset_target function should just reset the view matrix to the state before surface_set_target was called.
Steps To Reproduce1) Run the attached sample
2) Press + or - to rotate
3) See that your sprites rotate in different directions even though you're only rotating the camera
4) Within the Draw event uncomment the line specified
5) Run it again and rotate
6) See that this has fixed it
1.4 Found In
2.x Runtime Found In2.1.3.189
2.x Runtime Verified In2.1.3.189


Stewart Bishop

2018-01-05 12:02


view-surface-bug.yyz (24,201 bytes)

Mike Dailly

2018-01-08 13:45

Manager   ~0057211

This is by design. Setting a surface sets the model, view and project matrix, and when popping will restore the current camera one.

We do not store what was "there" as this could easily lead to errors if the camera has changed in anyway. The camera must be restored. This is also true for pushing multiple surfaces, we need to restore the last one to keep consistency.

If you use a custom matrix you will need to reset this yourself after popping off a surface from the stack.