summaryrefslogtreecommitdiff
path: root/src/video
diff options
context:
space:
mode:
authorrubidium42 <rubidium@openttd.org>2021-06-12 09:10:17 +0200
committerrubidium42 <rubidium42@users.noreply.github.com>2021-06-13 12:45:45 +0200
commit55a11710a6c0f7942f3947711f2050c34782c39d (patch)
tree491b3009324e623236977614e91371a0ea4abac7 /src/video
parenta99ac62c1ab816ee48cac85fdf834f9fdc599cb1 (diff)
downloadopenttd-55a11710a6c0f7942f3947711f2050c34782c39d.tar.xz
Codechange: convert printf DEBUG statements to fmt Debug statements
Diffstat (limited to 'src/video')
-rw-r--r--src/video/allegro_v.cpp8
-rw-r--r--src/video/cocoa/cocoa_v.mm6
-rw-r--r--src/video/cocoa/cocoa_wnd.mm6
-rw-r--r--src/video/dedicated_v.cpp8
-rw-r--r--src/video/null_v.cpp2
-rw-r--r--src/video/opengl.cpp14
-rw-r--r--src/video/sdl2_v.cpp16
-rw-r--r--src/video/sdl_v.cpp14
-rw-r--r--src/video/video_driver.cpp2
-rw-r--r--src/video/win32_v.cpp8
10 files changed, 42 insertions, 42 deletions
diff --git a/src/video/allegro_v.cpp b/src/video/allegro_v.cpp
index 3d8ca65aa..6693932c7 100644
--- a/src/video/allegro_v.cpp
+++ b/src/video/allegro_v.cpp
@@ -191,7 +191,7 @@ static bool CreateMainSurface(uint w, uint h)
GetAvailableVideoMode(&w, &h);
if (set_gfx_mode(_fullscreen ? GFX_AUTODETECT_FULLSCREEN : GFX_AUTODETECT_WINDOWED, w, h, 0, 0) != 0) {
- DEBUG(driver, 0, "Allegro: Couldn't allocate a window to draw on '%s'", allegro_error);
+ Debug(driver, 0, "Allegro: Couldn't allocate a window to draw on '{}'", allegro_error);
return false;
}
@@ -327,8 +327,8 @@ static uint32 ConvertAllegroKeyIntoMy(WChar *character)
if (key_shifts & KB_CTRL_FLAG) key |= WKC_CTRL;
if (key_shifts & KB_ALT_FLAG) key |= WKC_ALT;
#if 0
- DEBUG(driver, 0, "Scancode character pressed %u", scancode);
- DEBUG(driver, 0, "Unicode character pressed %u", unicode);
+ Debug(driver, 0, "Scancode character pressed {}", scancode);
+ Debug(driver, 0, "Unicode character pressed {}", unicode);
#endif
*character = unicode;
@@ -425,7 +425,7 @@ int _allegro_instance_count = 0;
const char *VideoDriver_Allegro::Start(const StringList &param)
{
if (_allegro_instance_count == 0 && install_allegro(SYSTEM_AUTODETECT, &errno, nullptr)) {
- DEBUG(driver, 0, "allegro: install_allegro failed '%s'", allegro_error);
+ Debug(driver, 0, "allegro: install_allegro failed '{}'", allegro_error);
return "Failed to set up Allegro";
}
_allegro_instance_count++;
diff --git a/src/video/cocoa/cocoa_v.mm b/src/video/cocoa/cocoa_v.mm
index c16d19690..2a8737333 100644
--- a/src/video/cocoa/cocoa_v.mm
+++ b/src/video/cocoa/cocoa_v.mm
@@ -363,7 +363,7 @@ bool VideoDriver_Cocoa::MakeWindow(int width, int height)
unsigned int style = NSTitledWindowMask | NSResizableWindowMask | NSMiniaturizableWindowMask | NSClosableWindowMask;
this->window = [ [ OTTD_CocoaWindow alloc ] initWithContentRect:contentRect styleMask:style backing:NSBackingStoreBuffered defer:NO driver:this ];
if (this->window == nil) {
- DEBUG(driver, 0, "Could not create the Cocoa window.");
+ Debug(driver, 0, "Could not create the Cocoa window.");
this->setup = false;
return false;
}
@@ -391,7 +391,7 @@ bool VideoDriver_Cocoa::MakeWindow(int width, int height)
NSRect view_frame = [ this->window contentRectForFrameRect:[ this->window frame ] ];
this->cocoaview = [ [ OTTD_CocoaView alloc ] initWithFrame:view_frame ];
if (this->cocoaview == nil) {
- DEBUG(driver, 0, "Could not create the event wrapper view.");
+ Debug(driver, 0, "Could not create the event wrapper view.");
this->setup = false;
return false;
}
@@ -400,7 +400,7 @@ bool VideoDriver_Cocoa::MakeWindow(int width, int height)
/* Create content view. */
NSView *draw_view = this->AllocateDrawView();
if (draw_view == nil) {
- DEBUG(driver, 0, "Could not create the drawing view.");
+ Debug(driver, 0, "Could not create the drawing view.");
this->setup = false;
return false;
}
diff --git a/src/video/cocoa/cocoa_wnd.mm b/src/video/cocoa/cocoa_wnd.mm
index 825130006..c0a1bb694 100644
--- a/src/video/cocoa/cocoa_wnd.mm
+++ b/src/video/cocoa/cocoa_wnd.mm
@@ -273,7 +273,7 @@ bool CocoaSetupApplication()
/* Tell the dock about us */
OSStatus returnCode = TransformProcessType(&psn, kProcessTransformToForegroundApplication);
- if (returnCode != 0) DEBUG(driver, 0, "Could not change to foreground application. Error %d", (int)returnCode);
+ if (returnCode != 0) Debug(driver, 0, "Could not change to foreground application. Error {}", (int)returnCode);
/* Disable the system-wide tab feature as we only have one window. */
if ([ NSWindow respondsToSelector:@selector(setAllowsAutomaticWindowTabbing:) ]) {
@@ -700,9 +700,9 @@ void CocoaDialog(const char *title, const char *message, const char *buttonLabel
if (!EditBoxInGlobalFocus() || IsInsideMM(pressed_key & ~WKC_SPECIAL_KEYS, WKC_F1, WKC_PAUSE + 1)) {
HandleKeypress(pressed_key, unicode);
}
- DEBUG(driver, 3, "cocoa_v: QZ_KeyEvent: %x (%x), down, mapping: %x", keycode, unicode, pressed_key);
+ Debug(driver, 3, "cocoa_v: QZ_KeyEvent: {:x} ({:x}), down, mapping: {:x}", keycode, (int)unicode, pressed_key);
} else {
- DEBUG(driver, 3, "cocoa_v: QZ_KeyEvent: %x (%x), up", keycode, unicode);
+ Debug(driver, 3, "cocoa_v: QZ_KeyEvent: {:x} ({:x}), up", keycode, (int)unicode);
}
return interpret_keys;
diff --git a/src/video/dedicated_v.cpp b/src/video/dedicated_v.cpp
index 445ff19e4..75f173544 100644
--- a/src/video/dedicated_v.cpp
+++ b/src/video/dedicated_v.cpp
@@ -108,7 +108,7 @@ static void CreateWindowsConsoleThread()
_hThread = CreateThread(nullptr, 0, (LPTHREAD_START_ROUTINE)CheckForConsoleInput, nullptr, 0, &dwThreadId);
if (_hThread == nullptr) usererror("Cannot create console thread!");
- DEBUG(driver, 2, "Windows console thread started");
+ Debug(driver, 2, "Windows console thread started");
}
static void CloseWindowsConsoleThread()
@@ -116,7 +116,7 @@ static void CloseWindowsConsoleThread()
CloseHandle(_hThread);
CloseHandle(_hInputReady);
CloseHandle(_hWaitForInputHandling);
- DEBUG(driver, 2, "Windows console thread shut down");
+ Debug(driver, 2, "Windows console thread shut down");
}
#endif
@@ -164,7 +164,7 @@ const char *VideoDriver_Dedicated::Start(const StringList &parm)
OS2_SwitchToConsoleMode();
#endif
- DEBUG(driver, 1, "Loading dedicated server");
+ Debug(driver, 1, "Loading dedicated server");
return nullptr;
}
@@ -256,7 +256,7 @@ void VideoDriver_Dedicated::MainLoop()
* intro game... */
if (SaveOrLoad(_file_to_saveload.name, _file_to_saveload.file_op, _file_to_saveload.detail_ftype, BASE_DIR) == SL_ERROR) {
/* Loading failed, pop out.. */
- DEBUG(net, 0, "Loading requested map failed; closing server.");
+ Debug(net, 0, "Loading requested map failed; closing server.");
return;
} else {
/* We can load this game, so go ahead */
diff --git a/src/video/null_v.cpp b/src/video/null_v.cpp
index e4f4ecf47..36947750a 100644
--- a/src/video/null_v.cpp
+++ b/src/video/null_v.cpp
@@ -35,7 +35,7 @@ const char *VideoDriver_Null::Start(const StringList &parm)
ScreenSizeChanged();
/* Do not render, nor blit */
- DEBUG(misc, 1, "Forcing blitter 'null'...");
+ Debug(misc, 1, "Forcing blitter 'null'...");
BlitterFactory::SelectBlitter("null");
return nullptr;
}
diff --git a/src/video/opengl.cpp b/src/video/opengl.cpp
index df0d12d07..576bdd78b 100644
--- a/src/video/opengl.cpp
+++ b/src/video/opengl.cpp
@@ -428,7 +428,7 @@ void APIENTRY DebugOutputCallback(GLenum source, GLenum type, GLuint id, GLenum
case GL_DEBUG_TYPE_PORTABILITY: type_str = "Portability"; break;
}
- DEBUG(driver, 6, "OpenGL: %s (%s) - %s", type_str, severity_str, message);
+ Debug(driver, 6, "OpenGL: {} ({}) - {}", type_str, severity_str, message);
}
/** Enable OpenGL debug messages if supported. */
@@ -536,7 +536,7 @@ const char *OpenGLBackend::Init(const Dimension &screen_res)
if (ver == nullptr || vend == nullptr || renderer == nullptr) return "OpenGL not supported";
- DEBUG(driver, 1, "OpenGL driver: %s - %s (%s)", vend, renderer, ver);
+ Debug(driver, 1, "OpenGL driver: {} - {} ({})", vend, renderer, ver);
#ifndef GL_ALLOW_SOFTWARE_RENDERER
/* Don't use MESA software rendering backends as they are slower than
@@ -584,10 +584,10 @@ const char *OpenGLBackend::Init(const Dimension &screen_res)
#endif
if (this->persistent_mapping_supported && !BindPersistentBufferExtensions()) {
- DEBUG(driver, 1, "OpenGL claims to support persistent buffer mapping but doesn't export all functions, not using persistent mapping.");
+ Debug(driver, 1, "OpenGL claims to support persistent buffer mapping but doesn't export all functions, not using persistent mapping.");
this->persistent_mapping_supported = false;
}
- if (this->persistent_mapping_supported) DEBUG(driver, 3, "OpenGL: Using persistent buffer mapping");
+ if (this->persistent_mapping_supported) Debug(driver, 3, "OpenGL: Using persistent buffer mapping");
/* Check maximum texture size against screen resolution. */
GLint max_tex_size = 0;
@@ -599,7 +599,7 @@ const char *OpenGLBackend::Init(const Dimension &screen_res)
_glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &max_tex_units);
if (max_tex_units < 4) return "Not enough simultaneous textures supported";
- DEBUG(driver, 2, "OpenGL shading language version: %s, texture units = %d", (const char *)_glGetString(GL_SHADING_LANGUAGE_VERSION), (int)max_tex_units);
+ Debug(driver, 2, "OpenGL shading language version: {}, texture units = {}", (const char *)_glGetString(GL_SHADING_LANGUAGE_VERSION), (int)max_tex_units);
if (!this->InitShaders()) return "Failed to initialize shaders";
@@ -761,7 +761,7 @@ static bool VerifyShader(GLuint shader)
_glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &log_len);
if (log_len > 0) {
_glGetShaderInfoLog(shader, log_len, nullptr, log_buf.Allocate(log_len));
- DEBUG(driver, result != GL_TRUE ? 0 : 2, "%s", log_buf.GetBuffer()); // Always print on failure.
+ Debug(driver, result != GL_TRUE ? 0 : 2, "{}", log_buf.GetBuffer()); // Always print on failure.
}
return result == GL_TRUE;
@@ -784,7 +784,7 @@ static bool VerifyProgram(GLuint program)
_glGetProgramiv(program, GL_INFO_LOG_LENGTH, &log_len);
if (log_len > 0) {
_glGetProgramInfoLog(program, log_len, nullptr, log_buf.Allocate(log_len));
- DEBUG(driver, result != GL_TRUE ? 0 : 2, "%s", log_buf.GetBuffer()); // Always print on failure.
+ Debug(driver, result != GL_TRUE ? 0 : 2, "{}", log_buf.GetBuffer()); // Always print on failure.
}
return result == GL_TRUE;
diff --git a/src/video/sdl2_v.cpp b/src/video/sdl2_v.cpp
index 2d8558534..66bea5d8c 100644
--- a/src/video/sdl2_v.cpp
+++ b/src/video/sdl2_v.cpp
@@ -119,7 +119,7 @@ static uint FindStartupDisplay(uint startup_display)
for (int display = 0; display < num_displays; ++display) {
SDL_Rect r;
if (SDL_GetDisplayBounds(display, &r) == 0 && IsInsideBS(mx, r.x, r.w) && IsInsideBS(my, r.y, r.h)) {
- DEBUG(driver, 1, "SDL2: Mouse is at (%d, %d), use display %d (%d, %d, %d, %d)", mx, my, display, r.x, r.y, r.w, r.h);
+ Debug(driver, 1, "SDL2: Mouse is at ({}, {}), use display {} ({}, {}, {}, {})", mx, my, display, r.x, r.y, r.w, r.h);
return display;
}
}
@@ -168,7 +168,7 @@ bool VideoDriver_SDL_Base::CreateMainWindow(uint w, uint h, uint flags)
flags);
if (this->sdl_window == nullptr) {
- DEBUG(driver, 0, "SDL2: Couldn't allocate a window to draw on: %s", SDL_GetError());
+ Debug(driver, 0, "SDL2: Couldn't allocate a window to draw on: {}", SDL_GetError());
return false;
}
@@ -192,7 +192,7 @@ bool VideoDriver_SDL_Base::CreateMainWindow(uint w, uint h, uint flags)
bool VideoDriver_SDL_Base::CreateMainSurface(uint w, uint h, bool resize)
{
GetAvailableVideoMode(&w, &h);
- DEBUG(driver, 1, "SDL2: using mode %ux%u", w, h);
+ Debug(driver, 1, "SDL2: using mode {}x{}", w, h);
if (!this->CreateMainWindow(w, h)) return false;
if (resize) SDL_SetWindowSize(this->sdl_window, w, h);
@@ -547,7 +547,7 @@ const char *VideoDriver_SDL_Base::Initialize()
if (error != nullptr) return error;
FindResolutions();
- DEBUG(driver, 2, "Resolution for display: %ux%u", _cur_resolution.width, _cur_resolution.height);
+ Debug(driver, 2, "Resolution for display: {}x{}", _cur_resolution.width, _cur_resolution.height);
return nullptr;
}
@@ -566,7 +566,7 @@ const char *VideoDriver_SDL_Base::Start(const StringList &param)
}
const char *dname = SDL_GetCurrentVideoDriver();
- DEBUG(driver, 1, "SDL2: using driver '%s'", dname);
+ Debug(driver, 1, "SDL2: using driver '{}'", dname);
MarkWholeScreenDirty();
@@ -680,20 +680,20 @@ bool VideoDriver_SDL_Base::ToggleFullscreen(bool fullscreen)
/* Find fullscreen window size */
SDL_DisplayMode dm;
if (SDL_GetCurrentDisplayMode(0, &dm) < 0) {
- DEBUG(driver, 0, "SDL_GetCurrentDisplayMode() failed: %s", SDL_GetError());
+ Debug(driver, 0, "SDL_GetCurrentDisplayMode() failed: {}", SDL_GetError());
} else {
SDL_SetWindowSize(this->sdl_window, dm.w, dm.h);
}
}
- DEBUG(driver, 1, "SDL2: Setting %s", fullscreen ? "fullscreen" : "windowed");
+ Debug(driver, 1, "SDL2: Setting {}", fullscreen ? "fullscreen" : "windowed");
int ret = SDL_SetWindowFullscreen(this->sdl_window, fullscreen ? SDL_WINDOW_FULLSCREEN : 0);
if (ret == 0) {
/* Switching resolution succeeded, set fullscreen value of window. */
_fullscreen = fullscreen;
if (!fullscreen) SDL_SetWindowSize(this->sdl_window, w, h);
} else {
- DEBUG(driver, 0, "SDL_SetWindowFullscreen() failed: %s", SDL_GetError());
+ Debug(driver, 0, "SDL_SetWindowFullscreen() failed: {}", SDL_GetError());
}
InvalidateWindowClassesData(WC_GAME_OPTIONS, 3);
diff --git a/src/video/sdl_v.cpp b/src/video/sdl_v.cpp
index 03f174794..644978e1f 100644
--- a/src/video/sdl_v.cpp
+++ b/src/video/sdl_v.cpp
@@ -236,7 +236,7 @@ bool VideoDriver_SDL::CreateMainSurface(uint w, uint h)
GetAvailableVideoMode(&w, &h);
- DEBUG(driver, 1, "SDL: using mode %ux%ux%d", w, h, bpp);
+ Debug(driver, 1, "SDL: using mode {}x{}x{}", w, h, bpp);
if (bpp == 0) usererror("Can't use a blitter that blits 0 bpp for normal visuals");
@@ -282,7 +282,7 @@ bool VideoDriver_SDL::CreateMainSurface(uint w, uint h)
want_hwpalette = _use_hwpalette;
}
- if (want_hwpalette) DEBUG(driver, 1, "SDL: requesting hardware palette");
+ if (want_hwpalette) Debug(driver, 1, "SDL: requesting hardware palette");
/* Free any previously allocated shadow surface */
if (_sdl_surface != nullptr && _sdl_surface != _sdl_realscreen) SDL_FreeSurface(_sdl_surface);
@@ -297,7 +297,7 @@ bool VideoDriver_SDL::CreateMainSurface(uint w, uint h)
* windowed), we restart the entire video
* subsystem to force creating a new window.
*/
- DEBUG(driver, 0, "SDL: Restarting SDL video subsystem, to force hwpalette change");
+ Debug(driver, 0, "SDL: Restarting SDL video subsystem, to force hwpalette change");
SDL_QuitSubSystem(SDL_INIT_VIDEO);
SDL_InitSubSystem(SDL_INIT_VIDEO);
ClaimMousePointer();
@@ -313,7 +313,7 @@ bool VideoDriver_SDL::CreateMainSurface(uint w, uint h)
/* DO NOT CHANGE TO HWSURFACE, IT DOES NOT WORK */
newscreen = SDL_SetVideoMode(w, h, bpp, SDL_SWSURFACE | (want_hwpalette ? SDL_HWPALETTE : 0) | (_fullscreen ? SDL_FULLSCREEN : SDL_RESIZABLE));
if (newscreen == nullptr) {
- DEBUG(driver, 0, "SDL: Couldn't allocate a window to draw on");
+ Debug(driver, 0, "SDL: Couldn't allocate a window to draw on");
return false;
}
_sdl_realscreen = newscreen;
@@ -337,10 +337,10 @@ bool VideoDriver_SDL::CreateMainSurface(uint w, uint h)
* This shadow surface will have SDL_HWPALLETE set, so
* we won't create a second shadow surface in this case.
*/
- DEBUG(driver, 1, "SDL: using shadow surface");
+ Debug(driver, 1, "SDL: using shadow surface");
newscreen = SDL_CreateRGBSurface(SDL_SWSURFACE, w, h, bpp, 0, 0, 0, 0);
if (newscreen == nullptr) {
- DEBUG(driver, 0, "SDL: Couldn't allocate a shadow surface to draw on");
+ Debug(driver, 0, "SDL: Couldn't allocate a shadow surface to draw on");
return false;
}
}
@@ -594,7 +594,7 @@ const char *VideoDriver_SDL::Start(const StringList &param)
}
SDL_VideoDriverName(buf, sizeof buf);
- DEBUG(driver, 1, "SDL: using driver '%s'", buf);
+ Debug(driver, 1, "SDL: using driver '{}'", buf);
MarkWholeScreenDirty();
SetupKeyboard();
diff --git a/src/video/video_driver.cpp b/src/video/video_driver.cpp
index 0af716f05..27824674a 100644
--- a/src/video/video_driver.cpp
+++ b/src/video/video_driver.cpp
@@ -87,7 +87,7 @@ void VideoDriver::StartGameThread()
this->is_game_threaded = StartNewThread(&this->game_thread, "ottd:game", &VideoDriver::GameThreadThunk, this);
}
- DEBUG(driver, 1, "using %sthread for game-loop", this->is_game_threaded ? "" : "no ");
+ Debug(driver, 1, "using {}thread for game-loop", this->is_game_threaded ? "" : "no ");
}
void VideoDriver::StopGameThread()
diff --git a/src/video/win32_v.cpp b/src/video/win32_v.cpp
index 4afc751af..df0917ffa 100644
--- a/src/video/win32_v.cpp
+++ b/src/video/win32_v.cpp
@@ -234,7 +234,7 @@ static LRESULT HandleCharMsg(uint keycode, WChar charcode)
/* Did we get a lead surrogate? If yes, store and exit. */
if (Utf16IsLeadSurrogate(charcode)) {
- if (prev_char != 0) DEBUG(driver, 1, "Got two UTF-16 lead surrogates, dropping the first one");
+ if (prev_char != 0) Debug(driver, 1, "Got two UTF-16 lead surrogates, dropping the first one");
prev_char = charcode;
return 0;
}
@@ -244,7 +244,7 @@ static LRESULT HandleCharMsg(uint keycode, WChar charcode)
if (Utf16IsTrailSurrogate(charcode)) {
charcode = Utf16DecodeSurrogate(prev_char, charcode);
} else {
- DEBUG(driver, 1, "Got an UTF-16 lead surrogate without a trail surrogate, dropping the lead surrogate");
+ Debug(driver, 1, "Got an UTF-16 lead surrogate without a trail surrogate, dropping the lead surrogate");
}
}
prev_char = 0;
@@ -794,7 +794,7 @@ void VideoDriver_Win32Base::Initialize()
this->width = this->width_org = _cur_resolution.width;
this->height = this->height_org = _cur_resolution.height;
- DEBUG(driver, 2, "Resolution for display: %ux%u", _cur_resolution.width, _cur_resolution.height);
+ Debug(driver, 2, "Resolution for display: {}x{}", _cur_resolution.width, _cur_resolution.height);
}
void VideoDriver_Win32Base::Stop()
@@ -1361,7 +1361,7 @@ void VideoDriver_Win32OpenGL::ToggleVsync(bool vsync)
if (_wglSwapIntervalEXT != nullptr) {
_wglSwapIntervalEXT(vsync);
} else if (vsync) {
- DEBUG(driver, 0, "OpenGL: Vsync requested, but not supported by driver");
+ Debug(driver, 0, "OpenGL: Vsync requested, but not supported by driver");
}
}