在我調用OpenGL函數後,我每次都在代碼中添加glGetError()
。來自glGetError()的INVALID_ENUM錯誤。 gl,glu,glew,glfw?
其實我不會撥打glGetError()
,而是寫一個函數(DisplayGlErrors()
)來打印控制檯中的所有錯誤(通過一個循環)。所以,現在我想,每次我打電話給我的功能後(例如)gluLookAt()
我應該能夠得到所有由openGL槽功能引起的錯誤。
現在讓我們來談談我的問題。從這段代碼:
GL_engine::GL_engine(Application* appli):engine(appli), width(get_parent()->getWidth()), height(get_parent()->getHeight())
{
if (GLEW_OK != glewInit()) // glew needs to be initialised, otherwise we get an error, AFTER a windows has been created BUT BEFORE using buffers
{
std::cout << "glewInit() failed" << std::endl;
exit(EXIT_FAILURE);
}
DisplayGlErrors(__FILE__, __LINE__);
glGetIntegerv(GL_MAJOR_VERSION, &contextMajor); DisplayGlErrors(__FILE__, __LINE__);
glGetIntegerv(GL_MINOR_VERSION, &contextMinor); DisplayGlErrors(__FILE__, __LINE__);
std::cout << "Created OpenGL " << contextMajor <<"."<< contextMinor << " context" << std::endl;
glClearColor(0.25f, 0.25f, 0.25f, 1.0f); DisplayGlErrors(__FILE__, __LINE__);
cam = Camera(); DisplayGlErrors(__FILE__, __LINE__);
worldAxis.initialise(); DisplayGlErrors(__FILE__, __LINE__); DisplayGlErrors(__FILE__, __LINE__);
worldGrid.initialise(); DisplayGlErrors(__FILE__, __LINE__); DisplayGlErrors(__FILE__, __LINE__);
}
我(在控制檯):
OpenGL error #1: INVALID_ENUM(/WelcomeToYourPersonalComputerInferno/666/src/GL_engine.cc, 40)
OpenGL error #1: INVALID_ENUM(/WelcomeToYourPersonalComputerInferno/666/src/GL_engine.cc, 41)
Created OpenGL 0.0 context
注: :contextMajor
和contextMinor
是GLint
變量。
我沒有任何想法意味着這些INVALID_ENUM
...我甚至覺得它的OpenGL也不知道......
if for any reason you want to look inside my code, I just updated my git
要完成,因爲我使用GLFW,GLU ,GLEW在我的程序中。我想知道在我從這些庫中調用函數之後調用glGetError()
(仍然低谷DisplayGlErrors()
)是否有意義。
thx爲您的答案,這是完美的!我知道GLU已被棄用,我認爲要刪除它,但要做很多事情......其實我在很多地方添加了'glGetError()'調用來檢查一切是否正常,並且直接獲取行是錯的。我將在未來刪除它們。再次謝謝你 – 2014-09-02 01:19:59