-
Notifications
You must be signed in to change notification settings - Fork 39
/
common.m
72 lines (55 loc) · 1.33 KB
/
common.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/*
*/
#import <UIKit/UIKit.h>
#include "common.h"
#include <SDL/SDL.h>
#include <stdlib.h>
#import <OpenGLES/EAGL.h>
#import <OpenGLES/ES1/gl.h>
#import <OpenGLES/ES1/glext.h>
#include <FFPlayer/SDL_uikitappdelegate.h>
#include <SDL/SDL_uikitopenglview.h>
/*
Produces a random int x, min <= x <= max
following a uniform distribution
*/
int
randomInt(int min, int max)
{
return min + rand() % (max - min + 1);
}
/*
Produces a random float x, min <= x <= max
following a uniform distribution
*/
float
randomFloat(float min, float max)
{
return rand() / (float) RAND_MAX *(max - min) + min;
}
void iPhonePumpMessages()
{
////av_log(" ","runloop return %u\n",CFRunLoopRunInMode(kCFRunLoopDefaultMode, 1, TRUE));
CFRunLoopRunInMode(kCFRunLoopDefaultMode, 1, TRUE);
}
void
fatalError(const char *string)
{
////(" ","%s: %s\n", string, SDL_GetError());
exit(1);
}
void switchWindows() {
SDLUIKitDelegate *appDelegate = [SDLUIKitDelegate sharedAppDelegate];
NSLog(@"switch windows");
[appDelegate switchTopWindow];
}
int eaglSetContext(void) {
EAGLContext *context
= [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES1];
if (![EAGLContext setCurrentContext:context]) {
NSLog(@"Error: Failed to set current openGL context in [Player initWithFrame:]");
[context release];
return -1;
}
return 0;
}