Trying to install from SDL and OpenGL to D. In particular, SDL2 and OpenGL 3.3 with kernel / forwarding support. (although I left the last two in the example, because it breaks in the same place, regardless of whether they are there). In GLFW, this is equivalent to the following: I seem to screw things up on the SDL end, or the SDL does some magic things that break Derelict - which seems hard to believe, given that Derelict-gl doesn't do all that much except loading a few function pointers, but something goes wrong, and I do not rule out an error in Derelict or SDL, although this is more likely my code.
I do not see this, and here it is:
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()
{
DerelictGL.load();
DerelictSDL2.load();
fatal_error_if(SDL_Init(SDL_INIT_VIDEO),"Failed to initialize sdl!");
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);
fatal_error_if(window is null,"Failed to create SDL window!");
auto glprof = SDL_GL_CreateContext(window);
fatal_error_if(glprof is null,"Failed to create GL context!");
DerelictGL.reload();
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...");
}
Like the title of the question, it breaks down into DerelictGL.reload () (which should load OpenGL functions like GLEW). Here stacktrace ...
#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, , , PostGL1.1 post .
- - ? , ?
, OpenGL 3.3 - glGet 3 GL_MAJOR_VERSION GL_MINOR_VERSION .