Fix: Don't allow right-click to close world generation progress window. (#13084)
[openttd-github.git] / src / video / sdl2_opengl_v.h
blobb1e2f09f04479b4ed1c4f5774c9a7a0837b6cf09
1 /*
2 * This file is part of OpenTTD.
3 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
6 */
8 /** @file sdl2_opengl_v.h OpenGL backend of the SDL2 video driver. */
10 #include "sdl2_v.h"
12 /** The OpenGL video driver for windows. */
13 class VideoDriver_SDL_OpenGL : public VideoDriver_SDL_Base {
14 public:
15 VideoDriver_SDL_OpenGL() : VideoDriver_SDL_Base(true), gl_context(nullptr), anim_buffer(nullptr) {}
17 std::optional<std::string_view> Start(const StringList &param) override;
19 void Stop() override;
21 bool HasEfficient8Bpp() const override { return true; }
23 bool UseSystemCursor() override { return true; }
25 void ClearSystemSprites() override;
27 void PopulateSystemSprites() override;
29 bool HasAnimBuffer() override { return true; }
30 uint8_t *GetAnimBuffer() override { return this->anim_buffer; }
32 void ToggleVsync(bool vsync) override;
34 std::string_view GetName() const override { return "sdl-opengl"; }
36 protected:
37 bool AllocateBackingStore(int w, int h, bool force = false) override;
38 void *GetVideoPointer() override;
39 void ReleaseVideoPointer() override;
40 void Paint() override;
41 bool CreateMainWindow(uint w, uint h, uint flags) override;
43 private:
44 void *gl_context; ///< OpenGL context.
45 uint8_t *anim_buffer; ///< Animation buffer from OpenGL back-end.
47 std::optional<std::string_view> AllocateContext();
48 void DestroyContext();
51 /** The factory for SDL' OpenGL video driver. */
52 class FVideoDriver_SDL_OpenGL : public DriverFactoryBase {
53 public:
54 FVideoDriver_SDL_OpenGL() : DriverFactoryBase(Driver::DT_VIDEO, 8, "sdl-opengl", "SDL OpenGL Video Driver") {}
55 /* virtual */ Driver *CreateInstance() const override { return new VideoDriver_SDL_OpenGL(); }
57 protected:
58 bool UsesHardwareAcceleration() const override { return true; }