mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 05:07:45 +00:00
LibAccelGfx: Switch from OpenGL ES 2.0 to OpenGL 3.3
Desktop OpenGL 3.3 is currently supported by both EGL on Linux and macOS.
This commit is contained in:
parent
2d12d1538d
commit
99caf4e649
2 changed files with 24 additions and 9 deletions
|
@ -49,6 +49,12 @@ OwnPtr<Context> Context::create()
|
||||||
EGLint minor;
|
EGLint minor;
|
||||||
eglInitialize(egl_display, &major, &minor);
|
eglInitialize(egl_display, &major, &minor);
|
||||||
|
|
||||||
|
EGLBoolean ok = eglBindAPI(EGL_OPENGL_API);
|
||||||
|
if (ok == EGL_FALSE) {
|
||||||
|
dbgln("eglBindAPI failed");
|
||||||
|
VERIFY_NOT_REACHED();
|
||||||
|
}
|
||||||
|
|
||||||
static EGLint const config_attributes[] = {
|
static EGLint const config_attributes[] = {
|
||||||
EGL_SURFACE_TYPE, EGL_PBUFFER_BIT,
|
EGL_SURFACE_TYPE, EGL_PBUFFER_BIT,
|
||||||
EGL_BLUE_SIZE, 8,
|
EGL_BLUE_SIZE, 8,
|
||||||
|
@ -64,10 +70,15 @@ OwnPtr<Context> Context::create()
|
||||||
eglChooseConfig(egl_display, config_attributes, &egl_config, 1, &num_configs);
|
eglChooseConfig(egl_display, config_attributes, &egl_config, 1, &num_configs);
|
||||||
|
|
||||||
static EGLint const context_attributes[] = {
|
static EGLint const context_attributes[] = {
|
||||||
EGL_CONTEXT_CLIENT_VERSION, 2,
|
EGL_CONTEXT_MAJOR_VERSION, 3,
|
||||||
|
EGL_CONTEXT_MINOR_VERSION, 3,
|
||||||
EGL_NONE
|
EGL_NONE
|
||||||
};
|
};
|
||||||
EGLContext egl_context = eglCreateContext(egl_display, egl_config, EGL_NO_CONTEXT, context_attributes);
|
EGLContext egl_context = eglCreateContext(egl_display, egl_config, EGL_NO_CONTEXT, context_attributes);
|
||||||
|
if (egl_context == EGL_FALSE) {
|
||||||
|
dbgln("eglCreateContext failed");
|
||||||
|
VERIFY_NOT_REACHED();
|
||||||
|
}
|
||||||
|
|
||||||
EGLBoolean result = eglMakeCurrent(egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE, egl_context);
|
EGLBoolean result = eglMakeCurrent(egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE, egl_context);
|
||||||
if (result == EGL_FALSE) {
|
if (result == EGL_FALSE) {
|
||||||
|
|
|
@ -43,23 +43,26 @@ Gfx::FloatRect Painter::to_clip_space(Gfx::FloatRect const& screen_rect) const
|
||||||
}
|
}
|
||||||
|
|
||||||
char const* vertex_shader_source = R"(
|
char const* vertex_shader_source = R"(
|
||||||
attribute vec2 aVertexPosition;
|
#version 330 core
|
||||||
|
in vec2 aVertexPosition;
|
||||||
void main() {
|
void main() {
|
||||||
gl_Position = vec4(aVertexPosition, 0.0, 1.0);
|
gl_Position = vec4(aVertexPosition, 0.0, 1.0);
|
||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
|
|
||||||
char const* solid_color_fragment_shader_source = R"(
|
char const* solid_color_fragment_shader_source = R"(
|
||||||
precision mediump float;
|
#version 330 core
|
||||||
uniform vec4 uColor;
|
uniform vec4 uColor;
|
||||||
|
out vec4 fragColor;
|
||||||
void main() {
|
void main() {
|
||||||
gl_FragColor = uColor;
|
fragColor = uColor;
|
||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
|
|
||||||
char const* blit_vertex_shader_source = R"(
|
char const* blit_vertex_shader_source = R"(
|
||||||
attribute vec4 aVertexPosition;
|
#version 330 core
|
||||||
varying vec2 vTextureCoord;
|
in vec4 aVertexPosition;
|
||||||
|
out vec2 vTextureCoord;
|
||||||
void main() {
|
void main() {
|
||||||
gl_Position = vec4(aVertexPosition.xy, 0.0, 1.0);
|
gl_Position = vec4(aVertexPosition.xy, 0.0, 1.0);
|
||||||
vTextureCoord = aVertexPosition.zw;
|
vTextureCoord = aVertexPosition.zw;
|
||||||
|
@ -67,12 +70,13 @@ void main() {
|
||||||
)";
|
)";
|
||||||
|
|
||||||
char const* blit_fragment_shader_source = R"(
|
char const* blit_fragment_shader_source = R"(
|
||||||
precision mediump float;
|
#version 330 core
|
||||||
uniform vec4 uColor;
|
uniform vec4 uColor;
|
||||||
varying vec2 vTextureCoord;
|
in vec2 vTextureCoord;
|
||||||
uniform sampler2D uSampler;
|
uniform sampler2D uSampler;
|
||||||
|
out vec4 fragColor;
|
||||||
void main() {
|
void main() {
|
||||||
gl_FragColor = texture2D(uSampler, vTextureCoord) * uColor;
|
fragColor = texture2D(uSampler, vTextureCoord) * uColor;
|
||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue