diff options
author | Michael Lutz <michi@icosahedron.de> | 2021-01-16 16:43:04 +0100 |
---|---|---|
committer | Michael Lutz <michi@icosahedron.de> | 2021-02-22 22:16:07 +0100 |
commit | ef478ade649add1ab1706370ff53bcb0c32798d1 (patch) | |
tree | bf39b20030319377edec1b654fe4e8c7ba4594a3 /src/video/win32_v.h | |
parent | af4d32357cc4cea6878c61c366378477e62915d0 (diff) | |
download | openttd-ef478ade649add1ab1706370ff53bcb0c32798d1.tar.xz |
Add: [Win32] Video driver that uses OpenGL to transfer the video buffer to the screen.
Diffstat (limited to 'src/video/win32_v.h')
-rw-r--r-- | src/video/win32_v.h | 48 |
1 files changed, 45 insertions, 3 deletions
diff --git a/src/video/win32_v.h b/src/video/win32_v.h index b50f4e7a5..1840bbe86 100644 --- a/src/video/win32_v.h +++ b/src/video/win32_v.h @@ -48,8 +48,10 @@ protected: void Initialize(); bool MakeWindow(bool full_screen); - virtual uint8 GetFullscreenBpp(); + void ClientSizeChanged(int w, int h); + /** Get screen depth to use for fullscreen mode. */ + virtual uint8 GetFullscreenBpp(); /** (Re-)create the backing store. */ virtual bool AllocateBackingStore(int w, int h, bool force = false) = 0; /** Palette of the window has changed. */ @@ -58,8 +60,6 @@ protected: private: std::unique_lock<std::recursive_mutex> draw_lock; - void ClientSizeChanged(int w, int h); - static void PaintThreadThunk(VideoDriver_Win32Base *drv); friend LRESULT CALLBACK WndProcGdi(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); @@ -102,4 +102,46 @@ public: Driver *CreateInstance() const override { return new VideoDriver_Win32GDI(); } }; +#ifdef WITH_OPENGL + +/** The OpenGL video driver for windows. */ +class VideoDriver_Win32OpenGL : public VideoDriver_Win32Base { +public: + VideoDriver_Win32OpenGL() : dc(nullptr), gl_rc(nullptr) {} + + const char *Start(const StringList ¶m) override; + + void Stop() override; + + bool ToggleFullscreen(bool fullscreen) override; + + bool AfterBlitterChange() override; + + const char *GetName() const override { return "win32-opengl"; } + +protected: + HDC dc; ///< Window device context. + HGLRC gl_rc; ///< OpenGL context. + + uint8 GetFullscreenBpp() override { return 32; } // OpenGL is always 32 bpp. + + void Paint() override; + void PaintThread() override {} + + bool AllocateBackingStore(int w, int h, bool force = false) override; + void PaletteChanged(HWND hWnd) override {} + + const char *AllocateContext(); + void DestroyContext(); +}; + +/** The factory for Windows' OpenGL video driver. */ +class FVideoDriver_Win32OpenGL : public DriverFactoryBase { +public: + FVideoDriver_Win32OpenGL() : DriverFactoryBase(Driver::DT_VIDEO, 9, "win32-opengl", "Win32 OpenGL Video Driver") {} + /* virtual */ Driver *CreateInstance() const override { return new VideoDriver_Win32OpenGL(); } +}; + +#endif /* WITH_OPENGL */ + #endif /* VIDEO_WIN32_H */ |