the first working version
This commit is contained in:
parent
dfc6dc2fa1
commit
d1ffab40cc
|
|
@ -20,29 +20,23 @@
|
||||||
//------------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------------
|
||||||
typedef enum GameScreen { LOGO = 0, TITLE, GAMEPLAY, ENDING } GameScreen;
|
typedef enum GameScreen { LOGO = 0, TITLE, GAMEPLAY, ENDING } GameScreen;
|
||||||
|
|
||||||
//------------------------------------------------------------------------------------
|
|
||||||
// Program main entry point
|
|
||||||
//------------------------------------------------------------------------------------
|
|
||||||
int ios_main(int argc, char * argv[])
|
|
||||||
{
|
|
||||||
// Initialization
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
const int screenWidth = 800;
|
const int screenWidth = 800;
|
||||||
const int screenHeight = 450;
|
const int screenHeight = 450;
|
||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [core] example - basic screen manager");
|
|
||||||
|
|
||||||
GameScreen currentScreen = LOGO;
|
GameScreen currentScreen = LOGO;
|
||||||
|
|
||||||
// TODO: Initialize all required variables and load all required data here!
|
|
||||||
|
|
||||||
int framesCounter = 0; // Useful to count frames
|
int framesCounter = 0; // Useful to count frames
|
||||||
|
|
||||||
|
void ios_ready(){
|
||||||
|
// Initialization
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
InitWindow(screenWidth, screenHeight, "raylib [core] example - basic screen manager");
|
||||||
|
|
||||||
|
// TODO: Initialize all required variables and load all required data here!
|
||||||
SetTargetFPS(60); // Set desired framerate (frames-per-second)
|
SetTargetFPS(60); // Set desired framerate (frames-per-second)
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
}
|
||||||
|
|
||||||
// Main game loop
|
|
||||||
while (!WindowShouldClose()) // Detect window close button or ESC key
|
void ios_update()
|
||||||
{
|
{
|
||||||
// Update
|
// Update
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
|
@ -51,7 +45,6 @@ int ios_main(int argc, char * argv[])
|
||||||
case LOGO:
|
case LOGO:
|
||||||
{
|
{
|
||||||
// TODO: Update LOGO screen variables here!
|
// TODO: Update LOGO screen variables here!
|
||||||
|
|
||||||
framesCounter++; // Count frames
|
framesCounter++; // Count frames
|
||||||
|
|
||||||
// Wait for 2 seconds (120 frames) before jumping to TITLE screen
|
// Wait for 2 seconds (120 frames) before jumping to TITLE screen
|
||||||
|
|
@ -140,6 +133,7 @@ int ios_main(int argc, char * argv[])
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ios_destroy(){
|
||||||
// De-Initialization
|
// De-Initialization
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
@ -148,5 +142,4 @@ int ios_main(int argc, char * argv[])
|
||||||
CloseWindow(); // Close window and OpenGL context
|
CloseWindow(); // Close window and OpenGL context
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -341,6 +341,11 @@
|
||||||
CURRENT_PROJECT_VERSION = 1;
|
CURRENT_PROJECT_VERSION = 1;
|
||||||
DEVELOPMENT_TEAM = A7A93GC9AY;
|
DEVELOPMENT_TEAM = A7A93GC9AY;
|
||||||
GCC_C_LANGUAGE_STANDARD = gnu17;
|
GCC_C_LANGUAGE_STANDARD = gnu17;
|
||||||
|
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||||
|
"DEBUG=1",
|
||||||
|
GRAPHICS_API_OPENGL_ES2,
|
||||||
|
PLATFORM_IOS,
|
||||||
|
);
|
||||||
GCC_WARN_64_TO_32_BIT_CONVERSION = NO;
|
GCC_WARN_64_TO_32_BIT_CONVERSION = NO;
|
||||||
GCC_WARN_UNINITIALIZED_AUTOS = YES;
|
GCC_WARN_UNINITIALIZED_AUTOS = YES;
|
||||||
GENERATE_INFOPLIST_FILE = YES;
|
GENERATE_INFOPLIST_FILE = YES;
|
||||||
|
|
@ -379,6 +384,10 @@
|
||||||
CURRENT_PROJECT_VERSION = 1;
|
CURRENT_PROJECT_VERSION = 1;
|
||||||
DEVELOPMENT_TEAM = A7A93GC9AY;
|
DEVELOPMENT_TEAM = A7A93GC9AY;
|
||||||
GCC_C_LANGUAGE_STANDARD = gnu17;
|
GCC_C_LANGUAGE_STANDARD = gnu17;
|
||||||
|
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||||
|
GRAPHICS_API_OPENGL_ES2,
|
||||||
|
PLATFORM_IOS,
|
||||||
|
);
|
||||||
GCC_WARN_64_TO_32_BIT_CONVERSION = NO;
|
GCC_WARN_64_TO_32_BIT_CONVERSION = NO;
|
||||||
GCC_WARN_UNINITIALIZED_AUTOS = YES;
|
GCC_WARN_UNINITIALIZED_AUTOS = YES;
|
||||||
GENERATE_INFOPLIST_FILE = YES;
|
GENERATE_INFOPLIST_FILE = YES;
|
||||||
|
|
|
||||||
|
|
@ -49,10 +49,17 @@
|
||||||
// TODO: Include the platform specific libraries
|
// TODO: Include the platform specific libraries
|
||||||
#include "libEGL/libEGL.h"
|
#include "libEGL/libEGL.h"
|
||||||
|
|
||||||
|
// iOS only supports callbacks
|
||||||
|
// We are not able to give users full control of the game loop
|
||||||
|
extern void ios_ready();
|
||||||
|
extern void ios_update();
|
||||||
|
extern void ios_destroy();
|
||||||
|
|
||||||
#import <UIKit/UIKit.h>
|
#import <UIKit/UIKit.h>
|
||||||
|
|
||||||
/* GameViewController */
|
/* GameViewController */
|
||||||
@interface GameViewController : UIViewController
|
@interface GameViewController : UIViewController
|
||||||
|
- (void)update;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
/* AppDelegate */
|
/* AppDelegate */
|
||||||
|
|
@ -476,10 +483,17 @@ int InitPlatform(void)
|
||||||
EGL_NONE
|
EGL_NONE
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// const EGLint contextAttribs[] =
|
||||||
|
// {
|
||||||
|
// EGL_CONTEXT_CLIENT_VERSION, 2,
|
||||||
|
// EGL_NONE
|
||||||
|
// };
|
||||||
|
|
||||||
const EGLint contextAttribs[] =
|
const EGLint contextAttribs[] =
|
||||||
{
|
{
|
||||||
EGL_CONTEXT_CLIENT_VERSION, 2,
|
EGL_CONTEXT_MAJOR_VERSION, 2,
|
||||||
EGL_NONE
|
EGL_CONTEXT_MINOR_VERSION, 0,
|
||||||
|
EGL_NONE,
|
||||||
};
|
};
|
||||||
|
|
||||||
EGLint numConfigs = 0;
|
EGLint numConfigs = 0;
|
||||||
|
|
@ -590,7 +604,7 @@ int InitPlatform(void)
|
||||||
CORE.Storage.basePath = GetWorkingDirectory();
|
CORE.Storage.basePath = GetWorkingDirectory();
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
|
|
||||||
TRACELOG(LOG_INFO, "PLATFORM: CUSTOM: Initialized successfully");
|
TRACELOG(LOG_INFO, "PLATFORM: IOS: Initialized successfully");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -632,6 +646,11 @@ void ClosePlatform(void)
|
||||||
platform.viewController = self;
|
platform.viewController = self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)update
|
||||||
|
{
|
||||||
|
ios_update();
|
||||||
|
}
|
||||||
|
|
||||||
- (bool)prefersStatusBarHidden
|
- (bool)prefersStatusBarHidden
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -644,10 +663,14 @@ void ClosePlatform(void)
|
||||||
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
|
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
|
||||||
// Override point for customization after application launch.
|
// Override point for customization after application launch.
|
||||||
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
|
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
|
||||||
NSLog(@"bounds: %@", NSStringFromCGRect([UIScreen mainScreen].bounds));
|
|
||||||
self.window.backgroundColor = [UIColor redColor];
|
self.window.backgroundColor = [UIColor redColor];
|
||||||
self.window.rootViewController = [[GameViewController alloc] init];
|
self.window.rootViewController = [[GameViewController alloc] init];
|
||||||
[self.window makeKeyAndVisible];
|
[self.window makeKeyAndVisible];
|
||||||
|
|
||||||
|
ios_ready();
|
||||||
|
|
||||||
|
CADisplayLink *displayLink = [CADisplayLink displayLinkWithTarget:self.window.rootViewController selector:@selector(update)];
|
||||||
|
[displayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -668,11 +691,11 @@ void ClosePlatform(void)
|
||||||
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
|
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
- (void)applicationWillTerminate:(UIApplication *)application {
|
||||||
|
ios_destroy();
|
||||||
|
}
|
||||||
|
|
||||||
// To allow easier porting to android, we allow the user to define a
|
@end
|
||||||
// main function which we call from android_main, defined by ourselves
|
|
||||||
extern int ios_main(int argc, char *argv[]);
|
|
||||||
|
|
||||||
/* main() */
|
/* main() */
|
||||||
int main(int argc, char * argv[]) {
|
int main(int argc, char * argv[]) {
|
||||||
|
|
|
||||||
|
|
@ -502,7 +502,7 @@ const char *TextFormat(const char *text, ...); // Formatting of tex
|
||||||
#include "platforms/rcore_drm.c"
|
#include "platforms/rcore_drm.c"
|
||||||
#elif defined(PLATFORM_ANDROID)
|
#elif defined(PLATFORM_ANDROID)
|
||||||
#include "platforms/rcore_android.c"
|
#include "platforms/rcore_android.c"
|
||||||
#elif defined(PLATFORM_IOS) || defined(PLATFORM_IOSSIMULATOR)
|
#elif defined(PLATFORM_IOS)
|
||||||
#include "platforms/rcore_ios.c"
|
#include "platforms/rcore_ios.c"
|
||||||
#else
|
#else
|
||||||
// TODO: Include your custom platform backend!
|
// TODO: Include your custom platform backend!
|
||||||
|
|
|
||||||
|
|
@ -815,7 +815,14 @@ RLAPI void rlLoadDrawQuad(void); // Load and draw a quad
|
||||||
#include "external/glad.h" // GLAD extensions loading library, includes OpenGL headers
|
#include "external/glad.h" // GLAD extensions loading library, includes OpenGL headers
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(GRAPHICS_API_OPENGL_ES3)
|
#if defined(PLATFORM_IOS)
|
||||||
|
#ifndef GRAPHICS_API_OPENGL_ES2
|
||||||
|
#error "GRAPHICS_API_OPENGL_ES2 required on PLATFORM_IOS"
|
||||||
|
#endif
|
||||||
|
#include "libGLESv2/GLES/glext.h"
|
||||||
|
#include "libGLESv2/GLES2/gl2.h"
|
||||||
|
#include "libGLESv2/GLES2/gl2ext.h" // OpenGL ES 2.0 extensions library
|
||||||
|
#elif defined(GRAPHICS_API_OPENGL_ES3)
|
||||||
#include <GLES3/gl3.h> // OpenGL ES 3.0 library
|
#include <GLES3/gl3.h> // OpenGL ES 3.0 library
|
||||||
#define GL_GLEXT_PROTOTYPES
|
#define GL_GLEXT_PROTOTYPES
|
||||||
#include <GLES2/gl2ext.h> // OpenGL ES 2.0 extensions library
|
#include <GLES2/gl2ext.h> // OpenGL ES 2.0 extensions library
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user