如何打开和关闭场景中的环境光

时间:2016-04-12 10:41:11

标签: opengl

在我的场景中,我有环境光,其值为:

GLfloat global_ambient[] = {0.4, 0.4, 0.4};

在我的initGL中,我启用了它:

glLightModelfv(GL_LIGHT_MODEL_AMBIENT, global_ambient);

我想按“s”键来打开和关闭灯光。我知道如何切换光线,我的问题是有一种方法,如glEnagle和glDisable用于环境光吗?

1 个答案:

答案 0 :(得分:0)

自己想一想。在用户按下'关键这就是我在做的事情:

#include <iostream>
#include <exception>
using namespace std;

void C() 
{
    throw exception();
}

void B() 
{
    C();
}

void A() 
{
    try {
        B();
    } catch (exception& e) {
        cout << e.what();      // Here you can access the exception thrown by C()
    }
}

int main()
{
    A();
}

在我的DrawScene方法中:

insert into test (sometext) values ("?"),("?")