Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for SDL 2.0 #173

Open
DerekBronson opened this issue Mar 31, 2014 · 16 comments
Open

Add support for SDL 2.0 #173

DerekBronson opened this issue Mar 31, 2014 · 16 comments
Labels

Comments

@DerekBronson
Copy link

The first release of Linux platform support introduced SDL 1.3 to the engine. While functional, it limits features and is "ugly" according to the author. Implementing SDL 2.0 would fix some issues and be far prettier. A question that popped up was whether SDL 2.0 should be implemented across all platforms. The author suggested it would be helpful, but not a high priority.

T2D Linux First Release Blog: http://www.garagegames.com/community/blog/view/22545/1
Comment on SDL 2.0: http://www.garagegames.com/community/blogs/view/22545/1#comment-195505

@DerekBronson DerekBronson added this to the 3.0 milestone Mar 31, 2014
@MichPerry-GG
Copy link
Contributor

Updated original post to clarify the origin of this issue.

@DerekBronson DerekBronson removed this from the 3.0 milestone Mar 31, 2014
@tapir
Copy link

tapir commented May 4, 2014

Currrently Torque2D 3.0 does not even build in Linux although it's claimed that it works for Linux.
The make error is: "/.../Torque2D/engine/compilers/Make/../../source/platformX86UNIX/x86UNIXInputManager.cc:71: undefined reference to `X11_KeyToUnicode'" and is related to SDL 1.3 (which is a development version)

@camporter
Copy link
Contributor

Unfortunately I wasn't able to get a keybinding fix in place for the 3.0 release. The X11_KeyToUnicode function is only available in the older SDL 1.2 releases (even though it shouldn't have been used at all). SDL 1.3 is essentially the pre-release of 2.0, which has an entirely different interface. I believe @Syrup84 meant to say SDL 1.2.

Let me know if you have any other problems. Extra details such as which compiler, architecture, kernel/distro version and graphics driver/card are also appreciated!

@tapir
Copy link

tapir commented May 5, 2014

So how do we build Torque in Linux? Sorry to hijack this bug report but it seems to be related.

@lilligreen
Copy link
Contributor

Build guide is available on the wiki: https://github.com/GarageGames/Torque2D/wiki/Linux-Development-Guide

If anything in the guide is unclear, needs correcting, etc, please let me know either via the T2D forums or by opening up a new issue.

@tapir
Copy link

tapir commented May 5, 2014

Well that guide doesn't mention "X11_KeyToUnicode" issue.
Created a new issue #185

@camporter
Copy link
Contributor

Could you provide more information about your environment? SDL 1.2 is the only supported version. I am currently linking against SDL 1.2.5. Here's the change in libSDL for the fix that was made two years ago: https://hg.libsdl.org/SDL/rev/900a0fae90ca

@tapir
Copy link

tapir commented May 6, 2014

I'm on Arch linux with SDL 1.2.15.

SDL 1.2.5 is very old (2002-2003?) and on any modern linux distro, you
won't find it. Did you maybe mean 1.2.15 also?

EDIT: I've looked at 1.2.15 source (SDL_x11events.c to be exact) and I don't see that X11_KetToUnicode() is exported as a library function.
From the patch you've sent: "extern DECLSPEC Uint16 SDLCALL X11_KeyToUnicode(SDLKey, SDLMod);". This line is missing in 1.2.15 source. Am I missing something?

EDIT2: Turns out that patch was commited after 1.2.15 release of SDL which is the latest official release.
In this case I suggest avoiding the linux support claim of Torque2D 3.0. Unless you compile SDL yourself or use an ancient version, Torque2D won't compile in linux.

On 6 May 2014 02:25, "Cameron Porter" [email protected] wrote:

Could you provide more information about your environment? SDL 1.2 is the
only supported version. I am currently linking against SDL 1.2.5. Here's
the change in libSDL for the fix that was made two years ago:
https://hg.libsdl.org/SDL/rev/900a0fae90ca


Reply to this email directly or view it on GitHubhttps://github.com//issues/173#issuecomment-42252734
.

@raichu
Copy link

raichu commented May 6, 2014

Same here. It seems Ubuntu people patched this themselves:
https://launchpad.net/ubuntu/+source/libsdl1.2/+bug/66217

Unless they mean Linux support only means Ubuntu, they should indeed either fix it or remove the claim.

@tapir
Copy link

tapir commented May 6, 2014

On a side note, why not get rid of all the platform specific code?
SDL 2.0 supports all the big platforms. From the website:

SDL officially supports Windows, Mac OS X, Linux, iOS, and Android

For the web, we can keep using emscripten.

@camporter
Copy link
Contributor

I've dusted off the SDL2 code that I have, most of the input code is working, window handling and rendering are working as well. Just have to rip out the remaining Xlib junk, then try to make the whole thing more intelligible and try to document what's going on as well.

At the time of testing for T2D 3.0, we didn't have anyone on other distributions to test, so unfortunately the missing symbol was never noticed (except by the nag message built in with having used it).

If you can't wait for SDL2 support, you have a few options:

  • Copy the implementation of X11_KeyToUnicode from SDL.
  • Statically link SDL with the patch into your build to ensure that it will work on any distribution. SDL is zlib licensed, so no problems there. I haven't tried this, but presumably it should work.
  • Change the input mapping code to do similar behavior to what the emscripten code does, and set your own maps.

If I make good progress this weekend, the PR could be up as well.

@lilligreen
Copy link
Contributor

Torque 3D also has Linux using SDL2, not sure if it is worth looking at any of their platform code: https://github.com/BeamNG/Torque3D/tree/dev_linux_opengl

On a side note, why not get rid of all the platform specific code?

The idea is good, I'm guessing the amount of work to get there has kept anyone from attempting this yet.

@tapir
Copy link

tapir commented May 10, 2014

@camporter Instead I've sent the patch to my distro's bugzilla and now it's fixed (https://bugs.archlinux.org/task/40292)

@lilligreen I'm guessing once the switch is done from SDL-1.2 to 2.0 for linux, it shouldn't be that much work to make it run in other platforms.

@camporter
Copy link
Contributor

Here is my initial commit for SDL2: camporter@94ed1af

Not that this is still being tested, and keyboard input is currently broken. Extra window shows up because I'm not yet saving a ref to the SDL_Window. That will be the next task.

@tapir
Copy link

tapir commented May 26, 2014

@camporter That's some work! I can't wait to see it finished.

@tapir
Copy link

tapir commented Nov 21, 2014

Any updates on when we can have SDL 2.0 support?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants