• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

GameMaker 3D Causing strange bug with surfaces since recent patch

Kealor

Member
I am using a 3D environment and Basically yesterday my hud was drawing properly and today its not. For instance draw_circle(0,0,10,false) does not actually draw a circle with radius 10 at [0,0], it draws at an adjusted position and at an odd scaling.

The first thought ofcourse is to disable 3D during the draw phase, however i cannot find any method of doing this that actually works, changing to an orthographic camera, changing the perspective to be orthographic and disabling surface depths all do nothing.

I have this problem in a project which is very entangled so i made a test that seems to get the idea across, it is very simple: https://www.dropbox.com/s/5nym0akqhcf4d86/3d bug test.yyz?dl=0 . I can give additional code from my main project if it would help.

In that test project some circles should be drawn to a surface, which then in turn is drawn to the gui. But that just doesnt happen. You can click the left mouse button to toggle 3d on/of, and the magic part is if you turn it off then on again, the circles now draw.

This issue is absolutely baffling, and even better, it only seems to have been since the recent patch. I have pulled up old build on my github and this issue has never been present in the past before. One of the recent patches seems to have broken it (last 8-9 days ish) but it only showed up after cleaning and building again.

Documentation for surfaces in 3d are scarce since most guides/tutorials seem to end at getting the basics of 3d up and running. Ive seen 2 cases where this issue was found online, but both of their solutions dont help, one even makes things worse.

Here is a circle allegedly being drawn at 0,0.
unknown.png
GMS2 for some reason flipping all of my surfaces i have come to terms with, however even when upside down, that is not 0,0, more like 50,30.

Special-er still, changing the depth of the object drawing does affect the output, but its is absurd and unpredictable, ie of the same cricle draws get bigger, some get smaller, others have larger offsets etc.

What the hell is going on.
Please send help.
 

Bart

WiseBart
You should always make sure to clear a surface before drawing to it. That solves the first issue.

For the second issue, are you sure that the projection is correct and that it is active (for this, there is camera_apply)?

Not entirely sure about the last issue you're describing. Although it does sound like another issue with the projection.
If the circle size changes when you change its depth, chances are that you're still using a perspective projection at the moment that circle gets drawn.
 

Kealor

Member
You should always make sure to clear a surface before drawing to it. That solves the first issue.

For the second issue, are you sure that the projection is correct and that it is active (for this, there is camera_apply)?

Not entirely sure about the last issue you're describing. Although it does sound like another issue with the projection.
If the circle size changes when you change its depth, chances are that you're still using a perspective projection at the moment that circle gets drawn.
Cheers for the help

okay so i did forget to add a clear in the test project and that does make the circles draw, but in my main project i have draw clears after every surface_set_target(). So draw clear has some hidden functionality in it where it resets the camera settings of a surface to the current camera settings? Whyyyyyyy though? And how come i cant find anything written about this lmao.

I tried using camera_apply in multiple ways but none of them seemed to work, i may have missed the correct way but i have no idea what that way is (if this is the issue). I tried using a "scr_3D_enable" and "scr_3D_disable" script system where in it ztesting/zdrawing were enabled/disabled and either: setting the current cameras projection matrix to be ortho/proj or switching to a different camera which was ortho then back. Then running camera_apply for the relevant camera in each of those scripts.
Projection matrices are defined by:
Code:
    //perspective (-fovY = 60)
projMatPers = matrix_build_projection_perspective_fov(-fovY, view_get_wport(0)/view_get_hport(0), 5, 32000);
       //Orthographic
projMatOrth = matrix_build_projection_ortho(320,176,5, 32000);
Ill dump some code from my project and ill see about making the test project more analogous to mine in a sec:
https://www.dropbox.com/s/5fk30yqz0gjsx11/hudmanager snippet.txt?dl=0
(this uses alot of #region/#endregion stuff so dropping it in gms2 or a supporting editor will be MUCH neater)
 

Kealor

Member
Did you use camera apply after setting the surface as the render target, but before drawing anything to that surface?
just tried that and it doesnt work, but i did find a lead from that which i dont think im going to like.

So when i add a "camera_apply(Camera.cam)" immediately after each surface, and wrap the entire drawGUI event in:

Code:
camera_set_proj_mat(Camera.camNormal,Camera.projMatOrth);
gpu_set_zwriteenable(false);
gpu_set_ztestenable(false);

//MY CODE HERE

camera_set_proj_mat(Camera.camNormal,Camera.projMatPers);
gpu_set_zwriteenable(true);
gpu_set_ztestenable(true);
i get this (note there is still a circle being drawn at 0,0 like before, its just that position is now off-screen):
Untitled.png
joyfully it is now mirrored AND flipped.

So my question is: is this because my ortho projection is not accustomed to this surface of 640x360, and for every single surface usage i have to custom rig it with a unique projection matrix?

Also there has to be a reason as to why this exact same setup im using worked on yesterdays GMS2, but not todays.
 
If you're using an orthograhpic projection, and you want things to be scaled 1:1, then you must set the size of that projection equal to the size of the surface you're drawing onto.

You will also need to set the view matrix to make sure the camera is located at the right position, and pointing in the right direction.
 

Kealor

Member
If you're using an orthograhpic projection, and you want things to be scaled 1:1, then you must set the size of that projection equal to the size of the surface you're drawing onto.

You will also need to set the view matrix to make sure the camera is located at the right position, and pointing in the right direction.
That does sound really annoying, ill try that right now, but it doesnt make 100% sense to me. When in 2D you dont need to organize your default projection to be in line with each surface constantly, is "gpu_set_zwriteenable" delayed till the end of the event or something?

And is there any way to circumvent this without having to do this projection stuff for every surface (though i can imagine a clean-ish method where i make some dupe of "surface_set_target" script)
 
Well, I only have GMS1, but it appears, reading the GMS2 docs, that there are other ways of setting an orthographic projection, using camera set view functions. zwriting shouldn't have any effect on the size or shape of the view, as long as it isn't causing things to be occluded that you are expecting to see, and thus leading you to believe that the view is not correct.

In gms1, and I believe it used to work this way in gms2 in the past, when you set a surface as a render target, it appears to automatically set an orthographic projection to fit that surface. Now the real mystery is why, as you say, the behavoir seems to change when working with 3d, because how does gamemaker even know when you've been using a perspective projection? In which draw event are you drawing onto your surface?
 

Kealor

Member
Well, I only have GMS1, but it appears, reading the GMS2 docs, that there are other ways of setting an orthographic projection, using camera set view functions. zwriting shouldn't have any effect on the size or shape of the view, as long as it isn't causing things to be occluded that you are expecting to see, and thus leading you to believe that the view is not correct.

In gms1, and I believe it used to work this way in gms2 in the past, when you set a surface as a render target, it appears to automatically set an orthographic projection to fit that surface. Now the real mystery is why, as you say, the behavoir seems to change when working with 3d, because how does gamemaker even know when you've been using a perspective projection? In which draw event are you drawing onto your surface?
in the draw GUI event (not begin or end, just the regular). which is further odd since it seems that gms2 forces 3d off there anyway. So if i use "draw_circle(0,0,10,false)" with no surface it all comes out fine.
 

Bart

WiseBart
Ah yes. You're drawing in the Draw GUI event. So no view camera is active there.

Just an idea, but since the issue seems to lie somewhere in drawing to a surface in the Draw GUI event, why not draw the surface in the Pre-Draw event and then simply do a draw_surface in the Draw GUI event?
The Pre-Draw event is also an event where views aren't in use.
 

Kealor

Member
Okay so i replaced all instances of "surface_set_target" with "surface_set_target_test", same with reset:

surface_set_target_test:
Code:
///@arg surfaceID

var surf = argument0;

surface_set_target(surf);

var newMat = matrix_build_projection_ortho(surface_get_width(surf),surface_get_height(surf),5,32000);
camera_set_proj_mat(Camera.camNormal,newMat);
camera_apply(Camera.camNormal);
surface_reset_target_test:
Code:
surface_reset_target();

camera_set_proj_mat(Camera.camNormal,Camera.projMatPers);
camera_apply(Camera.camNormal);
and the result is:
Untitled.png

now that quarter circle up top looks promising because thats how the circle should look. Buuuuuut thats not actually what the surface looks like
Untitled.png
its just being cropped in the next surface (the pipeline here is actually surface1 gets drawn onto surface 2, then surface 2 is drawn to gui)

Also the base circle+spear thingos are vibrating constantly, and the green/blue bars and their backs are moving relative to the camera
 

Kealor

Member
Ah yes. You're drawing in the Draw GUI event. So no view camera is active there.

Just an idea, but since the issue seems to lie somewhere in drawing to a surface in the Draw GUI event, why not draw the surface in the Pre-Draw event and then simply do a draw_surface in the Draw GUI event?
The Pre-Draw event is also an event where views aren't in use.
Ive tried that before and everything was blank in the final, but i just looked into it and everything varies randomly :D

Code:
Code:
    //initials
var GUIWidth = surface_get_width(application_surface);
var GUIHeight = surface_get_height(application_surface);
var camX = camera_get_view_x(Camera.camNormal);
var camY = camera_get_view_y(Camera.camNormal);

    #region setup surfaces
    if !surface_exists(topLeftSurf) {topLeftSurf = surface_create(GUIWidth/topLeftResolutionScale,GUIHeight/topLeftResolutionScale); resetBars = true;};
    if !surface_exists(hpSurf) {hpSurf = surface_create(GUIWidth/topLeftResolutionScale,GUIHeight/topLeftResolutionScale); resetBars = true;}
    if !surface_exists(hpSurfA) {hpSurfA = surface_create(GUIWidth/topLeftResolutionScale,GUIHeight/topLeftResolutionScale); resetBars = true;}
    if !surface_exists(hpSurfB) {hpSurfB = surface_create(GUIWidth/topLeftResolutionScale,GUIHeight/topLeftResolutionScale); resetBars = true;}
    if !surface_exists(hpSurfC) {hpSurfC = surface_create(GUIWidth/topLeftResolutionScale,GUIHeight/topLeftResolutionScale); resetBars = true;}
    if !surface_exists(hpSurfD) {hpSurfD = surface_create(GUIWidth/topLeftResolutionScale,GUIHeight/topLeftResolutionScale); resetBars = true;}
    if !surface_exists(mpSurf) {mpSurf = surface_create(GUIWidth/topLeftResolutionScale,GUIHeight/topLeftResolutionScale); resetBars = true;}
    if !surface_exists(mpSurfA) {mpSurfA = surface_create(GUIWidth/topLeftResolutionScale,GUIHeight/topLeftResolutionScale); resetBars = true;}
   
    if (resetBars)
    {
        hpDamageDisplayPrev = noone;
        hpMaxPrev = noone;
        hpPrev = noone;
        mpMaxPrev = noone;
        mpPrev = noone;
    }
    resetBars = false;
        #endregion
       
    #region Base
    surface_set_target(hpSurfD);
        draw_clear_alpha(c_black,0.0);
            #region Spears and band
    if (mouse_check_button_pressed(mb_left)) expansionOpen = !expansionOpen;
    if (expansionOpen) expansionSpd += 0.1;
    else expansionSpd -= 0.03;
   
    var p = expansionVar;
    expansionVar = clamp(expansionVar+expansionSpd,0.0,1.0);
    if (expansionVar != p+expansionSpd)
    {
        expansionSpd *= -0.68;
        if (abs(expansionSpd) <= 0.03) expansionSpd = 0;
    }
           
    var cx = hpXI-5;
    var cy = hpYI-5;
    var rootDist = expansionRootDist;
    var minDist = expansionBaseDist;
    var maxDist = expansionBaseDist+expansionVar*(expansionMaxDist-expansionBaseDist);
    var s1x,s1y,s2x,s2y;
   
                #region spears
        //spear 1
    var dir = 270;
    var col = make_colour_rgb(204,183,133);
    s1x = cx+rootDist*dcos(dir);
    s1y = cy-rootDist*dsin(dir);
    s2x = cx+maxDist*dcos(dir);
    s2y = cy-maxDist*dsin(dir);
    draw_line_color(s1x,s1y,s2x,s2y,col,col);
    draw_sprite(spr_uiBase_spear1,0,s2x,s2y);
        //spear 2
    var dir = 292.5;
    var col = make_colour_rgb(170,170,170);
    s1x = cx+rootDist*dcos(dir);
    s1y = cy-rootDist*dsin(dir);
    s2x = cx+maxDist*dcos(dir);
    s2y = cy-maxDist*dsin(dir);
    draw_line_color(s1x,s1y,s2x,s2y,col,col);
    draw_sprite(spr_uiBase_spear2,0,s2x,s2y);
        //spear 3
    var dir = 315;
    var col = make_colour_rgb(213,213,213);
    s1x = cx+rootDist*dcos(dir);
    s1y = cy-rootDist*dsin(dir);
    s2x = cx+maxDist*dcos(dir);
    s2y = cy-maxDist*dsin(dir);
    draw_line_color(s1x,s1y,s2x,s2y,col,col);
    draw_sprite(spr_uiBase_spear3,0,s2x,s2y);
        //spear 4
    var dir = 337.5;
    var col = make_colour_rgb(170,170,170);
    s1x = cx+rootDist*dcos(dir);
    s1y = cy-rootDist*dsin(dir);
    s2x = cx+maxDist*dcos(dir);
    s2y = cy-maxDist*dsin(dir);
    draw_line_color(s1x,s1y,s2x,s2y,col,col);
    draw_sprite(spr_uiBase_spear4,0,s2x,s2y);
        //spear 5
    var _mpMax = floor(PlayerStats.mpMax);
    var _mpSize = max(floor(_mpMax/mpPP)+2,2);
    var col = make_colour_rgb(204,183,133);
    s1x = cx+max(min(minDist,_mpSize+8),16);
    s1y = cy;
    s2x = cx+max(maxDist,minDist,_mpSize+26);
    s2y = cy;
    draw_line_color(s1x,s1y,s2x,s2y,col,col);
    draw_sprite(spr_uiBase_spear5,0,s2x,s2y+1);
                #endregion
                #region Band
    draw_sprite(spr_uiBase_band,0,cx+2,cy+3);
                #endregion
            #endregion
            #region Back static
        draw_sprite(spr_uiBase_base,0,hpXI,hpYI);
        /**/draw_circle(0,0,10,false);/**/
            #endregion
    surface_reset_target();
        #endregion
    #region Mp
    var mp = floor(PlayerStats.mp);
    var mpMax = floor(PlayerStats.mpMax);
   
    if mp != mpPrev || mpMax != mpMaxPrev
    {
        surface_set_target(mpSurf);
        draw_clear_alpha(c_white,0);
            #region Back
                #region draw bar mp + caps
    //bar
    var size = max(floor(mpMax/mpPP)+2,2);
    var sprW = sprite_get_width(spr_mp_base_bar);
    var sprH = sprite_get_height(spr_mp_base_bar);
    var n = size/sprW;
    for(var i = 0; i < n; i++)
    {
        var xPart = min(n-i,1);
        draw_sprite_part(spr_mp_base_bar,min(i,1),0,0,floor(sprW*xPart),sprH,mpXI+i*sprW,mpYI);
    }
    //bar2/3
    var sprW = sprite_get_width(spr_mp_base_bar2);
    var sprH = sprite_get_height(spr_mp_base_bar2);
    var n = round((size)/sprW);
    for(var i = 0; i < n; i++)
    {
        if (i != 0) draw_sprite(spr_mp_base_bar2,0,mpXI+i*sprW+6,mpYI+9);
        else draw_sprite_part(spr_mp_base_bar2,0,12,0,12,5,mpXI+i*sprW+6-2,mpYI+9);
    }
    //end cap
    var cX = mpXI+size;
    var cY = mpYI+5;
    draw_sprite_ext(spr_mp_base_cap,0,cX,cY,1,1,-90,c_white,1.0);
        #endregion
            #endregion  
            #region fill
                #region draw bar mp
    //bar
    var size = floor(mp/mpPP);
    var sprW = sprite_get_width(spr_mp_fill_bar);
    var sprH = sprite_get_height(spr_mp_fill_bar);
    var n = size/sprW;
    for(var i = 0; i < n; i++)
    {
        var xPart = min(n-i,1);
        draw_sprite_part_ext(spr_mp_fill_bar,min(i,1),0,0,round(sprW*xPart),sprH,mpXI+1+i*sprW,mpYI+2,1,1,mpColour,1.0);
    }
        #endregion
            #endregion      
        surface_reset_target();
    }
    mpPrev = mp;
    mpMaxPrev = mpMax;
   
    surface_set_target(mpSurfA);
    draw_clear_alpha(c_white,0);
            #region Animation
    //preliminaries
    mpAnimTimer++;
    var subID = floor(mpAnimTimer/mpAnimStep);
    //bar
    var size = (mp/mpPP);
    var sprW = sprite_get_width(spr_mp_anim_bar1);
    var sprH = sprite_get_height(spr_mp_anim_bar1);
    var n = size/sprW;
    for(var i = 0; i < n; i++)
    {
        var xPart = min(n-i,1);
        var spr = spr_mp_anim_bar2;
        if (i == 0) spr = spr_mp_anim_bar1;
        draw_sprite_part(spr,subID,0,0,sprW*xPart,sprH,mpXI+1+i*sprW,mpYI+2);
    }
            #endregion
    surface_reset_target();
    draw_set_colour(c_white);

        #endregion
    #region Hp
    var v = hpPP*pi*hpR1*(4/3);
            #region Back
    var hpMax = PlayerStats.hpMax;
    //show_debug_message(hpMax)
    if hpMax != hpMaxPrev
    {
        surface_set_target(hpSurfB);
        draw_clear_alpha(c_white,0);
        #region preliminaries
var barHp = max(hpMax-v,0);
var curveHp = clamp(hpMax,0,v);
var hpd = 270*(curveHp/v);

draw_set_colour(hpBackColour);
        #endregion
        #region draw circle-triangle
draw_sprite(spr_hp_base_curve_0,0,hpXI+1,hpYI+1);
draw_sprite(spr_hp_base_curve_1,0,hpXI,hpYI+1);
draw_sprite(spr_hp_base_curve_2,0,hpXI,hpYI);
        #endregion
        #region draw circle-triangle cutout
d = 90;
gpu_set_blendmode(bm_subtract)
for(var i=0; i<hpA; i++;)
{
var p1x= hpXI;
var p1y= hpYI;
var p2x= hpXI + dcos(d)*(hpRMax);
var p2y= hpYI - dsin(d)*(hpRMax);
d += (270-hpd)/hpA;
var p3x= hpXI + dcos(d)*(hpRMax);
var p3y= hpYI - dsin(d)*(hpRMax);
draw_triangle(p1x,p1y,p2x,p2y,p3x,p3y,0);
}
gpu_set_blendmode(bm_normal)
        #endregion
        #region draw bar hp + caps
//bar
var size = floor(barHp/hpPP);
var sprW = sprite_get_width(spr_hp_base_bar);
var sprH = sprite_get_height(spr_hp_base_bar);
var n = size/sprW;
for(var i = 0; i < n; i++)
{
var xPart = min(n-i,1);
draw_sprite_part(spr_hp_base_bar,0,0,0,floor(sprW*xPart),sprH,hpXI+1+i*sprW,hpYI-35);
}
//start cap
var dst = 25;
draw_sprite_ext(spr_hp_base_cap,0,hpXI+1+dst,hpYI,1,1,0,c_white,1.0);
//end cap
if hpMax < v
{
var cX = hpXI+1+dcos(hpd+1.8)*dst;
var cY = hpYI+1+dsin(hpd+1.8)*dst;
draw_sprite_ext(spr_hp_base_cap,1,cX,cY,1,1,180-hpd,c_white,1.0);
}
else
{
var cX = hpXI+2+size;
var cY = hpYI+1-dst;
draw_sprite_ext(spr_hp_base_cap,2,cX,cY,1,1,-90,c_white,1.0);
}
//little bit
var xPart = min(n,1);
draw_sprite_part(spr_hp_littleBit,0,0,0,sprW*xPart,sprH,hpXI+1,hpYI-19);
#endregion
        surface_reset_target();
    }
    hpMaxPrev = hpMax;
            #endregion
            #region Fill
        var hp = PlayerStats.hp;
        var hpDam = min(hpDamageDisplay,hpMax);
            #region preliminaries
        if PlayerStats.hpMax < hpDamageDisplay hpDamageDisplay = PlayerStats.hpMax;
               
        if hp > hpDamageDisplay
        {
            hpDamageTarget = hp;
            hpDamageDisplay = hp;
        }
        else if hp == hpDamageTarget
        {
            hpDamageDisplay += (hp-hpDamageDisplay)/8;
        }
        else
        {
            hpDamageDelayTimer++;
            if hpDamageDelayTimer >= round(hpDamageDelay*room_speed)
            {
                hpDamageTarget = hp;
                hpDamageDelayTimer = 0;
            }
        }
                #endregion
        if hpDam != hpDamageDisplayPrev || hp != hpPrev
        {
                #region draw damage portion
                    #region preliminaries
    var barHp= max(hpDam-v,0);
    var curveHp= clamp(hpDam,0,v);
    var hpd = 270*(curveHp/v);
       
    draw_set_colour(hpBackColour);
                    #endregion
                    surface_set_target(hpSurfC);
                    draw_clear_alpha(c_white,0);
                    #region draw circle-triangle
        draw_sprite_ext(spr_hp_fill_curve_0,0,hpXI+1,hpYI+1,1,1,0,hpDamageColour,1.0);
        draw_sprite_ext(spr_hp_fill_curve_1,0,hpXI,hpYI+1,1,1,0,hpDamageColour,1.0);
        draw_sprite_ext(spr_hp_fill_curve_2,0,hpXI,hpYI,1,1,0,hpDamageColour,1.0);
                    #endregion
                    #region draw circle-triangle cutout
        d = 90;
        gpu_set_blendmode(bm_subtract)
        for(var i=0; i<hpA; i++;)
        {
            var p1x = hpXI;
            var p1y = hpYI;
            var p2x = hpXI + dcos(d)*(hpRMax);
            var p2y = hpYI - dsin(d)*(hpRMax);
            d += (270-hpd)/hpA;
            var p3x = hpXI + dcos(d)*(hpRMax);
            var p3y = hpYI - dsin(d)*(hpRMax);
            draw_triangle(p1x,p1y,p2x,p2y,p3x,p3y,0);
        }
        gpu_set_blendmode(bm_normal)
                    #endregion
                    #region draw bar hp
    //bar
    var size = floor(barHp/hpPP);
    var sprW = sprite_get_width(spr_hp_fill_bar);
    var sprH = sprite_get_height(spr_hp_fill_bar);
    var n = size/sprW;
    for(var i = 0; i < n; i++)
    {
        var xPart = min(n-i,1);
        draw_sprite_part_ext(spr_hp_fill_bar,0,0,0,round(sprW*xPart),sprH,hpXI+1+i*sprW,hpYI-28,1,1,hpDamageColour,1.0);
    }
        #endregion
                    surface_reset_target();
                #endregion
                #region draw main hp portion
                    #region preliminaries
    var barHp= max(hp-v,0);
    var curveHp= clamp(hp,0,v);
    var hpd = 270*(curveHp/v);
       
    draw_set_colour(hpBackColour);
                    #endregion
                    surface_set_target(hpSurf);
                    draw_clear_alpha(c_white,0);
                    #region draw circle-triangle
        draw_sprite_ext(spr_hp_fill_curve_0,0,hpXI+1,hpYI+1,1,1,0,hpColour,1.0);
        draw_sprite_ext(spr_hp_fill_curve_1,0,hpXI,hpYI+1,1,1,0,hpColour,1.0);
        draw_sprite_ext(spr_hp_fill_curve_2,0,hpXI,hpYI,1,1,0,hpColour,1.0);
                    #endregion
                    #region draw circle-triangle cutout
        d = 90;
        gpu_set_blendmode(bm_subtract)
        for(var i=0; i<hpA; i++;)
        {
            var p1x = hpXI;
            var p1y = hpYI;
            var p2x = hpXI + dcos(d)*(hpRMax);
            var p2y = hpYI - dsin(d)*(hpRMax);
            d += (270-hpd)/hpA;
            var p3x = hpXI + dcos(d)*(hpRMax);
            var p3y = hpYI - dsin(d)*(hpRMax);
            draw_triangle(p1x,p1y,p2x,p2y,p3x,p3y,0);
        }
        gpu_set_blendmode(bm_normal)
                    #endregion
                    #region draw bar hp
    //bar
    var size = floor(barHp/hpPP);
    var sprW = sprite_get_width(spr_hp_fill_bar);
    var sprH = sprite_get_height(spr_hp_fill_bar);
    var n = size/sprW;
    for(var i = 0; i < n; i++)
    {
        var xPart = min(n-i,1);
        draw_sprite_part_ext(spr_hp_fill_bar,0,0,0,round(sprW*xPart),sprH,hpXI+1+i*sprW,hpYI-28,1,1,hpColour,1.0);
    }
        #endregion
                    surface_reset_target();
                #endregion
        }
        hpDamageDisplayPrev = hpDam;
        hpPrev = hp;
                #region animation
                    #region preliminaries
    hpAnimTimer++;
    var animHP = max(hpDamageDisplay,hp);
    var barHp= max(animHP-v,0);
    var curveHp= clamp(animHP,0,v);
    var hpd = 270*(curveHp/v);
   
    var subID = floor(hpAnimTimer/hpAnimStep);
       
    draw_set_colour(hpBackColour);
                    #endregion
                    surface_set_target(hpSurfA);
                    draw_clear_alpha(c_black,0.0);
                    #region draw circle-triangle
        draw_sprite(spr_hp_anim_curve_0,subID,hpXI+1,hpYI+1);
        draw_sprite(spr_hp_anim_curve_1,subID,hpXI,hpYI+1);
        draw_sprite(spr_hp_anim_curve_2,subID,hpXI,hpYI);
                    #endregion
                    #region draw circle-triangle cutout
        d = 90;
        gpu_set_blendmode(bm_subtract);
        draw_set_colour(c_white);
        for(var i=0; i<hpA; i++;)
        {
            var p1x = hpXI;
            var p1y = hpYI;
            var p2x = hpXI + dcos(d)*(hpRMax);
            var p2y = hpYI - dsin(d)*(hpRMax);
            d += (270-hpd)/hpA;
            var p3x = hpXI + dcos(d)*(hpRMax);
            var p3y = hpYI - dsin(d)*(hpRMax);
            draw_triangle(p1x,p1y,p2x,p2y,p3x,p3y,0);
        }
        gpu_set_blendmode(bm_normal)
                    #endregion
                    #region draw bar hp
    //bar
    var size = floor(barHp/hpPP-1);
    var sprW = sprite_get_width(spr_hp_anim_bar);
    var sprH = sprite_get_height(spr_hp_anim_bar);
    var n = size/sprW;
    for(var i = 0; i < n; i++)
    {
        var xPart = min(n-i,1);
        draw_sprite_part(spr_hp_anim_bar,subID,0,0,ceil(sprW*xPart),sprH,hpXI+1+i*sprW,hpYI-28);
    }
        #endregion
                    surface_reset_target();
                #endregion
            #endregion
        #endregion

    #region final draw
    surface_set_target(topLeftSurf);
        draw_clear_alpha(c_black,0);
            draw_surface(hpSurfD,0,0); //Back Static
        //if (!keyboard_check(vk_numpad0)) {
            draw_surface(hpSurfB,0,0); //Outline
        //}
        //if (!keyboard_check(vk_numpad4)) {
            draw_surface(hpSurfC,0,0); //Red bar
        //}
        //if (!keyboard_check(vk_numpad2)) {
            draw_surface(hpSurf,0,0); //Green bar
        //}
        gpu_set_blendmode(bm_add)
        //if (!keyboard_check(vk_numpad3)) {
            draw_surface_ext(hpSurfA,0,0,1,1,0,c_white,0.3);
        //}
        gpu_set_blendmode(bm_normal);
        draw_surface(mpSurf,0,0);
        gpu_set_blendmode(bm_add)
        draw_surface_ext(mpSurfA,0,0,1,1,0,c_white,0.3);
        gpu_set_blendmode(bm_normal);
    surface_reset_target();
    #endregion

More important bits:
hpSurfD:
Code:
    surface_set_target(hpSurfD);
        draw_clear_alpha(c_black,0.0);
            #region Spears and band                                               //(CLOSED FOR THIS FORUM POST, THERE IS STUFF IN HERE)
            #region Back static
        draw_sprite(spr_uiBase_base,0,hpXI,hpYI);
        /**/draw_circle(0,0,10,false);/**/
            #endregion
    surface_reset_target();
Result:Untitled.png

hpSurfB:
Code:
if hpMax != hpMaxPrev
    {
        surface_set_target(hpSurfB);
        draw_clear_alpha(c_white,0);
        #region preliminaries                                                       //(CLOSED FOR THIS FORUM POST, THERE IS STUFF IN HERE)
        #region draw circle-triangle                                             //(CLOSED FOR THIS FORUM POST, THERE IS STUFF IN HERE)
        #region draw circle-triangle cutout                                  //(CLOSED FOR THIS FORUM POST, THERE IS STUFF IN HERE)
        #region draw bar hp + caps                                            //(CLOSED FOR THIS FORUM POST, THERE IS STUFF IN HERE)
        surface_reset_target();
    }
ResultUntitled.png

So one actually gets something drawn, the other doesnt. The main difference in the code is that the one that does draw is conditional, in this case it is only drawn on the first run, the others are updated per-frame though.

Edit: combining this with the previous solution and using my "surface_set/reset_target_test" scripts in place of the normal ones just adds an offset to the ones that do draw, nothing else.
 

Kealor

Member
Update and slight bumpage

So ive tested my "ree this isnt my fault" theory and loaded up older runtimes.

Runtimes 2.2.4.364 and newer have all of the issues above and my surfaces are borked
Runtimes 2.2.3.344 and older (atleast the last 2 before) work perfectly fine

can anybody think of an explanation as to how this could be caused? If nobody else has reported experiencing this then what could i be doing that others arent?

And also, should i try to get in contact with YYG somehow? Even if my code was the most spaghetti thing imaginable, an issue like this shouldn't be varying across run-times right?

Finally, can it be fixed? Temp solution is to just use that older runtime, but i would like to stay up to date lol
 
Last edited:

Nocturne

Friendly Tyrant
Forum Staff
Admin
Runtimes 2.2.4.364 and newer have all of the issues above and my surfaces are borked
Runtimes 2.2.3.344 and older (atleast the last 2 before) work perfectly fine

can anybody think of an explanation as to how this could be caused? If nobody else has reported experiencing this then what could i be doing that others arent?

And also, should i try to get in contact with YYG somehow? Even if my code was the most spaghetti thing imaginable, an issue like this should be varying across run-times right?
I would create a YYZ of the project and file a bug with YYG. If there is a clear difference between runtimes then it would suggest that either something has changed (and should be documented) or something has broken (and should be fixed). Either ay, YYG has to know about it. You can file a bug from the IDE Help menu and you'll need to host the YYZ file somewhere and supply a link to it in the bug report...
 

Kealor

Member
I would create a YYZ of the project and file a bug with YYG. If there is a clear difference between runtimes then it would suggest that either something has changed (and should be documented) or something has broken (and should be fixed). Either ay, YYG has to know about it. You can file a bug from the IDE Help menu and you'll need to host the YYZ file somewhere and supply a link to it in the bug report...
Sent a bug report, fingers crossed lol
 
Top