Should SDL be used as the GUI instead of Ogre?

Programmers discuss here anything related to FreeOrion programming. Primarily for the developers to discuss.

Moderator: Committer

Message
Author
Mitten.O
Programmer
Posts: 255
Joined: Sun Apr 06, 2014 4:15 pm

Re: Should SDL be used as the GUI instead of Ogre?

#31 Post by Mitten.O »

All right, more progress.

I managed to implement the fake fullscreen idea.
It is an option that defaults to true.
Unfortunately it requires an OpenGL extension (frame buffer objects) that isn't core until 3.0.
The extension loading code I put together is extremely crude, not thread safe,
and may not work on windows at all.
I'll have to study OpenGL extension loading best practices and improve it.

But it does work quite nicely. It allows switching between resolutions,
windowed and fullscreen, and alt tabbing to your hearts content.
Even moving the full screen window from one virtual desktop to another using
hotkeys works.

The implementation has to be made saner, but the basic principle feels like a winner.
Wider data is of course required.
Attachments

[The extension patch has been deactivated and can no longer be displayed.]

Any code by me in this post is released under GPL 2.0 or later.

User avatar
adrian_broher
Programmer
Posts: 1156
Joined: Fri Mar 01, 2013 9:52 am
Location: Germany

Re: Should SDL be used as the GUI instead of Ogre?

#32 Post by adrian_broher »

Mitten.O wrote:I managed to implement the fake fullscreen idea.
This is feature creep. Please keep the patch to the minimum changes required for a transition to SDL2.
Resident code gremlin
Attached patches are released under GPL 2.0 or later.
Git author: Marcel Metz

User avatar
Geoff the Medio
Programming, Design, Admin
Posts: 13587
Joined: Wed Oct 08, 2003 1:33 am
Location: Munich

Re: Should SDL be used as the GUI instead of Ogre?

#33 Post by Geoff the Medio »

adrian_broher wrote:This is feature creep. Please keep the patch to the minimum changes required for a transition to SDL2.
Having functional full screen mode seems like a pretty important feature to retain...

User avatar
adrian_broher
Programmer
Posts: 1156
Joined: Fri Mar 01, 2013 9:52 am
Location: Germany

Re: Should SDL be used as the GUI instead of Ogre?

#34 Post by adrian_broher »

Geoff the Medio wrote:
adrian_broher wrote:This is feature creep. Please keep the patch to the minimum changes required for a transition to SDL2.
Having functional full screen mode seems like a pretty important feature to retain...
Fake Fullscreen is not Fullscreen as the name already says. Relying on OpenGL 3 features for implementing this means removing all OpenGL legacy code in the application and libraries because neither Linux nor MacOSX support OpenGL with compat profile.
Resident code gremlin
Attached patches are released under GPL 2.0 or later.
Git author: Marcel Metz

Mitten.O
Programmer
Posts: 255
Joined: Sun Apr 06, 2014 4:15 pm

Re: Should SDL be used as the GUI instead of Ogre?

#35 Post by Mitten.O »

Well, it is full screen in the sense that it fully fills the screen.
What is fake is not really the fullscreenness, but the resolution change.

No need to abandon any legacy code, as I said, it is core in 3,
but as an extension it only requires 1.1.
See http://www.opengl.org/registry/specs/EX ... object.txt
They sloppy way I put it in to test it might only work in situations where
the driver actually supports 3, but using it as an extension should be as simple as
checking if it is supported and suffixing the SDL_GL_GetProcAddress calls with EXT.

Being core in 3, I expect it is extremely widely supported,
but we can of course just disable the option based on opengl feature detection.
Any code by me in this post is released under GPL 2.0 or later.

User avatar
vincele
Space Dragon
Posts: 341
Joined: Sun Mar 23, 2014 6:10 pm

Re: Should SDL be used as the GUI instead of Ogre?

#36 Post by vincele »

adrian_broher wrote:
Mitten.O wrote:I managed to implement the fake fullscreen idea.
This is feature creep. Please keep the patch to the minimum changes required for a transition to SDL2.
The patch seems in heavy flux, it may need to be split into logical parts before commit, but that may be done later...

Edit: BTW I tested the .5 patch, and FS is not working properly, either with or without the FFS option. there's flickering occurring, with parts of the XFCE desktop & apps showing around FO, mouse cursor get painted and let a trail... This may be due to me patching and old svn copy (4-5 days ago), I'll retest, though...
All the patches I'll provide for freeorion will be released under the GPL v2 or later license.
Let's unleash the dyson forest powa!

Mitten.O
Programmer
Posts: 255
Joined: Sun Apr 06, 2014 4:15 pm

Re: Should SDL be used as the GUI instead of Ogre?

#37 Post by Mitten.O »

The patch seems in heavy flux, it may need to be split into logical parts before commit, but that may be done later...
This is a good idea. I do share adrian_brohers concern about the size.
And since I am developing it locally with git, it already consists of many pieces to me,
albeit the pieces are for now more chronological than logical.
BTW I tested the .5 patch, and FS is not working properly, either with or without the FFS option. there's flickering occurring, with parts of the XFCE desktop & apps showing around FO, mouse cursor get painted and let a trail... This may be due to me patching and old svn copy (4-5 days ago), I'll retest, though...
I'll have to test it with a non-compositing window manager myself. That is the largest difference that is obvious in your description.
Any code by me in this post is released under GPL 2.0 or later.

User avatar
vincele
Space Dragon
Posts: 341
Joined: Sun Mar 23, 2014 6:10 pm

Re: Should SDL be used as the GUI instead of Ogre?

#38 Post by vincele »

Mitten.O wrote:I'll have to test it with a non-compositing window manager myself.
I tested with up to date svn+patch, flickering occurs with XFCE desktop, but not under gnome. That should make your assumption correct, I think...
All the patches I'll provide for freeorion will be released under the GPL v2 or later license.
Let's unleash the dyson forest powa!

Mitten.O
Programmer
Posts: 255
Joined: Sun Apr 06, 2014 4:15 pm

Re: Should SDL be used as the GUI instead of Ogre?

#39 Post by Mitten.O »

I managed to replicate and fix the flicker.
The problem was I wasn't properly clearing the real screen
when using a fake mode change.

Also, the mode change fakeness was not updated on Apply from settings.

PS. Didn't have time to build this after rebasing on current svn,
so a conflict isn't inconceivable, but it did rebase cleanly, so it's probably all right.
EDIT: Yes. Works against 7491.
Attachments

[The extension patch has been deactivated and can no longer be displayed.]

Any code by me in this post is released under GPL 2.0 or later.

Mitten.O
Programmer
Posts: 255
Joined: Sun Apr 06, 2014 4:15 pm

Re: Should SDL be used as the GUI instead of Ogre?

#40 Post by Mitten.O »

* Advise SDL to load an OpenGL 2 context.
* rename fake fullscreen to fake mode change
* Use frame buffers as an extension to implement fake mode change
* Use OpenGL extension detection to disable fake mode change
when the extension is not available and even hide the option
* Fix too small alpha in visibility radii when using fake mode change

So it should be safe to run this on sub OpenGL3 systems now,
even ones without the extension.

The real fullscreen is still very troublesome.
Attachments

[The extension patch has been deactivated and can no longer be displayed.]

Any code by me in this post is released under GPL 2.0 or later.

Mitten.O
Programmer
Posts: 255
Joined: Sun Apr 06, 2014 4:15 pm

Re: Should SDL be used as the GUI instead of Ogre?

#41 Post by Mitten.O »

Done!
There are surely still bugs and such,
and I didn't do a proper formatting check,
but now the switch to sdl is fully functional.

I make it available as a single lump for easy testing,
but also in four pieces for easier review.
They are still a bit large, but the fact is you can't
really jump from a windowing/event system to another
with small incremental steps.
(Unless you are willing to have intermediate states that work very poorly,
which admittedly may be considered a fair price for smaller steps.
(A temporary public branch that is established to be transient so that it can be
reorganized before inclusion in master would of course be a wonderful compromise, but alas, svn ))

Piece 1 upgrades SDLGUI to use SDL2 and add feature that were previously only
available in the OgreGUI. Warning: does not compile, since moves stuff to GUI that OGreGUI doesn't have
Piece 2 Makes it compile again by making OgreGUI fullfill the new GUI requirements
Piece 3 Creates the possibility for virtual full resolutions.
Piece 4 Actually makes freeorion use SDLGUI instead of the ogre one
Piece 5 Exposes the virtual resolution change option to the user

PS. Actual resolution change sill buggy on linux, interested in behaviour on windows.
Attachments
sdl2_switch.pieces.zip
(24.95 KiB) Downloaded 127 times

[The extension patch has been deactivated and can no longer be displayed.]

Any code by me in this post is released under GPL 2.0 or later.

User avatar
vincele
Space Dragon
Posts: 341
Joined: Sun Mar 23, 2014 6:10 pm

Re: Should SDL be used as the GUI instead of Ogre?

#42 Post by vincele »

Mitten.O wrote:Piece 1 upgrades SDLGUI to use SDL2 and add feature that were previously only
available in the OgreGUI. Warning: does not compile, since moves stuff to GUI that OGreGUI doesn't have
Piece 2 Makes it compile again by making OgreGUI fullfill the new GUI requirements
Piece 3 Creates the possibility for virtual full resolutions.
Piece 4 Actually makes freeorion use SDLGUI instead of the ogre one
Piece 5 Exposes the virtual resolution change option to the user
Hello,
I've still not tested this one properly, but be wary of committing unbuildable code, it breaks people bissecting through code revisions to find bugs, and that is sometimes a very effective way of finding them. So I would suggest to fold patch 2 inside patch 1, or if it's doable, change their order, so that it's always buildable, even if you introduce unused code in the first patch...

I just re-read the whole thread and don't understand the FFS or VRC thing, can you explain it ?
Is that really necessary ?
What are others doing for this (Battle for Wesnoth, as an example of a working FS / Windowed on the fly switching game...)

Thanks for your work, I really am waiting for it to land, as an ALT-TABbing fan...
All the patches I'll provide for freeorion will be released under the GPL v2 or later license.
Let's unleash the dyson forest powa!

Mitten.O
Programmer
Posts: 255
Joined: Sun Apr 06, 2014 4:15 pm

Re: Should SDL be used as the GUI instead of Ogre?

#43 Post by Mitten.O »

Good point about unbuildability.
I maybe went too far in breaking it logically.

The resolution thing, simply put, goes like this:
For some reason, SDL fails to switch the resolution of the screen correctly on linux.
(At least for me, don't really have extensive reports on this)
Fake resolution change works around the issue by not changing the screen resolution.
To achieve the performance benefits of having fewer pixels, it instead renders
the game on an off-screen buffer of the desired resolution and then stretches that to fill the screen.

For me (ubuntu 14.04, unity wm), battle for wesnoth does not allow alt-tabbing, but does otherwise have a functional full screen.
I do not really know how they do it, and since I like alt-tabbing and I have a solution that allows it,
without any proof that theirs does, I do not at the moment see need to find out.

On the status of this patch: I wanted to let this rest until 0.4.4 was out,
whis it apparently now is? Although there is not announcement in announcements.
But now I want to see how the OpenGL changes from the font change work out
before rebasing since they affect this.
Any code by me in this post is released under GPL 2.0 or later.

User avatar
Geoff the Medio
Programming, Design, Admin
Posts: 13587
Joined: Wed Oct 08, 2003 1:33 am
Location: Munich

Re: Should SDL be used as the GUI instead of Ogre?

#44 Post by Geoff the Medio »

I've set up a branch for SDL migration. The initial changes are based on the patch posted here.

https://sourceforge.net/p/freeorion/cod ... s_Updates/

I'm mixing in a simultaneous update of various other dependencies, as the boost update has gotten complicated.

User avatar
Geoff the Medio
Programming, Design, Admin
Posts: 13587
Joined: Wed Oct 08, 2003 1:33 am
Location: Munich

Re: Should SDL be used as the GUI instead of Ogre?

#45 Post by Geoff the Medio »

In the SDL / SDK branch build, it's mostly running OK on Windows in windowed mode.

As seen in the attached, though, it always creates the window such that the title bar is above the top of the screen, and the left side is hidden under the taskbar I've got at the left side due to poorly-designed laptop aspect ratio. It should be appearing by default to the right of the taskbar, and so that the window title bar is visible.

Also, it won't start in fullscreen mode:

Code: Select all

C:\Users\Geoff\Desktop\FreeOrion_VS2010_SDK_Sept_2014\FreeOrion>freeorion.exe -f

main() caught exception(std::runtime_error): Failed to create framebuffer
Attachments
Running with SDL
Running with SDL
sdl.png (159.15 KiB) Viewed 1187 times

Post Reply