SDL 및 OpenGL을 사용하여 D로 설정하려고합니다. 특히 SDL2 및 OpenGL 3.3 코어/포워드 호환. (예를 들어 마지막 두 개를 예제에 남겨 두었습니다. 왜냐하면 그곳에 있는지 여부와 같은 시점에서 끊어지기 때문입니다). GLFW에서 다음과 동등하게 잘 작동하므로 분명히 SDL 끝에서 뭔가를 망가 뜨리고 있습니다. SDL은 Derelict를 깨는 마술 같은 것을합니다. Derelict-gl이 그렇게 많이하지 않는다고 생각하는 것이 어렵습니다. 몇 가지 함수 포인터를로드하는 것 외에는 어딘가에 문제가 생겨서 Derelict 나 SDL의 버그를 제외하지 않을 것입니다.Derelict3 SDL2 및 OpenGL 이상한 SIGSEGV on DerelictGL.reload()
그래도 난 그것을 볼 수 없습니다, 그리고 여기있다 : 질문 제목 말한다
import std.stdio;
import std.c.stdlib;
import derelict.sdl2.sdl;
import derelict.opengl3.gl;
void fatal_error_if(Cond,Args...)(Cond cond, string format, Args args) {
if(!!cond) {
stderr.writefln(format,args);
exit(1);
}
}
void main()
{
//set up D bindings to SDL and OpenGL 1.1
DerelictGL.load();
DerelictSDL2.load();
fatal_error_if(SDL_Init(SDL_INIT_VIDEO),"Failed to initialize sdl!");
// we want OpenGL 3.3
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION,3);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION,3);
auto window = SDL_CreateWindow(
"An SDL2 window",
SDL_WINDOWPOS_UNDEFINED,
SDL_WINDOWPOS_UNDEFINED,
800,
600,
SDL_WINDOW_OPENGL); // we want this window to support OpenGL
fatal_error_if(window is null,"Failed to create SDL window!");
auto glprof = SDL_GL_CreateContext(window); // Create the actual context and make it current
fatal_error_if(glprof is null,"Failed to create GL context!");
DerelictGL.reload(); //<-- BOOM SIGSEGV
// just some stuff so we actually see something if nothing exploded
glClearColor(1,0,0,0);
glClear(GL_COLOR_BUFFER_BIT);
SDL_GL_SwapWindow(window);
SDL_Delay(5000);
SDL_DestroyWindow(window);
SDL_Quit();
writeln("If we got to this point everything went alright...");
}
처럼, 그것은 (GLEW와 유사한는 OpenGL 기능을로드하도록되어) DerelictGL.reload()에 중단 . 스택 트레이스는 다음과 같습니다 ...
#0 0x00007ffff71a398d in __strstr_sse2_unaligned() from /usr/lib/libc.so.6
#1 0x000000000048b8d5 in derelict.opengl3.internal.findEXT() (extname=..., extstr=0x0)
at ../../../../.dub/packages/derelict-gl3-master/source/derelict/opengl3/internal.d:74
#2 0x000000000048b8b0 in derelict.opengl3.internal.isExtSupported() (name=..., glversion=<incomplete type>)
at ../../../../.dub/packages/derelict-gl3-master/source/derelict/opengl3/internal.d:67
#3 0x0000000000487778 in derelict.opengl3.gl.DerelictGLLoader.reload() (this=0x7ffff7ec5e80)
at ../../../../.dub/packages/derelict-gl3-master/source/derelict/opengl3/gl.d:48
#4 0x0000000000473bba in D main() at source/app.d:36
#5 0x00000000004980c8 in rt.dmain2._d_run_main()()
#6 0x0000000000498022 in rt.dmain2._d_run_main()()
#7 0x0000000000498088 in rt.dmain2._d_run_main()()
#8 0x0000000000498022 in rt.dmain2._d_run_main()()
#9 0x0000000000497fa3 in _d_run_main()
#10 0x00000000004809e5 in main()
여기에 오류가 발생하는 이유는 glGetString (GL_EXTENSIONS)가 null을 반환하기 때문입니다. 왜 내가 이해가 안가요? DerelictGL.reload에 대한 호출을 제거하면 나머지 프로그램이 실행되지만 OpenGL1.1 이후 기능은로드되지 않습니다.
실제 질문으로 문구하려면 - 내가 잘못하고 있습니까? 그렇다면, 무엇? glGet 각각 GL_MAJOR_VERSION 및 GL_MINOR_VERSION에 3을 반환 -
추가
내가는 OpenGL 3.3 컨텍스트가 생성 된 것을 확인했다.