Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length

 
Advanced search

1075933 Posts in 44152 Topics- by 36119 Members - Latest Member: Royalhandstudios

December 29, 2014, 04:21:48 PM
TIGSource ForumsDeveloperTechnical (Moderators: Glaiel-Gamer, ThemsAllTook)Strange Game Maker surface glitch?
Pages: [1]
Print
Author Topic: Strange Game Maker surface glitch?  (Read 1499 times)
BlueSweatshirt
Level 10
*****

the void


View Profile WWW
« on: July 25, 2011, 02:10:20 AM »

This is among the reasons I detest the deceiving 'simplicity' of Game Maker.

When drawing to a surface in the Draw event, apparently surface_reset_target() won't reset view offset.
Surfaces normally draw to the screen buffer disregarding view coordinates. All other draw calls consider the view's position.

So all objects drawn after the object which had the surface drawing code will be drawn in an incorrect position on the screen. I can't fathom why the heck this is, especially since I am indeed calling surface_reset_target(). Is this a glitch in game maker or am I missing something?

Here's an example:
Code:
var s;
s = surface_create(32, 32);
surface_set_target(s);
surface_reset_target();
surface_free(s);
With that code in  the draw event, all objects drawn later will be drawn without the view position being taken into account, messing up the way sprites are drawn in your game if you're using the built-in view system.

I'm using the 8.0 version of Game Maker, so this bug might be fixed in the latest release.
Logged

Desert Dog
Level 4
****



View Profile
« Reply #1 on: July 25, 2011, 02:39:49 AM »

Why are you drawing it in the draw event? I don't work with surfaces much, but I'm fairly certain you are not meant to do that.. do it in the step event, then use the draw_surface functions.

Quote from: GM help
You should never change the drawing target while you are actually drawing on the screen, that is, never use it in drawing events. This will cause serious problems with the projection and viewport
Logged

JMickle
Level 10
*****


lqikq come home


View Profile
« Reply #2 on: July 25, 2011, 05:51:13 AM »

you really shouldn't be doing any of that in the draw event. move any code that isn't actual drawing or at the most small calculations to somewhere else, like the create or step event.
Logged

BlueSweatshirt
Level 10
*****

the void


View Profile WWW
« Reply #3 on: July 25, 2011, 10:15:31 AM »

I find that very bizarre.  Waaagh!


Good to know, though.
Logged

ஒழுக்கின்மை
Level 10
*****


Also known as रिंकू.

RinkuHero
View Profile WWW Email
« Reply #4 on: July 25, 2011, 10:18:47 AM »

yeah, don't draw to surfaces in the draw event, it slows down drawing and in some cases won't even work

also, i'm not actually sure what you're talking about regarding views and surfaces. wouldn't it be weirder if drawing on surfaces *did* take the views into account? it makes more sense to me that views are ignored when you draw on a surface, because a surface is for most practical purposes a separate 'view' of the game, just one that isn't visible, and one that you can draw on top of other views
Logged

BlueSweatshirt
Level 10
*****

the void


View Profile WWW
« Reply #5 on: July 25, 2011, 10:26:52 AM »

Of course.

But the problem was that it wasn't changing back to using the view coordinates after I tried to reset the surface.

Meh.
Logged

ஒழுக்கின்மை
Level 10
*****


Also known as रिंकू.

RinkuHero
View Profile WWW Email
« Reply #6 on: July 25, 2011, 11:11:33 AM »

ah, i see. yes, drawing on surfaces in the step event rather than the draw event should solve that.
Logged

Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic