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/>.
8 /** @file sdl2_opengl_v.h OpenGL backend of the SDL2 video driver. */
12 /** The OpenGL video driver for windows. */
13 class VideoDriver_SDL_OpenGL
: public VideoDriver_SDL_Base
{
15 VideoDriver_SDL_OpenGL() : VideoDriver_SDL_Base(true), gl_context(nullptr), anim_buffer(nullptr) {}
17 const char *Start(const StringList
¶m
) 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 const char *GetName() const override
{ return "sdl-opengl"; }
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
;
44 void *gl_context
; ///< OpenGL context.
45 uint8_t *anim_buffer
; ///< Animation buffer from OpenGL back-end.
47 const char *AllocateContext();
48 void DestroyContext();
51 /** The factory for SDL' OpenGL video driver. */
52 class FVideoDriver_SDL_OpenGL
: public DriverFactoryBase
{
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(); }
58 bool UsesHardwareAcceleration() const override
{ return true; }