Add: Show current video driver info in Options window

This commit is contained in:
Niels Martin Hansen
2022-04-30 14:52:39 +02:00
parent be72f1e54b
commit 345dcd3c7b
13 changed files with 55 additions and 3 deletions

View File

@@ -18,11 +18,12 @@ class VideoDriver_CocoaOpenGL : public VideoDriver_Cocoa {
CGLContextObj gl_context;
uint8 *anim_buffer; ///< Animation buffer from OpenGL back-end.
std::string driver_info; ///< Information string about selected driver.
const char *AllocateContext(bool allow_software);
public:
VideoDriver_CocoaOpenGL() : gl_context(nullptr), anim_buffer(nullptr) {}
VideoDriver_CocoaOpenGL() : gl_context(nullptr), anim_buffer(nullptr), driver_info(this->GetName()) {}
const char *Start(const StringList &param) override;
void Stop() override;
@@ -41,6 +42,8 @@ public:
/** Return driver name */
const char *GetName() const override { return "cocoa-opengl"; }
const char *GetInfoString() const override { return this->driver_info.c_str(); }
void AllocateBackingStore(bool force = false) override;
protected:

View File

@@ -203,6 +203,11 @@ const char *VideoDriver_CocoaOpenGL::Start(const StringList &param)
return err;
}
this->driver_info = GetName();
this->driver_info += " (";
this->driver_info += OpenGLBackend::Get()->GetDriverName();
this->driver_info += ")";
bool fullscreen = _fullscreen;
if (!this->MakeWindow(_cur_resolution.width, _cur_resolution.height)) {
this->Stop();

View File

@@ -745,6 +745,16 @@ void OpenGLBackend::PrepareContext()
_glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}
std::string OpenGLBackend::GetDriverName()
{
std::string res{};
/* Skipping GL_VENDOR as it tends to be "obvious" from the renderer and version data, and just makes the string pointlessly longer */
res += reinterpret_cast<const char *>(_glGetString(GL_RENDERER));
res += ", ";
res += reinterpret_cast<const char *>(_glGetString(GL_VERSION));
return res;
}
/**
* Check a shader for compilation errors and log them if necessary.
* @param shader Shader to check.

View File

@@ -92,6 +92,8 @@ public:
void PrepareContext();
std::string GetDriverName();
void UpdatePalette(const Colour *pal, uint first, uint length);
bool Resize(int w, int h, bool force = false);
void Paint();

View File

@@ -64,6 +64,10 @@ const char *VideoDriver_SDL_OpenGL::Start(const StringList &param)
return error;
}
this->driver_info += " (";
this->driver_info += OpenGLBackend::Get()->GetDriverName();
this->driver_info += ")";
/* Now we have a OpenGL context, force a client-size-changed event,
* so all buffers are allocated correctly. */
int w, h;

View File

@@ -540,6 +540,11 @@ const char *VideoDriver_SDL_Base::Start(const StringList &param)
const char *dname = SDL_GetCurrentVideoDriver();
Debug(driver, 1, "SDL2: using driver '{}'", dname);
this->driver_info = this->GetName();
this->driver_info += " (";
this->driver_info += dname;
this->driver_info += ")";
MarkWholeScreenDirty();
SDL_StopTextInput();

View File

@@ -17,7 +17,7 @@
/** The SDL video driver. */
class VideoDriver_SDL_Base : public VideoDriver {
public:
VideoDriver_SDL_Base() : sdl_window(nullptr), buffer_locked(false) {}
VideoDriver_SDL_Base() : sdl_window(nullptr), buffer_locked(false), driver_info(this->GetName()) {}
const char *Start(const StringList &param) override;
@@ -43,11 +43,14 @@ public:
const char *GetName() const override { return "sdl"; }
const char *GetInfoString() const override { return this->driver_info.c_str(); }
protected:
struct SDL_Window *sdl_window; ///< Main SDL window.
Palette local_palette; ///< Current palette to use for drawing.
bool buffer_locked; ///< Video buffer was locked by the main thread.
Rect dirty_rect; ///< Rectangle encompassing the dirty area of the video buffer.
std::string driver_info; ///< Information string about selected driver.
Dimension GetScreenSize() const override;
void InputLoop() override;

View File

@@ -178,6 +178,11 @@ public:
return ZOOM_LVL_OUT_4X;
}
virtual const char *GetInfoString() const
{
return this->GetName();
}
/**
* Queue a function to be called on the main thread with game state
* lock held and video buffer locked. Queued functions will be

View File

@@ -1310,6 +1310,11 @@ const char *VideoDriver_Win32OpenGL::Start(const StringList &param)
return err;
}
this->driver_info = GetName();
this->driver_info += " (";
this->driver_info += OpenGLBackend::Get()->GetDriverName();
this->driver_info += ")";
this->ClientSizeChanged(this->width, this->height, true);
/* We should have a valid screen buffer now. If not, something went wrong and we should abort. */
if (_screen.dst_ptr == nullptr) {

View File

@@ -117,7 +117,7 @@ public:
/** The OpenGL video driver for windows. */
class VideoDriver_Win32OpenGL : public VideoDriver_Win32Base {
public:
VideoDriver_Win32OpenGL() : dc(nullptr), gl_rc(nullptr), anim_buffer(nullptr) {}
VideoDriver_Win32OpenGL() : dc(nullptr), gl_rc(nullptr), anim_buffer(nullptr), driver_info(this->GetName()) {}
const char *Start(const StringList &param) override;
@@ -142,10 +142,13 @@ public:
const char *GetName() const override { return "win32-opengl"; }
const char *GetInfoString() const override { return this->driver_info.c_str(); }
protected:
HDC dc; ///< Window device context.
HGLRC gl_rc; ///< OpenGL context.
uint8 *anim_buffer; ///< Animation buffer from OpenGL back-end.
std::string driver_info; ///< Information string about selected driver.
uint8 GetFullscreenBpp() override { return 32; } // OpenGL is always 32 bpp.