Harmony port: entrypoint

This commit is contained in:
Jack253-png 2025-06-01 09:28:52 +08:00
parent 04e80426fb
commit d4039d3d66
No known key found for this signature in database
GPG Key ID: 51EA61206B02D886
3 changed files with 27 additions and 1 deletions

View File

@ -139,6 +139,15 @@ void OHOS_UnlockPage()
SDL_UnlockMutex(g_ohosPageMutex);
}
int OHOS_FetchWidth()
{
return wid;
}
int OHOS_FetchHeight()
{
return hei;
}
static napi_value minus(napi_env env, napi_callback_info info)
{
size_t argc = 2;

View File

@ -10,6 +10,8 @@ void OHOS_windowDataFill(SDL_Window* w);
void OHOS_removeWindow(SDL_Window* w);
void OHOS_LockPage();
void OHOS_UnlockPage();
int OHOS_FetchWidth();
int OHOS_FetchHeight();
typedef struct SDL_VideoData {
SDL_Rect textRect;

View File

@ -1,3 +1,5 @@
#include "SDL3/SDL_pixels.h"
#include "SDL3/SDL_video.h"
#include "SDL_internal.h"
#include "../SDL_sysvideo.h"
@ -9,6 +11,20 @@
bool OHOS_VideoInit(SDL_VideoDevice *_this)
{
_this->num_displays = 1;
SDL_DisplayMode mode;
SDL_zero(mode);
mode.format = SDL_PIXELFORMAT_RGBA32;
mode.w = OHOS_FetchWidth();
mode.h = OHOS_FetchHeight();
mode.refresh_rate = 60;
SDL_DisplayID displayID = SDL_AddBasicVideoDisplay(&mode);
if (displayID == 0) {
return false;
}
_this->displays = SDL_calloc(1, sizeof(SDL_VideoDisplay*));
_this->displays[0] = SDL_GetVideoDisplay(displayID);
return true;
}
void OHOS_VideoQuit(SDL_VideoDevice *_this)
@ -33,7 +49,6 @@ static SDL_VideoDevice *OHOS_CreateDevice(void)
return NULL;
}
device->num_displays = 1;
device->internal = data;
device->free = OHOS_DeviceFree;