c++ - 最后一幕出现黑色背景

标签 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

最佳答案

当气球到达最终位置时,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;
}

关于c++ - 最后一幕出现黑色背景,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54091033/

相关文章:

glTexImage2D 上的 OpenGL 3.2 GL_INVALID_ENUM(GL_PROXY_TEXTURE_2D ...)

c++ - PBO 的竞争条件

c++ - 重绘时如何避免重新启动多边形?

c++ - SIGABRT 试图抛出异常时

c++ - 如何从 C 代码调用 C++ 函数

OpenGL 是否足够稳定以支持 24/7 运行程序?

c - 在等待响应的同时保持游戏运行?

c++ - 测试低带宽网络

C++ 在 while 循环中使用 switch 时输出相同

c++ - 在 VirtualBox 的共享文件夹中构建符号链接(symbolic link)共享库