Search code examples
c++openglglut

Black background appears on the last scene


I have a problem, once the hot air balloon reaches the ground, a black background appears.

enter image description here

// a switch case based on state with appropriate calls
switch (state) {
// scene 1
case 1:     
    drawBackground1(); // the first background to appear
    drawSlogan1(); // display the first slogan
    break;
// scene 2
case 2:     
    drawBackground2(); // the second background to appear
    drawSlogan2(); // display the second slogan
    break;
// scene 3
case 3:     
    drawBackground1(); // the third background to appear
    drawSlogan3(); // display the last slogan
    break;
}

I am showing this code here is because this is the only code I have changed, that made the black background appear.

Click here to see the full code


Solution

  • When the balloon reaches the final position, then state is 0. You have to draw the background if state == 0, too:

    switch (state) {
    case 0: 
        drawBackground1(); // the third background to appear
        break;
    case 1:     
        drawBackground1(); // the first background to appear
        drawSlogan1(); // display the first slogan
        break;
    case 2:     
        drawBackground2(); // the second background to appear
        drawSlogan2(); // display the second slogan
        break;
    case 3:     
        drawBackground1(); // the third background to appear
        drawSlogan3(); // display the last slogan
        break;
    }