最后一个场景出现黑色背景

时间:2019-01-08 11:37:37

标签: c++ opengl glut

我有一个问题,一旦热气球降落到地面,就会出现黑色背景。

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;
}

我在这里显示此代码是因为这是我更改的唯一代码,使黑色背景出现。

Click here to see the full code

1 个答案:

答案 0 :(得分:2)

气球序号到达最终位置时,state为0。如果state == 0也必须绘制背景:

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;
}