OpenTTD Source  1.11.2
allegro_v.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of OpenTTD.
3  * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4  * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5  * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
6  */
7 
15 #ifdef WITH_ALLEGRO
16 
17 #include "../stdafx.h"
18 #include "../openttd.h"
19 #include "../gfx_func.h"
20 #include "../rev.h"
21 #include "../blitter/factory.hpp"
22 #include "../core/random_func.hpp"
23 #include "../core/math_func.hpp"
24 #include "../framerate_type.h"
25 #include "../progress.h"
26 #include "../thread.h"
27 #include "../window_func.h"
28 #include "allegro_v.h"
29 #include <allegro.h>
30 
31 #include "../safeguards.h"
32 
33 #ifdef _DEBUG
34 /* Allegro replaces SEGV/ABRT signals meaning that the debugger will never
35  * be triggered, so rereplace the signals and make the debugger useful. */
36 #include <signal.h>
37 #endif
38 
39 static FVideoDriver_Allegro iFVideoDriver_Allegro;
40 
41 static BITMAP *_allegro_screen;
42 
43 #define MAX_DIRTY_RECTS 100
44 static PointDimension _dirty_rects[MAX_DIRTY_RECTS];
45 static int _num_dirty_rects;
46 
47 void VideoDriver_Allegro::MakeDirty(int left, int top, int width, int height)
48 {
49  if (_num_dirty_rects < MAX_DIRTY_RECTS) {
50  _dirty_rects[_num_dirty_rects].x = left;
51  _dirty_rects[_num_dirty_rects].y = top;
52  _dirty_rects[_num_dirty_rects].width = width;
53  _dirty_rects[_num_dirty_rects].height = height;
54  }
55  _num_dirty_rects++;
56 }
57 
59 {
60  PerformanceMeasurer framerate(PFE_VIDEO);
61 
62  int n = _num_dirty_rects;
63  if (n == 0) return;
64 
65  _num_dirty_rects = 0;
66  if (n > MAX_DIRTY_RECTS) {
67  blit(_allegro_screen, screen, 0, 0, 0, 0, _allegro_screen->w, _allegro_screen->h);
68  return;
69  }
70 
71  for (int i = 0; i < n; i++) {
72  blit(_allegro_screen, screen, _dirty_rects[i].x, _dirty_rects[i].y, _dirty_rects[i].x, _dirty_rects[i].y, _dirty_rects[i].width, _dirty_rects[i].height);
73  }
74 }
75 
76 
77 static void UpdatePalette(uint start, uint count)
78 {
79  static PALETTE pal;
80 
81  uint end = start + count;
82  for (uint i = start; i != end; i++) {
83  pal[i].r = _cur_palette.palette[i].r / 4;
84  pal[i].g = _cur_palette.palette[i].g / 4;
85  pal[i].b = _cur_palette.palette[i].b / 4;
86  pal[i].filler = 0;
87  }
88 
89  set_palette_range(pal, start, end - 1, 1);
90 }
91 
92 static void InitPalette()
93 {
94  UpdatePalette(0, 256);
95 }
96 
98 {
99  if (_cur_palette.count_dirty != 0) {
101 
102  switch (blitter->UsePaletteAnimation()) {
105  break;
106 
108  blitter->PaletteAnimate(_cur_palette);
109  break;
110 
112  break;
113 
114  default:
115  NOT_REACHED();
116  }
118  }
119 }
120 
121 static const Dimension default_resolutions[] = {
122  { 640, 480},
123  { 800, 600},
124  {1024, 768},
125  {1152, 864},
126  {1280, 800},
127  {1280, 960},
128  {1280, 1024},
129  {1400, 1050},
130  {1600, 1200},
131  {1680, 1050},
132  {1920, 1200}
133 };
134 
135 static void GetVideoModes()
136 {
137  /* Need to set a gfx_mode as there is NO other way to autodetect for
138  * cards ourselves... and we need a card to get the modes. */
139  set_gfx_mode(_fullscreen ? GFX_AUTODETECT_FULLSCREEN : GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0);
140 
141  _resolutions.clear();
142 
143  GFX_MODE_LIST *mode_list = get_gfx_mode_list(gfx_driver->id);
144  if (mode_list == nullptr) {
145  _resolutions.assign(std::begin(default_resolutions), std::end(default_resolutions));
146  return;
147  }
148 
149  GFX_MODE *modes = mode_list->mode;
150 
151  for (int i = 0; modes[i].bpp != 0; i++) {
152  uint w = modes[i].width;
153  uint h = modes[i].height;
154  if (w < 640 || h < 480) continue;
155  if (std::find(_resolutions.begin(), _resolutions.end(), Dimension(w, h)) != _resolutions.end()) continue;
156  _resolutions.emplace_back(w, h);
157  }
158 
159  SortResolutions();
160 
161  destroy_gfx_mode_list(mode_list);
162 }
163 
164 static void GetAvailableVideoMode(uint *w, uint *h)
165 {
166  /* No video modes, so just try it and see where it ends */
167  if (_resolutions.empty()) return;
168 
169  /* is the wanted mode among the available modes? */
170  if (std::find(_resolutions.begin(), _resolutions.end(), Dimension(*w, *h)) != _resolutions.end()) return;
171 
172  /* use the closest possible resolution */
173  uint best = 0;
174  uint delta = Delta(_resolutions[0].width, *w) * Delta(_resolutions[0].height, *h);
175  for (uint i = 1; i != _resolutions.size(); ++i) {
176  uint newdelta = Delta(_resolutions[i].width, *w) * Delta(_resolutions[i].height, *h);
177  if (newdelta < delta) {
178  best = i;
179  delta = newdelta;
180  }
181  }
182  *w = _resolutions[best].width;
183  *h = _resolutions[best].height;
184 }
185 
186 static bool CreateMainSurface(uint w, uint h)
187 {
189  if (bpp == 0) usererror("Can't use a blitter that blits 0 bpp for normal visuals");
190  set_color_depth(bpp);
191 
192  GetAvailableVideoMode(&w, &h);
193  if (set_gfx_mode(_fullscreen ? GFX_AUTODETECT_FULLSCREEN : GFX_AUTODETECT_WINDOWED, w, h, 0, 0) != 0) {
194  DEBUG(driver, 0, "Allegro: Couldn't allocate a window to draw on '%s'", allegro_error);
195  return false;
196  }
197 
198  /* The size of the screen might be bigger than the part we can actually draw on!
199  * So calculate the size based on the top, bottom, left and right */
200  _allegro_screen = create_bitmap_ex(bpp, screen->cr - screen->cl, screen->cb - screen->ct);
201  _screen.width = _allegro_screen->w;
202  _screen.height = _allegro_screen->h;
203  _screen.pitch = ((byte*)screen->line[1] - (byte*)screen->line[0]) / (bpp / 8);
204  _screen.dst_ptr = _allegro_screen->line[0];
205 
206  /* Initialise the screen so we don't blit garbage to the screen */
207  memset(_screen.dst_ptr, 0, _screen.height * _screen.pitch);
208 
209  /* Set the mouse at the place where we expect it */
210  poll_mouse();
211  _cursor.pos.x = mouse_x;
212  _cursor.pos.y = mouse_y;
213 
215 
216  InitPalette();
217 
218  char caption[32];
219  seprintf(caption, lastof(caption), "OpenTTD %s", _openttd_revision);
220  set_window_title(caption);
221 
222  enable_hardware_cursor();
223  select_mouse_cursor(MOUSE_CURSOR_ARROW);
224  show_mouse(_allegro_screen);
225 
226  GameSizeChanged();
227 
228  return true;
229 }
230 
231 bool VideoDriver_Allegro::ClaimMousePointer()
232 {
233  select_mouse_cursor(MOUSE_CURSOR_NONE);
234  show_mouse(nullptr);
235  disable_hardware_cursor();
236  return true;
237 }
238 
240 {
241  std::vector<int> rates = {};
242 
243  int refresh_rate = get_refresh_rate();
244  if (refresh_rate != 0) rates.push_back(refresh_rate);
245 
246  return rates;
247 }
248 
249 struct AllegroVkMapping {
250  uint16 vk_from;
251  byte vk_count;
252  byte map_to;
253 };
254 
255 #define AS(x, z) {x, 0, z}
256 #define AM(x, y, z, w) {x, y - x, z}
257 
258 static const AllegroVkMapping _vk_mapping[] = {
259  /* Pageup stuff + up/down */
260  AM(KEY_PGUP, KEY_PGDN, WKC_PAGEUP, WKC_PAGEDOWN),
261  AS(KEY_UP, WKC_UP),
262  AS(KEY_DOWN, WKC_DOWN),
263  AS(KEY_LEFT, WKC_LEFT),
264  AS(KEY_RIGHT, WKC_RIGHT),
265 
266  AS(KEY_HOME, WKC_HOME),
267  AS(KEY_END, WKC_END),
268 
269  AS(KEY_INSERT, WKC_INSERT),
270  AS(KEY_DEL, WKC_DELETE),
271 
272  /* Map letters & digits */
273  AM(KEY_A, KEY_Z, 'A', 'Z'),
274  AM(KEY_0, KEY_9, '0', '9'),
275 
276  AS(KEY_ESC, WKC_ESC),
277  AS(KEY_PAUSE, WKC_PAUSE),
278  AS(KEY_BACKSPACE, WKC_BACKSPACE),
279 
280  AS(KEY_SPACE, WKC_SPACE),
281  AS(KEY_ENTER, WKC_RETURN),
282  AS(KEY_TAB, WKC_TAB),
283 
284  /* Function keys */
285  AM(KEY_F1, KEY_F12, WKC_F1, WKC_F12),
286 
287  /* Numeric part. */
288  AM(KEY_0_PAD, KEY_9_PAD, '0', '9'),
289  AS(KEY_SLASH_PAD, WKC_NUM_DIV),
290  AS(KEY_ASTERISK, WKC_NUM_MUL),
291  AS(KEY_MINUS_PAD, WKC_NUM_MINUS),
292  AS(KEY_PLUS_PAD, WKC_NUM_PLUS),
293  AS(KEY_ENTER_PAD, WKC_NUM_ENTER),
294  AS(KEY_DEL_PAD, WKC_DELETE),
295 
296  /* Other non-letter keys */
297  AS(KEY_SLASH, WKC_SLASH),
298  AS(KEY_SEMICOLON, WKC_SEMICOLON),
299  AS(KEY_EQUALS, WKC_EQUALS),
300  AS(KEY_OPENBRACE, WKC_L_BRACKET),
301  AS(KEY_BACKSLASH, WKC_BACKSLASH),
302  AS(KEY_CLOSEBRACE, WKC_R_BRACKET),
303 
304  AS(KEY_QUOTE, WKC_SINGLEQUOTE),
305  AS(KEY_COMMA, WKC_COMMA),
306  AS(KEY_MINUS, WKC_MINUS),
307  AS(KEY_STOP, WKC_PERIOD),
308  AS(KEY_TILDE, WKC_BACKQUOTE),
309 };
310 
311 static uint32 ConvertAllegroKeyIntoMy(WChar *character)
312 {
313  int scancode;
314  int unicode = ureadkey(&scancode);
315 
316  const AllegroVkMapping *map;
317  uint key = 0;
318 
319  for (map = _vk_mapping; map != endof(_vk_mapping); ++map) {
320  if ((uint)(scancode - map->vk_from) <= map->vk_count) {
321  key = scancode - map->vk_from + map->map_to;
322  break;
323  }
324  }
325 
326  if (key_shifts & KB_SHIFT_FLAG) key |= WKC_SHIFT;
327  if (key_shifts & KB_CTRL_FLAG) key |= WKC_CTRL;
328  if (key_shifts & KB_ALT_FLAG) key |= WKC_ALT;
329 #if 0
330  DEBUG(driver, 0, "Scancode character pressed %u", scancode);
331  DEBUG(driver, 0, "Unicode character pressed %u", unicode);
332 #endif
333 
334  *character = unicode;
335  return key;
336 }
337 
338 static const uint LEFT_BUTTON = 0;
339 static const uint RIGHT_BUTTON = 1;
340 
342 {
343  poll_mouse();
344 
345  bool mouse_action = false;
346 
347  /* Mouse buttons */
348  static int prev_button_state;
349  if (prev_button_state != mouse_b) {
350  uint diff = prev_button_state ^ mouse_b;
351  while (diff != 0) {
352  uint button = FindFirstBit(diff);
353  ClrBit(diff, button);
354  if (HasBit(mouse_b, button)) {
355  /* Pressed mouse button */
356  if (_rightclick_emulate && (key_shifts & KB_CTRL_FLAG)) {
357  button = RIGHT_BUTTON;
358  ClrBit(diff, RIGHT_BUTTON);
359  }
360  switch (button) {
361  case LEFT_BUTTON:
362  _left_button_down = true;
363  break;
364 
365  case RIGHT_BUTTON:
366  _right_button_down = true;
367  _right_button_clicked = true;
368  break;
369 
370  default:
371  /* ignore rest */
372  break;
373  }
374  } else {
375  /* Released mouse button */
376  if (_rightclick_emulate) {
377  _right_button_down = false;
378  _left_button_down = false;
379  _left_button_clicked = false;
380  } else if (button == LEFT_BUTTON) {
381  _left_button_down = false;
382  _left_button_clicked = false;
383  } else if (button == RIGHT_BUTTON) {
384  _right_button_down = false;
385  }
386  }
387  }
388  prev_button_state = mouse_b;
389  mouse_action = true;
390  }
391 
392  /* Mouse movement */
393  if (_cursor.UpdateCursorPosition(mouse_x, mouse_y, false)) {
394  position_mouse(_cursor.pos.x, _cursor.pos.y);
395  }
396  if (_cursor.delta.x != 0 || _cursor.delta.y) mouse_action = true;
397 
398  static int prev_mouse_z = 0;
399  if (prev_mouse_z != mouse_z) {
400  _cursor.wheel = (prev_mouse_z - mouse_z) < 0 ? -1 : 1;
401  prev_mouse_z = mouse_z;
402  mouse_action = true;
403  }
404 
405  if (mouse_action) HandleMouseEvents();
406 
407  poll_keyboard();
408  if ((key_shifts & KB_ALT_FLAG) && (key[KEY_ENTER] || key[KEY_F])) {
409  ToggleFullScreen(!_fullscreen);
410  } else if (keypressed()) {
411  WChar character;
412  uint keycode = ConvertAllegroKeyIntoMy(&character);
413  HandleKeypress(keycode, character);
414  }
415 
416  return false;
417 }
418 
423 int _allegro_instance_count = 0;
424 
425 const char *VideoDriver_Allegro::Start(const StringList &param)
426 {
427  if (_allegro_instance_count == 0 && install_allegro(SYSTEM_AUTODETECT, &errno, nullptr)) {
428  DEBUG(driver, 0, "allegro: install_allegro failed '%s'", allegro_error);
429  return "Failed to set up Allegro";
430  }
431  _allegro_instance_count++;
432 
433  this->UpdateAutoResolution();
434 
435  install_timer();
436  install_mouse();
437  install_keyboard();
438 
439 #if defined _DEBUG
440 /* Allegro replaces SEGV/ABRT signals meaning that the debugger will never
441  * be triggered, so rereplace the signals and make the debugger useful. */
442  signal(SIGABRT, nullptr);
443  signal(SIGSEGV, nullptr);
444 #endif
445 
446  GetVideoModes();
447  if (!CreateMainSurface(_cur_resolution.width, _cur_resolution.height)) {
448  return "Failed to set up Allegro video";
449  }
451  set_close_button_callback(HandleExitGameRequest);
452 
453  this->is_game_threaded = !GetDriverParamBool(param, "no_threads") && !GetDriverParamBool(param, "no_thread");
454 
455  return nullptr;
456 }
457 
459 {
460  if (--_allegro_instance_count == 0) allegro_exit();
461 }
462 
464 {
465  bool old_ctrl_pressed = _ctrl_pressed;
466 
467  _ctrl_pressed = !!(key_shifts & KB_CTRL_FLAG);
468  _shift_pressed = !!(key_shifts & KB_SHIFT_FLAG);
469 
470 #if defined(_DEBUG)
472 #else
473  /* Speedup when pressing tab, except when using ALT+TAB
474  * to switch to another application. */
475  this->fast_forward_key_pressed = key[KEY_TAB] && (key_shifts & KB_ALT_FLAG) == 0;
476 #endif
477 
478  /* Determine which directional keys are down. */
479  _dirkeys =
480  (key[KEY_LEFT] ? 1 : 0) |
481  (key[KEY_UP] ? 2 : 0) |
482  (key[KEY_RIGHT] ? 4 : 0) |
483  (key[KEY_DOWN] ? 8 : 0);
484 
485  if (old_ctrl_pressed != _ctrl_pressed) HandleCtrlChanged();
486 }
487 
489 {
490  this->StartGameThread();
491 
492  for (;;) {
493  if (_exit_game) break;
494 
495  this->Tick();
496  this->SleepTillNextTick();
497  }
498 
499  this->StopGameThread();
500 }
501 
502 bool VideoDriver_Allegro::ChangeResolution(int w, int h)
503 {
504  return CreateMainSurface(w, h);
505 }
506 
507 bool VideoDriver_Allegro::ToggleFullscreen(bool fullscreen)
508 {
509  _fullscreen = fullscreen;
510  GetVideoModes(); // get the list of available video modes
511  if (_resolutions.empty() || !this->ChangeResolution(_cur_resolution.width, _cur_resolution.height)) {
512  /* switching resolution failed, put back full_screen to original status */
513  _fullscreen ^= true;
514  return false;
515  }
516  return true;
517 }
518 
520 {
521  return CreateMainSurface(_screen.width, _screen.height);
522 }
523 
524 #endif /* WITH_ALLEGRO */
_dirkeys
byte _dirkeys
1 = left, 2 = up, 4 = right, 8 = down
Definition: gfx.cpp:31
WKC_SINGLEQUOTE
@ WKC_SINGLEQUOTE
' Single quote
Definition: gfx_type.h:101
VideoDriver::Tick
void Tick()
Give the video-driver a tick.
Definition: video_driver.cpp:100
Palette::first_dirty
int first_dirty
The first dirty element.
Definition: gfx_type.h:315
WChar
char32_t WChar
Type for wide characters, i.e.
Definition: string_type.h:35
usererror
void CDECL usererror(const char *s,...)
Error handling for fatal user errors.
Definition: openttd.cpp:103
PFE_VIDEO
@ PFE_VIDEO
Speed of painting drawn video buffer.
Definition: framerate_type.h:59
Dimension
Dimensions (a width and height) of a rectangle in 2D.
Definition: geometry_type.hpp:27
_left_button_down
bool _left_button_down
Is left mouse button pressed?
Definition: gfx.cpp:38
Blitter::UsePaletteAnimation
virtual Blitter::PaletteAnimation UsePaletteAnimation()=0
Check if the blitter uses palette animation at all.
HandleKeypress
void HandleKeypress(uint keycode, WChar key)
Handle keyboard input.
Definition: window.cpp:2681
Blitter
How all blitters should look like.
Definition: base.hpp:28
FVideoDriver_Allegro
Factory for the allegro video driver.
Definition: allegro_v.h:46
Blitter::GetScreenDepth
virtual uint8 GetScreenDepth()=0
Get the screen depth this blitter works for.
VideoDriver_Allegro::AfterBlitterChange
bool AfterBlitterChange() override
Callback invoked after the blitter was changed.
WKC_SLASH
@ WKC_SLASH
/ Forward slash
Definition: gfx_type.h:95
HasBit
static bool HasBit(const T x, const uint8 y)
Checks if a bit in a value is set.
Definition: bitmath_func.hpp:103
WKC_BACKSLASH
@ WKC_BACKSLASH
\ Backslash
Definition: gfx_type.h:99
PerformanceMeasurer
RAII class for measuring simple elements of performance.
Definition: framerate_type.h:92
ClrBit
static T ClrBit(T &x, const uint8 y)
Clears a bit in a variable.
Definition: bitmath_func.hpp:151
WKC_L_BRACKET
@ WKC_L_BRACKET
[ Left square bracket
Definition: gfx_type.h:98
_ctrl_pressed
bool _ctrl_pressed
Is Ctrl pressed?
Definition: gfx.cpp:35
VideoDriver::StartGameThread
void StartGameThread()
Start the loop for game-tick.
Definition: video_driver.cpp:84
AS
#define AS(ap_name, size_x, size_y, min_year, max_year, catchment, noise, maint_cost, ttdpatch_type, class_id, name, preview)
AirportSpec definition for airports with at least one depot.
Definition: airport_defaults.h:391
VideoDriver_Allegro::Paint
void Paint() override
Paint the window.
VideoDriver_Allegro::ChangeResolution
bool ChangeResolution(int w, int h) override
Change the resolution of the window.
VideoDriver_Allegro::Start
const char * Start(const StringList &param) override
Start this driver.
VideoDriver_Allegro::InputLoop
void InputLoop() override
Handle input logic, is CTRL pressed, should we fast-forward, etc.
VideoDriver_Allegro::GetListOfMonitorRefreshRates
std::vector< int > GetListOfMonitorRefreshRates() override
Get a list of refresh rates of each available monitor.
WKC_EQUALS
@ WKC_EQUALS
= Equals
Definition: gfx_type.h:97
HandleMouseEvents
void HandleMouseEvents()
Handle a mouse event from the video driver.
Definition: window.cpp:2989
CursorVars::UpdateCursorPosition
bool UpdateCursorPosition(int x, int y, bool queued_warp)
Update cursor position on mouse movement.
Definition: gfx.cpp:1806
DEBUG
#define DEBUG(name, level,...)
Output a line of debugging information.
Definition: debug.h:35
Palette::palette
Colour palette[256]
Current palette. Entry 0 has to be always fully transparent!
Definition: gfx_type.h:314
allegro_v.h
Blitter::PostResize
virtual void PostResize()
Post resize event.
Definition: base.hpp:209
VideoDriver_Allegro::CheckPaletteAnim
void CheckPaletteAnim() override
Process any pending palette animation.
BlitterFactory::GetCurrentBlitter
static Blitter * GetCurrentBlitter()
Get the current active blitter (always set by calling SelectBlitter).
Definition: factory.hpp:141
StringList
std::vector< std::string > StringList
Type for a list of strings.
Definition: string_type.h:58
_resolutions
std::vector< Dimension > _resolutions
List of resolutions.
Definition: driver.cpp:24
_shift_pressed
bool _shift_pressed
Is Shift pressed?
Definition: gfx.cpp:36
CursorVars::wheel
int wheel
mouse wheel movement
Definition: gfx_type.h:119
Palette::count_dirty
int count_dirty
The number of dirty elements.
Definition: gfx_type.h:316
VideoDriver_Allegro::MakeDirty
void MakeDirty(int left, int top, int width, int height) override
Mark a particular area dirty.
VideoDriver::StopGameThread
void StopGameThread()
Stop the loop for the game-tick.
Definition: video_driver.cpp:93
WKC_R_BRACKET
@ WKC_R_BRACKET
] Right square bracket
Definition: gfx_type.h:100
_rightclick_emulate
bool _rightclick_emulate
Whether right clicking is emulated.
Definition: driver.cpp:26
WKC_PERIOD
@ WKC_PERIOD
. Period
Definition: gfx_type.h:103
VideoDriver::UpdateAutoResolution
void UpdateAutoResolution()
Apply resolution auto-detection and clamp to sensible defaults.
Definition: video_driver.hpp:239
endof
#define endof(x)
Get the end element of an fixed size array.
Definition: stdafx.h:377
Blitter::PALETTE_ANIMATION_VIDEO_BACKEND
@ PALETTE_ANIMATION_VIDEO_BACKEND
Palette animation should be done by video backend (8bpp only!)
Definition: base.hpp:51
CursorVars::delta
Point delta
relative mouse movement in this tick
Definition: gfx_type.h:118
seprintf
int CDECL seprintf(char *str, const char *last, const char *format,...)
Safer implementation of snprintf; same as snprintf except:
Definition: string.cpp:460
WKC_COMMA
@ WKC_COMMA
, Comma
Definition: gfx_type.h:102
Blitter::PALETTE_ANIMATION_NONE
@ PALETTE_ANIMATION_NONE
No palette animation.
Definition: base.hpp:50
WKC_SEMICOLON
@ WKC_SEMICOLON
; Semicolon
Definition: gfx_type.h:96
_cur_palette
Palette _cur_palette
Current palette.
Definition: gfx.cpp:48
GameSizeChanged
void GameSizeChanged()
Size of the application screen changed.
Definition: main_gui.cpp:561
VideoDriver_Allegro::MainLoop
void MainLoop() override
Perform the actual drawing.
Blitter::PaletteAnimate
virtual void PaletteAnimate(const Palette &palette)=0
Called when the 8bpp palette is changed; you should redraw all pixels on the screen that are equal to...
HandleCtrlChanged
void HandleCtrlChanged()
State of CONTROL key has changed.
Definition: window.cpp:2738
MarkWholeScreenDirty
void MarkWholeScreenDirty()
This function mark the whole screen as dirty.
Definition: gfx.cpp:1597
VideoDriver::SleepTillNextTick
void SleepTillNextTick()
Sleep till the next tick is about to happen.
Definition: video_driver.cpp:162
Blitter::PALETTE_ANIMATION_BLITTER
@ PALETTE_ANIMATION_BLITTER
The blitter takes care of the palette animation.
Definition: base.hpp:52
VideoDriver_Allegro::ToggleFullscreen
bool ToggleFullscreen(bool fullscreen) override
Change the full screen setting.
VideoDriver::fast_forward_key_pressed
bool fast_forward_key_pressed
The fast-forward key is being pressed.
Definition: video_driver.hpp:325
PointDimension
Specification of a rectangle with an absolute top-left coordinate and a (relative) width/height.
Definition: geometry_type.hpp:58
VideoDriver_Allegro::Stop
void Stop() override
Stop this driver.
WKC_MINUS
@ WKC_MINUS
Definition: gfx_type.h:104
VideoDriver_Allegro::PollEvent
bool PollEvent() override
Process a single system event.
CursorVars::pos
Point pos
logical mouse position
Definition: gfx_type.h:117
_right_button_clicked
bool _right_button_clicked
Is right mouse button clicked?
Definition: gfx.cpp:41
lastof
#define lastof(x)
Get the last element of an fixed size array.
Definition: stdafx.h:385
GetDriverParamBool
bool GetDriverParamBool(const StringList &parm, const char *name)
Get a boolean parameter the list of parameters.
Definition: driver.cpp:61
_left_button_clicked
bool _left_button_clicked
Is left mouse button clicked?
Definition: gfx.cpp:39
_cur_resolution
Dimension _cur_resolution
The current resolution.
Definition: driver.cpp:25
_right_button_down
bool _right_button_down
Is right mouse button pressed?
Definition: gfx.cpp:40
FindFirstBit
uint8 FindFirstBit(uint32 x)
Search the first set bit in a 32 bit variable.
Definition: bitmath_func.cpp:37
Delta
static T Delta(const T a, const T b)
Returns the (absolute) difference between two (scalar) variables.
Definition: math_func.hpp:170