I’ve been working on an SDL2/OpenGL project in the D programming
language and I’m having a really nasty time trying to get an
accelerated OpenGL 3.x context. I’m using the following code:
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);
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_DEPTH_SIZE, depthBufferSize);
SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, stencilBufferSize);
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
window = SDL_CreateWindow(null, SDL_WINDOWPOS_UNDEFINED,
SDL_WINDOWPOS_UNDEFINED,
width, height, SDL_WINDOW_OPENGL);
if(!window)
throw new Error("Unable to create SDL window: " ~
to!string(SDL_GetError()));
context = SDL_GL_CreateContext(window);
if(!context) {
throw new Error(“Unable to create OpenGL context”);
}
writeln(to!string(glGetString(GL_VERSION)));
writeln(to!string(glGetString(GL_VENDOR)));
writeln(to!string(SDL_GetError()));
The output I get says that I’m getting Microsoft’s OpenGL 1.1 driver
instead of a more modern one; I’ve updated my
drivers and tested on other machines, so I don’t think the issue is my
machine’s configuration. SDL_GetError()
returns a message about being unable to load RegisterTouchWindow, but
from what I understand, this is just a
common Windows XP issue that only affects multi-touch input code. I
don’t think it’s an issue with the language or
bindings, either, because others have gotten it to work just fine with
similar setups.
Can anyone see anything wrong with my code?