1 /*
2 	This file is part of Warzone 2100.
3 	Copyright (C) 1999-2004  Eidos Interactive
4 	Copyright (C) 2005-2020  Warzone 2100 Project
5 
6 	Warzone 2100 is free software; you can redistribute it and/or modify
7 	it under the terms of the GNU General Public License as published by
8 	the Free Software Foundation; either version 2 of the License, or
9 	(at your option) any later version.
10 
11 	Warzone 2100 is distributed in the hope that it will be useful,
12 	but WITHOUT ANY WARRANTY; without even the implied warranty of
13 	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 	GNU General Public License for more details.
15 
16 	You should have received a copy of the GNU General Public License
17 	along with Warzone 2100; if not, write to the Free Software
18 	Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20 /*! \file frame.h
21  * \brief The framework library initialisation and shutdown routines.
22  */
23 #ifndef _frame_h
24 #define _frame_h
25 
26 #include "wzglobal.h"
27 #include <stdlib.h>
28 
29 // Workaround X11 headers #defining Status
30 #ifdef Status
31 # undef Status
32 #endif
33 
34 #ifndef WZ_CXX11
35 # define nullptr NULL
36 #endif
37 
38 #include "types.h"
39 /**
40 * NOTE: the next two #include lines are needed by MSVC to override the default,
41 * non C99 compliant routines, and redefinition; different linkage errors
42 */
43 #include "stdio_ext.h"
44 #include "string_ext.h"
45 
46 #include "macros.h"
47 #include "debug.h"
48 
49 #include "i18n.h"
50 #include "trig.h"
51 #include "cursors.h"
52 
53 #if defined(__clang__)
54 // workaround LLVM bug https://bugs.llvm.org//show_bug.cgi?id=21629
55 #pragma clang diagnostic ignored "-Wmissing-braces"
56 #endif
57 
58 #define REALCONCAT(x, y) x ## y
59 #define CONCAT(x, y) REALCONCAT(x, y)
60 
61 extern uint32_t selectedPlayer;      ///< The player number corresponding to this client.
62 extern uint32_t realSelectedPlayer;  ///< The player number corresponding to this client (same as selectedPlayer, unless changing players in the debug menu).
63 #define MAX_PLAYERS         11                 ///< Maximum number of players in the game.
64 #define MAX_PLAYERS_IN_GUI  (MAX_PLAYERS - 1)  ///< One player reserved for scavengers.
65 #define PLAYER_FEATURE      (MAX_PLAYERS + 1)
66 #define MAX_PLAYER_SLOTS    (MAX_PLAYERS + 2)  ///< Max players plus 1 baba and 1 reserved for features. Actually, if baba is a regular player, then it's plus 1 unused?
67 
68 #if MAX_PLAYERS <= 8
69 typedef uint8_t PlayerMask;
70 #elif MAX_PLAYERS <= 16
71 typedef uint16_t PlayerMask;
72 #else
73 #error Warzone 2100 is not a MMO.
74 #endif
75 
76 enum QUEUE_MODE
77 {
78 	ModeQueue,      ///< Sends a message on the game queue, which will get synchronised, by sending a GAME_ message.
79 	ModeImmediate   ///< Performs the action immediately. Must already have been synchronised, for example by sending a GAME_ message.
80 };
81 
82 
83 /** Initialise the framework library
84  *  @param pWindowName the text to appear in the window title bar
85  *  @param width the display widget
86  *  @param height the display height
87  *  @param bitDepth the display bit depth
88  *  @param fullScreen whether to start full screen or windowed
89  *  @param vsync if to sync to the vertical blanking interval or not
90  *
91  *  @return true when the framework library is successfully initialised, false
92  *          when a part of the initialisation failed.
93  */
94 bool frameInitialise();
95 
96 /** Shut down the framework library.
97  */
98 void frameShutDown();
99 
100 /** Call this each cycle to allow the framework to deal with
101  * windows messages, and do general house keeping.
102  */
103 void frameUpdate();
104 
105 /** Returns the current frame we're on - used to establish whats on screen. */
106 UDWORD frameGetFrameNumber();
107 
108 /** Return framerate of the last second. */
109 int frameRate();
110 
bool2string(bool var)111 static inline WZ_DECL_CONST const char *bool2string(bool var)
112 {
113 	return (var ? "true" : "false");
114 }
115 
116 // video_backend - begin
117 enum class video_backend
118 {
119 	opengl,
120 	opengles,
121 	vulkan,
122 #if defined(WZ_BACKEND_DIRECTX)
123 	directx,
124 #endif
125 	num_backends // Must be last!
126 };
127 
128 bool video_backend_from_str(const char *str, video_backend &output_backend);
129 std::string to_string(video_backend backend);
130 std::string to_display_string(const video_backend& backend);
131 // video_backend - end
132 
133 // fullscreen_mode - begin
134 
135 enum class WINDOW_MODE : int
136 {
137 	desktop_fullscreen = -1,
138 	windowed = 0,
139 	fullscreen = 1
140 };
141 std::string to_display_string(const WINDOW_MODE& mode);
142 
143 #define MIN_VALID_WINDOW_MODE WINDOW_MODE::desktop_fullscreen
144 #define MAX_VALID_WINDOW_MODE WINDOW_MODE::fullscreen
145 
146 // fullscreen_mode - end
147 
148 #endif
149