// SDL 2.0.6, glew 2.1.0
SDL_Init(SDL_INIT_EVENTS | SDL_INIT_VIDEO);
SDL_Window *w = SDL_CreateWindow("Open GL", 0, 0, 1000, 1000, SDL_WINDOW_SHOWN | SDL_WINDOW_OPENGL);
SDL_GLContext ctx = SDL_GL_CreateContext(w);
// values returned by SDL_GL_GetAttribute are commented
SDL_GL_SetAttribute(SDL_GLattr::SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE); // doesn't help
SDL_GL_SetAttribute(SDL_GLattr::SDL_GL_CONTEXT_MAJOR_VERSION, 4); // 4
SDL_GL_SetAttribute(SDL_GLattr::SDL_GL_CONTEXT_MINOR_VERSION, 5); // 5, these two accept even 10.10 without error actually, I also tried not calling them and had 2.1 in return
SDL_GL_SetAttribute(SDL_GLattr::SDL_GL_DOUBLEBUFFER, 1); // 1
SDL_GL_SetAttribute(SDL_GLattr::SDL_GL_RED_SIZE, 8); // 8
SDL_GL_SetAttribute(SDL_GLattr::SDL_GL_GREEN_SIZE, 8); // 8
SDL_GL_SetAttribute(SDL_GLattr::SDL_GL_BLUE_SIZE, 8); // 8
SDL_GL_SetAttribute(SDL_GLattr::SDL_GL_DEPTH_SIZE, 24); // 16
SDL_GL_SetAttribute(SDL_GLattr::SDL_GL_STENCIL_SIZE, 8); // 0
//SDL_GLContext ctx = SDL_GL_CreateContext(w); // nothing gets rendered if this is called here instead
//SDL_GL_MakeCurrent(w, ctx); // doesn't help
if (ctx == 0){ // never fails
cout << "context creation error" << endl;
}
glewExperimental = true;
GLenum e = GLEW_OK;
e = glewInit();
if (e != GLEW_OK){ // never fails
cout << "glew error" << endl;
}
私の調査では、ステンシルバッファが機能していなかったので、私は調査に来ました。すべてのSDL_GL_SetAttribute関数は0を返します。同じコード(glewを除く)はUbuntuのラップトップでテストされ、深さ/ステンシルの場合は24/8を返します。私は間違って何をしていますか?OpenGLとglewとSDL2を連携させることはできません
答えをいただきありがとうございますが、私はもっと徹底的にドキュメントを読んでください。それでも私のラップトップでは間違った方法で動作します... – Alex