Jump to content


Photo

Surface_set_target


  • Please log in to reply
6 replies to this topic

#1 vann

vann

    GMC Member

  • GMC Member
  • 356 posts
  • Version:GM:Studio

Posted 18 May 2012 - 03:00 AM

There is a post in the tracker now which states it is no longer best practice to change the draw target outside the draw event, it is now, in fact, the opposite. This essentially means no more drawing to surfaces outside of the draw event.

I am happy to accept change if change is required, but this has been cited as a documentation error, whereas it actually appears to be a decision made to longer operate surfaces in this manner. I think this needs a bit more attention in the forums as afaik for years the community had done this outside draw events, some recent examples including:

Icuurds tiling surface example often cited in other posts. I was myself pointed to this by Nocturne as an example of how to better manage large surfaces. This draws objects on their collision event before destroying them.
http://gmc.yoyogames...howtopic=351841

http://gmc.yoyogames...howtopic=536334

http://gmc.yoyogames...howtopic=535668

http://gmc.yoyogames...howtopic=527207

http://gmc.yoyogames...howtopic=539230

http://gmc.yoyogames...howtopic=536334

This one posted in March is an example where performing this in draw event specifically used to not work (GM8 i will presume).
http://gmc.yoyogames...howtopic=534776

It would seem having to call this inside draw events is going to make it more difficult to do a lot of the things people do with surfaces, such as acting as catchers for splats, scars etc. So perhaps some people could get together some examples of nice tidy ways to do this in the future? If this is changing the community has just lost a lot of best practice knowledge about how to use surfaces, and we will need some new examples on how to acheive certain things so new users arent confused by the conflicting information.

As a note to be fair, Mike had indicated a while ago he DID intend to change this in GM9 http://gmc.yoyogames...howtopic=522345, following a period where it wasnt supported in HTML5 either.

All I am saying is that I think it needs some attention here as a significant change, rather than a error in the documentation, so as people realise they shouldn't follow any of the examples on the forums any more regarding surfaces, and ensure they are implementing any projects in GMS with this in mind at the outset.

EDIT: the bug tracker ticket http://bugs.yoyogame...iew.php?id=3485

Edited by vann, 18 May 2012 - 03:11 AM.

  • 2

#2 rwkay

rwkay

    YoYo Games CTO

  • YoYo Games Staff
  • 1440 posts
  • Version:Unknown

Posted 18 May 2012 - 07:39 AM

In the future (in GMNext timeframe) it will no longer be possible to render outside of the draw event - as this will allow us to parallelise the rendering and drawing code, so we are encouraging everyone to think in terms of putting all the rendering code in the Draw event, if you are not using multiple views then this will be the same as putting the code in the Step event, if you are using views then you just need to ensure that the surface is only being rendered once in the Draw event so you need to check which view you are in (the view_current built in variable will tell you the current view number).

It is relatively simple to setup communication between the Step and Draw events through global or instance variables to get the Draw event to perform the actual rendering.


We strongly encourage everyone to adopt this as it will help us make stronger optimisations in the future.

Russell
  • 0

#3 GStick

GStick

    All Secrets Exposed

  • GMC Member
  • 1631 posts
  • Version:GM:Studio

Posted 18 May 2012 - 08:12 AM

Interesting...

Going to have to change a few pieces of code when I wake up... Parallel, huh? Sounds like a change I can get behind.
  • 0

#4 vann

vann

    GMC Member

  • GMC Member
  • 356 posts
  • Version:GM:Studio

Posted 18 May 2012 - 11:29 AM

Thanks for the extra info Russell, as I tried to stress I'm not opposed to this move at all in that I am sure you have very good reason, I just wanted to help others realise early on that this change is being made, as not very many people probably read through all the tickets in the tracker.
  • 0

#5 gnysek

gnysek

    GMC Member

  • GMC Member
  • 338 posts
  • Version:GM:Studio

Posted 18 May 2012 - 02:46 PM

@vann: http://bugs.yoyogame...iew.php?id=3481 - check example that I've added and you'll see, that redrawing surface with exactly same code outside draw event can bring problems. I was also using that event outside of Draw event, and in Delphi runner it was ok, but in C++ it's not.
  • 0

#6 cotycrg

cotycrg

    GMC Member

  • GMC Member
  • 851 posts
  • Version:GM:Studio

Posted 18 May 2012 - 03:36 PM

Oh wow. Well that is depressing. I mean I like the parallel change, and I'm all for that. But drawing to the surface only in the draw event means I have a lot of code to rewrite/rethink. haha
  • 0

#7 gnysek

gnysek

    GMC Member

  • GMC Member
  • 338 posts
  • Version:GM:Studio

Posted 18 May 2012 - 08:40 PM

Not only you, I've also got it in my private game... I even thought that it's runner bug, but I've got Mike just two desks away, so I've quickly asked. Same as that surface size should be square of two, cause otherwise it also causes some problems (I've encountered them on iOS and Android).
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users