Page 1 of 1

SDL 1.2 to 2.0

Posted: Mon Aug 26, 2013 3:51 pm
by Lanica
Guide is here: http://wiki.libsdl.org/MigrationGuide

Some things have been done for SDL 1.3 but that was at a pretty dated version. There's lots to do to get to SDL 2.0. It sounds like it should actually get better performance overall, but I don't know for sure.

Should we ifdef a bunch for SDL2 or should we just go for it? Maybe ifdef first, then remove once all platforms are comfortable with it?

-Lanica

Re: SDL 1.2 to 2.0

Posted: Mon Aug 26, 2013 4:32 pm
by Dominus
I think ifdef first then remove.

Or actually a new branch solely for the 2.0 conversion. Marzo used some trickery before to keep the No-SDL-Mixer branch in sync with trunk. But with current development state, we probably wouldn't need to bother.

SDL 2 is probably the way to go, especially in regard to iOS and Android. The most offensive thing they did was doing away with CD-Rom support but that only bothers me in regard to Dosbox :)

Re: SDL 1.2 to 2.0

Posted: Mon Aug 26, 2013 4:50 pm
by Lanica
I can't help but agree. I think "well...we could just do one big commit and be done with it". But that will always break something. Plus if we go the ifdef route, then we can incrementally make change rather than all at once. So I can do some cycles, then you can do some cycles, etc.

It won't be too hard to pull out the ifdefs when we're ready, but if months in the future, we didn't do ifdefs, it would be more difficult.

-Lanica

Re: SDL 1.2 to 2.0

Posted: Mon Aug 26, 2013 5:03 pm
by Malignant Manor
That works.

Re: SDL 1.2 to 2.0

Posted: Mon Aug 26, 2013 5:43 pm
by Lanica
Also...SDL 2.0 only supports these platforms:
Windows, Linux, Mac OS X, iOS, Android.

Think this will cause any heart ache, break, or burn?

-Lanica

Re: SDL 1.2 to 2.0

Posted: Mon Aug 26, 2013 5:54 pm
by Dominus
mybe that's more reason to keep it ifdefed then.

Re: SDL 1.2 to 2.0

Posted: Mon Aug 26, 2013 11:50 pm
by Dominus
Maybe a different branch would have been the right way... Anyway, the ios thread needs to mention in the instructions to grab rev 7406 because afterwards it may no longer work ;)

Re: SDL 1.2 to 2.0

Posted: Tue Aug 27, 2013 2:07 am
by Lanica
Made a lot of progress on SDL2....Exult compiles for Mac OS X against SDL2...but it does not work.

Did:
sudo port install libsdl2
./configure SDL_CONFIG=/opt/local/bin/sdl2-config

-Lanica

Re: SDL 1.2 to 2.0

Posted: Tue Aug 27, 2013 5:44 pm
by Dominus
hmm, didn't compile for me.
I got this error:
imagewin.cc:739:9: error: unknown type name 'SDL_VideoInfo'
const SDL_VideoInfo *vinfo = SDL_GetVideoInfo();
^
imagewin.cc:739:32: error: use of undeclared identifier 'SDL_GetVideoInfo'
const SDL_VideoInfo *vinfo = SDL_GetVideoInfo();
^
imagewin.cc:746:21: error: use of undeclared identifier 'SDL_OPENGL'
int video_flags = SDL_OPENGL | SDL_GL_DOUBLEBUFFER |
^
imagewin.cc:747:37: error: use of undeclared identifier 'SDL_RESIZABLE'
SDL_HWPALETTE | SDL_RESIZABLE |
^
imagewin.cc:751:19: error: use of undeclared identifier 'SDL_HWSURFACE'
video_flags |= SDL_HWSURFACE;
^
imagewin.cc:755:19: error: use of undeclared identifier 'SDL_HWACCEL'
video_flags |= SDL_HWACCEL;
^
imagewin.cc:763:42: error: use of undeclared identifier 'SDL_SetVideoMode'
if ((display_surface = inter_surface = SDL_SetVideoMode(w, h,
^
7 errors generated.
I wonder how this was able to compile for you. All those are no longer in SDL2

Re: SDL 1.2 to 2.0

Posted: Tue Aug 27, 2013 8:46 pm
by Lanica
Looks like you're falling in the case of "HAVE_OPENGL", and I am not. I'll work to validate all platform configs once I get one basic one working :)

Re: SDL 1.2 to 2.0

Posted: Tue Aug 27, 2013 9:04 pm
by Dominus
oh, oops, yes, defined opengl :)

Without that, it compiles as well for me and doesn't work as well :)

Re: SDL 1.2 to 2.0

Posted: Wed Aug 28, 2013 1:05 am
by Lanica
I can now get screen output when scaling is disabled! Audio works as well!

Re: SDL 1.2 to 2.0

Posted: Wed Aug 28, 2013 7:29 pm
by Dominus
yes, confirmed :) (though couldn't test audio yet)

Re: SDL 1.2 to 2.0

Posted: Wed Aug 28, 2013 8:43 pm
by Lanica
Ok, NOW its working with scaling. Keyboard input doesn't work right in some cases and in other cases it doesn't work at all. Again this is the selective case of being on a Mac OS X and without OPENGL. I might try another platform tonight to see if it works.

Re: SDL 1.2 to 2.0

Posted: Wed Aug 28, 2013 9:20 pm
by Malignant Manor
Windows works when I comment out some stuff in exult.cc (the SetIcon function (non OSX), some SDL_GetWMInfo related Exult Studio support, and SDL_putenv (OSX with ES support and Win)).

Changing video settings causes a new window to be created. Setting game area to auto doesn't work properly.

Re: SDL 1.2 to 2.0

Posted: Wed Aug 28, 2013 11:14 pm
by Lanica
Did you have a patch of what you've done? Feel free to commit if you're confident in your actions of course :) I'm validating on Linux right now.

Re: SDL 1.2 to 2.0

Posted: Wed Aug 28, 2013 11:49 pm
by Malignant Manor
I just quickly commented stuff out to get it to compile. The video problems mentioned earlier likely happen in other operating systems so you probably want to test it.

Re: SDL 1.2 to 2.0

Posted: Thu Aug 29, 2013 1:10 am
by Lanica
SetIcon issue should be fixed. That's all I have time for tonight.

Re: SDL 1.2 to 2.0

Posted: Thu Aug 29, 2013 2:04 am
by Malignant Manor
I haven't looked into the game area issue but it only seems broken when scale = 1.

Image_window::create_surface and Image_window::create_scale_surfaces are called when toggling fullscreen or applying video settings. They will create a new window instead of overriding the current one or destroying the current one before creating a new one. I have a fix but SDL_GetWindowID(0) != NULL doesn't seem to work as a check and screen_window will be uninitialized when first checked.

Code: Select all

Index: imagewin/imagewin.cc
===================================================================
--- imagewin/imagewin.cc	(revision 7415)
+++ imagewin/imagewin.cc	(working copy)
@@ -544,7 +544,7 @@
 /*
 *   Create the surface.
 */
-
+int test = 0;
 void Image_window::create_surface(
     unsigned int w,
     unsigned int h
@@ -577,7 +577,10 @@
 	if (!paletted_surface && !force_bpp) {      // No scaling, or failed?
 		uint32 flags = SDL_SWSURFACE | (fullscreen ? SDL_FULLSCREEN : 0) | (ibuf->depth == 8 ? SDL_HWPALETTE : 0);
 #if SDL_VERSION_ATLEAST(2, 0, 0)
-		screen_window = SDL_CreateWindow("", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, w / scale, h / scale, flags);
+		if (test == 1)
+			SDL_DestroyWindow(screen_window);
+		screen_window = SDL_CreateWindow("Exult Ultima7 Engine", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, w / scale, h / scale, flags);
+		test = 1;
 		if (screen_window == NULL)
 			cout depth == 8 ? SDL_HWPALETTE : 0);
 #if SDL_VERSION_ATLEAST(2, 0, 0)
-		screen_window = SDL_CreateWindow("", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, w / scale, h / scale, flags);
+		if (test == 1) {
+			SDL_SetWindowSize(screen_window, w / scale, h / scale);
+			SDL_SetWindowFullscreen(screen_window, flags);
+			SDL_DestroyRenderer(screen_renderer);
+			SDL_DestroyTexture(screen_texture);
+		} else
+			screen_window = SDL_CreateWindow("", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, w / scale, h / scale, flags);
+		test = 1;
 		if (screen_window == NULL)
 			cout << "Couldn't create window: " << SDL_GetError() << std::endl;
 
@@ -667,7 +674,14 @@
 	if (!hwdepth) return false;
 
 #if SDL_VERSION_ATLEAST(2, 0, 0)
-	screen_window = SDL_CreateWindow("", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, w, h, flags);
+	if (test == 1) {
+		SDL_SetWindowSize(screen_window, w, h);
+		SDL_SetWindowFullscreen(screen_window, flags);
+		SDL_DestroyRenderer(screen_renderer);
+		SDL_DestroyTexture(screen_texture);
+	} else
+		screen_window = SDL_CreateWindow("", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, w, h, flags);
+	test = 1;
 	if (screen_window == NULL)
 		cout << "Couldn't create window: " << SDL_GetError() << std::endl;
 	screen_renderer = SDL_CreateRenderer(screen_window, -1, 0);


Re: SDL 1.2 to 2.0

Posted: Thu Aug 29, 2013 12:49 pm
by Malignant Manor
Game area auto works when scale = 1 if aspect correction is enabled.

SetIcon crashes when calling SDL_SetPaletteColors.

#0 0x77c46fa3 in msvcrt!memcpy () from C:\WINDOWS\system32\msvcrt.dll
#1 0x6c7d6614 in SDL_SetPaletteColors () from C:\exult_bin\SDL2.dll
(gdb)


Edit: Wow, sound is horrible except for MT32Emu and FMOpl.

Re: SDL 1.2 to 2.0

Posted: Thu Aug 29, 2013 5:21 pm
by Lanica
We should probably do a NULL check on screen_window (make sure to set it in an init).

SetIcon isn't perfect yet. Seems like its throwing out white if an alpha is present of any kind.

FYI, last night it did work on Linux once I "fixed" SetIcon. The remaining flaws with it might be causing crashes in Windows but in Linux it just has some ill effects. Quick and dirty rather than slow and correct I suppose.


This is definitely a work in progress and is NOT meant to be complete of course. This allows us to work progressively as a team, and with the ifdefs we shouldn't be affecting normal compiles with SDL 1.2 and SDL 1.3

I do try to make sure SDL 1.2 works once I get done, as I have had a few errors that prevented it from working, as you may have seen from the commit logs....

Re: SDL 1.2 to 2.0

Posted: Thu Aug 29, 2013 7:43 pm
by Dominus
I might lead you a wrong way but the WIP patch for DOSBox adaption to SDL 2 might be useful to look at. http://www.vogons.org/viewtopic.php?f=32&t=34770

Re: SDL 1.2 to 2.0

Posted: Fri Aug 30, 2013 10:44 pm
by Lanica
That could be helpful as a reference if we are unable to solve certain problems.

I noticed with some audio there was sometimes an issue. Likely has to do with SDL_KillThread no longer existing, or at least that's my assumption.

Re: SDL 1.2 to 2.0

Posted: Sat Aug 31, 2013 1:14 am
by Lanica
We should be in better shape now:
* imagewin/imagewin.cc: Applied Malignant Manor's fix for SDL2 window resizes. Added NULL-check instead of using test variable.
* gamemgr/bggame.cc, gamemgr/sigame.cc: Fixed text input for initial BG and SI game screen for SDL2
* gumps/Gump_manager.cc: Fixed text input for save screens and such for SDL2
* drag.cc: Fixed crash when dragging items for SDL2


I think the only real outstanding issue is SDL_KillThread...it no longer works so I changed it to SDL_WaitThread, but what we really need is a way to trigger when it should be done.
( in audio/midi_drivers/LowLevelMidiDriver.cpp )

That may or may not fix some of the other audio issues.

Then, of course, extensive testing.

I'll be on vacation pretty soon which means I probably will not be working on this during that time...

Re: SDL 1.2 to 2.0

Posted: Sat Aug 31, 2013 1:43 am
by Lanica
* audio/midi_drivers/LowLevelMidiDriver.cpp, audio/midi_drivers/LowLevelMidiDriver.h: Added a quit_thread flag -- really only used for SDL2

Took care of the Create/Kill/Wait thread issue. Audio is sometimes messed up...at least on Mac. Have to restart Exult to fix it.

Also forgot...need to fix SetIcon ... the compile issue for Windows and the odd display for Linux.

Re: SDL 1.2 to 2.0

Posted: Sat Aug 31, 2013 2:28 am
by Lanica
Oh and OpenGL needs to be handled too!

Re: SDL 1.2 to 2.0

Posted: Sat Aug 31, 2013 6:18 pm
by Malignant Manor
Yeah, sfx and speech still cause issues.
The icon has the wrong palette in Windows too but doesn't crash anymore. (If you don't set an icon in Windows. it looks better than the white palette but has thicker outlines than normal.)

Thanks, for the work so far.

Re: SDL 1.2 to 2.0

Posted: Sun Sep 01, 2013 12:57 am
by Lanica
SetIcon now works. However, its not optimal. Really just couldn't get the paletted surface to work with SDL2.

Re: SDL 1.2 to 2.0

Posted: Sun Sep 01, 2013 7:34 pm
by Malignant Manor
The icon has a black background in Windows.

The game area and screen size being equal causes the previously mentioned scale=1 game rendering issue.

Re: SDL 1.2 to 2.0

Posted: Mon Sep 02, 2013 1:08 pm
by Lanica
Fixed the transparency for SetIcon...bleh...I see my mistake clearly.

As far as the scale=1 issue....you have said it is "broken" .. .by "broken" do you mean it crashes? Can you provide specific settings (or perhaps a cfg file) that cause it to break? If its not crashing, what exactly do you mean by "broken"? Thanks!

Re: SDL 1.2 to 2.0

Posted: Mon Sep 02, 2013 1:15 pm
by Lanica
Nevermind I had AR correction enabled...if I disable it, I see the issue. It warps the screen so the left side shows some very stretched screen material and right side is all black. No clue as of yet...

Re: SDL 1.2 to 2.0

Posted: Mon Sep 02, 2013 1:22 pm
by Malignant Manor
Some more about the screen issue is here

edit: I forgot that exultbot and usecode.org were down for parts of the conversation. I think Colourless and wjp mentioned it looked like an 8bit (surface or palette?) being written to a 32 bit buffer. (force_bpp cfg setting will show correctly but isn't really a good solution)

[13:43:10] wjp:, Colourless: how does this look? http://pastebin.com/XU9LuXVi
[13:45:31] Maybe have a variable in the constructor force_scaling or something and set it with SDL2 instead of that mess.
[13:47:52] i wouldn't be writing code like that, unless its a last resort and someone tracks down while paletted surfaces aren't working
[13:48:24] there is probably a mistake somewhere else

Re: SDL 1.2 to 2.0

Posted: Wed Sep 18, 2013 8:22 pm
by Dominus
I wonder if this thread http://forums.libsdl.org/viewtopic.php? ... sc&start=0 is of relevance. If I understood anything it seems that SDL declares all little endian and that might screw our side of the code?

Re: SDL 1.2 to 2.0

Posted: Sun Nov 03, 2013 10:47 am
by Dominus
Anything new? Back from holidays?

Re: SDL 1.2 to 2.0

Posted: Tue Jan 28, 2014 5:37 pm
by Malignant Manor
The audio problem with sfx and speech repeating is fixed in revision 7459. It was surprisingly easy. I basically have no chance to implement a real fix for the graphical issue.

Re: SDL 1.2 to 2.0

Posted: Sat Jan 10, 2015 9:18 am
by Dominus
Hmm, just tried with latest SDL2 code and apart from the OpenGL scaler, everything seems fine...
I probably need to be pointed at stuff directly!

I plan on handling both SDL versions with the acinclude.m4 similar to what the above mentioned patch for Dosbox does.

Re: SDL 1.2 to 2.0

Posted: Sat Jan 17, 2015 10:14 pm
by Dominus
Some more tests, this time trying to build with Exult Studio support.

exult.cc doesn't want to cooperate :(

first in line 1052, I needed to change

Code: Select all

xdnd = new Xdnd(info.info.x11.display, info.info.x11.wmwindow,
to

Code: Select all

xdnd = new Xdnd(info.info.x11.display, info.info.x11.window,
but then compilation failed with

Code: Select all

exult.cc:1740:33: error: no member named 'event' in 'SDL_SysWMmsg'
                XEvent &ev = event.syswm.msg->event.event;
                             ~~~~~~~~~~~~~~~  ^
and I found no fix :(


When I disable this part, Exult will build but it's not able to generate video ;(
(the culprit is not what I disabled, same disabled code runs well with SDL 1.2x + X11)

Re: SDL 1.2 to 2.0

Posted: Thu Jan 22, 2015 7:52 pm
by Dominus
For anyone wanting to try this on OS X 10.7 and newer:
https://www.dropbox.com/s/8tsithnumg8hm ... t.dmg?dl=0

Re: SDL 1.2 to 2.0

Posted: Fri Jan 23, 2015 3:53 pm
by HiPhish
Works on OS X 10.10.1, iMac early 2009. Even the intro works.

The OpenGL scaler is missing, that's the one I usually use, but I assume you already know that. One new feature of SDL is hardware-accelerated mouse cursors. OpenMW has that, so even if my framerate drops the cursor still fells smooth and not like I'm dragging it along a rubber band. Even at 60FPS cursors without hardware acceleration tend to feel off. It would be really cool if you could do that eventually.

Re: SDL 1.2 to 2.0

Posted: Fri Jan 23, 2015 4:09 pm
by Dominus
Yeah, the OpenGl scaler may be gone for good with SDL2. The way opengl is being used (as a graphics driver) is not really compatible with the way we made it work on SDL 1.2xy
That said, it was not trustworthy anyway.

The cursor already behaves much better with SDL2 and if you happen to have a multimonitor setup, enjoy playing fullscreen and being able to use the second display ;)

Re: SDL 1.2 to 2.0

Posted: Fri Jan 23, 2015 6:23 pm
by HiPhish
No, I have only one monitor, but I did notice that it's using the new Cocoa fullscreen where instead of taking over my entire screen it gets its own space instead. That way I can easily switch to another application using a four-finger swipe on the trackpad or using ctrl + arrows.

It's a shame about the OpenGL renderer, I always found it to have the best performance. I'm using Point now, it looks the same, but performance is slightly lower, the cursor is more sluggish, but not by much. Where it's really sluggish is the main menu, it's awful there, but luckily that's just until I pick my game, which takes a second or two.

Re: SDL 1.2 to 2.0

Posted: Sat Jan 24, 2015 8:39 am
by Dominus
We will happily accept patches ;)

Edit: while you are at it, can you implement the magic trackpad in a more sensible way? :)

Re: SDL 1.2 to 2.0

Posted: Sun Jan 25, 2015 1:20 am
by Malignant Manor
Dominus, if I remember correctly, Exult Studio itself has several files with SDL 2 update issues.

Re: SDL 1.2 to 2.0

Posted: Sun Jan 25, 2015 6:41 am
by Dominus
Hmm, no, I think ES has nothing to do with SDL.


Edit: when you look through the mapedit folder, you will find that only smooth and mockup use SDL.

Re: SDL 1.2 to 2.0

Posted: Sun Nov 11, 2018 3:42 am
by jdawg
i hope i am in the right place to post this.

what is the most recent 150 build WITHOUT SDL2?

the problem is that i use mt32emu. which to my knowledge is broken in all sdl2 builds. i followed malignant manors post about it working in 1.4.9rc1 and voila it works fine. however the mods i use require 1.5.. please sticky this for someone like me who had to find out the hard way. as we all know the mt32emu is the most accurate and best sound. i dont want to use the prerecorded ogg audio mt32 pack as my system is already slow enough as it is. thank you

Re: SDL 1.2 to 2.0

Posted: Sun Nov 11, 2018 7:01 am
by jdawg
if i remember correctly..mt32emu is supposedly broken in all 32 builds after 1.4.9rc1. if there exists a 1.5.0 x64 build that is compatible with server 2003 x64 or xp 64. i would be happy to try that. i am not upgrading my computer. also my graphics is GMA 3000...which totally sucks. which again is why i would prefer a x64 sdl1 build of exult

Re: SDL 1.2 to 2.0

Posted: Sun Nov 11, 2018 9:42 am
by Dominus
- Exult's built in mt32 emu is working fine in all builds, afaik. I have no knowledge of anything broken
- you can also use munt as a midi device for mt32 emulation
- mt32 emulation costs more cpu power than playback of the prerecorded ogg files.

If you have a reproducable problem with Exult and mt32 emulation, please post everything we need to know about it.
Exult version (use the latest snapshot), Windows version, exult.cfg, stderr.txt and stdout.txt.
And please use a new thread.