Commit Graph

436 Commits

Author SHA1 Message Date
Patric Stout 34051c10df
Doc: some comments for the win32 video driver (#8409)
Co-authored-by: Niels Martin Hansen <nielsm@indvikleren.dk>
2020-12-21 22:28:56 +01:00
Michael Lutz 4c1ee264a6
Fix: [OSX] Warning about ambiguous method (-Wobjc-multiple-method-names). (#8399) 2020-12-19 21:59:27 +01:00
Patric Stout d5b9f7ac37 Add: [Emscripten] use "relative mouse mode" with SDL2
This mode doesn't wrap the mouse constantly, but requests SDL
to lock the mouse pointer. This is needed, as with Emscripten
you are not allowed to change the mouse poisition (only to lock
it into place).
2020-12-15 15:46:39 +01:00
Patric Stout d15dc9f40f Add: support for emscripten (play-OpenTTD-in-the-browser)
Emscripten compiles to WASM, which can be loaded via
HTML / JavaScript. This allows you to play OpenTTD inside a
browser.

Co-authored-by: milek7 <me@milek7.pl>
2020-12-15 15:46:39 +01:00
Patric Stout 2da07f7615 Codechange: unroll the SDL2 main loop
This commit prepares for the next commit, as Emscripten needs to
have a way to trigger a single iteration of the main loop. To
keep the real changes more clear, this commit only unrolls the
loop, and makes no changes to the logic itself.
2020-12-15 15:46:39 +01:00
Charles Pigott 348c231e12 Codechange: Make codestyle for CMake files consistent for 'control' statements 2020-09-25 14:43:13 +01:00
nikolas c9aff698d0
Fix #8104: Always add WINDOW_RESIZABLE flag to SDL2 (#8211)
This fixes a bug that can reproduced with these steps:
* Start openttd in fullscreen mode
* Turn off fullscreen mode
* Try to resize the window. The window can't be resized.
2020-06-18 08:53:06 +01:00
TechGeekNZ fe1925931d Cleanup: Correct typographic errors in code comments. 2020-06-07 01:04:41 +01:00
Patric Stout 56d54cf60e Add: introduce CMake for project management
CMake works on all our supported platforms, like MSVC, Mingw, GCC,
Clang, and many more. It allows for a single way of doing things,
so no longer we need shell scripts and vbs scripts to work on all
our supported platforms.

Additionally, CMake allows to generate project files for like MSVC,
KDevelop, etc.

This heavily reduces the lines of code we need to support multiple
platforms from a project perspective.

Addtiionally, this heavily improves our detection of libraries, etc.
2020-06-05 19:36:05 +02:00
TechGeekNZ cdd2892c49 Codechange: Realign SDL driver with SDL2 driver to ease maintenance and emphasise differences. 2020-06-04 09:05:21 +01:00
Niels Martin Hansen 764497206a Fix #8066: Try another fallback colourspace if first one fails 2020-06-01 19:43:37 +02:00
Michael Lutz 37bc2f8064 Codechange: Use std::string in the driver and blitter selection code. 2020-05-21 20:02:34 +02:00
Michael Lutz 9dd8b3d430 Remove: [OSX] Stuff that is pre-10.7 from the Cocoa/Quartz video driver. 2020-04-12 18:44:43 +02:00
Michael Lutz 0e5be3887c Remove: [OSX] Old fullscreen subdriver for pre 10.7 systems.
Since the move to C++11, building for pre 10.7 is not possible with the native
Apple tools. Also, due to bitrot, the file doesn't even compile anymore. While
this could be fixed, it shows that this subdriver is basically never used anymore.
2020-04-12 18:44:43 +02:00
Michael Lutz a31cbbf67f Remove: [OSX] QuickDraw video subdriver used for OSX versions up to 10.4.
Since the C++11 move, getting OpenTTD to compile and run for anything
below 10.7 basically requires building a custom compiler and libc++.
Also, the QuickDraw subdriver crashes on more modern OSX version. While this
is fixable, keeping the driver around is probably pointless.
2020-04-12 18:44:43 +02:00
Sebastian Pauka bd3a5876b0 Fix #7644: [Cocoa] Manually set colorspace to sRGB 2020-03-30 08:25:14 +02:00
xdavidwu 8fe38afd2b Fix: [SDL2] Correct name of the video driver in debug log
SDL_GetVideoDriver(0) returns name of first video driver included in
the library, not the driver currently used.
SDL_GetCurrentVideoDriver() does what we want here.
2020-01-15 20:16:53 +00:00
S. D. Cloudt 13cc8a0cee Cleanup: Removed SVN headers 2019-11-10 17:59:20 +00:00
Jonathan G Rennison a15ace0f5b Fix #7783, Fix #7816: [SDL2] Fix input handling in edit context
In particular this fixes handling of the shift key
2019-11-10 17:58:42 +00:00
Jonathan G Rennison 81f159434d Codechange: Add EditBoxGainedFocus method to VideoDriver base class 2019-11-10 17:58:42 +00:00
Jonathan G Rennison 46f7c6a641 Change: [SDL2] Add an "unprintable" flag to struct VkMapping
SDL_Keysym::sym is not suitable for checking whether the character
is printable or not
2019-11-10 17:58:42 +00:00
Jonathan G Rennison d41378c00a Fix: [SDL2] Page down key not handled
SDLK_PAGEUP and SDLK_PAGEDOWN are not sequential
They must have separate entries in _vk_mapping
2019-11-10 17:58:42 +00:00
Jonathan G Rennison 3db399d7d9 Fix: [SDL2] Detection of backtick scancode
SDL_Keysym::scancode is a SDL_SCANCODE_* constant, not a raw scan code
2019-11-10 17:58:42 +00:00
Nikolas Nyby 4884dcacba Fix #7784: up/down/home/end key behavior in SDL2
Closes #7784.
2019-11-01 23:41:47 +01:00
Michael Lutz d5a9bd404a Codechange: [OSX] Use std::unique_ptr with a custom deleter to simply memory management of Core Foundation types. 2019-11-01 22:32:53 +01:00
Nikolas Nyby f13b184588 Codechange: Don't use SDL_CreateRGBSurfaceWithFormat()
This function requires libSDL 2.0.5 or higher. It looks like we don't
need to use it, and can just use the original SDL_CreateRGBSurface(),
with the masks set to 0, to trigger the default 8-bit format, which is
SDL_PIXELFORMAT_INDEX8.

Closes #7785

Note: this code path is activated by using an 8-bit blitter, like:

    ./bin/openttd -b 8bpp-simple
2019-10-25 22:23:57 +01:00
JMcKiern 04f659e768 Fix: Some typos found using codespell 2019-09-29 21:27:32 +01:00
nikolas 2d27e8e685 Add #6173: New SDL 2 based video and sound drivers (#7086) 2019-09-19 17:18:50 +02:00
Michael Lutz ed6a427fcc Change: [OSX] Recreate backing store if the colour profile of the screen (or the screen) the game window is one changes.
This will result in changing colours if moving OpenTTD from one screen to another, but should avoid performance problems if the window is moved.
2019-09-16 19:11:08 +01:00
Michael Lutz 994664dec5 Fix #7644: [OSX] Try to use system colour space to avoid video output performance degradation. 2019-09-16 19:11:08 +01:00
Andy 9014633866 Fix: change Quartz driver colorSpace handling to address certain macOS performance issues (#7644) 2019-09-07 22:09:17 +02:00
nikolas 9d6fb257c3 Cleanup: Remove duplicate thread.h include (#7683) 2019-08-06 07:43:00 +01:00
glx 9195f2337a Codechange: use std::vector for _resolutions 2019-04-18 21:49:34 +02:00
Henry Wilson 7c8e7c6b6e Codechange: Use null pointer literal instead of the NULL macro 2019-04-10 23:22:20 +02:00
Michael Lutz 967b27a2c1 Codechange: C++11 STL has a function for getting the number of CPU cores. 2019-04-06 11:27:39 +02:00
Michael Lutz ae748166d0 Codechange: Use platform independent C++11 function for sleeping on a thread. 2019-04-06 11:27:39 +02:00
Michael Lutz 05bc2ed7cb Codechange: Replace custom thread code with C++11 thread objects.
We assume a conforming C++11 compiler environment that has a valid <thread>-header.
Failure to run a real thread is handled gracefully.
2019-04-06 11:27:39 +02:00
Michael Lutz 05f4e73608 Codechange: Replace custom mutex code with C++11 mutex'es.
A conforming compiler with a valid <mutex>-header is expected.
Most parts of the code assume that locking a mutex will never fail unexpectedly,
which is generally true on all common platforms that don't just pretend to
be C++11. The use of condition variables in driver code is checked.
2019-04-06 11:27:39 +02:00
Niels Martin Hansen 66c60e52ba Change: [SDL] Do not offer video smaller than 640x480 2019-03-30 22:02:14 +01:00
Henry Wilson af7d9020a1 Codechange: Use override specifer for overriding member declarations
This is a C++11 feature that allows the compiler to check that a virtual
member declaration overrides a base-class member with the same signature.

Also src/blitter/32bpp_anim_sse4.hpp +38 is no longer erroneously marked
as virtual despite being a template.
2019-03-24 16:10:04 +01:00
Patric Stout e3c639a09f Remove: ENABLE_NETWORK switch
This switch has been a pain for years. Often disabling broke
compilation, as no developer compiles OpenTTD without, neither do
any of our official binaries.

Additionaly, it has grown so hugely in our codebase, that it
clearly shows that the current solution was a poor one. 350+
instances of "#ifdef ENABLE_NETWORK" were in the code, of which
only ~30 in the networking code itself. The rest were all around
the code to do the right thing, from GUI to NewGRF.

A more proper solution would be to stub all the functions, and
make sure the rest of the code can simply assume network is
available. This was also partially done, and most variables were
correct if networking was disabled. Despite that, often the #ifdefs
were still used.

With the recent removal of DOS, there is also no platform anymore
which we support where networking isn't working out-of-the-box.

All in all, it is time to remove the ENABLE_NETWORK switch. No
replacement is planned, but if you feel we really need this option,
we welcome any Pull Request which implements this in a way that
doesn't crawl through the code like this diff shows we used to.
2019-03-20 19:24:55 +01:00
Patric Stout 72c5f2b3ee Remove: DOS support
In 10 years there was no active development on DOS. Although it
turned out to still work, the FPS was very bad. There is little
interest in the current community to look into this.

Further more, we like to switch to c++11 functions for threads,
which are not implemented by DJGPP, the only current compiler
for DOS.

Additionally, DOS is the only platform which does not support
networking. It is the reason we have tons of #ifdefs to support
disabling networking.

By removing DOS support, we can both use c++11 functions for threads,
and remove all the code related to disabling network. Sadly, this
means we have to see DOS go.

Of course, if you feel up for the task, simply revert this commit,
and implement stub c++11 functions for threads and stub functions
for networking. We are more than happy to accept such Pull Request.
2019-03-19 23:22:51 +01:00
Patric Stout f58db44ff2 Remove: BeOS support (deprecated by Haiku)
In 10 years there is no commit to change how BeOS works, and we
have no active maintainer for it. It is unlikely it works in its
current state (but not impossible).

With the arrival of SDL2 (and removal of SDL), BeOS is no longer
support. SDL2 suggests to use Haiku instead of BeOS.
2019-03-05 22:03:00 +01:00
Patric Stout 7784d77713 Remove: MorphOS / AmigaOS support
In 10 years there is no commit to change how MorphOS works, and we
have no active maintainer for it. It is unlikely it works in its
current state (but not impossible).

With the arrival of SDL2 (and removal of SDL), MorphOS is no longer
support. There is an SDL2 port for MorphOS, but it is not maintained
by upstream SDL2, and nobody can currently test it out.

If anyone wants to re-add MorphOS, please do (revert this patch,
fix the problems, and create a Pull Request). If you need any help
doing so, let us know! It is not that we don't like MorphOS, it is
that we don't have anyone fixing the problems :(
2019-03-05 22:03:00 +01:00
Charles Pigott c3bc7d657e Codechange: Remove ability for SDL to be dynamically loaded on Windows 2019-03-02 17:13:05 +01:00
Alexander Weiss 77ab6f8ec7 Change: [OSX] Prevent 2D scrolling for traditional scroll wheel mice 2019-02-24 17:54:59 +01:00
Alexander Weiss 0bb395b21d Change #6800: [OSX] Use high-precision scrolling deltas for 2D scrolling 2019-02-24 17:54:59 +01:00
Charles Pigott fe8c24e081 Codechange: Remove unnecessarily defined functions under MinGW 2019-01-17 21:55:15 +00:00
Charles Pigott 2d981a4b2c Fix: A few minor compile warnings under MinGW 2019-01-17 21:55:15 +00:00
glx c540d72445 Fix: [Win32] WIN32 may not be defined, always prefer the compiler predefined macro _WIN32 2018-12-27 18:09:16 +01:00