I am trying to use Derelict and D to write a simple graphics test program.
When I try to do nearly anything with SDL it will seg-fault. Here is the code that is having issues:
import std.stdio;
import derelict.opengl3.gl3;
import derelict.sdl2.sdl;
import derelict.sdl2.image;
import derelict.sdl2.mixer;
import derelict.sdl2.ttf;
import derelict.sdl2.net;
void main()
{
SDL_Window* mainWindow;
SDL_GLContext mainGLContext;
try
{
DerelictGL3.load();
// Load the SDL 2 library.
DerelictSDL2.load();
.
DerelictSDL2Image.load();
DerelictSDL2Mixer.load();
DerelictSDL2ttf.load();
DerelictSDL2Net.load();
}
catch(Exception e){}
finally{}
// Initialise SDL
if( SDL_Init( SDL_INIT_EVERYTHING ) == -1 ) {
throw new Exception("SDL initialization failed");
}
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION,3);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION,3);
Uint32 flags = SDL_WINDOW_SHOWN|SDL_WINDOW_OPENGL;
int width = 1024;
int height = 768;
mainWindow = SDL_CreateWindow("SDL2 OpenGL Example", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, width, height, flags);
mainGLContext = SDL_GL_CreateContext(mainWindow);
DerelictGL3.reload();
SDL_DestroyWindow(mainWindow);
SDL_Quit();
}
The issue will still occur even if everything below SDL_GL_SetAttribute()
is commented out.
Additionally, derelict throws an exception when trying load SDL, but I think this is fairly common:
derelict.util.exception.SymbolLoadException@../../.dub/packages/derelict-util-2.0.4/source/derelict/util/exception.d(35): Failed to load symbol SDL_QueueAudio from shared library libSDL2.so
I am running Elementary OS and have used apt-get to ensure that SDL is up to date.
Thank you very much for your help.