Creating an OpenGL 3.2/3.x context in SDL 1.3

故事扮演 提交于 2019-12-03 06:17:45

since I don't know if you already found a solution, here is mine:

I struggled around a lot today and yesterday with this stuff. Advanced GL functions couldn't be used, so I even debugged into opengl32.dll just to see it really works and wraps the calls into the hardware-specific OpenGL DLL (nvoglnt.dll). So there must have been another cause. There were even tips in the internet to link to opengl32.lib before all other libraries, because ChoosePixelFormat and some other functions are overwritten by each other.

But that wasn't the cause, too. My solution was to enable the accelerated visuals here:

// init SDL
if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_HAPTIC | SDL_INIT_TIMER) < 0) {       
    fprintf(stderr, "Could not init SDL");
    return 1;
}

// we must wish our OpenGL Version!!
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2);
SDL_GL_SetAttribute(SDL_GL_ACCELERATED_VISUAL, 1);

because in the current SDL revision (Dec 15, 2011) he checks for it in SDL_windowsopengl.c

if (_this->gl_config.accelerated >= 0) {
       *iAttr++ = WGL_ACCELERATION_ARB;
        *iAttr++ = (_this->gl_config.accelerated ? WGL_FULL_ACCELERATION_ARB :
                                                   WGL_NO_ACCELERATION_ARB);
   }

and this attribute is initialized to -1 if you did not define it on your own.

And: Never set the version attributes before initializing SDL, because settings attributes needs the video backend to be initialized properly!

I hope this helps.

I followed this tutorial. Everything works fine on windowz and linux. http://people.cs.uct.ac.za/~aflower/tutorials.html

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!