Added debug labels for the OpenGL ES objects created with SDL_GL_CreateContext on iOS. More misc. code cleanup.
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 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162
diff --git a/src/video/uikit/SDL_uikitmodes.m b/src/video/uikit/SDL_uikitmodes.m
index 26858a8..8b9d7c9 100644
--- a/src/video/uikit/SDL_uikitmodes.m
+++ b/src/video/uikit/SDL_uikitmodes.m
@@ -150,7 +150,6 @@ UIKit_AddDisplay(UIScreen *uiscreen)
display.driverdata = (void *) CFBridgingRetain(data);
SDL_AddVideoDisplay(&display);
-
return 0;
}
diff --git a/src/video/uikit/SDL_uikitopenglview.h b/src/video/uikit/SDL_uikitopenglview.h
index 6502d03..8221988 100644
--- a/src/video/uikit/SDL_uikitopenglview.h
+++ b/src/video/uikit/SDL_uikitopenglview.h
@@ -57,6 +57,8 @@
- (void)updateFrame;
+- (void)setDebugLabels;
+
- (void)setAnimationCallback:(int)interval
callback:(void (*)(void*))callback
callbackParam:(void*)callbackParam;
diff --git a/src/video/uikit/SDL_uikitopenglview.m b/src/video/uikit/SDL_uikitopenglview.m
index 5da30c3..f0237ca 100644
--- a/src/video/uikit/SDL_uikitopenglview.m
+++ b/src/video/uikit/SDL_uikitopenglview.m
@@ -93,7 +93,7 @@
if (sRGB) {
/* sRGB EAGL drawable support was added in iOS 7. */
- if (UIKit_IsSystemVersionAtLeast(@"7.0")) {
+ if (UIKit_IsSystemVersionAtLeast(7.0)) {
colorFormat = kEAGLColorFormatSRGBA8;
} else {
SDL_SetError("sRGB drawables are not supported.");
@@ -164,6 +164,8 @@
}
glBindRenderbuffer(GL_RENDERBUFFER, viewRenderbuffer);
+
+ [self setDebugLabels];
}
return self;
@@ -200,6 +202,27 @@
}
glBindRenderbuffer(GL_RENDERBUFFER, viewRenderbuffer);
+
+ [self setDebugLabels];
+}
+
+- (void)setDebugLabels
+{
+ if (viewFramebuffer != 0) {
+ glLabelObjectEXT(GL_FRAMEBUFFER, viewFramebuffer, 0, "context FBO");
+ }
+
+ if (viewRenderbuffer != 0) {
+ glLabelObjectEXT(GL_RENDERBUFFER, viewRenderbuffer, 0, "context color buffer");
+ }
+
+ if (depthRenderbuffer != 0) {
+ if (depthBufferFormat == GL_DEPTH24_STENCIL8_OES) {
+ glLabelObjectEXT(GL_RENDERBUFFER, depthRenderbuffer, 0, "context depth-stencil buffer");
+ } else {
+ glLabelObjectEXT(GL_RENDERBUFFER, depthRenderbuffer, 0, "context depth buffer");
+ }
+ }
}
- (void)setAnimationCallback:(int)interval
diff --git a/src/video/uikit/SDL_uikitvideo.h b/src/video/uikit/SDL_uikitvideo.h
index dec49cd..dac80a2 100644
--- a/src/video/uikit/SDL_uikitvideo.h
+++ b/src/video/uikit/SDL_uikitvideo.h
@@ -25,7 +25,7 @@
#include "../SDL_sysvideo.h"
-BOOL UIKit_IsSystemVersionAtLeast(NSString *version);
+BOOL UIKit_IsSystemVersionAtLeast(double version);
CGRect UIKit_ComputeViewFrame(SDL_Window *window, UIScreen *screen);
#endif /* _SDL_uikitvideo_h */
diff --git a/src/video/uikit/SDL_uikitvideo.m b/src/video/uikit/SDL_uikitvideo.m
index 5d4e812..c2ceb0d 100644
--- a/src/video/uikit/SDL_uikitvideo.m
+++ b/src/video/uikit/SDL_uikitvideo.m
@@ -130,16 +130,15 @@ UIKit_VideoQuit(_THIS)
}
BOOL
-UIKit_IsSystemVersionAtLeast(NSString *version)
+UIKit_IsSystemVersionAtLeast(double version)
{
- NSString *sysversion = [UIDevice currentDevice].systemVersion;
- return [sysversion compare:version options:NSNumericSearch] != NSOrderedAscending;
+ return [[UIDevice currentDevice].systemVersion doubleValue] >= version;
}
CGRect
UIKit_ComputeViewFrame(SDL_Window *window, UIScreen *screen)
{
- BOOL hasiOS7 = UIKit_IsSystemVersionAtLeast(@"7.0");
+ BOOL hasiOS7 = UIKit_IsSystemVersionAtLeast(7.0);
if (hasiOS7 || (window->flags & (SDL_WINDOW_BORDERLESS|SDL_WINDOW_FULLSCREEN))) {
/* The view should always show behind the status bar in iOS 7+. */
diff --git a/src/video/uikit/SDL_uikitview.m b/src/video/uikit/SDL_uikitview.m
index 2cb07ca..7238baf 100644
--- a/src/video/uikit/SDL_uikitview.m
+++ b/src/video/uikit/SDL_uikitview.m
@@ -193,19 +193,17 @@ void _uikit_keyboard_init();
/* UITextFieldDelegate method. Invoked when user types something. */
- (BOOL)textField:(UITextField *)_textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
- if ([string length] == 0) {
+ NSUInteger len = string.length;
+
+ if (len == 0) {
/* it wants to replace text with nothing, ie a delete */
SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_BACKSPACE);
SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_BACKSPACE);
- }
- else {
+ } else {
/* go through all the characters in the string we've been sent
and convert them to key presses */
- int i;
- for (i = 0; i < [string length]; i++) {
-
+ for (int i = 0; i < len; i++) {
unichar c = [string characterAtIndex:i];
-
Uint16 mod = 0;
SDL_Scancode code;
@@ -224,16 +222,20 @@ void _uikit_keyboard_init();
/* If character uses shift, press shift down */
SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_LSHIFT);
}
+
/* send a keydown and keyup even for the character */
SDL_SendKeyboardKey(SDL_PRESSED, code);
SDL_SendKeyboardKey(SDL_RELEASED, code);
+
if (mod & KMOD_SHIFT) {
/* If character uses shift, press shift back up */
SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_LSHIFT);
}
}
+
SDL_SendKeyboardText([string UTF8String]);
}
+
return NO; /* don't allow the edit! (keep placeholder text there) */
}