OpenTTD Source
1.11.0-beta2
|
Go to the documentation of this file.
14 #include "../stdafx.h"
15 #include "../openttd.h"
16 #include "../gfx_func.h"
18 #include "../blitter/factory.hpp"
19 #include "../network/network.h"
20 #include "../thread.h"
21 #include "../progress.h"
22 #include "../core/random_func.hpp"
23 #include "../core/math_func.hpp"
24 #include "../core/mem_func.hpp"
25 #include "../core/geometry_func.hpp"
26 #include "../fileio_func.h"
27 #include "../framerate_type.h"
28 #include "../window_func.h"
32 #include <condition_variable>
34 #include "../3rdparty/opengl/glext.h"
37 # include <emscripten.h>
38 # include <emscripten/html5.h>
41 #include "../safeguards.h"
48 return reinterpret_cast<OGLProc
>(SDL_GL_GetProcAddress(proc));
61 error = this->AllocateContext();
62 if (
error !=
nullptr) {
81 this->DestroyContext();
85 void VideoDriver_SDL_OpenGL::DestroyContext()
95 const char *VideoDriver_SDL_OpenGL::AllocateContext()
97 SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
98 SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
99 SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
100 SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 0);
101 SDL_GL_SetAttribute(SDL_GL_ACCELERATED_VISUAL, 1);
102 SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
104 if (_debug_driver_level >= 8) {
105 SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, SDL_GL_CONTEXT_DEBUG_FLAG);
109 if (this->
gl_context ==
nullptr)
return "SDL2: Can't active GL context";
121 if (this->
gl_context ==
nullptr)
return false;
int first_dirty
The first dirty element.
bool draw_threaded
Whether the drawing is/may be done in a separate thread.
bool AllocateBackingStore(int w, int h, bool force=false) override
(Re-)create the backing store.
@ PFE_VIDEO
Speed of painting drawn video buffer.
virtual Blitter::PaletteAnimation UsePaletteAnimation()=0
Check if the blitter uses palette animation at all.
How all blitters should look like.
void Stop() override
Stop this driver.
bool CreateMainWindow(uint w, uint h, uint flags) override
Create the main window.
static OpenGLBackend * Get()
Get singleton instance of this class.
void DrawMouseCursor()
Draw mouse cursor on screen.
void Stop() override
Stop this driver.
void Paint() override
Paint the window.
Colour palette[256]
Current palette. Entry 0 has to be always fully transparent!
void ReleaseVideoBuffer(const Rect &update_rect)
Update video buffer texture after the video buffer was filled.
Palette local_palette
Copy of _cur_palette.
static Blitter * GetCurrentBlitter()
Get the current active blitter (always set by calling SelectBlitter).
void * GetVideoBuffer()
Get a pointer to the memory for the video driver to draw to.
std::vector< std::string > StringList
Type for a list of strings.
static void Destroy()
Free resources and destroy singleton back-end class.
virtual bool CreateMainWindow(uint w, uint h, uint flags=0)
Create the main window.
int count_dirty
The number of dirty elements.
const char * Start(const StringList ¶m) override
Start this driver.
void ClearCursorCache()
Clear all cached cursor sprites.
void ReleaseVideoPointer() override
Hand video buffer back to the painting backend.
void ClientSizeChanged(int w, int h, bool force)
Indicate to the driver the client-side might have changed.
void * GetVideoPointer() override
Get a pointer to the video buffer.
static OGLProc GetOGLProcAddressCallback(const char *proc)
Platform-specific callback to get an OpenGL funtion pointer.
Rect dirty_rect
Rectangle encompassing the dirty area of the video buffer.
void Paint()
Render video buffer to the screen.
Palette _cur_palette
Current palette.
The factory for SDL' OpenGL video driver.
void CDECL error(const char *s,...)
Error handling for fatal non-user errors.
void UpdatePalette(const Colour *pal, uint first, uint length)
Update the stored palette.
virtual void PaletteAnimate(const Palette &palette)=0
Called when the 8bpp palette is changed; you should redraw all pixels on the screen that are equal to...
@ PALETTE_ANIMATION_BLITTER
The blitter takes care of the palette animation.
static void MemSetT(T *ptr, byte value, size_t num=1)
Type-safe version of memset().
void ClearSystemSprites() override
Clear all cached sprites.
bool in_window
mouse inside this window, determines drawing logic
void ReleaseAnimBuffer(const Rect &update_rect)
Update animation buffer texture after the animation buffer was filled.
bool GetDriverParamBool(const StringList &parm, const char *name)
Get a boolean parameter the list of parameters.
void * gl_context
OpenGL context.
bool Resize(int w, int h, bool force=false)
Change the size of the drawing window and allocate matching resources.
uint8 * GetAnimBuffer()
Get a pointer to the memory for the separate animation buffer.
uint8 * anim_buffer
Animation buffer from OpenGL back-end.
static const char * Create(GetOGLProcAddressProc get_proc)
Create and initialize the singleton back-end class.
struct SDL_Window * sdl_window
Main SDL window.
const char * Start(const StringList ¶m) override
Start this driver.