What am I doing Wrong (OpenGL & SDL)
Entity325 via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Wed Feb 4 17:51:04 PST 2015
I am having a problem which is similar in appearance to the OP's,
but it does not seem to be similar in function. When I try to
execute any of the Gl functions in the (protected)
DerelictGL3.gl.loadSymbols function, I get an access violation.
Checking for null reveals that the functions are indeed null and
therefore have not been loaded into memory.
Now for where it gets weird.
Here's the code I'm using to load DerelictGL and create an OpenGL
context in my test program(to make sure all the libraries are
built correctly.)
SDL_GLContext context;
*sdlWindow = SDL_CreateWindow("New SDL Window",
SDL_WINDOWPOS_UNDEFINED,
SDL_WINDOWPOS_UNDEFINED,
800, 600,
//SDL_WINDOW_FULLSCREEN_DESKTOP |
SDL_WINDOW_OPENGL);
context = SDL_GL_CreateContext(*sdlWindow);
/* Turn on double buffering with a 24bit Z buffer.
* You may need to change this to 16 or 32 for your system */
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, bitsPerPixel);
GLVersion glVersion = DerelictGL.reload();
if(glVersion > GLVersion.GL20)
{
writeln("Sufficient OpenGL version found.");
writeln("Loaded OGL version is: ", glVersion);
string glVersionStr = to!(string)(glGetString( GL_VERSION
));
writeln("GL version reported as ", glVersionStr);
}
else
{
writeln("Error: OpenGL version ", glVersion, " not
supported.");
context = null;
}
if(glMatrixMode is null)
writeln("*****glMatrixMode not loaded");
else
writeln("*****All functions loaded properly.");
("sdlWindow" is a pointer to an SDL_Window, the reference of
which is passed into the function doing all this so that I can
load the window into it)
Console output for this code:
Sufficient OpenGL version found.
Loaded OGL version is: GL45
GL version reported as 4.5.0 NVIDIA 347.09
*****All functions loaded properly.
So that's good.
Now in the project that I'm actually working on, something very
different happens.
Here's the code from that project:
[insert variable passing and assignments here, I'm trying to save
you guys some reading.]
// Flags tell SDL about the type of window we are
creating.
windowFlags =
SDL_WINDOW_OPENGL;//|SDL_WINDOW_RESIZABLE;
if(fullscreen)
windowFlags |= SDL_WINDOW_FULLSCREEN_DESKTOP;
// SDL_SetVideoMode( sdlvideoinfo.current_w,
sdlvideoinfo.current_h, bpp, flags );
thisWindow = SDL_CreateWindow(startTitle.toStringz,
SDL_WINDOWPOS_UNDEFINED,
SDL_WINDOWPOS_UNDEFINED,
startSize.x,
startSize.y,
windowFlags);
if(thisWindow is null)
return false;
glContext = SDL_GL_CreateContext(thisWindow);
GLVersion glVersion = DerelictGL.reload();
if(glVersion > GLVersion.GL20)
{
writeln("Sufficient OpenGL version found.");
writeln("Loaded OGL version is: ", glVersion);
string glVersionStr = to!(string)(glGetString( GL_VERSION
));
writeln("GL version reported as ", glVersionStr);
}
else
{
writeln("Error: OpenGL version ", glVersion, " not
supported.");
glContext = null;
}
if(glMatrixMode is null)
writeln("*****glMatrixMode not loaded");
else
writeln("*****All functions loaded properly.");
My, doesn't that look familiar? That's because it wasn't working
before, so I copied over the code from my test program, which
includes diagnostic statements such as ouptutting the GL version
loaded.
Console output for this code:
Sufficient OpenGL version found.
Loaded OGL version is: GL45
GL version reported as 4.5.0 NVIDIA 347.09
*****glMatrixMode not loaded
What.
As far as I know, the code on both sides is functionally the
same. The build environments are as identical as I can reasonably
make them, and the execution directory for the second program has
at minimum any libraries that the first program has.
And of course, I'm loading the new OpenGL versions, so that's not
the problem.
More information about the Digitalmars-d-learn
mailing list