Changeset - r26238:1e3d0e5795b7
[Not reviewed]
master
0 13 0
Niels Martin Hansen - 2 years ago 2022-04-30 12:52:39
nielsm@indvikleren.dk
Add: Show current video driver info in Options window
13 files changed with 55 insertions and 3 deletions:
0 comments (0 inline, 0 general)
src/lang/english.txt
Show inline comments
 
@@ -1025,6 +1025,8 @@ STR_GAME_OPTIONS_VIDEO_ACCELERATION_REST
 
STR_GAME_OPTIONS_VIDEO_VSYNC                                    :{BLACK}VSync
 
STR_GAME_OPTIONS_VIDEO_VSYNC_TOOLTIP                            :{BLACK}Check this box to v-sync the screen. A changed setting will only be applied upon game restart. Only works with hardware acceleration enabled
 

	
 
STR_GAME_OPTIONS_VIDEO_DRIVER_INFO                              :{BLACK}Current driver: {RAW_STRING}
 

	
 
STR_GAME_OPTIONS_GUI_ZOOM_FRAME                                 :{BLACK}Interface size
 
STR_GAME_OPTIONS_GUI_ZOOM_DROPDOWN_TOOLTIP                      :{BLACK}Select the interface element size to use
 

	
src/settings_gui.cpp
Show inline comments
 
@@ -310,6 +310,7 @@ struct GameOptionsWindow : Window {
 
			case WID_GO_BASE_SFX_DROPDOWN:     SetDParamStr(0, BaseSounds::GetUsedSet()->name); break;
 
			case WID_GO_BASE_MUSIC_DROPDOWN:   SetDParamStr(0, BaseMusic::GetUsedSet()->name); break;
 
			case WID_GO_BASE_MUSIC_STATUS:     SetDParam(0, BaseMusic::GetUsedSet()->GetNumInvalid()); break;
 
			case WID_GO_VIDEO_DRIVER_INFO:     SetDParamStr(0, VideoDriver::GetInstance()->GetInfoString()); break;
 
			case WID_GO_REFRESH_RATE_DROPDOWN: SetDParam(0, _settings_client.gui.refresh_rate); break;
 
			case WID_GO_RESOLUTION_DROPDOWN: {
 
				auto current_resolution = GetCurrentResolutionIndex();
 
@@ -690,6 +691,9 @@ static const NWidgetPart _nested_game_op
 
						NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_GO_VIDEO_VSYNC_BUTTON), SetMinimalSize(21, 9), SetDataTip(STR_EMPTY, STR_GAME_OPTIONS_VIDEO_VSYNC_TOOLTIP),
 
					EndContainer(),
 
#endif
 
					NWidget(NWID_HORIZONTAL),
 
						NWidget(WWT_TEXT, COLOUR_GREY, WID_GO_VIDEO_DRIVER_INFO), SetMinimalSize(0, 12), SetFill(1, 0), SetDataTip(STR_GAME_OPTIONS_VIDEO_DRIVER_INFO, STR_NULL),
 
					EndContainer(),
 
				EndContainer(),
 
			EndContainer(),
 
		EndContainer(),
src/video/cocoa/cocoa_ogl.h
Show inline comments
 
@@ -18,11 +18,12 @@ class VideoDriver_CocoaOpenGL : public V
 
	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:
src/video/cocoa/cocoa_ogl.mm
Show inline comments
 
@@ -203,6 +203,11 @@ const char *VideoDriver_CocoaOpenGL::Sta
 
		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();
src/video/opengl.cpp
Show inline comments
 
@@ -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.
src/video/opengl.h
Show inline comments
 
@@ -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();
src/video/sdl2_opengl_v.cpp
Show inline comments
 
@@ -64,6 +64,10 @@ const char *VideoDriver_SDL_OpenGL::Star
 
		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;
src/video/sdl2_v.cpp
Show inline comments
 
@@ -540,6 +540,11 @@ const char *VideoDriver_SDL_Base::Start(
 
	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();
src/video/sdl2_v.h
Show inline comments
 
@@ -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;
src/video/video_driver.hpp
Show inline comments
 
@@ -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
src/video/win32_v.cpp
Show inline comments
 
@@ -1310,6 +1310,11 @@ const char *VideoDriver_Win32OpenGL::Sta
 
		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) {
src/video/win32_v.h
Show inline comments
 
@@ -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.
 

	
src/widgets/settings_widget.h
Show inline comments
 
@@ -37,6 +37,7 @@ enum GameOptionsWidgets {
 
	WID_GO_VIDEO_ACCEL_BUTTON,     ///< Toggle for video acceleration.
 
	WID_GO_VIDEO_VSYNC_BUTTON,     ///< Toggle for video vsync.
 
	WID_GO_REFRESH_RATE_DROPDOWN,  ///< Dropdown for all available refresh rates.
 
	WID_GO_VIDEO_DRIVER_INFO,      ///< Label showing details about the current video driver.
 
};
 

	
 
/** Widgets of the #GameSettingsWindow class. */
0 comments (0 inline, 0 general)