CreateRenderer降级OpenGL上下文,是否可以防止?
我在Mac OS(10.9.3)上。 我可以根据请求创建一个窗口+上下文,它是一个3.3上下文。 但是一旦我创建了渲染器,SDL告诉我渲染器无效。 除此之外,我可以使用渲染器来绘制和复制纹理。 但创建渲染器似乎也将OpenGL上下文更改为2.1个配置文件:(
有没有办法阻止?
[编辑]
SDL2和glew作为静态库链接。 glewExperimental未设置为GL_TRUE。
C ++源码:
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
SDL_GL_SetAttribute(SDL_GL_ACCELERATED_VISUAL, 1);
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
h_main_window = SDL_CreateWindow(
title.c_str(),
SDL_WINDOWPOS_CENTERED,
SDL_WINDOWPOS_CENTERED,
width,
height,
SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN
)
SDL_GL_CreateContext(h_main_window)
glewInit()
std::cout << "gl_renderer:" << glGetString(GL_RENDERER) << std::endl;
std::cout << "gl_context: " << glGetString(GL_VERSION) << std::endl;
std::cout << "gl_shading_lang_version: " << glGetString(GL_SHADING_LANGUAGE_VERSION) << std::endl;
SDL_CreateRenderer(
h_main_window,
-1,
SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_TARGETTEXTURE
)
std::cout << "gl_renderer:" << glGetString(GL_RENDERER) << std::endl;
std::cout << "gl_context: " << glGetString(GL_VERSION) << std::endl;
std::cout << "gl_shading_lang_version: " << glGetString(GL_SHADING_LANGUAGE_VERSION) << std::endl;
initShaders()
输出:
gl_renderer:Intel HD Graphics 3000 OpenGL Engine
gl_context: 3.3 INTEL-8.24.13
gl_shading_lang_version: 3.30
SDL Error: Invalid renderer
gl_renderer:Intel HD Graphics 3000 OpenGL Engine
gl_context: 2.1 INTEL-8.24.13
gl_shading_lang_version: 1.20
Compile failure in vertex shader:
ERROR: 0:1: '' : version '330' is not supported
ERROR: 0:3: 'layout' : syntax error syntax error
Compile failure in fragment shader:
ERROR: 0:1: '' : version '330' is not supported
Linker failure: ERROR: One or more attached shaders not successfully compiled
您收到的错误可能是一个错误,特别是如果渲染器结束工作正常,尽管报告“无效渲染器”。
SDL降低上下文版本所带来的问题是由于渲染器是使用OpenGL 2.1调用实现的,所以需要创建2.1 GL上下文。
您可以尝试先创建渲染器,然后设置SDL_GL_CONTEXT_MAJOR_VERSION等来创建3.3上下文。
链接地址: http://www.djcxy.com/p/67581.html上一篇: CreateRenderer downgrades the OpenGL context, can it be prevented?