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

Replacing SDL1.2 with SDL2.0 #1246

Merged
merged 10 commits into from Mar 22, 2015
Merged

Replacing SDL1.2 with SDL2.0 #1246

merged 10 commits into from Mar 22, 2015

Conversation

swick
Copy link
Contributor

@swick swick commented Jun 29, 2014

This branch contains minimal changes to replace SDL1.2 with SDL2.0. It should behave exactly like the older version except for internal changes in SDL2.

SDL touches many parts of the system and is important for a user therefor it should be tested thoroughly. Testing, comments and patches welcome.

Known Bugs:

  • mouse input lags: I didn't touch the mouse movement code at all, will investigate further
  • ...

@@ -9,3 +9,4 @@ scripts/work/
/SDL.dll
/freetype.dll
/autoexec.cfg
*~
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't be here (;

@cinaera
Copy link
Contributor

cinaera commented Jun 29, 2014

Thanks for the pull request! Looks pretty good (:
Please rename the linked libs from "SDL" and "SDLmain" to "SDL2" and "SDL2main" in sdl.lua to fix windows build
About the mouse warping im not totally sure, would prefer to just set the relative mouse mode and remove InpGrab.
Also noticed that on win32 you can't create windows with full screen boundaries when you are not in fullscreen mode, which results in smaller windows. In consequence to this the height and width are wrong, which leads to UI bugs(wrong clipping in the TextEditBoxes).

@swick
Copy link
Contributor Author

swick commented Jun 29, 2014

  • Mouse movement works fine now
  • The glu header is at GL/glu.h for me. Is it anywhere else on other systems?
  • Windows now uses the SDL_WINDOW_FULLSCREEN flag, other operating systems use SDL_WINDOW_FULLSCREEN_DESKTOP. Does it fix your problem?

@cinaera
Copy link
Contributor

cinaera commented Jun 30, 2014

On Mac OS X is glu.h located at OpenGL/glu.h (sry forgot to mention the OS)
WarpMouse() can be removed I guess as it's not used anymore.

Edit:
The window and the OpenGL context should probably destroyed on shutdown
Will test it later, thanks for the update (:

@heinrich5991
Copy link
Contributor

I see some 'screen' stuff, does this implement some kind of support for multiple monitors?

@cinaera
Copy link
Contributor

cinaera commented Jun 30, 2014

The glTexImage3D = (PFNGLTEXIMAGE3DPROC) wglGetProcAddress("glTexImage3D"); part has to be called after the context creation but before the context is released.

About the wrong window boundaries:
It seems like it can't create windows with screen boundaries (or larger) in windowed mode.
E.g my screen has a resolution of 1680x1050 but it only creates a window up to 1680x1032 (client size)
This results in clipping errors

@swick
Copy link
Contributor Author

swick commented Jun 30, 2014

The glTexImage3D = (PFNGLTEXIMAGE3DPROC) wglGetProcAddress("glTexImage3D"); part has to be called after the context creation but before the context is released.

Woops, makes sense.

It seems like it can't create windows with screen boundaries (or larger) in windowed mode.

Does fullscreen work?
I really don't know what I should do about the wrong window size.

@swick
Copy link
Contributor Author

swick commented Jul 1, 2014

Any news? Does it work now on Linux, Windows and Mac OSX?

@cinaera
Copy link
Contributor

cinaera commented Jul 2, 2014

Tested on windows, looks good.
Just seen that SDL_GL_SetSwapInterval(Flags&IGraphicsBackend::INITFLAG_VSYNC ? 1 : 0); needs also be called after the context creation else vsync won't work

@swick swick changed the title Replacing SDL1.2 with SDL2.0 [RFC] Replacing SDL1.2 with SDL2.0 Jul 2, 2014
@swick
Copy link
Contributor Author

swick commented Jul 2, 2014

This is probably ready to merge.

@ghost91-
Copy link
Contributor

ghost91- commented Jul 2, 2014

On OS X I'm getting some errors like
src/engine/client/sound.cpp:11:10: fatal error: 'SDL2/SDL.h' file not found
This is due to the fact that
sdl2-config --cflags
returns
-I/opt/local/include/SDL2 -D_THREAD_SAFE
so the "SDL2" is not needed. This should also happen on Linux, because on Linux sdl2-config is used, too. This is easily fixed by replacing all includes of SDL2/SDL.h by includes of SDL.h.

You are sometimes using '""' and sometimes '<>' for the includes of SDL, this should be unified...

In src/engine/client/backend_sdl.cpp we need
#include <base/detect.h>
so that "CONF_PLATFORM_MACOSX" is defined.

If all the things a mentioned are fixed, it compiles on OS X.

When starting (in Fullscreen mode) after the game is loaded and we are in the menu, the curser is locked in the upper left corner. Once the console or the remote console has been opened (f1, f2), I can move the cursor. Aside from that, everything seems to work fine. I will do some more testing tomorrow.

@swick
Copy link
Contributor Author

swick commented Jul 2, 2014

This is familiar :)
Anyway, that hopefully fixed the build. Waiting for your input on the input bug (pun not intended).

@ghost91-
Copy link
Contributor

ghost91- commented Jul 3, 2014

you forgot one SDL2/SDL.h in src/engine/client/client.cpp

@swick
Copy link
Contributor Author

swick commented Jul 3, 2014

The whole keyboard handling seems broken. It seemingly randomly registers keys which were not pressed.

@TsFreddie
Copy link
Contributor

SDL2 is one of the solutions for asia players' communication issue (but only in Windows). SDL2 is fully compatible with Windows IME (but need to be modified to compatible with candidates feature).

For linux, SDL2 doesn't support every input method for Chinese or Japanese or some other language (e.g. Fcitx can send chinese Unicode characters as a keycode which can type chinese in SDL1, but it is broken with SDL2. SDL2 can be compatible by IME, but it can not just compatible with IME.)

SDL2 provided a function that draws candidates list on SDL2 surface. But can not used by OpenGL function in SDL2. I tried to combined two drawing engine, but it can not work as I thought. Still, there ARE full functions with Windows IME just modified the event part of SDL2. I haven't done this thing because I got problems on compiling SDL2 source code, and I'm waiting this pull for further modify in Teeworlds.

@darvin
Copy link

darvin commented Nov 15, 2014

Libsdl2 is also requirement for much easier porting onto ios.

@heinrich5991
Copy link
Contributor

If someone wants to test it, a more up-to-date version of swick's code can be found here: heinrich5991/teeworlds/sdl2_test. Please report bugs in this thread!

@def-
Copy link
Contributor

def- commented Nov 28, 2014

Bugs I have on Linux with xmonad window manager:

  • Mouse just moves out of window, doesn't get grabbed
  • Entering unusual characters (for example Ô) causes an SDL warning on the console:
    The key you just pressed is not recognized by SDL. To help get this fixed, please report this to the SDL mailing list sdl@libsdl.org X11 KeyCode 0 (-8), X11 KeySym 0x0 ((null)).
  • Some character inputs that worked before don't work anymore, for example ⁵ or ₅ (using xcompose, nothing happens)
  • Open a window, resize it to fullscreen: Then the window is at bottom left, while it was at top left on SDL 1.2

@def- def- mentioned this pull request Dec 7, 2014
@oy oy merged commit 2232a73 into teeworlds:master Mar 22, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants