Added debug labels for the OpenGL ES objects created with SDL_GL_CreateContext on iOS. iOS-improvements
authorAlex Szpakowski <slime73@gmail.com>
Fri, 21 Nov 2014 03:29:57 -0400
branchiOS-improvements
changeset 952564e3f446d6d7
parent 9524 9de159f9cefd
child 9526 b1e51123fbea
Added debug labels for the OpenGL ES objects created with SDL_GL_CreateContext on iOS.
More misc. code cleanup.
src/video/uikit/SDL_uikitmodes.m
src/video/uikit/SDL_uikitopenglview.h
src/video/uikit/SDL_uikitopenglview.m
src/video/uikit/SDL_uikitvideo.h
src/video/uikit/SDL_uikitvideo.m
src/video/uikit/SDL_uikitview.m
     1.1 --- a/src/video/uikit/SDL_uikitmodes.m	Thu Nov 20 18:45:04 2014 -0400
     1.2 +++ b/src/video/uikit/SDL_uikitmodes.m	Fri Nov 21 03:29:57 2014 -0400
     1.3 @@ -150,7 +150,6 @@
     1.4      display.driverdata = (void *) CFBridgingRetain(data);
     1.5      SDL_AddVideoDisplay(&display);
     1.6  
     1.7 -
     1.8      return 0;
     1.9  }
    1.10  
     2.1 --- a/src/video/uikit/SDL_uikitopenglview.h	Thu Nov 20 18:45:04 2014 -0400
     2.2 +++ b/src/video/uikit/SDL_uikitopenglview.h	Fri Nov 21 03:29:57 2014 -0400
     2.3 @@ -57,6 +57,8 @@
     2.4  
     2.5  - (void)updateFrame;
     2.6  
     2.7 +- (void)setDebugLabels;
     2.8 +
     2.9  - (void)setAnimationCallback:(int)interval
    2.10                      callback:(void (*)(void*))callback
    2.11                 callbackParam:(void*)callbackParam;
     3.1 --- a/src/video/uikit/SDL_uikitopenglview.m	Thu Nov 20 18:45:04 2014 -0400
     3.2 +++ b/src/video/uikit/SDL_uikitopenglview.m	Fri Nov 21 03:29:57 2014 -0400
     3.3 @@ -93,7 +93,7 @@
     3.4  
     3.5          if (sRGB) {
     3.6              /* sRGB EAGL drawable support was added in iOS 7. */
     3.7 -            if (UIKit_IsSystemVersionAtLeast(@"7.0")) {
     3.8 +            if (UIKit_IsSystemVersionAtLeast(7.0)) {
     3.9                  colorFormat = kEAGLColorFormatSRGBA8;
    3.10              } else {
    3.11                  SDL_SetError("sRGB drawables are not supported.");
    3.12 @@ -164,6 +164,8 @@
    3.13          }
    3.14  
    3.15          glBindRenderbuffer(GL_RENDERBUFFER, viewRenderbuffer);
    3.16 +
    3.17 +        [self setDebugLabels];
    3.18      }
    3.19  
    3.20      return self;
    3.21 @@ -200,6 +202,27 @@
    3.22      }
    3.23  
    3.24      glBindRenderbuffer(GL_RENDERBUFFER, viewRenderbuffer);
    3.25 +
    3.26 +    [self setDebugLabels];
    3.27 +}
    3.28 +
    3.29 +- (void)setDebugLabels
    3.30 +{
    3.31 +    if (viewFramebuffer != 0) {
    3.32 +        glLabelObjectEXT(GL_FRAMEBUFFER, viewFramebuffer, 0, "context FBO");
    3.33 +    }
    3.34 +
    3.35 +    if (viewRenderbuffer != 0) {
    3.36 +        glLabelObjectEXT(GL_RENDERBUFFER, viewRenderbuffer, 0, "context color buffer");
    3.37 +    }
    3.38 +
    3.39 +    if (depthRenderbuffer != 0) {
    3.40 +        if (depthBufferFormat == GL_DEPTH24_STENCIL8_OES) {
    3.41 +            glLabelObjectEXT(GL_RENDERBUFFER, depthRenderbuffer, 0, "context depth-stencil buffer");
    3.42 +        } else {
    3.43 +            glLabelObjectEXT(GL_RENDERBUFFER, depthRenderbuffer, 0, "context depth buffer");
    3.44 +        }
    3.45 +    }
    3.46  }
    3.47  
    3.48  - (void)setAnimationCallback:(int)interval
     4.1 --- a/src/video/uikit/SDL_uikitvideo.h	Thu Nov 20 18:45:04 2014 -0400
     4.2 +++ b/src/video/uikit/SDL_uikitvideo.h	Fri Nov 21 03:29:57 2014 -0400
     4.3 @@ -25,7 +25,7 @@
     4.4  
     4.5  #include "../SDL_sysvideo.h"
     4.6  
     4.7 -BOOL UIKit_IsSystemVersionAtLeast(NSString *version);
     4.8 +BOOL UIKit_IsSystemVersionAtLeast(double version);
     4.9  CGRect UIKit_ComputeViewFrame(SDL_Window *window, UIScreen *screen);
    4.10  
    4.11  #endif /* _SDL_uikitvideo_h */
     5.1 --- a/src/video/uikit/SDL_uikitvideo.m	Thu Nov 20 18:45:04 2014 -0400
     5.2 +++ b/src/video/uikit/SDL_uikitvideo.m	Fri Nov 21 03:29:57 2014 -0400
     5.3 @@ -130,16 +130,15 @@
     5.4  }
     5.5  
     5.6  BOOL
     5.7 -UIKit_IsSystemVersionAtLeast(NSString *version)
     5.8 +UIKit_IsSystemVersionAtLeast(double version)
     5.9  {
    5.10 -    NSString *sysversion = [UIDevice currentDevice].systemVersion;
    5.11 -    return [sysversion compare:version options:NSNumericSearch] != NSOrderedAscending;
    5.12 +    return [[UIDevice currentDevice].systemVersion doubleValue] >= version;
    5.13  }
    5.14  
    5.15  CGRect
    5.16  UIKit_ComputeViewFrame(SDL_Window *window, UIScreen *screen)
    5.17  {
    5.18 -    BOOL hasiOS7 = UIKit_IsSystemVersionAtLeast(@"7.0");
    5.19 +    BOOL hasiOS7 = UIKit_IsSystemVersionAtLeast(7.0);
    5.20  
    5.21      if (hasiOS7 || (window->flags & (SDL_WINDOW_BORDERLESS|SDL_WINDOW_FULLSCREEN))) {
    5.22          /* The view should always show behind the status bar in iOS 7+. */
     6.1 --- a/src/video/uikit/SDL_uikitview.m	Thu Nov 20 18:45:04 2014 -0400
     6.2 +++ b/src/video/uikit/SDL_uikitview.m	Fri Nov 21 03:29:57 2014 -0400
     6.3 @@ -193,19 +193,17 @@
     6.4  /* UITextFieldDelegate method.  Invoked when user types something. */
     6.5  - (BOOL)textField:(UITextField *)_textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
     6.6  {
     6.7 -    if ([string length] == 0) {
     6.8 +    NSUInteger len = string.length;
     6.9 +
    6.10 +    if (len == 0) {
    6.11          /* it wants to replace text with nothing, ie a delete */
    6.12          SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_BACKSPACE);
    6.13          SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_BACKSPACE);
    6.14 -    }
    6.15 -    else {
    6.16 +    } else {
    6.17          /* go through all the characters in the string we've been sent
    6.18             and convert them to key presses */
    6.19 -        int i;
    6.20 -        for (i = 0; i < [string length]; i++) {
    6.21 -
    6.22 +        for (int i = 0; i < len; i++) {
    6.23              unichar c = [string characterAtIndex:i];
    6.24 -
    6.25              Uint16 mod = 0;
    6.26              SDL_Scancode code;
    6.27  
    6.28 @@ -224,16 +222,20 @@
    6.29                  /* If character uses shift, press shift down */
    6.30                  SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_LSHIFT);
    6.31              }
    6.32 +
    6.33              /* send a keydown and keyup even for the character */
    6.34              SDL_SendKeyboardKey(SDL_PRESSED, code);
    6.35              SDL_SendKeyboardKey(SDL_RELEASED, code);
    6.36 +
    6.37              if (mod & KMOD_SHIFT) {
    6.38                  /* If character uses shift, press shift back up */
    6.39                  SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_LSHIFT);
    6.40              }
    6.41          }
    6.42 +
    6.43          SDL_SendKeyboardText([string UTF8String]);
    6.44      }
    6.45 +
    6.46      return NO; /* don't allow the edit! (keep placeholder text there) */
    6.47  }
    6.48