On Monday, 8 December 2014 at 12:53:11 UTC, Paul wrote:
Sorry this is a bit off topic but as there doesn't seem to be an active forum for Derelict atm....

This simple test code is giving me an error 'Error executing command run: Program exited with code -11' (or a seg fault if executed from a terminal). The problem line is:

SDL_RenderCopy(renderer, texture, &sourceRect, &destRect);

I've tried this call with the 'null' options as well as passing the address of the rects but neither works (I've also tried manually assigning the various struct components rather than using the c style initialisation in case that was the problem).

Any ideas please?

import derelict.sdl2.sdl;
import std.stdio;

void main()
{
    scope(exit) SDL_Quit();

    DerelictSDL2.load();
    writeln( "SDL loaded ok");


    //init sdl
        if (SDL_Init(SDL_INIT_EVERYTHING) != 0){
                writeln("SDL_Init Error: ", SDL_GetError() );
                return;
        }
                
        //open a window
SDL_Window *window = SDL_CreateWindow("Window Title!", 100, 100, 640, 480, SDL_WINDOW_SHOWN);
        if (window == null){
                writeln("SDL_CreateWindow Error: ", SDL_GetError() );
                return;
        }       
                
        //get a renderer (ie buffer), use software renderer for now
SDL_Renderer *renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_SOFTWARE);
        if (renderer == null){
                writeln( "SDL_CreateRenderer Error: " , SDL_GetError() );
                return;
        }
        
        //load a bitmap
        SDL_Surface *image = SDL_LoadBMP("./test.bmp");
        if (image == null){
                writeln( "SDL_LoadBMP error: " , SDL_GetError() );
                return;
        }       
        
        //create texture for bitmap
SDL_Texture *texture = SDL_CreateTextureFromSurface(renderer, image);
        if (texture == null){
writeln( "CreateTextureFromSurface error: " , SDL_GetError() );
                return;
        }               
        
    //copy to renderer at correct position & scale
    SDL_Rect sourceRect = { 0, 0, 64, 64 };
    SDL_Rect destRect = { 100, 100, 64, 64 };
    SDL_RenderCopy(renderer, texture, &sourceRect, &destRect);  
                
        
    //display and pause
    SDL_RenderPresent(renderer);
    SDL_Delay(2000);
        
                
}

I'm running ArchLinux 64-bit on Vbox and tested out the code.
There haven't been any problems. Have you tried updating
whatever tools you're using?(dmd, dub, etc....) Might've been an outdated piece of software that's been making the fuss.

Reply via email to