OpenTTD Source  1.11.0-beta1
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 "../network/network.h"
23 #include "../core/random_func.hpp"
24 #include "../core/math_func.hpp"
25 #include "../framerate_type.h"
26 #include "../thread.h"
27 #include "allegro_v.h"
28 #include <allegro.h>
29 
30 #include "../safeguards.h"
31 
32 #ifdef _DEBUG
33 /* Allegro replaces SEGV/ABRT signals meaning that the debugger will never
34  * be triggered, so rereplace the signals and make the debugger useful. */
35 #include <signal.h>
36 #endif
37 
38 static FVideoDriver_Allegro iFVideoDriver_Allegro;
39 
40 static BITMAP *_allegro_screen;
41 
42 #define MAX_DIRTY_RECTS 100
43 static PointDimension _dirty_rects[MAX_DIRTY_RECTS];
44 static int _num_dirty_rects;
45 
46 void VideoDriver_Allegro::MakeDirty(int left, int top, int width, int height)
47 {
48  if (_num_dirty_rects < MAX_DIRTY_RECTS) {
49  _dirty_rects[_num_dirty_rects].x = left;
50  _dirty_rects[_num_dirty_rects].y = top;
51  _dirty_rects[_num_dirty_rects].width = width;
52  _dirty_rects[_num_dirty_rects].height = height;
53  }
54  _num_dirty_rects++;
55 }
56 
57 static void DrawSurfaceToScreen()
58 {
59  PerformanceMeasurer framerate(PFE_VIDEO);
60 
61  int n = _num_dirty_rects;
62  if (n == 0) return;
63 
64  _num_dirty_rects = 0;
65  if (n > MAX_DIRTY_RECTS) {
66  blit(_allegro_screen, screen, 0, 0, 0, 0, _allegro_screen->w, _allegro_screen->h);
67  return;
68  }
69 
70  for (int i = 0; i < n; i++) {
71  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);
72  }
73 }
74 
75 
76 static void UpdatePalette(uint start, uint count)
77 {
78  static PALETTE pal;
79 
80  uint end = start + count;
81  for (uint i = start; i != end; i++) {
82  pal[i].r = _cur_palette.palette[i].r / 4;
83  pal[i].g = _cur_palette.palette[i].g / 4;
84  pal[i].b = _cur_palette.palette[i].b / 4;
85  pal[i].filler = 0;
86  }
87 
88  set_palette_range(pal, start, end - 1, 1);
89 }
90 
91 static void InitPalette()
92 {
93  UpdatePalette(0, 256);
94 }
95 
96 static void CheckPaletteAnim()
97 {
98  if (_cur_palette.count_dirty != 0) {
100 
101  switch (blitter->UsePaletteAnimation()) {
104  break;
105 
107  blitter->PaletteAnimate(_cur_palette);
108  break;
109 
111  break;
112 
113  default:
114  NOT_REACHED();
115  }
117  }
118 }
119 
120 static const Dimension default_resolutions[] = {
121  { 640, 480},
122  { 800, 600},
123  {1024, 768},
124  {1152, 864},
125  {1280, 800},
126  {1280, 960},
127  {1280, 1024},
128  {1400, 1050},
129  {1600, 1200},
130  {1680, 1050},
131  {1920, 1200}
132 };
133 
134 static void GetVideoModes()
135 {
136  /* Need to set a gfx_mode as there is NO other way to autodetect for
137  * cards ourselves... and we need a card to get the modes. */
138  set_gfx_mode(_fullscreen ? GFX_AUTODETECT_FULLSCREEN : GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0);
139 
140  _resolutions.clear();
141 
142  GFX_MODE_LIST *mode_list = get_gfx_mode_list(gfx_driver->id);
143  if (mode_list == nullptr) {
144  _resolutions.assign(std::begin(default_resolutions), std::end(default_resolutions));
145  return;
146  }
147 
148  GFX_MODE *modes = mode_list->mode;
149 
150  for (int i = 0; modes[i].bpp != 0; i++) {
151  uint w = modes[i].width;
152  uint h = modes[i].height;
153  if (w < 640 || h < 480) continue;
154  if (std::find(_resolutions.begin(), _resolutions.end(), Dimension(w, h)) != _resolutions.end()) continue;
155  _resolutions.emplace_back(w, h);
156  }
157 
158  SortResolutions();
159 
160  destroy_gfx_mode_list(mode_list);
161 }
162 
163 static void GetAvailableVideoMode(uint *w, uint *h)
164 {
165  /* No video modes, so just try it and see where it ends */
166  if (_resolutions.empty()) return;
167 
168  /* is the wanted mode among the available modes? */
169  if (std::find(_resolutions.begin(), _resolutions.end(), Dimension(*w, *h)) != _resolutions.end()) return;
170 
171  /* use the closest possible resolution */
172  uint best = 0;
173  uint delta = Delta(_resolutions[0].width, *w) * Delta(_resolutions[0].height, *h);
174  for (uint i = 1; i != _resolutions.size(); ++i) {
175  uint newdelta = Delta(_resolutions[i].width, *w) * Delta(_resolutions[i].height, *h);
176  if (newdelta < delta) {
177  best = i;
178  delta = newdelta;
179  }
180  }
181  *w = _resolutions[best].width;
182  *h = _resolutions[best].height;
183 }
184 
185 static bool CreateMainSurface(uint w, uint h)
186 {
188  if (bpp == 0) usererror("Can't use a blitter that blits 0 bpp for normal visuals");
189  set_color_depth(bpp);
190 
191  GetAvailableVideoMode(&w, &h);
192  if (set_gfx_mode(_fullscreen ? GFX_AUTODETECT_FULLSCREEN : GFX_AUTODETECT_WINDOWED, w, h, 0, 0) != 0) {
193  DEBUG(driver, 0, "Allegro: Couldn't allocate a window to draw on '%s'", allegro_error);
194  return false;
195  }
196 
197  /* The size of the screen might be bigger than the part we can actually draw on!
198  * So calculate the size based on the top, bottom, left and right */
199  _allegro_screen = create_bitmap_ex(bpp, screen->cr - screen->cl, screen->cb - screen->ct);
200  _screen.width = _allegro_screen->w;
201  _screen.height = _allegro_screen->h;
202  _screen.pitch = ((byte*)screen->line[1] - (byte*)screen->line[0]) / (bpp / 8);
203  _screen.dst_ptr = _allegro_screen->line[0];
204 
205  /* Initialise the screen so we don't blit garbage to the screen */
206  memset(_screen.dst_ptr, 0, _screen.height * _screen.pitch);
207 
208  /* Set the mouse at the place where we expect it */
209  poll_mouse();
210  _cursor.pos.x = mouse_x;
211  _cursor.pos.y = mouse_y;
212 
214 
215  InitPalette();
216 
217  char caption[32];
218  seprintf(caption, lastof(caption), "OpenTTD %s", _openttd_revision);
219  set_window_title(caption);
220 
221  enable_hardware_cursor();
222  select_mouse_cursor(MOUSE_CURSOR_ARROW);
223  show_mouse(_allegro_screen);
224 
225  GameSizeChanged();
226 
227  return true;
228 }
229 
230 bool VideoDriver_Allegro::ClaimMousePointer()
231 {
232  select_mouse_cursor(MOUSE_CURSOR_NONE);
233  show_mouse(nullptr);
234  disable_hardware_cursor();
235  return true;
236 }
237 
238 struct VkMapping {
239  uint16 vk_from;
240  byte vk_count;
241  byte map_to;
242 };
243 
244 #define AS(x, z) {x, 0, z}
245 #define AM(x, y, z, w) {x, y - x, z}
246 
247 static const VkMapping _vk_mapping[] = {
248  /* Pageup stuff + up/down */
249  AM(KEY_PGUP, KEY_PGDN, WKC_PAGEUP, WKC_PAGEDOWN),
250  AS(KEY_UP, WKC_UP),
251  AS(KEY_DOWN, WKC_DOWN),
252  AS(KEY_LEFT, WKC_LEFT),
253  AS(KEY_RIGHT, WKC_RIGHT),
254 
255  AS(KEY_HOME, WKC_HOME),
256  AS(KEY_END, WKC_END),
257 
258  AS(KEY_INSERT, WKC_INSERT),
259  AS(KEY_DEL, WKC_DELETE),
260 
261  /* Map letters & digits */
262  AM(KEY_A, KEY_Z, 'A', 'Z'),
263  AM(KEY_0, KEY_9, '0', '9'),
264 
265  AS(KEY_ESC, WKC_ESC),
266  AS(KEY_PAUSE, WKC_PAUSE),
267  AS(KEY_BACKSPACE, WKC_BACKSPACE),
268 
269  AS(KEY_SPACE, WKC_SPACE),
270  AS(KEY_ENTER, WKC_RETURN),
271  AS(KEY_TAB, WKC_TAB),
272 
273  /* Function keys */
274  AM(KEY_F1, KEY_F12, WKC_F1, WKC_F12),
275 
276  /* Numeric part. */
277  AM(KEY_0_PAD, KEY_9_PAD, '0', '9'),
278  AS(KEY_SLASH_PAD, WKC_NUM_DIV),
279  AS(KEY_ASTERISK, WKC_NUM_MUL),
280  AS(KEY_MINUS_PAD, WKC_NUM_MINUS),
281  AS(KEY_PLUS_PAD, WKC_NUM_PLUS),
282  AS(KEY_ENTER_PAD, WKC_NUM_ENTER),
283  AS(KEY_DEL_PAD, WKC_DELETE),
284 
285  /* Other non-letter keys */
286  AS(KEY_SLASH, WKC_SLASH),
287  AS(KEY_SEMICOLON, WKC_SEMICOLON),
288  AS(KEY_EQUALS, WKC_EQUALS),
289  AS(KEY_OPENBRACE, WKC_L_BRACKET),
290  AS(KEY_BACKSLASH, WKC_BACKSLASH),
291  AS(KEY_CLOSEBRACE, WKC_R_BRACKET),
292 
293  AS(KEY_QUOTE, WKC_SINGLEQUOTE),
294  AS(KEY_COMMA, WKC_COMMA),
295  AS(KEY_MINUS, WKC_MINUS),
296  AS(KEY_STOP, WKC_PERIOD),
297  AS(KEY_TILDE, WKC_BACKQUOTE),
298 };
299 
300 static uint32 ConvertAllegroKeyIntoMy(WChar *character)
301 {
302  int scancode;
303  int unicode = ureadkey(&scancode);
304 
305  const VkMapping *map;
306  uint key = 0;
307 
308  for (map = _vk_mapping; map != endof(_vk_mapping); ++map) {
309  if ((uint)(scancode - map->vk_from) <= map->vk_count) {
310  key = scancode - map->vk_from + map->map_to;
311  break;
312  }
313  }
314 
315  if (key_shifts & KB_SHIFT_FLAG) key |= WKC_SHIFT;
316  if (key_shifts & KB_CTRL_FLAG) key |= WKC_CTRL;
317  if (key_shifts & KB_ALT_FLAG) key |= WKC_ALT;
318 #if 0
319  DEBUG(driver, 0, "Scancode character pressed %u", scancode);
320  DEBUG(driver, 0, "Unicode character pressed %u", unicode);
321 #endif
322 
323  *character = unicode;
324  return key;
325 }
326 
327 static const uint LEFT_BUTTON = 0;
328 static const uint RIGHT_BUTTON = 1;
329 
330 static void PollEvent()
331 {
332  poll_mouse();
333 
334  bool mouse_action = false;
335 
336  /* Mouse buttons */
337  static int prev_button_state;
338  if (prev_button_state != mouse_b) {
339  uint diff = prev_button_state ^ mouse_b;
340  while (diff != 0) {
341  uint button = FindFirstBit(diff);
342  ClrBit(diff, button);
343  if (HasBit(mouse_b, button)) {
344  /* Pressed mouse button */
345  if (_rightclick_emulate && (key_shifts & KB_CTRL_FLAG)) {
346  button = RIGHT_BUTTON;
347  ClrBit(diff, RIGHT_BUTTON);
348  }
349  switch (button) {
350  case LEFT_BUTTON:
351  _left_button_down = true;
352  break;
353 
354  case RIGHT_BUTTON:
355  _right_button_down = true;
356  _right_button_clicked = true;
357  break;
358 
359  default:
360  /* ignore rest */
361  break;
362  }
363  } else {
364  /* Released mouse button */
365  if (_rightclick_emulate) {
366  _right_button_down = false;
367  _left_button_down = false;
368  _left_button_clicked = false;
369  } else if (button == LEFT_BUTTON) {
370  _left_button_down = false;
371  _left_button_clicked = false;
372  } else if (button == RIGHT_BUTTON) {
373  _right_button_down = false;
374  }
375  }
376  }
377  prev_button_state = mouse_b;
378  mouse_action = true;
379  }
380 
381  /* Mouse movement */
382  if (_cursor.UpdateCursorPosition(mouse_x, mouse_y, false)) {
383  position_mouse(_cursor.pos.x, _cursor.pos.y);
384  }
385  if (_cursor.delta.x != 0 || _cursor.delta.y) mouse_action = true;
386 
387  static int prev_mouse_z = 0;
388  if (prev_mouse_z != mouse_z) {
389  _cursor.wheel = (prev_mouse_z - mouse_z) < 0 ? -1 : 1;
390  prev_mouse_z = mouse_z;
391  mouse_action = true;
392  }
393 
394  if (mouse_action) HandleMouseEvents();
395 
396  poll_keyboard();
397  if ((key_shifts & KB_ALT_FLAG) && (key[KEY_ENTER] || key[KEY_F])) {
398  ToggleFullScreen(!_fullscreen);
399  } else if (keypressed()) {
400  WChar character;
401  uint keycode = ConvertAllegroKeyIntoMy(&character);
402  HandleKeypress(keycode, character);
403  }
404 }
405 
410 int _allegro_instance_count = 0;
411 
412 const char *VideoDriver_Allegro::Start(const StringList &parm)
413 {
414  if (_allegro_instance_count == 0 && install_allegro(SYSTEM_AUTODETECT, &errno, nullptr)) {
415  DEBUG(driver, 0, "allegro: install_allegro failed '%s'", allegro_error);
416  return "Failed to set up Allegro";
417  }
418  _allegro_instance_count++;
419 
420  this->UpdateAutoResolution();
421 
422  install_timer();
423  install_mouse();
424  install_keyboard();
425 
426 #if defined _DEBUG
427 /* Allegro replaces SEGV/ABRT signals meaning that the debugger will never
428  * be triggered, so rereplace the signals and make the debugger useful. */
429  signal(SIGABRT, nullptr);
430  signal(SIGSEGV, nullptr);
431 #endif
432 
433  GetVideoModes();
434  if (!CreateMainSurface(_cur_resolution.width, _cur_resolution.height)) {
435  return "Failed to set up Allegro video";
436  }
438  set_close_button_callback(HandleExitGameRequest);
439 
440  return nullptr;
441 }
442 
444 {
445  if (--_allegro_instance_count == 0) allegro_exit();
446 }
447 
448 #if defined(UNIX) || defined(__OS2__)
449 # include <sys/time.h> /* gettimeofday */
450 
451 static uint32 GetTime()
452 {
453  struct timeval tim;
454 
455  gettimeofday(&tim, nullptr);
456  return tim.tv_usec / 1000 + tim.tv_sec * 1000;
457 }
458 #else
459 static uint32 GetTime()
460 {
461  return GetTickCount();
462 }
463 #endif
464 
465 
467 {
468  uint32 cur_ticks = GetTime();
469  uint32 last_cur_ticks = cur_ticks;
470  uint32 next_tick = cur_ticks + MILLISECONDS_PER_TICK;
471 
472  CheckPaletteAnim();
473 
474  for (;;) {
475  uint32 prev_cur_ticks = cur_ticks; // to check for wrapping
476  InteractiveRandom(); // randomness
477 
478  PollEvent();
479  if (_exit_game) return;
480 
481 #if defined(_DEBUG)
482  if (_shift_pressed)
483 #else
484  /* Speedup when pressing tab, except when using ALT+TAB
485  * to switch to another application */
486  if (key[KEY_TAB] && (key_shifts & KB_ALT_FLAG) == 0)
487 #endif
488  {
489  if (!_networking && _game_mode != GM_MENU) _fast_forward |= 2;
490  } else if (_fast_forward & 2) {
491  _fast_forward = 0;
492  }
493 
494  cur_ticks = GetTime();
495  if (cur_ticks >= next_tick || (_fast_forward && !_pause_mode) || cur_ticks < prev_cur_ticks) {
496  _realtime_tick += cur_ticks - last_cur_ticks;
497  last_cur_ticks = cur_ticks;
498  next_tick = cur_ticks + MILLISECONDS_PER_TICK;
499 
500  bool old_ctrl_pressed = _ctrl_pressed;
501 
502  _ctrl_pressed = !!(key_shifts & KB_CTRL_FLAG);
503  _shift_pressed = !!(key_shifts & KB_SHIFT_FLAG);
504 
505  /* determine which directional keys are down */
506  _dirkeys =
507  (key[KEY_LEFT] ? 1 : 0) |
508  (key[KEY_UP] ? 2 : 0) |
509  (key[KEY_RIGHT] ? 4 : 0) |
510  (key[KEY_DOWN] ? 8 : 0);
511 
512  if (old_ctrl_pressed != _ctrl_pressed) HandleCtrlChanged();
513 
514  GameLoop();
515 
516  UpdateWindows();
517  CheckPaletteAnim();
518  DrawSurfaceToScreen();
519  } else {
520  CSleep(1);
522  DrawMouseCursor();
523  DrawSurfaceToScreen();
524  }
525  }
526 }
527 
528 bool VideoDriver_Allegro::ChangeResolution(int w, int h)
529 {
530  return CreateMainSurface(w, h);
531 }
532 
534 {
535  _fullscreen = fullscreen;
536  GetVideoModes(); // get the list of available video modes
537  if (_resolutions.empty() || !this->ChangeResolution(_cur_resolution.width, _cur_resolution.height)) {
538  /* switching resolution failed, put back full_screen to original status */
539  _fullscreen ^= true;
540  return false;
541  }
542  return true;
543 }
544 
546 {
547  return CreateMainSurface(_screen.width, _screen.height);
548 }
549 
550 #endif /* WITH_ALLEGRO */
_dirkeys
byte _dirkeys
1 = left, 2 = up, 4 = right, 8 = down
Definition: gfx.cpp:31
fullscreen
bool fullscreen
Whether to use (true) fullscreen mode.
Definition: win32_v.cpp:52
WKC_SINGLEQUOTE
@ WKC_SINGLEQUOTE
' Single quote
Definition: gfx_type.h:101
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:100
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
CSleep
void CSleep(int milliseconds)
Sleep on the current thread for a defined time.
Definition: thread.h:25
_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:38
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
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
UpdateWindows
void UpdateWindows()
Update the continuously changing contents of the windows, such as the viewports.
Definition: window.cpp:3139
height
int height
Height in pixels of our display surface.
Definition: win32_v.cpp:49
VkMapping
Definition: sdl_v.cpp:406
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.
WKC_EQUALS
@ WKC_EQUALS
= Equals
Definition: gfx_type.h:97
HandleMouseEvents
void HandleMouseEvents()
Handle a mouse event from the video driver.
Definition: window.cpp:2988
CursorVars::UpdateCursorPosition
bool UpdateCursorPosition(int x, int y, bool queued_warp)
Update cursor position on mouse movement.
Definition: gfx.cpp:1819
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:201
_pause_mode
PauseMode _pause_mode
The current pause mode.
Definition: gfx.cpp:47
BlitterFactory::GetCurrentBlitter
static Blitter * GetCurrentBlitter()
Get the current active blitter (always set by calling SelectBlitter).
Definition: factory.hpp:131
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:22
_networking
bool _networking
are we in networking mode?
Definition: network.cpp:52
_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.
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:24
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:124
endof
#define endof(x)
Get the end element of an fixed size array.
Definition: stdafx.h:385
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
width
int width
Width in pixels of our display surface.
Definition: win32_v.cpp:48
seprintf
int CDECL seprintf(char *str, const char *last, const char *format,...)
Safer implementation of snprintf; same as snprintf except:
Definition: string.cpp:442
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.
MILLISECONDS_PER_TICK
static const uint MILLISECONDS_PER_TICK
The number of milliseconds per game tick.
Definition: gfx_type.h:310
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:1610
Blitter::PALETTE_ANIMATION_BLITTER
@ PALETTE_ANIMATION_BLITTER
The blitter takes care of the palette animation.
Definition: base.hpp:52
NetworkDrawChatMessage
void NetworkDrawChatMessage()
Draw the chat message-box.
Definition: network_chat_gui.cpp:198
VideoDriver_Allegro::ToggleFullscreen
bool ToggleFullscreen(bool fullscreen) override
Change the full screen setting.
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
_realtime_tick
uint32 _realtime_tick
The real time in the game.
Definition: debug.cpp:48
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:393
_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:23
_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