Harmony port: egl/gles lib

This commit is contained in:
Jack253-png 2025-05-31 17:24:09 +08:00
parent 8b6c78c688
commit 9e61fcb7f1
No known key found for this signature in database
GPG key ID: 51EA61206B02D886
3 changed files with 76 additions and 0 deletions

View file

@ -0,0 +1,49 @@
#include "SDL_internal.h"
#ifdef SDL_VIDEO_DRIVER_OHOS
#include "SDL_ohosvideo.h"
#include "../../core/ohos/SDL_ohos.h"
bool OHOS_GLES_MakeCurrent(SDL_VideoDevice *_this, SDL_Window *window, SDL_GLContext context)
{
if (window && context)
{
return SDL_EGL_MakeCurrent(_this, window->internal->egl_xcomponent, context);
}
else
{
return SDL_EGL_MakeCurrent(_this, NULL, NULL);
}
}
SDL_GLContext OHOS_GLES_CreateContext(SDL_VideoDevice *_this, SDL_Window *window)
{
SDL_GLContext result;
SDL_LockMutex(g_ohosPageMutex);
result = SDL_EGL_CreateContext(_this, window->internal->egl_xcomponent);
SDL_UnlockMutex(g_ohosPageMutex);
return result;
}
bool OHOS_GLES_SwapWindow(SDL_VideoDevice *_this, SDL_Window *window)
{
bool result;
SDL_LockMutex(g_ohosPageMutex);
result = SDL_EGL_SwapBuffers(_this, window->internal->egl_xcomponent);
SDL_UnlockMutex(g_ohosPageMutex);
return result;
}
bool OHOS_GLES_LoadLibrary(SDL_VideoDevice *_this, const char *path)
{
return SDL_EGL_LoadLibrary(_this, path, (NativeDisplayType)0, 0);
}
#endif

View file

@ -0,0 +1,9 @@
#ifdef SDL_VIDEO_DRIVER_OHOS
#include "SDL_ohosvideo.h"
bool OHOS_GLES_MakeCurrent(SDL_VideoDevice *_this, SDL_Window *window, SDL_GLContext context);
SDL_GLContext OHOS_GLES_CreateContext(SDL_VideoDevice *_this, SDL_Window *window);
bool OHOS_GLES_SwapWindow(SDL_VideoDevice *_this, SDL_Window *window);
bool OHOS_GLES_LoadLibrary(SDL_VideoDevice *_this, const char *path);
#endif

View file

@ -3,6 +3,7 @@
#ifdef SDL_VIDEO_DRIVER_OHOS
#include "SDL_ohosvulkan.h"
#include "SDL_ohosgl.h"
#include "SDL_ohoswindow.h"
#include "../../core/ohos/SDL_ohos.h"
@ -13,6 +14,10 @@ bool OHOS_VideoInit(SDL_VideoDevice *_this)
void OHOS_VideoQuit(SDL_VideoDevice *_this)
{
}
void OHOS_DeviceFree(SDL_VideoDevice *device)
{
SDL_free(device);
}
static SDL_VideoDevice *OHOS_CreateDevice(void)
{
SDL_VideoDevice *device;
@ -23,6 +28,7 @@ static SDL_VideoDevice *OHOS_CreateDevice(void)
}
device->internal = &videoData;
device->free = OHOS_DeviceFree;
device->VideoInit = OHOS_VideoInit;
device->VideoQuit = OHOS_VideoQuit;
@ -36,6 +42,18 @@ static SDL_VideoDevice *OHOS_CreateDevice(void)
device->CreateSDLWindow = OHOS_CreateWindow;
device->DestroyWindow = OHOS_DestroyWindow;
#ifdef SDL_VIDEO_OPENGL_EGL
device->GL_LoadLibrary = OHOS_GLES_LoadLibrary;
device->GL_MakeCurrent = OHOS_GLES_MakeCurrent;
device->GL_CreateContext = OHOS_GLES_CreateContext;
device->GL_SwapWindow = OHOS_GLES_SwapWindow;
device->GL_GetProcAddress = SDL_EGL_GetProcAddressInternal;
device->GL_UnloadLibrary = SDL_EGL_UnloadLibrary;
device->GL_SetSwapInterval = SDL_EGL_SetSwapInterval;
device->GL_GetSwapInterval = SDL_EGL_GetSwapInterval;
device->GL_DestroyContext = SDL_EGL_DestroyContext;
#endif
return device;
}
VideoBootStrap OHOS_bootstrap = {