Register
mmozeiko
Mārtiņš Možeiko
1131 posts
1 project
#6103 Bug with fader window
March 13, 2016, 2:17 a.m. Edited by Mārtiņš Možeiko on March 13, 2016, 2:35 a.m.

In win32_handmade.cpp we have following code:
1
2
    win32_fader Fader;
    InitFader(&Fader, Instance);

InitFader function only tries to set Fader->Window member, but always leaves Fader->State and Fader->Alpha uninitialized. It actually can also skip assignment to Fader->Window if RegisterClassA fails (unlikely).

Not initializing Fader->State member, will make assertion later in UpdateFade to fail:
1
2
3
4
5
6
7
8
switch(Fader->State)
{
    ...
    default:
    {
        Assert(!"Unrecognized fader state!");
    } break;    
}

Because Fader->State will contain garbage value (whatever is on the stack in Fader structure) and no case will match it.