Commit graph

158 commits

Author SHA1 Message Date
Charles Dang
4435b25523 Remove calls to empty update_whole_screen() function
The function's contents were SDL1.2 only, and it now does nothing in
SDL2.
2016-03-13 22:17:36 +11:00
Andreas Löf
358bd1235f Remove SDL1.2 code
This removes all legacy SDL1.2 code. It was done by invoking:
coan source --replace --no-transients -D"SDL_VERSION_ATLEAST(X, Y, Z)"=1 <file>
on each file.
2016-03-13 11:34:34 +13:00
Andreas Löf
b308df8c7e Make sure bigmap isn't overdrawn by in-game UI
The storyscreen would trigger a full redraw-cycle partially through
displaying bigmap. Due to the implementation of the storyscreen, this
would cause it to have the background overdrawn and never updated. The
fix implemented here is to remove layered-drawing functionality from
the storyscreen and trigger a full redraw manually at the end of the
story screen functionality.
2016-03-05 17:15:40 +13:00
Andreas Löf
bdac437efc Fix compilation with SDL1
This fixes two compilation errors when compiling against SDL1. At
least one was brought over from master.
2016-02-28 13:21:36 +13:00
Andreas Löf
b8f18919dd Merge remote-tracking branch 'origin/master' into guifixes
Conflicts:
	src/events.cpp
	src/hotkey/command_executor.hpp
	src/video.cpp

Resolved manually.
2016-02-21 23:00:14 +13:00
Charles Dang
6626bbce22 Add flag to get_available_resolutions() to include current resolution 2016-02-06 20:19:46 +11:00
Andreas Löf
a5f8d62a75 Add initial support for GUI layering
This introduces a subclass of events::sdl_handler that keeps track of
all instantiated classes. When a new instance is created it's pushed
onto a list of all tracked instances. When an instance is destroyed,
all known instances are sent a resize event (under SDL2) to mark them
as dirty. After that there's a DRAW_ALL event pushed onto the event
queue to cause a redraw. There's currently no logic in place to ensure
that there's only one DRAW_ALL event in the event queue at any given
time, but it should be harmless as long as no components are marked as
dirty.
2016-01-30 15:11:20 +13:00
Charles Dang
4afd415143 Decoupled delay() from display class and moved it to a static CVideo function 2016-01-12 10:55:55 +11:00
gfgtdf
93091519bd make CVideo a singleton
half of CVideo's member variables were already static members (in anon
namespaces) so it was never possibel to have more than one of this
class. Making this class a singelton allows us to move all these
variables into the CVideo class.
2016-01-12 00:17:26 +01:00
Andreas Löf
5f5a334fba Make window events a separate handler for sdl_events
This adds a new function to sdl_handler, handle_window_event that is called for all window events. It is propogated to all event contexts instead of just the current one.
events::raise_draw_all_event (and a volatile variant) are added, that also sends draw events to all event contexts in reverse order so that the draw-stack can be redrawn bottom-up.
2016-01-11 18:59:33 +13:00
Chris Beck
ba51524f6e update copyright to year 2016
using this shell script:

find src -type f -print0 | xargs -0 sed -i "s|Copyright (C) \([[:digit:]]*\)\([ ]*\)-\([ ]*\)2015|Copyright (C) \1\2-\32016|g"
2016-01-02 23:59:31 -05:00
Charles Dang
68a7259265 Marked a variable as SDL1.2 only 2016-01-03 05:47:42 +11:00
Charles Dang
3c5e6cbdb6 More progress on refactoring window handling under SDL2
General changes in this commit:
* Split window initialization out of setMode and into its own function
* Remove local flags for window state and instead get them directly from the
  window itself.
* Improve handling of distinct window change cases in setMode.
* Refactored and cleaned up several functions.
2016-01-03 04:55:41 +11:00
Charles Dang
8732d8179c Added and deployed getter method for current window resolution 2016-01-01 18:29:54 +11:00
Charles Dang
6272190ec5 Restrict CVideo::modePossible to SDL1 only
It's only called from SDL1 functions anyway
2016-01-01 18:29:51 +11:00
Andreas Löf
544b61534c Fix bug #24209 and add a global event scope
This adds a global event scope that an sdl_handler can register to in
order to receive all current events, regardless of the current
scope. Care should be taken to not be registerd in a local event
context and the global context at the same time as it will lead to the
event handler potentially being invoked twice.

This also adds the workaround needed for #24209 in the new event
handler in the video class.
2016-01-01 17:56:59 +13:00
Charles Dang
ccc2433979 Move relevant functions from preferences to display class
This affects window setter functions such as set_fullscreen() and set_resolution()
2015-12-31 14:00:54 +11:00
Charles Dang
136ca10a9a Added DefaultBpp var to CVideo class 2015-12-31 14:00:52 +11:00
Charles Dang
9ac728cef7 Relegate some unneeded Bpp-related functions to SDL1 2015-12-31 14:00:19 +11:00
gfgtdf
6cf73ad76e move unused variables into their ifdefs 2015-12-30 21:17:06 +01:00
Charles Dang
a929397cc0 Removed an additional macro alias for fullscreen 2015-12-30 11:52:26 +11:00
Elvish_Hunter
9b7b1751fd Removed trailing tabs and whitespaces from C++ source
I used this command line: find <source directory> -name \*.\[ch\]pp -print0 | xargs -0 sed -i 's/[[:blank:]]*$//'
2015-12-21 20:39:46 +01:00
Andreas Löf
36456df46f Fixes bug #24138 and disables SDL_PumpEvent() in grid.cpp
This removes the usage of the display::get_singleton() in the event
handling code since it may cause incorrect behaviour (crash) when the
singleton has been incorrectly set to null.

This also removes SDL_PumpEvents() from grid.cpp the rendering code
should not be directly interacting with the event handling and it's
causing instabilities.
2015-12-05 21:12:20 +13:00
Andreas Löf
449aed0a64 Fix Bug #23908 - Crash on resize with SDL2.
SDL2 uses shared memory to communicate with the graphics system when
using a software renderer. A resize event will cause SDL2 to
invalidate the SDL_surface that relies on shared memory and any
subsequent calls to will be SDL_GetWindowSurface will cause the shared
memory do be unmapped as the old surface is released.  This is
problematic when it occurs during a rendering cycle, because the
software rendered may also invoke SDL_GetWindowSurface, making any
references to that surface that the game contains become stale. This
will in turn cause a segmentation fault during blitting.
2015-10-13 01:24:51 +13:00
Andreas Löf
0c27eb9490 Only use references to the screen surface.
This change makes sure that only references are used to the video
surface instead of a copy. This will help to avoid stale values after
a resize event has occured where it will cause a crash due to a stale
pointer.
2015-10-12 23:05:48 +13:00
Ignacio R. Morelle
57ae45387a New Year copyright update 2015-01-01 19:07:35 -03:00
Boldizsár Lipka
d0c30c6ad6 Apply updated overlay instantenously. 2014-08-19 20:43:26 +02:00
Boldizsár Lipka
27a1f195f9 Update overlay when changed. 2014-08-19 20:43:26 +02:00
Boldizsár Lipka
623fd991c3 Draw floating labels to the overlay texture. 2014-08-12 22:46:27 +02:00
Boldizsár Lipka
0b4bfc76db Fix fullscreen mode for SDL_gpu. 2014-08-11 23:01:56 +02:00
Boldizsár Lipka
e2c8957ab6 Implement vertical and horizontal flip and grayscale effects.
Raises required GLSL version to 1.30.
2014-08-11 23:01:55 +02:00
Boldizsár Lipka
888df77e7a Don't limit color modulation to the [-128, 127] range. 2014-08-11 23:01:54 +02:00
Mark de Wever
f62c63ea07 Fix some class/struct tags. 2014-07-29 20:45:10 +02:00
Boldizsár Lipka
b006dac297 Use shaders for color blending in SDL_gpu builds. 2014-07-29 19:04:31 +02:00
Boldizsár Lipka
7d3535645f Rename ttexture to timage. 2014-07-17 21:47:04 +02:00
Boldizsár Lipka
51aeb482a6 Guard CVideo::draw_texture with an ifdef. 2014-07-08 18:30:29 +02:00
Boldizsár Lipka
aeb1f5ea84 Move ttexture::draw calls into CVideo::draw_texture. 2014-07-08 18:10:59 +02:00
Boldizsár Lipka
fba9a360cc Enable OpenGL rendering. 2014-06-27 11:57:49 +02:00
Boldizsár Lipka
d85f74e64d Make the global twindow object globally available.
Note: This is a quick an not really elegant change. I'll fix this as
soon as I'll have figured how CVideo and twindow should relate to
eachother.
2014-06-08 10:58:38 +02:00
Mark de Wever
9de59be3a7 Update the Doxygen comments. 2014-03-09 15:21:31 +01:00
Mark de Wever
08e717e4cd Add a work-around for SDL_WM_SetIcon in SDL2.
The code compiles, but doesn't do anything useful at the moment.
2014-03-02 15:31:17 +01:00
Mark de Wever
c28579e1f1 Add a work-around for SDL_WM_SetCaption in SDL2.
The code compiles, but doesn't do anything useful at the moment.
2014-03-02 15:15:13 +01:00
Mark de Wever
04eea89636 Refactor show_video_mode_dialog.
Separated the dialog code from the resolution gathering code. This makes
it easier to port the code to SDL2.

This also changes the sorting of the resolutions, first width then
height instead of based on the area. Before a part of the list looked
like:
1280 x 720
1152 x 864
1280 x 960
1440 x 900
1282 x 1024
These now look like:
1152 x 864
1280 x 720
1280 x 960
1280 x 1024
1440 x 900
The new sorting makes more sense to me.
2014-03-02 13:11:48 +01:00
Mark de Wever
57432e805f Add a work-around for SDL_GetAppState in SDL2.
The code only compiles, but never return a sensible value. This should
be done later.
2014-03-02 10:56:21 +01:00
Ignacio R. Morelle
a4f47a63c7 New Year copyright update 2014-01-01 02:08:52 -03:00
Eric S. Raymond
043c4f9fd3 Remove $Id$ cookies. 2013-03-26 21:41:37 -04:00
Mark de Wever
3d964af76a Remove some unused defines. 2013-03-09 21:24:57 +00:00
Mark de Wever
43b71f2ff0 New year copyright update. 2013-01-01 09:22:03 +00:00
Ignacio R. Morelle
6ca69b2df5 New year copyright update 2012-01-07 02:35:17 +00:00
Karol Nowak
437ee1b853 Fixed a bug with --bpp setting being ignored upon resolution change.
Forcing --bpp still breaks the video mode selection dialog.
2011-06-15 20:54:03 +00:00