derelictorg / derelictsdl2 Goto Github PK
View Code? Open in Web Editor NEWDynamic bindings to SDL2 and its satellite libraries for the D Programming Language.
Dynamic bindings to SDL2 and its satellite libraries for the D Programming Language.
On Gentoo, the system's .so files are located in /usr/lib
.
This is the current situation:
derelict.util.exception.SharedLibLoadException@../../../../home/chad/.dub/packages/derelict-util-1.0.2/source/derelict/util/exception.d(35): Failed to load one or more shared libraries:
libSDL2_ttf.so - libSDL2_ttf.so: cannot open shared object file: No such file or directory
libSDL2_ttf-2.0.so - libSDL2_ttf-2.0.so: cannot open shared object file: No such file or directory
libSDL2_ttf-2.0.so.0 - libSDL2_ttf-2.0.so.0: cannot open shared object file: No such file or directory
/usr/local/lib/libSDL2_ttf-2.0.so - /usr/local/lib/libSDL2_ttf-2.0.so: cannot open shared object file: No such file or directory
/usr/local/lib/libSDL2_ttf-2.0.so.0 - /usr/local/lib/libSDL2_ttf-2.0.so.0: cannot open shared object file: No such file or directory
My system looks like this:
$ ls /usr/lib/libSDL_ttf*
/usr/lib/libSDL_ttf-2.0.so.0 /usr/lib/libSDL_ttf-2.0.so.0.10.1 /usr/lib/libSDL_ttf.so
$ ls /usr/local/lib
# ...crickets
Ideally, there should be some way for callers to include their own search paths in addition to the paths provided by Derelict. By default, Derelict should probably use the following search logic for .so files:
Look at any paths provided by the caller as arguments to .load(...)
.
Look in ./
Look in $LD_LIBRARY_PATH
(Reference)
Look in all directories listed in /etc/ld.so.conf
Look in a baked-in list of last-ditch fallback options. Although I'm sure better could be done, my current suggestion would look like this:
~/lib
/usr/local/lib
/usr/lib
Tangent time...
At some level, this is giving me a strong desire to have a standard (default) procedure for finding .so files on Linux/Posix systems for the entire D community. This is something that should "just work" for application developers and end-users, and it reflects poorly on application developers (and the Linux ecosystem) when users get spurious .so load failures. I wouldn't be surprised if this is a challenge on some other platforms as well.
Whew, when I look at what I wrote, it seems like a significant amount of work! Maybe, for now, just adding /usr/lib
(and maybe ~/lib
) to some of the enum libNames = ...
lines in a few .d files would be a good idea for some easy gratification ;)
Thank you for reading, and thank you for keeping Derelict maintained for a truly respectable length of time!
Mix_LoadMUS_RW takes only one argument, not two.
Some really simple code is already throwing an error for me (perhaps SDL2 has updated?):
import derelict.sdl2.sdl;
void main() {DerelictSDL2.load(); }
I'm including DerelictSDL2 and DerelictUtil libraries, and libdl, and everything compiles/links okay. However when running the program, I get the following error:
[email protected](35): Failed to load symbol SDL_HasAVX from shared library libSDL2.so
Somehow the change made here is no longer present in master, which is causing compile issues with mach: 8a281a4#diff-fa3c41fb49bcd5e2c7e65a92ed31d758
SDL_JoystickUpdate takes no parameters:
http://hg.libsdl.org/SDL/file/default/include/SDL_joystick.h#l164
https://github.com/DerelictOrg/DerelictSDL2/blob/master/source/derelict/sdl2/functions.d#L213
Invoking any of SDL_LoadBMP
, SDL_LoadBMP_RW
, IMG_Load
causes a segfault.
To reproduce, run the following:
import derelict.sdl2.sdl;
void main() {
SDL_Init(SDL_INIT_VIDEO);
SDL_Window *window = SDL_CreateWindow(
"Hello World!",
SDL_WINDOWPOS_UNDEFINED,
SDL_WINDOWPOS_UNDEFINED,
640, 480,
0);
SDL_RWops *file = SDL_RWFromFile("image.bmp", "rb");
// Next line segfaults
SDL_Surface *foo = SDL_LoadBMP_RW(file, 0);
SDL_Surface *surface = SDL_GetWindowSurface(window);
SDL_Rect r;
r.x=0; r.y=0; r.h=8*16; r.w=8*16;
SDL_BlitSurface(foo, &r, surface, &r);
SDL_UpdateWindowSurface(window);
while (1) {
SDL_PumpEvents();
SDL_Event e;
bool quitting = false;
while (SDL_PollEvent(&e) == 1) {
if (e.type == SDL_QUIT) quitting = true;
}
if (quitting) break;
}
}
The equivalent C
code does not exhibit this problem.
#include <SDL2/SDL.h>
void main(void) {
SDL_Init(SDL_INIT_VIDEO);
SDL_Window *window = SDL_CreateWindow(
"Hello World!",
SDL_WINDOWPOS_UNDEFINED,
SDL_WINDOWPOS_UNDEFINED,
640, 480,
0);
SDL_RWops *file = SDL_RWFromFile("image.bmp", "rb");
// Next line does what you would expect
SDL_Surface *foo = SDL_LoadBMP_RW(file, 0);
SDL_Surface *surface = SDL_GetWindowSurface(window);
SDL_Rect r;
r.x=0; r.y=0; r.h=8*16; r.w=8*16;
SDL_BlitSurface(foo, &r, surface, &r);
SDL_UpdateWindowSurface(window);
while (1) {
SDL_PumpEvents();
SDL_Event e;
int quitting = 0;
while (SDL_PollEvent(&e) == 1) {
if (e.type == SDL_QUIT) quitting = 1;
}
if (quitting) break;
}
}
The appears to be a discrepancy in the window bar's height on Windows specifically when setting the window to be non-resizable.
There's also another issue that I believe may be related, wherein which minimizing the window while set to non-resizable will shrink the window to the minimum possible size Windows can make it, leaving only the window bar and controls.
I've seen similar odd behaviors in other DLang libraries regarding locked window sizing, however. Is this a wider issue, if so is it known of?
I seem to have troubles calling DerelictSDL2.load();
. This causes the program to exit with code 1 whenever I try compiling it with dub run --force -v
. My dub.json has "derelict-sdl2": "~>3.0.0-beta.2"
as a dependency. Even
import derelict.sdl2.sdl;
void main() {
DerelictSDL2.load();
}
fails to run. The error I get is
derelict.util.exception.SymbolLoadException@../../../../.dub/packages/derelict-util-3.0.0-beta.1/derelict-util/source/derelict/util/sharedlib.d(181): Failed to load symbol SDL_DequeueAudio from shared library libSDL2.so
----------------
../../../../.dub/packages/derelict-util-3.0.0-beta.1/derelict-util/source/derelict/util/sharedlib.d:181 void* derelict.util.sharedlib.SharedLib.loadSymbol(immutable(char)[], bool) [0x445a3e]
../../../../.dub/packages/derelict-util-3.0.0-beta.1/derelict-util/source/derelict/util/loader.d:382 void* derelict.util.loader.SharedLibLoader.loadSymbol(immutable(char)[], bool) [0x443b44]
../../../../.dub/packages/derelict-util-3.0.0-beta.1/derelict-util/source/derelict/util/loader.d:71 void derelict.util.loader.SharedLibLoader.bindFunc(void**, immutable(char)[], bool) [0x443466]
../../../../.dub/packages/derelict-sdl2-3.0.0-beta.2/derelict-sdl2/source/derelict/sdl2/internal/sdl_dynload.d:72 void derelict.sdl2.internal.sdl_dynload.DerelictSDL2Loader.loadSymbols() [0x43fa01]
../../../../.dub/packages/derelict-util-3.0.0-beta.1/derelict-util/source/derelict/util/loader.d:253 void derelict.util.loader.SharedLibLoader.load(immutable(char)[][]) [0x443794]
../../../../.dub/packages/derelict-util-3.0.0-beta.1/derelict-util/source/derelict/util/loader.d:196 void derelict.util.loader.SharedLibLoader.load(immutable(char)[]) [0x443685]
../../../../.dub/packages/derelict-util-3.0.0-beta.1/derelict-util/source/derelict/util/loader.d:134 void derelict.util.loader.SharedLibLoader.load() [0x4434dd]
source/app.d:4 _Dmain [0x43f3da]
??:? _D2rt6dmain211_d_run_mainUiPPaPUAAaZiZ6runAllMFZ9__lambda1MFNlZv [0x44a1bf]
??:? scope void rt.dmain2._d_run_main(int, char**, extern (C) int function(char[][])*).tryExec(scope void delegate()) [0x44a0ef]
??:? scope void rt.dmain2._d_run_main(int, char**, extern (C) int function(char[][])*).runAll() [0x44a168]
??:? scope void rt.dmain2._d_run_main(int, char**, extern (C) int function(char[][])*).tryExec(scope void delegate()) [0x44a0ef]
??:? _d_run_main [0x44a05f]
??:? main [0x43f401]
??:? __libc_start_main [0x1bcb882f]
Program exited with code 1
which happens regardless of whichever dub run configuration I use. Any help would be appreciated.
On OSX, SDL2 suddenly started to fail in Release mode seemingly by silently failing and turning all SDL calls into no-ops ?
This minimal example:
SDL_Window *window;
SDL_Renderer *renderer;
DerelictSDL2.load();
enforce(SDL_Init(SDL_INIT_VIDEO) >= 0, "Failed to initialize SDL: " ~ to!string(SDL_GetError()));
assert(SDL_CreateWindowAndRenderer(640, 480, 0, &window, &renderer) == 0);
writeln(window, " ", renderer);
prints null null
when built using dub -b release
but works fine with dub -b debug
According to https://forum.dlang.org/post/[email protected]
Derelict libraries are not maintained anymore and are replaced by BindBC. That info is not found in these GitHub project pages, potentially confusing new users.
Should be just SDL_BLENDOPERATION_ADD.
Just a note to myself.
Making SDL_LogOutputFunction nothrow prevent you from using any writeln/writefln functions in log callbacks cause those functions are not nothrow.
When installing SDL with brew install sdl2
following path must be used:
/usr/local/lib/libSDL2/libSDL2.dylib
I'm rebuilding some Derelict libraries on a new installation of linux and while DerelictUtil and DerelictGL3 compile file with the same commands, I'm currently getting the following errors when compiling DerelictSDL2 in the 2.0.0 branch:
functions.d:414: error: undefined identifier SDL_SysWMinfo
sdl.d:383: error: undefined identifier SDL_GetWindowWMInfo
Subj.
When I build my app(with dub) on Linux(Mint) the dynamic bindings fail.
I get this log:
"""
derelict.util.exception.SymbolLoadException@../../../.dub/packages/derelict-util-3.0.0-beta.2/derelict-util/source/derelict/util/sharedlib.d(181): Failed to load symbol SDL_DequeueAudio from shared library libSDL2.so
"""
Is this a bug with these bindings or some noob mistake of my own?
SDL_CaptureMouse is a new function that appeared in SDL 2.0.4
Hi ! I just wonder why there's sint16 ... etc types ?
It is actually in C, where type sizes are not defined. In D size of each type is strongly defined, so i think we can use uint / short / ... types, can't we ?
Trying to build a package that requires DerelictSDL2.lib for building, but there's always an error writing the DerelictSDL2.lib.
> dub run
Performing "debug" build using dmd for x86.
derelict-util 3.0.0-beta.2: target for configuration "library" is up to date.
derelict-ft 2.0.0-beta.5: target for configuration "library" is up to date.
derelict-gl3 2.0.0-beta.8: target for configuration "library" is up to date.
derelict-sdl2 3.0.0-beta.8: building configuration "derelict-sdl2-dynamic"...
Error: Error writing file '..\..\..\..\AppData\Local\dub\packages\derelict-sdl2-3.0.0-beta.8\derelict-sdl2\.dub\build\derelict-sdl2-dynamic-debug-windows-x86-dmd_2068-BDC231064BB351BF6C13F99DC7A49CFA\DerelictSDL2.lib'
dmd failed with exit code 1.
Declared in functions.d:
alias da_SDL_EnclosePoints = void function(const(SDL_Point)*,int,const(SDL_Rect)*,SDL_Rect*);
but that function should be returning SDL_bool.
Origin.
The aforementioned function seems missing in the derelict-sdl2 library, yet it exists in SDL2 specification.
This header is useful to create a Direct3D context from a SDL window, also for making bgfx (https://github.com/bkaradzic/bgfx) work with SDL windows.
It seems that your forgot a few in functions.d:
https://github.com/DerelictOrg/DerelictSDL2/blob/master/source%2Fderelict%2Fsdl2%2Ffunctions.d#L551
https://github.com/DerelictOrg/DerelictSDL2/blob/master/source%2Fderelict%2Fsdl2%2Ffunctions.d#L556
https://github.com/DerelictOrg/DerelictSDL2/blob/master/source%2Fderelict%2Fsdl2%2Ffunctions.d#L561
https://github.com/DerelictOrg/DerelictSDL2/blob/master/source%2Fderelict%2Fsdl2%2Ffunctions.d#L566
https://github.com/DerelictOrg/DerelictSDL2/blob/master/source%2Fderelict%2Fsdl2%2Ffunctions.d#L572
https://github.com/DerelictOrg/DerelictSDL2/blob/master/source%2Fderelict%2Fsdl2%2Ffunctions.d#L576
There are three new functions in SDL2_TTF library that allow easy rendering of wrapped text:
TTF_RenderText_Blended_Wrapped
TTF_RenderUNICODE_Blended_Wrapped
TTF_RenderUTF8_Blended_Wrapped
but they are currently not bound in DerelictSDL2.
Those are badly documented but they can be easily found both in the source code and by inspecting the symbols exported in the SDL2_ttf.dll.
I will (try to) create a pull request for this tomorrow.
How do I compile a test program, I'm trying the one in the README.md file?
Joels-MacBook-Pro:DerelictSDL2 joelcnz$ dmd jest.d -Isource
source/derelict/sdl2/types.d(33): Error: module system is in file 'derelict/util/system.d' which cannot be read
import path[0] = source
import path[1] = /usr/share/dmd/src/phobos
import path[2] = /usr/share/dmd/src/druntime/import
Joels-MacBook-Pro:DerelictSDL2 joelcnz$
Here's some other questions:
How do you make files writable?
How do you open a finder window with the directory of the terminal from the terminal?
How do you add (or which one to choose) a new path on DMD, and how do you copy to them?
I´m trying a simple SDL app and it crash when calling SDL_LockTexture.
SDL_LockTexture(null, null,null, null); don´t crash.
But if I put the texture on first argument or any other combination of arguments, the app crash;
The fourth byte wasn't used in SDL, but in SDL2 it is used as the alpha channel and labeled 'a'.
https://wiki.libsdl.org/SDL_Color?highlight=%28%5CbCategoryStruct%5Cb%29%7C%28CategoryPixels%29
I am trying to get the example file to work ;)
the used dependancy is "derelict-sdl2":"~>1.0.0"
and just dubbing gives me
nikki@crunchbang:~/projects/d/myTest$ dub --force
derelict-util: ["derelict-util"]
derelict-sdl2: ["derelict-sdl2", "derelict-util"]
mysdltest: ["mysdltest", "derelict-sdl2", "derelict-util"]
Building derelict-util configuration "library", build type debug.
Running dmd...
Building derelict-sdl2 configuration "library", build type debug.
Running dmd...
Building mysdltest configuration "application", build type debug.
Compiling...
Linking...
Running ./mysdltest
derelict.util.exception.SymbolLoadException@../../../.dub/packages/derelict-util-1.0.2/source/derelict/util/exception.d(35): Failed to load symbol SDLNet_Linked_Version from shared library /usr/local/lib/libSDL2.so
----------------
./mysdltest(void derelict.util.loader.SharedLibLoader.bindFunc(void**, immutable(char)[], bool)+0x54) [0x80b2fcc]
./mysdltest(void derelict.sdl2.net.DerelictSDL2NetLoader.loadSymbols()+0x58) [0x80af4d0]
./mysdltest(void derelict.util.loader.SharedLibLoader.load(immutable(char)[][])+0x56) [0x80b2d8e]
./mysdltest(void derelict.util.loader.SharedLibLoader.load(immutable(char)[])+0xc0) [0x80b2d30]
./mysdltest(void derelict.util.loader.SharedLibLoader.load()+0x47) [0x80b2c67]
./mysdltest(_Dmain+0x47) [0x80a6857]
./mysdltest(void rt.dmain2._d_run_main(int, char**, extern (C) int function(char[][])*).runAll().void __lambda1()+0x10) [0x80b73c8]
./mysdltest(void rt.dmain2._d_run_main(int, char**, extern (C) int function(char[][])*).tryExec(scope void delegate())+0x18) [0x80b7340]
./mysdltest(void rt.dmain2._d_run_main(int, char**, extern (C) int function(char[][])*).runAll()+0x27) [0x80b738f]
./mysdltest(void rt.dmain2._d_run_main(int, char**, extern (C) int function(char[][])*).tryExec(scope void delegate())+0x18) [0x80b7340]
./mysdltest(_d_run_main+0x117) [0x80b72d7]
./mysdltest(main+0x14) [0x80ae55c]
/lib/i386-linux-gnu/i686/cmov/libc.so.6(__libc_start_main+0xe6) [0xb75d0e66]
./mysdltest() [0x80a6741]
Error executing command run: Program exited with code 1
I've installed all sdl2 libraries linked to in the readme, I specifically don't understand why it's looking for SDLNet_Linked_Version in /usr/local/lib/libSDL2.so I'd imagine the /usr/local/lib/libSDL2_net.so which is there too would be more the place to look in ?
All of this could also just be me not understanding something;)
And add pure & nothrow where possible.
E.g. https://github.com/DerelictOrg/DerelictSDL2/blob/master/source/derelict/sdl2/types.d#L1468
This could be @nogc, pure and nothrow
There is one difficulty with creating the bindings: we need to parse / look up SDL_config.h to see which driver SDL is configured to use (x11, mir or wayland.)
Mir and wayland types are not in derelict util, though their members in the syswm union could perhaps be opaque pointers until they are supported.
Platform: x86_64 Fedora 20
Compiler: dmd 2.065
Dub: 0.9.21
Having the package as dependency:
"dependencies": {
"derelict-sdl2": "~master"
}
Got following compilation errors (i've also removed ~/.dub folder for pure build):
../../../.dub/packages/derelict-sdl2-master/source/derelict/sdl2/types.d(1925): Error: undefined identifier Derelict_OS_iOS
../../../.dub/packages/derelict-sdl2-master/source/derelict/sdl2/types.d(1928): Error: undefined identifier Derelict_OS_Android
../../../.dub/packages/derelict-sdl2-master/source/derelict/sdl2/types.d(1932): Error: undefined identifier Derelict_OS_WindowsRT, did you mean variable Derelict_OS_Windows?
../../../.dub/packages/derelict-sdl2-master/source/derelict/sdl2/functions.d(428): Error: undefined identifier Derelict_OS_iOS
../../../.dub/packages/derelict-sdl2-master/source/derelict/sdl2/functions.d(432): Error: undefined identifier Derelict_OS_Android
../../../.dub/packages/derelict-sdl2-master/source/derelict/sdl2/functions.d(440): Error: undefined identifier Derelict_OS_WindowsRT, did you mean variable Derelict_OS_Windows?
../../../.dub/packages/derelict-sdl2-master/source/derelict/sdl2/functions.d(927): Error: undefined identifier Derelict_OS_iOS
../../../.dub/packages/derelict-sdl2-master/source/derelict/sdl2/functions.d(931): Error: undefined identifier Derelict_OS_Android
../../../.dub/packages/derelict-sdl2-master/source/derelict/sdl2/functions.d(939): Error: undefined identifier Derelict_OS_WindowsRT, did you mean variable Derelict_OS_Windows?
Documented here: https://wiki.libsdl.org/SDL_GetDefaultCursor
It should be an int.
But the binding wrongly specifies SDL_DisplayMode*.
A hack fix for now is to pass the int as a pointer. Might not work since the data types don't necessarily have the same size.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.