From ef478ade649add1ab1706370ff53bcb0c32798d1 Mon Sep 17 00:00:00 2001 From: Michael Lutz Date: Sat, 16 Jan 2021 16:43:04 +0100 Subject: Add: [Win32] Video driver that uses OpenGL to transfer the video buffer to the screen. --- src/video/win32_v.h | 48 +++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 45 insertions(+), 3 deletions(-) (limited to 'src/video/win32_v.h') 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 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 */ -- cgit v1.2.3-54-g00ecf