-
Notifications
You must be signed in to change notification settings - Fork 75
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
Oolite is still on SDL 1.2 #222
Comments
I'm thinking I'll take look into porting to SDL2. In #91 it was mentioned there are local changes to the in-tree binary libSDL-1.2, the Gentoo ebuild produces an Oolite binary linked to the system libSDL-1.2.so, maybe that explains the fullscreen vblank sync and performance issues with my build... nope it seems not. Is there any more information on what changes have been made to the in-tree version? |
@sjnewbury Yes. All modifications to the standard libraries are listed here: |
I've made a start. Initially I'm just doing the bare minimum to get it working with the same functionality. Later new features and capabilities are possible such as multiple screens OpenGL3/4 core profiles etc. I don't know if the Windows changes noted above are still necessary with SDL2. I'll create a pull request once I've tested it here on Linux, hopefully somebody with a Windows build setup can test it. |
Some thoughts while working on this: Splash screen could/(should?) be a separate window - I'm leaving the code as is at this stage for minimal invasiveness. A lot of special casing for Windows is probably not necessary with SDL2. I've removed some, but not all of this code. It will need testing. Probably most of it can be dropped. There is a lot of code handling screen modes, I'm dropping it all on the floor. The API has improved for SDL2 here and I don't think any of it is needed. Unless I'm missing something... "Surfaces" are a "compatible" feature with SDL2, to use GL you just need to create a GL context, so I've replaced "surface" with "glContext" thoughout, with the exception of the screenshot handling code, where I'm specifically creating a surface from the window for that function. Hopefully, that will let me get away with leaving all that code alone. HiDPI support should work on all supported platforms now, but I can't test it. I'm trying not to break it! |
I left in the screen mode support largely as is for now. As I mentioned, I just want to alter as little as possible. I've got the game running with "-nosplash". Obviously buggy, since without "-nosplash" the window fails to appear on screen although it shows up in the window list. I've still got some of the code I added to replace the screen mode handling which I guess I will revert before creating the (provisional - for testing) pull request. Good news, fullscreen is now fast and smooth for me. |
I am tempted to rip out and replace the splash screen code with a separate window. |
@AnotherCommander: Since the splash code has broken I've just ripped it out and left stubs. Perhaps I should copy the SDL directory to SDL2 before making the the pull request and make it a build time option? Preferences? It is working better for me than the SDL1 code in fullscreen. There is still too much code, on the other hand what I have now is working. I'm also wondering about the fullscreen mode switching generally, do we really want to switch resolutions rather than always use native? I did try to implement the fullscreen mode switch using the viewSize like on Windows but I've now dropped that code for simplicity. It is however mode switching when leaving the game to the desktop (since task switching works with fullscreen SDL2, along with volume controls!) and then still uses that low resolution on return since it's then the desktop resolution! |
@sjnewbury First of all, many thanks for the effort you are putting into this. It is much appreciated. The SDL2 code should definitely be inserted initially as a compile-time option. Whatever changes you are proposing, we should still be able to build the game using the current SDL. As I am sure you are aware, the transition to SDL2 is not a simple task and is, in fact, very invasive, considering the stability we have managed to achieve to this point. It is changing the functionality of the game at low-level. As a consequence, some very heavy and detailed testing will be required and this could take long, even months, depending on the availability of people and test systems. So it is necessary that, until we are happy with the status of the SDL2 port, we keep the current SDL tree unning in a totally unaffected manner. Regarding dropped features and stub functions: I would not agree with dropping existing features. The fullscreen mode changes may not seem of much use these days, but keep in mind that we are targeting also older machines and those may need the alternative modes for performance reasons. In any case, I would rather not have to pay the price of leaving behind existing features in favor of SDL2. If features do have to be dropped, then we'll have to have internal discussions about how we want to proceed. This is another reason why the existing SDL should remain alive until we are satisfied that the transition will be as transparent as possible. While we are at that, please test also joystick input. This is very important, almost critical I would say. Joysticks, controllers etc. must continue to function exactly as before, on all platforms. Also, multi-monitor support will have to be tested as well to ensure that it works on Linux or, at the very least, that it does not break the Windows port. Speaking of which, we'll have to see how to go about testing in Windows once the PR has been submitted. For the Windows port, all support libraries are built by ourselves; we do not use pre-built binaries and this is so that we are able to control any and all aspects of the game's code (we've already had to do plenty of editing into support libraries code, including gcc code in one extreme case - I can provide details if you want, but I'd rather forget about that torture :-)). So, SDL2 will have to be built for Windows, the Windows Dev Environment updated, then proceed with testing as time permits. I can tell you right now that this is going to take a while. I prefer putting time into the game's code rather than into its libraries and time is in short supply. I also don't have ability to test on a 64-bit system currently, so we'll have to see how we'll go about that too. And last but not least, even the Limux builds we provide may have to change the way they are generated, if SDL2 moves on. I'll let the details of this to our Linux experts, but be aware that the Linux builds we provide are completely independnet of distros and libraries provided by such distros. In summary, this is a subject that will probably not be resolved immmediately. We'll have to take time with it, test it thoroughly - and I mean that - and proceed only if we are all confident that the change is not causing more issues than it resolves and that the game is still as stable as we expect it to be. Looking forward to the first iteration of the PR when you have it ready. Thanks again for your work on this. |
I'm going to create a pull request with what I have now. Outstanding issues::
Joystick, mouse, keyboard, sound all seem to be working. |
@AnotherCommander, thanks for the feedback. I'll split the SDL directory into an SDL2 directory with the changed files, and make it build time selectable before making the PR. I'll see if I can get the splash screen going again as well, I was just spending too much time on it earlier today it's going to take a clean approach, I think. [snipped] The preferred SDL2 method is actually to always use the native resolution for display and use internal scaling from a lower resolution since not all SDL2 targets support mode switching, for example, native Wayland should be working as is. Android and iphone could work to. |
I just tested it under Weston. It works, it's buttery smooth, but it shows some issues with window resizing especially when switching to fullscreen. |
@AnotherCommander Many issues addressed. Mode switching works again. The code is back in place for the splash screen, but it isn't quite working due to a problem with the OpenGL bounds/offsets I think. The image often appears shifted down out of the view window. As I mentioned, I tested it under native Wayland (no X server at all), and it works fine. I think the flickering might well be related to the above mentioned OpenGL issues, and is probably due to my lack of experience/knowledge in that area, I'm working on it, but help would be really appreciated. This really clearly shows up when going up screen resolutions in fullscreen mode! |
One thing about the mode switching, SDL2 supports refresh rate, so that really needs to be supported properly, where currently it's only partial. |
Multi-monitor support is limited to only using the first display, that's where the mode list comes from. SDL2 isn't limited in that regard, and supports multiple windows and displays, it could in theory display a window for each Oolite game screen simultaneously and/or map them to multiple displays when fullscreen. That would be pretty cool IMHO. |
I have managed to compile SDL2 2.0.5 for Windows. First attempt at compiling Oolite with it: ended early:
I can already see that this is not going to be easy, like, at all... |
@AnotherCommander ...and I thought MY compilation issues, in the Linux DevEnv, were THE problem! 😥 |
@AnotherCommander Conflicting GL headers? I don't know how that differs for Windows.. No such errors here. @KonstantinosSykas did you have the same failure with Linux? |
I've not been working on this for a few days, been busy flying my Barracuda and hacking on OXPs instead! ;-) I'll see if I can work out what's happening above. My next plan for this week is to try using the Windows fullscreen handling code for the generic case just changing out the Windows calls for equivalent SDL2 calls. |
It differs quite substantially because on Windows we have to declare every single function newer than OpenGL 1.1 as an extension. This involves plenty of hocus-pocus with function pointers, but it's a more or less standardized routine for OpenGL applications. It does mean that the handling is completely different on Windows, though. You can see how exactly this works in OOOpenGLExtensionManager.m inside the Windows-specific guards. I'll try to have a look at it if I can, but can't say when that will be. |
Allow me to bring the discussion in here. The content is more general than just PullRequest-related.
This would actually mean a whole list of things, such as:
These are just the first things that I think of and I am mostly speaking for Linux. 😓 |
Concerning the GL headers compilation issue... @sjnewbury That point is not reached yet. |
@KonstantinosSykas Yes that's another issue... I'll see if I can create a VM and get SDL2 build in the "Oolite for Linux Development Environment". I''m quite used to getting things to compile against their will! ;-) @AnotherCommander Perhaps SDL2 takes care of all that for Windows now? I understand that the Windows support is much better than with SDL1, regarding cross-platform feature mapping and support. Windows was always and afterthought for SDL1. I'm afraid I got a bit sidetracked into learning how to write OXPs this week. I'll get back to this soon... |
@sjnewbury Can you please clarify a bit for me what you mean by "all that" in your previous response? I am not entirely sure what exactly you are referring to. In any case, SDL1 on the Windows version does fine most of the things we need and whatever it doesn't do that we want, we do by use of direct WinAPI calls. Not sure what will be needed to get an SDL2 port up to the same level we are at now, but we will need to achieve at least a 1-to-1 parity with the SDL1 build status before anything gets accepted. Having to do additional reading up on SDL2 just to get it on par with the current build does not help the situation much. As for SDL2 Windows support status, I have been doing some investigation on the compile issue reported earlier (I ended up spending time on non-game stuff after all :-( )and, if the problem is what I think it is, then I can say that SDL2 has still some road to cover on Windows before we can call its support adequate. I'll do some more tests to be sure and get back to you on that. But so far, I am not completely convinced that SDL2 (at least on Windows) is mature enough to be adopted. |
@AnotherCommander Sorry about being unclear, I was referring to handling of OpenGL headers in a cross-platform manner. I'm afraid I haven't used SDL at all on Windows, my Windows development experience is almost non-existent in actual fact. From the horses mouth: https://wiki.libsdl.org/FAQWindows https://wiki.libsdl.org/Installation SDL2 implements a lot of the functionality that is currently handled in Oolite by direct Windows API calls, how well it works, and whether it works on all supported Windows versions I'm afraid I do not know. |
SDL1 only incidentally worked [was made to work] on Windows it was originally made to port Windows games to Linux and MacOS 9 which is why all the Window API calls are needed. |
Well, that was interesting... I have concluded with my investigation regarding the Windows SDL_opengl.h compile issue. At the moment, the Windows SDL2 build attempt goes past the point where it was failing earlier but still fails later on when trying to compile MyOpenGLView.m. But I think this time it has more to do with porting details between SDL1 and SDL2 rather than actual SDL2 bugs. But before I go on with the results of the investigation, two quick comments to set the record straight:
With that said, let's go back to our specific build problem. As it turns out, it is a (quite serious IMO) bug in the SDL2 headers. The problem is that the OpenGL function declarations for glActiveTextureARB and glActiveClientTextureARB are not guarded in SDL_opengl.h. In SDL1, the block of GL_ARB_multitexture declarations containing those two functions is guarded with an So, after seeing this kind of bug remaining unfixed for three years now in a supposedly stable version, I have some doubts about how suitable SDL2 currently is for Oolite on Windows in its current shape and form. I have really spent a lot of time here for something that looks like an SDL2 bug and am once again debugging libraries, which is exactly what I don't want to do. I wonder what else awaits us if we hit those kind of walls so early in the process. Of course there is always the chance that I may have misunderstood something - at which point I'd be glad to be corrected - but I keep asking myself whether the effort and time required is justified with respect to the expected benefits. And I have not even touched any of the issues @KonstantinosSykas mentioned about Linux itself either. I'd like to try to continue the attempt to build the game under SDL2 now that I have modified the SDL2 headers and went past that hurdle just to see how it runs, if anything, but I am also starting to run out of patience. I'm afraid that if I hit one more issue like that, I may just let it go and not try anymore. Will post more once I have the chance to do more on this (hint: not soon). |
Any news on this? |
No great news on this. PR #234 has not been updated for a while and we do not have 1:1 parity with the SDL 1.2 build yet. Regarding the Windows port, I did manage to get an executable at some point, but only after disabling most of the Windows-specific window management code, thus sacrificing multi monitor (and proper fullscreen) support. The result was definitely not satisfactory and there werre also some serious issues which seemed related to threads management, but I was so frustrated at that point that I decided to not be bothered any longer. I have deleted my local copy of the SDL2 attempts since. |
I will get back to looking at this again, unfortunately I bought Elite Dangerous for my PS4 and there's only so much time... |
I want SDL2!
I play Pioneer instead of Oolite because of this.
The text was updated successfully, but these errors were encountered: