Update rcore_ios.c

This commit is contained in:
blueloveTH 2024-03-28 10:39:45 +08:00
parent 3c129644e5
commit b69cee5739

View File

@ -456,6 +456,11 @@ void PollInputEvents(void)
// https://developer.apple.com/documentation/uikit/touches_presses_and_gestures // https://developer.apple.com/documentation/uikit/touches_presses_and_gestures
} }
static void swap_uint(unsigned int* a, unsigned int * b){
unsigned tmp = *a;
*a = *b;
*b = tmp;
}
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Module Internal Functions Definition // Module Internal Functions Definition
@ -464,15 +469,6 @@ void PollInputEvents(void)
// Initialize platform: graphics, inputs and more // Initialize platform: graphics, inputs and more
int InitPlatform(void) int InitPlatform(void)
{ {
CORE.Window.display.width = [[UIScreen mainScreen] nativeBounds].size.width;
CORE.Window.display.height = [[UIScreen mainScreen] nativeBounds].size.height;
if(CORE.Window.screen.width == 0){
CORE.Window.screen.width = [[UIScreen mainScreen] bounds].size.width;
}
if(CORE.Window.screen.height == 0){
CORE.Window.screen.height = [[UIScreen mainScreen] bounds].size.height;
}
CORE.Window.fullscreen = true; CORE.Window.fullscreen = true;
CORE.Window.flags |= FLAG_FULLSCREEN_MODE; CORE.Window.flags |= FLAG_FULLSCREEN_MODE;
@ -559,17 +555,21 @@ int InitPlatform(void)
} }
else else
{ {
CORE.Window.display.width = [[UIScreen mainScreen] nativeBounds].size.width;
CORE.Window.display.height = [[UIScreen mainScreen] nativeBounds].size.height;
if(CORE.Window.screen.width == 0){
CORE.Window.screen.width = [[UIScreen mainScreen] bounds].size.width;
}
if(CORE.Window.screen.height == 0){
CORE.Window.screen.height = [[UIScreen mainScreen] bounds].size.height;
}
CORE.Window.render.width = CORE.Window.screen.width; CORE.Window.render.width = CORE.Window.screen.width;
CORE.Window.render.height = CORE.Window.screen.height; CORE.Window.render.height = CORE.Window.screen.height;
CORE.Window.currentFbo.width = CORE.Window.render.width; CORE.Window.currentFbo.width = CORE.Window.render.width;
CORE.Window.currentFbo.height = CORE.Window.render.height; CORE.Window.currentFbo.height = CORE.Window.render.height;
TRACELOG(LOG_INFO, "DISPLAY: Device initialized successfully"); TRACELOG(LOG_INFO, "DISPLAY: Device initialized successfully");
TRACELOG(LOG_INFO, " > Display size: %i x %i", CORE.Window.display.width, CORE.Window.display.height);
TRACELOG(LOG_INFO, " > Screen size: %i x %i", CORE.Window.screen.width, CORE.Window.screen.height);
TRACELOG(LOG_INFO, " > Render size: %i x %i", GetRenderWidth(), GetRenderHeight());
TRACELOG(LOG_INFO, " > Viewport offsets: %i, %i", CORE.Window.renderOffset.x, CORE.Window.renderOffset.y);
TRACELOG(LOG_INFO, " > EGL: %s", eglQueryString(platform.device, EGL_VERSION));
long long orientation = [[UIApplication sharedApplication] statusBarOrientation]; long long orientation = [[UIApplication sharedApplication] statusBarOrientation];
if(orientation == UIInterfaceOrientationPortrait){ if(orientation == UIInterfaceOrientationPortrait){
@ -578,11 +578,19 @@ int InitPlatform(void)
TRACELOG(LOG_INFO, " > Orientation: PortraitUpsideDown"); TRACELOG(LOG_INFO, " > Orientation: PortraitUpsideDown");
}else if(orientation == UIInterfaceOrientationLandscapeLeft){ }else if(orientation == UIInterfaceOrientationLandscapeLeft){
TRACELOG(LOG_INFO, " > Orientation: LandscapeLeft"); TRACELOG(LOG_INFO, " > Orientation: LandscapeLeft");
swap_uint(&CORE.Window.display.width, &CORE.Window.display.height);
}else if(orientation == UIInterfaceOrientationLandscapeRight){ }else if(orientation == UIInterfaceOrientationLandscapeRight){
TRACELOG(LOG_INFO, " > Orientation: LandscapeRight"); TRACELOG(LOG_INFO, " > Orientation: LandscapeRight");
swap_uint(&CORE.Window.display.width, &CORE.Window.display.height);
}else{ }else{
TRACELOG(LOG_INFO, " > Orientation: Unknown"); TRACELOG(LOG_ERROR, " > Orientation: Unknown");
} }
TRACELOG(LOG_INFO, " > Display size: %i x %i", CORE.Window.display.width, CORE.Window.display.height);
TRACELOG(LOG_INFO, " > Screen size: %i x %i", CORE.Window.screen.width, CORE.Window.screen.height);
TRACELOG(LOG_INFO, " > Render size: %i x %i", GetRenderWidth(), GetRenderHeight());
TRACELOG(LOG_INFO, " > Viewport offsets: %i, %i", CORE.Window.renderOffset.x, CORE.Window.renderOffset.y);
TRACELOG(LOG_INFO, " > EGL: %s", eglQueryString(platform.device, EGL_VERSION));
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
// Load OpenGL extensions // Load OpenGL extensions