Add: [Win32] Video driver that uses OpenGL to transfer the video buffer to the screen.

This commit is contained in:
Michael Lutz
2021-01-16 16:43:04 +01:00
parent af4d32357c
commit ef478ade64
12 changed files with 13670 additions and 3 deletions

View File

@@ -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 &param) 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 */