最近,我用OpenGL和LWJGL 2(Java)創建了自己的遊戲。之後,我想提高自己的編程技能,並開始學習如何在C++中使用OpenGL。OpenGL版本不等於支持的着色器版本
隨着LWJGL我可以使用#version 330
但與C++和SDL2我只能用#version 110
,但glGetString(GL_VERSION)
回報3.0 Mesa 12.0.6
。
我初始化我的窗前,像這樣:
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3);
SDL_Init(SDL_INIT_EVERYTHING);
SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_BUFFER_SIZE, 32);
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
m_window = SDL_CreateWindow(title.c_str(), SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, width, height, SDL_WINDOW_OPENGL|SDL_WINDOW_RESIZABLE);
m_glContext = SDL_GL_CreateContext(m_window);
GLenum status = glewInit();
if(status != GLEW_OK){
std::cerr << "Glew failed!" << std::endl;
}
哪裏是我的問題?
嘗試設置'SDL_GL_SetAttribute()'SDL_Init後'()的調用'... –
什麼' glxinfo | grep「着色語言版本」'不得不說? – keltar