mirror of
https://github.com/Relintai/sdl2_frt.git
synced 2024-12-20 22:16:49 +01:00
Added debug labels for the OpenGL ES objects created with SDL_GL_CreateContext on iOS.
More misc. code cleanup.
This commit is contained in:
parent
feb2ab1e85
commit
38c6e9d13b
@ -150,7 +150,6 @@ UIKit_AddDisplay(UIScreen *uiscreen)
|
|||||||
display.driverdata = (void *) CFBridgingRetain(data);
|
display.driverdata = (void *) CFBridgingRetain(data);
|
||||||
SDL_AddVideoDisplay(&display);
|
SDL_AddVideoDisplay(&display);
|
||||||
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,6 +57,8 @@
|
|||||||
|
|
||||||
- (void)updateFrame;
|
- (void)updateFrame;
|
||||||
|
|
||||||
|
- (void)setDebugLabels;
|
||||||
|
|
||||||
- (void)setAnimationCallback:(int)interval
|
- (void)setAnimationCallback:(int)interval
|
||||||
callback:(void (*)(void*))callback
|
callback:(void (*)(void*))callback
|
||||||
callbackParam:(void*)callbackParam;
|
callbackParam:(void*)callbackParam;
|
||||||
|
@ -93,7 +93,7 @@
|
|||||||
|
|
||||||
if (sRGB) {
|
if (sRGB) {
|
||||||
/* sRGB EAGL drawable support was added in iOS 7. */
|
/* sRGB EAGL drawable support was added in iOS 7. */
|
||||||
if (UIKit_IsSystemVersionAtLeast(@"7.0")) {
|
if (UIKit_IsSystemVersionAtLeast(7.0)) {
|
||||||
colorFormat = kEAGLColorFormatSRGBA8;
|
colorFormat = kEAGLColorFormatSRGBA8;
|
||||||
} else {
|
} else {
|
||||||
SDL_SetError("sRGB drawables are not supported.");
|
SDL_SetError("sRGB drawables are not supported.");
|
||||||
@ -164,6 +164,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
glBindRenderbuffer(GL_RENDERBUFFER, viewRenderbuffer);
|
glBindRenderbuffer(GL_RENDERBUFFER, viewRenderbuffer);
|
||||||
|
|
||||||
|
[self setDebugLabels];
|
||||||
}
|
}
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
@ -200,6 +202,27 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
glBindRenderbuffer(GL_RENDERBUFFER, viewRenderbuffer);
|
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
|
- (void)setAnimationCallback:(int)interval
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
#include "../SDL_sysvideo.h"
|
#include "../SDL_sysvideo.h"
|
||||||
|
|
||||||
BOOL UIKit_IsSystemVersionAtLeast(NSString *version);
|
BOOL UIKit_IsSystemVersionAtLeast(double version);
|
||||||
CGRect UIKit_ComputeViewFrame(SDL_Window *window, UIScreen *screen);
|
CGRect UIKit_ComputeViewFrame(SDL_Window *window, UIScreen *screen);
|
||||||
|
|
||||||
#endif /* _SDL_uikitvideo_h */
|
#endif /* _SDL_uikitvideo_h */
|
||||||
|
@ -130,16 +130,15 @@ UIKit_VideoQuit(_THIS)
|
|||||||
}
|
}
|
||||||
|
|
||||||
BOOL
|
BOOL
|
||||||
UIKit_IsSystemVersionAtLeast(NSString *version)
|
UIKit_IsSystemVersionAtLeast(double version)
|
||||||
{
|
{
|
||||||
NSString *sysversion = [UIDevice currentDevice].systemVersion;
|
return [[UIDevice currentDevice].systemVersion doubleValue] >= version;
|
||||||
return [sysversion compare:version options:NSNumericSearch] != NSOrderedAscending;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CGRect
|
CGRect
|
||||||
UIKit_ComputeViewFrame(SDL_Window *window, UIScreen *screen)
|
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))) {
|
if (hasiOS7 || (window->flags & (SDL_WINDOW_BORDERLESS|SDL_WINDOW_FULLSCREEN))) {
|
||||||
/* The view should always show behind the status bar in iOS 7+. */
|
/* The view should always show behind the status bar in iOS 7+. */
|
||||||
|
@ -193,19 +193,17 @@ void _uikit_keyboard_init();
|
|||||||
/* UITextFieldDelegate method. Invoked when user types something. */
|
/* UITextFieldDelegate method. Invoked when user types something. */
|
||||||
- (BOOL)textField:(UITextField *)_textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
|
- (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 */
|
/* it wants to replace text with nothing, ie a delete */
|
||||||
SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_BACKSPACE);
|
SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_BACKSPACE);
|
||||||
SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_BACKSPACE);
|
SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_BACKSPACE);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
/* go through all the characters in the string we've been sent
|
/* go through all the characters in the string we've been sent
|
||||||
and convert them to key presses */
|
and convert them to key presses */
|
||||||
int i;
|
for (int i = 0; i < len; i++) {
|
||||||
for (i = 0; i < [string length]; i++) {
|
|
||||||
|
|
||||||
unichar c = [string characterAtIndex:i];
|
unichar c = [string characterAtIndex:i];
|
||||||
|
|
||||||
Uint16 mod = 0;
|
Uint16 mod = 0;
|
||||||
SDL_Scancode code;
|
SDL_Scancode code;
|
||||||
|
|
||||||
@ -224,16 +222,20 @@ void _uikit_keyboard_init();
|
|||||||
/* If character uses shift, press shift down */
|
/* If character uses shift, press shift down */
|
||||||
SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_LSHIFT);
|
SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_LSHIFT);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* send a keydown and keyup even for the character */
|
/* send a keydown and keyup even for the character */
|
||||||
SDL_SendKeyboardKey(SDL_PRESSED, code);
|
SDL_SendKeyboardKey(SDL_PRESSED, code);
|
||||||
SDL_SendKeyboardKey(SDL_RELEASED, code);
|
SDL_SendKeyboardKey(SDL_RELEASED, code);
|
||||||
|
|
||||||
if (mod & KMOD_SHIFT) {
|
if (mod & KMOD_SHIFT) {
|
||||||
/* If character uses shift, press shift back up */
|
/* If character uses shift, press shift back up */
|
||||||
SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_LSHIFT);
|
SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_LSHIFT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_SendKeyboardText([string UTF8String]);
|
SDL_SendKeyboardText([string UTF8String]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return NO; /* don't allow the edit! (keep placeholder text there) */
|
return NO; /* don't allow the edit! (keep placeholder text there) */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user