mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-06-26 15:58:41 +00:00
Harmony port: egl/gles lib
This commit is contained in:
parent
8b6c78c688
commit
9e61fcb7f1
3 changed files with 76 additions and 0 deletions
49
src/video/ohos/SDL_ohosgl.c
Normal file
49
src/video/ohos/SDL_ohosgl.c
Normal 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
|
||||
9
src/video/ohos/SDL_ohosgl.h
Normal file
9
src/video/ohos/SDL_ohosgl.h
Normal 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
|
||||
|
|
@ -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 = {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue