• Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

Question - IDE trying to understand "Clear Viewport Background"

M

makani

Guest
I had some code that would change the x value of one of my objects. It worked - the object was redrawn in it's new location, but the drawing in it's old location was not cleared. I double checked that I was not creating new instances. To fix it, I ended up clicking "Enable Viewports" and then the checkbox "Clear Viewport Background" for Viewport 0 that I made visible.

But I don't know why that fixes it, and why it has that default behavior in the first place. Especially since if I call motion_add on that object, it moves just fine without leaving a trail. I'm guessing there's a good reason, but I don't know what it is.

If someone could point me at what to study up on to understand this, I would greatly appreciate it.
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
Okay, you DON'T need to enable vewports to fix this. What has happened is that your room has no lower background layer. When a room has no background (either a sprite or a simple colour) then it means that everything is being drawn directly to the back buffer, and the back buffer isn't being cleared between each game frame, which is what gives the trippy trail effects. Adding a background colour on the layer under all the others means that this background colour is used to clear the back buffer of old image data at the start of every frame, and so you get no trail effect.

Hope that helps!
 
M

makani

Guest
Thank you so much for the speedy response! That sounds reasonable, but there must be something else I am missing. I do have a background layer, with a sprite that I have tiled both horizontally and vertically. I even set a background color. And it's still happening. I should clarify too - the way I described it originally made it sound like perhaps the trail disappeared after a while, but it doesn't. Every old drawing of the object remains forever. Any other thoughts?
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
Thank you so much for the speedy response! That sounds reasonable, but there must be something else I am missing. I do have a background layer, with a sprite that I have tiled both horizontally and vertically. I even set a background color. And it's still happening. I should clarify too - the way I described it originally made it sound like perhaps the trail disappeared after a while, but it doesn't. Every old drawing of the object remains forever. Any other thoughts?
This can only really be caused by what I explained above... things being drawn to the back-buffer and it not being cleared. Can you post a screenshot of the room editor that shows the layers in the room please? And a screenshot of what you are seeing (or a gif, or a video or something)?
 
M

makani

Guest
I figured it out. The sprite I was using was mostly transparent - just the border was not. Sorry about that. I am very new to dealing with graphics at all. I learned something today, thank you again for your help and patience!
 
Top