15#include <condition_variable>
33 bool ClaimMousePointer()
override;
60 bool MakeWindow(
bool full_screen,
bool resize =
true);
61 void ClientSizeChanged(
int w,
int h,
bool force =
false);
75 friend LRESULT CALLBACK WndProcGdi(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
82 std::optional<std::string_view>
Start(
const StringList ¶m)
override;
88 std::string_view
GetName()
const override {
return "win32"; }
95 void Paint()
override;
101 void UpdatePalette(HDC dc, uint start, uint count);
105 static int RedrawScreenDebug();
121 VideoDriver_Win32OpenGL() :
VideoDriver_Win32Base(true), dc(nullptr), gl_rc(nullptr), anim_buffer(nullptr), driver_info(this->GetName()) {}
123 std::optional<std::string_view>
Start(
const StringList ¶m)
override;
125 void Stop()
override;
140 uint8_t *
GetAnimBuffer()
override {
return this->anim_buffer; }
144 std::string_view
GetName()
const override {
return "win32-opengl"; }
146 std::string_view GetInfoString()
const override {
return this->driver_info; }
151 uint8_t *anim_buffer;
152 std::string driver_info;
156 void Paint()
override;
163 std::optional<std::string_view> AllocateContext();
164 void DestroyContext();
170 FVideoDriver_Win32OpenGL() :
DriverFactoryBase(
Driver::DT_VIDEO, 10,
"win32-opengl",
"Win32 OpenGL Video Driver") {}
Base for all driver factories.
virtual bool UsesHardwareAcceleration() const
Does the driver use hardware acceleration (video-drivers only).
virtual Driver * CreateInstance() const =0
Create an instance of this driver-class.
A driver for communicating with the user.
virtual std::string_view GetName() const =0
Get the name of this driver.
@ DT_VIDEO
A video driver.
virtual std::optional< std::string_view > Start(const StringList &parm)=0
Start this driver.
The factory for Windows' video driver.
Driver * CreateInstance() const override
Create an instance of this driver-class.
Base class for Windows video drivers.
int height
Height in pixels of our display surface.
bool has_focus
Does our window have system focus?
void EditBoxLostFocus() override
An edit box lost the input focus.
void CheckPaletteAnim() override
Process any pending palette animation.
void Stop() override
Stop this driver.
int height_org
Original monitor resolution height, before we changed it.
HWND main_wnd
Handle to system window.
bool fullscreen
Whether to use (true) fullscreen mode.
int width_org
Original monitor resolution width, before we changed it.
bool MakeWindow(bool full_screen, bool resize=true)
Instantiate a new window.
bool buffer_locked
Video buffer was locked by the main thread.
virtual void * GetVideoPointer()=0
Get a pointer to the video buffer.
void MakeDirty(int left, int top, int width, int height) override
Mark a particular area dirty.
bool PollEvent() override
Process a single system event.
virtual void PaletteChanged(HWND hWnd)=0
Palette of the window has changed.
bool LockVideoBuffer() override
Make sure the video buffer is ready for drawing.
std::vector< int > GetListOfMonitorRefreshRates() override
Get a list of refresh rates of each available monitor.
virtual bool AllocateBackingStore(int w, int h, bool force=false)=0
(Re-)create the backing store.
int width
Width in pixels of our display surface.
void InputLoop() override
Handle input logic, is CTRL pressed, should we fast-forward, etc.
virtual uint8_t GetFullscreenBpp()
Get screen depth to use for fullscreen mode.
Dimension GetScreenSize() const override
Get the resolution of the main screen.
virtual void ReleaseVideoPointer()
Hand video buffer back to the painting backend.
void UnlockVideoBuffer() override
Unlock a previously locked video buffer.
void MainLoop() override
Perform the actual drawing.
Rect dirty_rect
Region of the screen that needs redrawing.
float GetDPIScale() override
Get DPI scaling factor of the screen OTTD is displayed on.
bool ToggleFullscreen(bool fullscreen) override
Change the full screen setting.
bool ChangeResolution(int w, int h) override
Change the resolution of the window.
The GDI video driver for windows.
std::string_view GetName() const override
Get the name of this driver.
void * buffer_bits
Internal rendering buffer.
HBITMAP dib_sect
System bitmap object referencing our rendering buffer.
void PaletteChanged(HWND hWnd) override
Palette of the window has changed.
std::optional< std::string_view > Start(const StringList ¶m) override
Start this driver.
void * GetVideoPointer() override
Get a pointer to the video buffer.
HPALETTE gdi_palette
Palette object for 8bpp blitter.
bool AllocateBackingStore(int w, int h, bool force=false) override
(Re-)create the backing store.
void Paint() override
Paint the window.
bool AfterBlitterChange() override
Callback invoked after the blitter was changed.
void Stop() override
Stop this driver.
The base of all video drivers.
virtual void PopulateSystemSprites()
Populate all sprites in cache.
virtual void ClearSystemSprites()
Clear all cached sprites.
virtual bool UseSystemCursor()
Get whether the mouse cursor is drawn by the video driver.
virtual bool HasAnimBuffer()
Does this video driver support a separate animation buffer in addition to the colour buffer?
virtual void ToggleVsync(bool vsync)
Change the vsync setting.
virtual bool AfterBlitterChange()
Callback invoked after the blitter was changed.
virtual bool HasEfficient8Bpp() const
Has this video driver an efficient code path for palette animated 8-bpp sprites?
virtual void Paint()
Paint the window.
virtual uint8_t * GetAnimBuffer()
Get a pointer to the animation buffer of the video back-end.
std::vector< std::string > StringList
Type for a list of strings.
Dimensions (a width and height) of a rectangle in 2D.
Specification of a rectangle with absolute coordinates of all edges.
Base of all video drivers.