[Feat] (MG_Impl/EGL): Implement a simplified egl temporarily.

This commit is contained in:
BZLZHH
2025-07-11 19:16:56 +08:00
parent 3078667e1d
commit f928661045
6 changed files with 250 additions and 28 deletions
@@ -0,0 +1,85 @@
#include "../../../Includes.h"
MOBILEGL_EGL_API EGLSurface eglCreateWindowSurface(EGLDisplay dpy, EGLConfig config, NativeWindowType window,
const EGLint* attrib_list) {
return MobileGL::MG_Impl::EGLImpl::CreateWindowSurface(dpy, config, window, attrib_list);
}
MOBILEGL_EGL_API EGLBoolean eglChooseConfig(EGLDisplay dpy, const EGLint* attrib_list, EGLConfig* configs,
EGLint config_size, EGLint* num_config) {
return MobileGL::MG_Impl::EGLImpl::ChooseConfig(dpy, attrib_list, configs, config_size, num_config);
}
MOBILEGL_EGL_API EGLContext eglCreateContext(EGLDisplay dpy, EGLConfig config, EGLContext shareCtx,
const EGLint* attrib_list) {
return MobileGL::MG_Impl::EGLImpl::CreateContext(dpy, config, shareCtx, attrib_list);
}
MOBILEGL_EGL_API EGLBoolean eglInitialize(EGLDisplay dpy, EGLint* major, EGLint* minor) {
return MobileGL::MG_Impl::EGLImpl::Initialize(dpy, major, minor);
}
MOBILEGL_EGL_API EGLDisplay eglGetDisplay(NativeDisplayType display) {
return MobileGL::MG_Impl::EGLImpl::GetDisplay(display);
}
MOBILEGL_EGL_API EGLint eglGetError() {
return MobileGL::MG_Impl::EGLImpl::GetError();
}
MOBILEGL_EGL_API EGLBoolean eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx) {
return MobileGL::MG_Impl::EGLImpl::MakeCurrent(dpy, draw, read, ctx);
}
MOBILEGL_EGL_API EGLBoolean eglDestroyContext(EGLDisplay dpy, EGLContext ctx) {
return MobileGL::MG_Impl::EGLImpl::DestroyContext(dpy, ctx);
}
MOBILEGL_EGL_API EGLBoolean eglDestroySurface(EGLDisplay dpy, EGLSurface surface) {
return MobileGL::MG_Impl::EGLImpl::DestroySurface(dpy, surface);
}
MOBILEGL_EGL_API EGLBoolean eglTerminate(EGLDisplay dpy) {
return MobileGL::MG_Impl::EGLImpl::Terminate(dpy);
}
MOBILEGL_EGL_API EGLBoolean eglReleaseThread(void) {
return MobileGL::MG_Impl::EGLImpl::ReleaseThread();
}
MOBILEGL_EGL_API EGLContext eglGetCurrentContext(void) {
return MobileGL::MG_Impl::EGLImpl::GetCurrentContext();
}
MOBILEGL_EGL_API EGLBoolean eglGetConfigAttrib(EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint* value) {
return MobileGL::MG_Impl::EGLImpl::GetConfigAttrib(dpy, config, attribute, value);
}
MOBILEGL_EGL_API EGLBoolean eglBindAPI(EGLenum api) {
return MobileGL::MG_Impl::EGLImpl::BindAPI(api);
}
MOBILEGL_EGL_API EGLSurface eglGetCurrentSurface(EGLint readdraw) {
return MobileGL::MG_Impl::EGLImpl::GetCurrentSurface(readdraw);
}
MOBILEGL_EGL_API EGLBoolean eglQuerySurface(EGLDisplay display, EGLSurface surface, EGLint attribute, EGLint* value) {
return MobileGL::MG_Impl::EGLImpl::QuerySurface(display, surface, attribute, value);
}
MOBILEGL_EGL_API EGLBoolean eglSwapInterval(EGLDisplay dpy, EGLint interval) {
return MobileGL::MG_Impl::EGLImpl::SwapInterval(dpy, interval);
}
MOBILEGL_EGL_API EGLBoolean eglSwapBuffers(EGLDisplay dpy, EGLSurface draw) {
return MobileGL::MG_Impl::EGLImpl::SwapBuffers(dpy, draw);
}
MOBILEGL_EGL_API EGLSurface eglCreatePbufferSurface(EGLDisplay dpy, EGLConfig config, const EGLint* attrib_list) {
return MobileGL::MG_Impl::EGLImpl::CreatePbufferSurface(dpy, config, attrib_list);
}
MOBILEGL_EGL_API __eglMustCastToProperFunctionPointerType eglGetProcAddress(const char* name) {
return MobileGL::MG_Impl::EGLImpl::GetProcAddress(name);
}
@@ -0,0 +1,101 @@
#include "../../../Includes.h"
namespace MobileGL {
namespace MG_Impl::EGLImpl {
// TODO: Implement complete EGL functionality
EGLSurface CreateWindowSurface(EGLDisplay dpy, EGLConfig config, NativeWindowType window,
const EGLint* attrib_list) {
return (EGLSurface)1;
}
EGLBoolean ChooseConfig(EGLDisplay dpy, const EGLint* attrib_list, EGLConfig* configs,
EGLint config_size, EGLint* num_config) {
*num_config = 1;
return EGL_TRUE;
}
EGLContext CreateContext(EGLDisplay dpy, EGLConfig config, EGLContext shareCtx,
const EGLint* attrib_list) {
return (EGLContext)1;
}
EGLBoolean Initialize(EGLDisplay dpy, EGLint* major, EGLint* minor) {
if (major) *major = 1;
if (minor) *minor = 5;
return EGL_TRUE;
}
EGLDisplay GetDisplay(NativeDisplayType display) {
return (EGLDisplay)1;
}
EGLint GetError() {
return EGL_SUCCESS;
}
EGLBoolean MakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx) {
return EGL_TRUE;
}
EGLBoolean DestroyContext(EGLDisplay dpy, EGLContext ctx) {
return EGL_TRUE;
}
EGLBoolean DestroySurface(EGLDisplay dpy, EGLSurface surface) {
return EGL_TRUE;
}
EGLBoolean Terminate(EGLDisplay dpy) {
return EGL_TRUE;
}
EGLBoolean ReleaseThread(void) {
return EGL_TRUE;
}
EGLContext GetCurrentContext(void) {
return (EGLContext)1;
}
EGLBoolean GetConfigAttrib(EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint* value) {
if (attribute == EGL_NATIVE_VISUAL_ID)
*value = AHARDWAREBUFFER_FORMAT_R8G8B8A8_UNORM;
return EGL_TRUE;
}
EGLBoolean BindAPI(EGLenum api) {
return EGL_TRUE;
}
EGLSurface GetCurrentSurface(EGLint readdraw) {
return (EGLSurface)1;
}
EGLBoolean QuerySurface(EGLDisplay display, EGLSurface surface, EGLint attribute, EGLint* value) {
return EGL_TRUE;
}
EGLBoolean SwapInterval(EGLDisplay dpy, EGLint interval) {
return EGL_TRUE;
}
EGLBoolean SwapBuffers(EGLDisplay dpy, EGLSurface draw) {
return EGL_TRUE;
}
EGLSurface CreatePbufferSurface(EGLDisplay dpy, EGLConfig config, const EGLint* attrib_list) {
return (EGLSurface)1;
}
__eglMustCastToProperFunctionPointerType GetProcAddress(const char* name) {
MGLOG_D("eglGetProcAddress(%s)", name);
void* proc = dlsym(RTLD_DEFAULT, (const char*)name);
if (!proc) {
MGLOG_W("Failed to get function: %s", (const char*)name);
return nullptr;
}
return (__eglMustCastToProperFunctionPointerType)proc;
}
}
}
@@ -0,0 +1,29 @@
#pragma once
namespace MobileGL {
namespace MG_Impl::EGLImpl {
EGLSurface CreateWindowSurface(EGLDisplay dpy, EGLConfig config, NativeWindowType window,
const EGLint* attrib_list);
EGLBoolean ChooseConfig(EGLDisplay dpy, const EGLint* attrib_list, EGLConfig* configs,
EGLint config_size, EGLint* num_config);
EGLContext CreateContext(EGLDisplay dpy, EGLConfig config, EGLContext shareCtx,
const EGLint* attrib_list);
EGLBoolean Initialize(EGLDisplay dpy, EGLint* major, EGLint* minor);
EGLDisplay GetDisplay(NativeDisplayType display);
EGLint GetError();
EGLBoolean MakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx);
EGLBoolean DestroyContext(EGLDisplay dpy, EGLContext ctx);
EGLBoolean DestroySurface(EGLDisplay dpy, EGLSurface surface);
EGLBoolean Terminate(EGLDisplay dpy);
EGLBoolean ReleaseThread(void);
EGLContext GetCurrentContext(void);
EGLBoolean GetConfigAttrib(EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint* value);
EGLBoolean BindAPI(EGLenum api);
EGLSurface GetCurrentSurface(EGLint readdraw);
EGLBoolean QuerySurface(EGLDisplay display, EGLSurface surface, EGLint attribute, EGLint* value);
EGLBoolean SwapInterval(EGLDisplay dpy, EGLint interval);
EGLBoolean SwapBuffers(EGLDisplay dpy, EGLSurface draw);
EGLSurface CreatePbufferSurface(EGLDisplay dpy, EGLConfig config, const EGLint* attrib_list);
__eglMustCastToProperFunctionPointerType GetProcAddress(const char* name);
}
}
@@ -1,6 +1,8 @@
#include "../../../Includes.h"
namespace MG_Impl::GLXImpl {
// TODO: Implement complete glx functionality
void* GetProcAddress(const char* name) {
MGLOG_D("glXGetProcAddress(\"%s\")", name);
void* proc = dlsym(RTLD_DEFAULT, (const char*)name);