December 08, 2014 Re: Derelict / SDL error | ||||
---|---|---|---|---|
| ||||
Posted in reply to ketmar | On Monday, 8 December 2014 at 14:35:17 UTC, ketmar via Digitalmars-d-learn wrote:
> On Mon, 08 Dec 2014 14:13:54 +0000
> Paul via Digitalmars-d-learn <digitalmars-d-learn@puremagic.com> wrote:
>
>> On Monday, 8 December 2014 at 13:48:27 UTC, Mike Parker wrote:
>>
>> > import std.conv : to;
>> > writeln( "Error: ", to!string( SDL_GetError() ));
>>
>> Cleaner!
> ah, sure. i just wanted to use libc's fprintf() to avoid importing
> std.stdio, so copy-pasted that code. but you get the idea anyway. ;-)
>
>> Any ideas where to look for the source of the problem?
> sorry, no. you can try to update SDL2 to the latest version and Derelict
> bindings to git head though. i don't think that this will help, but you
> at least be sure that the problem is not in some obsolete version of
> the code.
I've only just installed SDL/Derelict on this machine so it should be up to date. I'll keep digging...
|
December 08, 2014 Re: Derelict / SDL error | ||||
---|---|---|---|---|
| ||||
Posted in reply to Paul | 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.
|
December 08, 2014 Re: Derelict / SDL error | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jack | On Monday, 8 December 2014 at 17:48:55 UTC, Jack wrote:
> 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.
Thanks for that. I've just tried the code on a different machine (latest Lubuntu on a 32 bit laptop, latest SDL, dmd and current dub binary) and it has exactly the same problem. Can't think what the problem might be other than something wrong with the way I've compiled SDL...??
|
December 09, 2014 Re: Derelict / SDL error | ||||
---|---|---|---|---|
| ||||
Posted in reply to Paul | On Monday, 8 December 2014 at 21:01:40 UTC, Paul wrote:
> On Monday, 8 December 2014 at 17:48:55 UTC, Jack wrote:
>> 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.
>
> Thanks for that. I've just tried the code on a different machine (latest Lubuntu on a 32 bit laptop, latest SDL, dmd and current dub binary) and it has exactly the same problem. Can't think what the problem might be other than something wrong with the way I've compiled SDL...??
The only 'warning' during compilation of SDL is about dbus not being used so I installed all the related *dev files I could find (and recompiled after each) but despite dbus now being flagged as 'used' it was to no avail. Thinking...
|
December 09, 2014 Re: Derelict / SDL error | ||||
---|---|---|---|---|
| ||||
Posted in reply to Paul | On Tuesday, 9 December 2014 at 10:19:38 UTC, Paul wrote:
> On Monday, 8 December 2014 at 21:01:40 UTC, Paul wrote:
>> On Monday, 8 December 2014 at 17:48:55 UTC, Jack wrote:
>>> 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.
>>
>> Thanks for that. I've just tried the code on a different machine (latest Lubuntu on a 32 bit laptop, latest SDL, dmd and current dub binary) and it has exactly the same problem. Can't think what the problem might be other than something wrong with the way I've compiled SDL...??
>
> The only 'warning' during compilation of SDL is about dbus not being used so I installed all the related *dev files I could find (and recompiled after each) but despite dbus now being flagged as 'used' it was to no avail. Thinking...
Can't really think of anything that can solve your problem. Only time I had a seg fault is calling a method from an uninitialized class.
You can try to get a debugger and/or a gui that comes with it(personally I use gdb with ddd) to find something out.
Sorry but this is all the suggestions I can give to you, I'm not really an expert in Derelict or Libraries or something.
|
December 09, 2014 Re: Derelict / SDL error | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jack | On Tuesday, 9 December 2014 at 13:34:56 UTC, Jack wrote:
> Can't really think of anything that can solve your problem. Only time I had a seg fault is calling a method from an uninitialized class.
> You can try to get a debugger and/or a gui that comes with it(personally I use gdb with ddd) to find something out.
> Sorry but this is all the suggestions I can give to you, I'm not really an expert in Derelict or Libraries or something.
I don't fancy introduing another layer of complexity in a debugger at present! I wonder if it's the .bmp that's causing the problem. I can't quite figure how to get Derelict SDL_Image into my project at present (dub doesn't fetch it if I add import derelict.sdl.image; ) otherwise I'd try a png or something. Can't really see it being that anyway but worth a try I suppose.
Thanks for trying anway. :D
|
December 09, 2014 Re: Derelict / SDL error | ||||
---|---|---|---|---|
| ||||
Posted in reply to Paul | On 12/10/2014 12:19 AM, Paul wrote:
>
> I don't fancy introduing another layer of complexity in a debugger at
> present! I wonder if it's the .bmp that's causing the problem. I can't
> quite figure how to get Derelict SDL_Image into my project at present
> (dub doesn't fetch it if I add import derelict.sdl.image; ) otherwise
> I'd try a png or something. Can't really see it being that anyway but
> worth a try I suppose.
dub doesn't know anything about DerelictSDL2Image (and even if it did, just importing it isn't going to tell dub about it -- you would need to add it to your dub.json as a dependency). That's because DerelictSDL2Image is not an independent package. It's part of DerelictSDL2. You need to call DerelictSDL2Image.load() to load the SDL2_image shared library, then you can use it.
|
December 09, 2014 Re: Derelict / SDL error | ||||
---|---|---|---|---|
| ||||
Posted in reply to Mike Parker | On Tuesday, 9 December 2014 at 15:40:00 UTC, Mike Parker wrote: > On 12/10/2014 12:19 AM, Paul wrote: > dub doesn't know anything about DerelictSDL2Image (and even if it did, just importing it isn't going to tell dub about it -- you would need to add it to your dub.json as a dependency). That's because DerelictSDL2Image is not an independent package. It's part of DerelictSDL2. You need to call DerelictSDL2Image.load() to load the SDL2_image shared library, then you can use it. I realise both of those, but I can't find the relevant package name, I thought it might be like this.. "dependencies": { "derelict-sdl2":"~>1.0.0", "derelict-gl3":">=1.0.0", "derelict-sdl2-image":">=1.0.0" } I've tried several variations but no joy. |
December 09, 2014 Re: Derelict / SDL error | ||||
---|---|---|---|---|
| ||||
Posted in reply to Paul | On Tuesday, 9 December 2014 at 15:48:32 UTC, Paul wrote:
> On Tuesday, 9 December 2014 at 15:40:00 UTC, Mike Parker wrote:
>> On 12/10/2014 12:19 AM, Paul wrote:
>> dub doesn't know anything about DerelictSDL2Image (and even if it did, just importing it isn't going to tell dub about it -- you would need to add it to your dub.json as a dependency). That's because DerelictSDL2Image is not an independent package. It's part of DerelictSDL2. You need to call DerelictSDL2Image.load() to load the SDL2_image shared library, then you can use it.
>
> I realise both of those, but I can't find the relevant package name, I thought it might be like this..
>
> "dependencies": {
> "derelict-sdl2":"~>1.0.0",
> "derelict-gl3":">=1.0.0",
> "derelict-sdl2-image":">=1.0.0"
> }
>
> I've tried several variations but no joy.
Whoa, I read that wrong - I'm sure I tried just adding DerelictSDL2Image.load() to my program an it didnt work. Trying again.
|
December 09, 2014 Re: Derelict / SDL error | ||||
---|---|---|---|---|
| ||||
Posted in reply to Paul | On Tuesday, 9 December 2014 at 15:53:11 UTC, Paul wrote:
> Whoa, I read that wrong - I'm sure I tried just adding DerelictSDL2Image.load() to my program an it didnt work. Trying again.
The top of my app.d looks like this:
import derelict.sdl2.sdl;
import std.stdio;
import std.conv;
void main()
{
scope(exit) {
SDL_Quit();
}
DerelictSDL2.load();
DerelictSDL2Image.load();
When I run dub that last line gives me:
source/app.d(15): Error: undefined identifier DerelictSDL2Image
The deps in dub.json are:
"dependencies": {
"derelict-sdl2":"~>1.0.0",
"derelict-gl3":">=1.0.0"
}
Thanks for perseversing with my density.
|
Copyright © 1999-2021 by the D Language Foundation