0
我只是在嘗試使用SDL 2.0使OpenGL上下文和GLEW 1.9GLEW初始化失敗
沒問題,而建設該項目,但同時調試運行,GLEW失敗的初始化,我能做些什麼來解決這個問題?
我使用的Visual Studio 2012
這裏是輸出:
The program '[936] gravitation.exe' has exited with code -1 (0xffffffff).
這裏是代碼:
#include <GL/glew.h>
#include <SDL.h>
#include <iostream>
int main(int argc, char **argv)
{
SDL_Window* window = 0;
SDL_GLContext contextOpenGL = 0;
SDL_Event event;
bool terminate = false;
GLenum initGLEW = glewInit();
if(GLEW_OK != initGLEW)
{
std::cout << "initialisation error of GLEW : " << glewGetErrorString(initialisationGLEW) << std::endl;
SDL_GL_DeleteContext(contextOpenGL);
SDL_DestroyWindow(window);
SDL_Quit();
return -1;
}
while(!terminate)
{
SDL_WaitEvent(&event);
if(event.window.event == SDL_WINDOWEVENT_CLOSE)
terminer = true;
glClear(GL_COLOR_BUFFER_BIT);
SDL_GL_SwapWindow(window);
}
SDL_GL_DeleteContext(contextOpenGL);
SDL_DestroyWindow(window);
SDL_Quit();
return 0;
}
我從教程中得到了這段代碼,所以它被認爲是工作的:/ – user1854186
@ user1854186:如果您從教程中複製並粘貼了該代碼,那麼您錯過了幾件事情。如果這是原始教程代碼,那麼教程是錯誤的。 – datenwolf
是的,你是可怕的,我有點太快了。這是一個愚蠢的mystake:p Thanx爲您提供幫助 – user1854186