OpenTTD Source 20241224-master-gee860a5c8e
sdl2_opengl_v.h
Go to the documentation of this file.
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 */
7
10#include "sdl2_v.h"
11
14public:
16
17 std::optional<std::string_view> Start(const StringList &param) override;
18
19 void Stop() override;
20
21 bool HasEfficient8Bpp() const override { return true; }
22
23 bool UseSystemCursor() override { return true; }
24
25 void ClearSystemSprites() override;
26
27 void PopulateSystemSprites() override;
28
29 bool HasAnimBuffer() override { return true; }
30 uint8_t *GetAnimBuffer() override { return this->anim_buffer; }
31
32 void ToggleVsync(bool vsync) override;
33
34 std::string_view GetName() const override { return "sdl-opengl"; }
35
36protected:
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;
42
43private:
44 void *gl_context;
45 uint8_t *anim_buffer;
46
47 std::optional<std::string_view> AllocateContext();
48 void DestroyContext();
49};
50
53public:
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(); }
56
57protected:
58 bool UsesHardwareAcceleration() const override { return true; }
59};
Base for all driver factories.
Definition driver.h:57
A driver for communicating with the user.
Definition driver.h:21
@ DT_VIDEO
A video driver.
Definition driver.h:42
The factory for SDL' OpenGL video driver.
bool UsesHardwareAcceleration() const override
Does the driver use hardware acceleration (video-drivers only).
Driver * CreateInstance() const override
Create an instance of this driver-class.
The SDL video driver.
Definition sdl2_v.h:18
The OpenGL video driver for windows.
void Paint() override
Paint the window.
void ReleaseVideoPointer() override
Hand video buffer back to the painting backend.
void * gl_context
OpenGL context.
std::string_view GetName() const override
Get the name of this driver.
uint8_t * GetAnimBuffer() override
Get a pointer to the animation buffer of the video back-end.
bool HasEfficient8Bpp() const override
Has this video driver an efficient code path for palette animated 8-bpp sprites?
void ToggleVsync(bool vsync) override
Change the vsync setting.
bool CreateMainWindow(uint w, uint h, uint flags) override
Create the main window.
void * GetVideoPointer() override
Get a pointer to the video buffer.
void Stop() override
Stop this driver.
bool UseSystemCursor() override
Get whether the mouse cursor is drawn by the video driver.
void ClearSystemSprites() override
Clear all cached sprites.
bool AllocateBackingStore(int w, int h, bool force=false) override
(Re-)create the backing store.
std::optional< std::string_view > Start(const StringList &param) override
Start this driver.
void PopulateSystemSprites() override
Populate all sprites in cache.
uint8_t * anim_buffer
Animation buffer from OpenGL back-end.
bool HasAnimBuffer() override
Does this video driver support a separate animation buffer in addition to the colour buffer?
Base of the SDL2 video driver.
std::vector< std::string > StringList
Type for a list of strings.
Definition string_type.h:60