|
OpenTTD Source 20260109-master-g241b5fcdfe
|
OpenGL video driver support. More...
#include "../stdafx.h"#include <GL/gl.h>#include "../3rdparty/opengl/glext.h"#include "opengl.h"#include "../core/geometry_func.hpp"#include "../core/math_func.hpp"#include "../gfx_func.h"#include "../debug.h"#include "../blitter/factory.hpp"#include "../zoom_func.h"#include "../core/string_consumer.hpp"#include "../table/opengl_shader.h"#include "../table/sprites.h"#include "../safeguards.h"Go to the source code of this file.
Data Structures | |
| struct | Simple2DVertex |
| A simple 2D vertex with just position and texture. More... | |
| class | OpenGLSpriteAllocator |
Macros | |
| #define | GL_GLEXT_PROTOTYPES |
| #define | GL(function) static decltype(&function) _ ## function |
Functions | |
| GL (glGetString) | |
| GL (glGetIntegerv) | |
| GL (glGetError) | |
| GL (glDebugMessageControl) | |
| GL (glDebugMessageCallback) | |
| GL (glDisable) | |
| GL (glEnable) | |
| GL (glViewport) | |
| GL (glClear) | |
| GL (glClearColor) | |
| GL (glBlendFunc) | |
| GL (glDrawArrays) | |
| GL (glTexImage1D) | |
| GL (glTexImage2D) | |
| GL (glTexParameteri) | |
| GL (glTexSubImage1D) | |
| GL (glTexSubImage2D) | |
| GL (glBindTexture) | |
| GL (glDeleteTextures) | |
| GL (glGenTextures) | |
| GL (glPixelStorei) | |
| GL (glActiveTexture) | |
| GL (glGenBuffers) | |
| GL (glDeleteBuffers) | |
| GL (glBindBuffer) | |
| GL (glBufferData) | |
| GL (glBufferSubData) | |
| GL (glMapBuffer) | |
| GL (glUnmapBuffer) | |
| GL (glClearBufferSubData) | |
| GL (glBufferStorage) | |
| GL (glMapBufferRange) | |
| GL (glClientWaitSync) | |
| GL (glFenceSync) | |
| GL (glDeleteSync) | |
| GL (glGenVertexArrays) | |
| GL (glDeleteVertexArrays) | |
| GL (glBindVertexArray) | |
| GL (glCreateProgram) | |
| GL (glDeleteProgram) | |
| GL (glLinkProgram) | |
| GL (glUseProgram) | |
| GL (glGetProgramiv) | |
| GL (glGetProgramInfoLog) | |
| GL (glCreateShader) | |
| GL (glDeleteShader) | |
| GL (glShaderSource) | |
| GL (glCompileShader) | |
| GL (glAttachShader) | |
| GL (glGetShaderiv) | |
| GL (glGetShaderInfoLog) | |
| GL (glGetUniformLocation) | |
| GL (glUniform1i) | |
| GL (glUniform1f) | |
| GL (glUniform2f) | |
| GL (glUniform4f) | |
| GL (glGetAttribLocation) | |
| GL (glEnableVertexAttribArray) | |
| GL (glDisableVertexAttribArray) | |
| GL (glVertexAttribPointer) | |
| GL (glBindFragDataLocation) | |
| static std::optional< std::string_view > | GlGetString (GLenum name) |
| bool | HasStringInExtensionList (std::string_view string, std::string_view substring) |
| Find a substring in a string made of space delimited elements. | |
| static bool | IsOpenGLExtensionSupported (std::string_view extension) |
| Check if an OpenGL extension is supported by the current context. | |
| bool | IsOpenGLVersionAtLeast (uint8_t major, uint8_t minor) |
| Check if the current OpenGL version is equal or higher than a given one. | |
| template<typename F > | |
| static bool | BindGLProc (F &f, const char *name) |
| Try loading an OpenGL function. | |
| static bool | BindBasicInfoProcs () |
| Bind basic information functions. | |
| static bool | BindBasicOpenGLProcs () |
| Bind OpenGL 1.0 and 1.1 functions. | |
| static bool | BindTextureExtensions () |
| Bind texture-related extension functions. | |
| static bool | BindVBOExtension () |
| Bind vertex buffer object extension functions. | |
| static bool | BindVBAExtension () |
| Bind vertex array object extension functions. | |
| static bool | BindShaderExtensions () |
| Bind extension functions for shader support. | |
| static bool | BindPersistentBufferExtensions () |
| Bind extension functions for persistent buffer mapping. | |
| void APIENTRY | DebugOutputCallback (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *message, const void *userParam) |
| Callback to receive OpenGL debug messages. | |
| void | SetupDebugOutput () |
| Enable OpenGL debug messages if supported. | |
| static std::tuple< uint8_t, uint8_t > | DecodeVersion (std::string_view ver) |
| static bool | VerifyShader (GLuint shader) |
| Check a shader for compilation errors and log them if necessary. | |
| static bool | VerifyProgram (GLuint program) |
| Check a program for link errors and log them if necessary. | |
| template<class T > | |
| static void | ClearPixelBuffer (size_t len, T data) |
| Clear the bound pixel buffer to a specific value. | |
Variables | |
| static const int | MAX_CACHED_CURSORS = 48 |
| Maximum number of cursor sprites to cache. | |
| GetOGLProcAddressProc | GetOGLProcAddress |
| static uint8_t | _gl_major_ver = 0 |
| Major OpenGL version. | |
| static uint8_t | _gl_minor_ver = 0 |
| Minor OpenGL version. | |
OpenGL video driver support.
Definition in file opengl.cpp.
| #define GL | ( | function | ) | static decltype(&function) _ ## function |
Definition at line 48 of file opengl.cpp.
| #define GL_GLEXT_PROTOTYPES |
Definition at line 21 of file opengl.cpp.
|
static |
Bind basic information functions.
Definition at line 224 of file opengl.cpp.
References BindGLProc().
Referenced by OpenGLBackend::Init().
|
static |
Bind OpenGL 1.0 and 1.1 functions.
Definition at line 234 of file opengl.cpp.
References BindGLProc().
Referenced by OpenGLBackend::Init().
|
static |
Try loading an OpenGL function.
| F | Type of the function pointer. |
| f | Reference where to store the function pointer in. |
| name | Name of the function. |
Definition at line 217 of file opengl.cpp.
Referenced by BindBasicInfoProcs(), BindBasicOpenGLProcs(), BindPersistentBufferExtensions(), BindShaderExtensions(), BindTextureExtensions(), BindVBAExtension(), BindVBOExtension(), and SetupDebugOutput().
|
static |
Bind extension functions for persistent buffer mapping.
Definition at line 384 of file opengl.cpp.
References BindGLProc(), IsOpenGLExtensionSupported(), and IsOpenGLVersionAtLeast().
Referenced by OpenGLBackend::Init().
|
static |
Bind extension functions for shader support.
Definition at line 318 of file opengl.cpp.
References BindGLProc(), IsOpenGLExtensionSupported(), and IsOpenGLVersionAtLeast().
Referenced by OpenGLBackend::Init().
|
static |
Bind texture-related extension functions.
Definition at line 257 of file opengl.cpp.
References BindGLProc(), and IsOpenGLVersionAtLeast().
Referenced by OpenGLBackend::Init().
|
static |
Bind vertex array object extension functions.
Definition at line 299 of file opengl.cpp.
References BindGLProc(), IsOpenGLExtensionSupported(), and IsOpenGLVersionAtLeast().
Referenced by OpenGLBackend::Init().
|
static |
Bind vertex buffer object extension functions.
Definition at line 269 of file opengl.cpp.
References BindGLProc(), IsOpenGLExtensionSupported(), and IsOpenGLVersionAtLeast().
Referenced by OpenGLBackend::Init().
|
static |
Clear the bound pixel buffer to a specific value.
| len | Length of the buffer. |
| data | Value to set. |
| T | Pixel type. |
Definition at line 897 of file opengl.cpp.
| void APIENTRY DebugOutputCallback | ( | GLenum | source, |
| GLenum | type, | ||
| GLuint | id, | ||
| GLenum | severity, | ||
| GLsizei | length, | ||
| const GLchar * | message, | ||
| const void * | userParam | ||
| ) |
Callback to receive OpenGL debug messages.
Definition at line 405 of file opengl.cpp.
References Debug.
Referenced by SetupDebugOutput().
|
static |
Definition at line 517 of file opengl.cpp.
|
static |
Definition at line 136 of file opengl.cpp.
| bool HasStringInExtensionList | ( | std::string_view | string, |
| std::string_view | substring | ||
| ) |
Find a substring in a string made of space delimited elements.
The substring has to match the complete element, partial matches don't count.
| string | List of space delimited elements. |
| substring | Substring to find. |
Definition at line 150 of file opengl.cpp.
References StringConsumer::SKIP_ALL_SEPARATORS.
Referenced by IsOpenGLExtensionSupported().
|
static |
Check if an OpenGL extension is supported by the current context.
| extension | The extension string to test. |
Definition at line 165 of file opengl.cpp.
References HasStringInExtensionList(), and IsOpenGLVersionAtLeast().
Referenced by BindPersistentBufferExtensions(), BindShaderExtensions(), BindVBAExtension(), BindVBOExtension(), OpenGLBackend::Init(), and SetupDebugOutput().
| bool IsOpenGLVersionAtLeast | ( | uint8_t | major, |
| uint8_t | minor | ||
| ) |
Check if the current OpenGL version is equal or higher than a given one.
| major | Minimal major version. |
| minor | Minimal minor version. |
Definition at line 204 of file opengl.cpp.
References _gl_major_ver, and _gl_minor_ver.
Referenced by BindPersistentBufferExtensions(), BindShaderExtensions(), BindTextureExtensions(), BindVBAExtension(), BindVBOExtension(), OpenGLBackend::Init(), OpenGLBackend::InitShaders(), IsOpenGLExtensionSupported(), and SetupDebugOutput().
| void SetupDebugOutput | ( | ) |
Enable OpenGL debug messages if supported.
Definition at line 429 of file opengl.cpp.
References BindGLProc(), DebugOutputCallback(), IsOpenGLExtensionSupported(), and IsOpenGLVersionAtLeast().
Referenced by OpenGLBackend::Init().
|
static |
Check a program for link errors and log them if necessary.
| program | Program to check. |
Definition at line 783 of file opengl.cpp.
References ReusableBuffer< T >::Allocate(), Debug, and ReusableBuffer< T >::GetBuffer().
Referenced by OpenGLBackend::InitShaders().
|
static |
Check a shader for compilation errors and log them if necessary.
| shader | Shader to check. |
Definition at line 760 of file opengl.cpp.
References ReusableBuffer< T >::Allocate(), Debug, and ReusableBuffer< T >::GetBuffer().
Referenced by OpenGLBackend::InitShaders().
|
static |
Major OpenGL version.
Definition at line 194 of file opengl.cpp.
Referenced by OpenGLBackend::Init(), and IsOpenGLVersionAtLeast().
|
static |
Minor OpenGL version.
Definition at line 195 of file opengl.cpp.
Referenced by OpenGLBackend::Init(), and IsOpenGLVersionAtLeast().
| GetOGLProcAddressProc GetOGLProcAddress |
Definition at line 134 of file opengl.cpp.
|
static |
Maximum number of cursor sprites to cache.
Definition at line 130 of file opengl.cpp.