Style: Apply clang-format (3.9.1) to Obj-C++ files

This commit is contained in:
Rémi Verschelde 2017-04-09 14:18:49 +02:00
parent a1a0f021ea
commit 3fd10ff6f0
14 changed files with 638 additions and 703 deletions

View File

@ -31,7 +31,7 @@ PARSE_EXTS=true
# File types to parse. Only effective when PARSE_EXTS is true.
# FILE_EXTS=".c .h .cpp .hpp"
FILE_EXTS=".c .h .cpp .hpp .cc .hh .cxx .m"
FILE_EXTS=".c .h .cpp .hpp .cc .hh .cxx .m .mm .inc"
# Use pygmentize instead of cat to parse diff with highlighting.
# Install it with `pip install pygments` (Linux) or `easy_install Pygments` (Mac)

View File

@ -11,7 +11,7 @@ else
RANGE=HEAD
fi
FILES=$(git diff-tree --no-commit-id --name-only -r $RANGE | grep -v thirdparty/ | grep -e "\.cpp$" -e "\.h$" -e "\.inc$")
FILES=$(git diff-tree --no-commit-id --name-only -r $RANGE | grep -v thirdparty/ | grep -E "\.(c|h|cpp|hpp|cc|hh|cxx|m|mm|inc)$")
echo "Checking files:\n$FILES"
# create a random filename to store our generated patch

View File

@ -28,11 +28,11 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#import "app_delegate.h"
#import "gl_view.h"
#include "os_iphone.h"
#include "core/global_config.h"
#import "gl_view.h"
#include "main/main.h"
#include "os_iphone.h"
#ifdef MODULE_FACEBOOKSCORER_IOS_ENABLED
#include "modules/FacebookScorer_ios/FacebookScorer.h"
@ -45,8 +45,8 @@
#endif
#ifdef MODULE_PARSE_ENABLED
#import <Parse/Parse.h>
#import "FBSDKCoreKit/FBSDKCoreKit.h"
#import <Parse/Parse.h>
#endif
#define kFilteringFactor 0.1
@ -90,7 +90,8 @@ static ViewController* mainViewController = nil;
}
static int frame_count = 0;
- (void)drawView:(GLView*)view; {
- (void)drawView:(GLView *)view;
{
switch (frame_count) {
case 0: {
@ -240,7 +241,6 @@ static int frame_count = 0;
};
}; break;
};
};
@ -331,7 +331,6 @@ static int frame_count = 0;
advertisingTrackingEnabled:[[ASIdentifierManager sharedManager] isAdvertisingTrackingEnabled]];
#endif
};
- (void)applicationWillTerminate:(UIApplication *)application {
@ -401,13 +400,13 @@ static int frame_count = 0;
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
#ifdef MODULE_PARSE_ENABLED
NSLog(@"Handling application openURL");
return [[FBSDKApplicationDelegate sharedInstance] application:application
return [[FBSDKApplicationDelegate sharedInstance]
application:application
openURL:url
sourceApplication:sourceApplication
annotation:annotation];
#endif
#ifdef MODULE_FACEBOOKSCORER_IOS_ENABLED
return [[[FacebookScorer sharedInstance] facebook] handleOpenURL:url];
#else

View File

@ -63,7 +63,6 @@ void GameCenter::_bind_methods() {
ClassDB::bind_method(D_METHOD("pop_pending_event"), &GameCenter::pop_pending_event);
};
Error GameCenter::connect() {
//if this class isn't available, game center isn't implemented
@ -78,7 +77,10 @@ Error GameCenter::connect() {
ViewController *root_controller = (ViewController *)((AppDelegate *)[[UIApplication sharedApplication] delegate]).window.rootViewController;
ERR_FAIL_COND_V(!root_controller, FAILED);
//this handler is called serveral times. first when the view needs to be shown, then again after the view is cancelled or the user logs in. or if the user's already logged in, it's called just once to confirm they're authenticated. This is why no result needs to be specified in the presentViewController phase. in this case, more calls to this function will follow.
// This handler is called several times. First when the view needs to be shown, then again
// after the view is cancelled or the user logs in. Or if the user's already logged in, it's
// called just once to confirm they're authenticated. This is why no result needs to be specified
// in the presentViewController phase. In this case, more calls to this function will follow.
player.authenticateHandler = (^(UIViewController *controller, NSError *error) {
if (controller) {
[root_controller presentViewController:controller animated:YES completion:nil];
@ -119,7 +121,8 @@ Error GameCenter::post_score(Variant p_score) {
ERR_FAIL_COND_V([GKScore respondsToSelector:@selector(reportScores)], ERR_UNAVAILABLE);
[GKScore reportScores:@[reporter] withCompletionHandler:^(NSError* error) {
[GKScore reportScores:@[ reporter ]
withCompletionHandler:^(NSError *error) {
Dictionary ret;
ret["type"] = "post_score";
@ -156,7 +159,8 @@ Error GameCenter::award_achievement(Variant p_params) {
achievement.showsCompletionBanner = params["show_completion_banner"] ? YES : NO;
}
[GKAchievement reportAchievements:@[achievement] withCompletionHandler:^(NSError *error) {
[GKAchievement reportAchievements:@[ achievement ]
withCompletionHandler:^(NSError *error) {
Dictionary ret;
ret["type"] = "award_achievement";
@ -229,7 +233,6 @@ void GameCenter::request_achievement_descriptions() {
}];
};
void GameCenter::request_achievements() {
[GKAchievement loadAchievementsWithCompletionHandler:^(NSArray *achievements, NSError *error) {
@ -353,9 +356,6 @@ GameCenter::GameCenter() {
connected = false;
};
GameCenter::~GameCenter() {
};
GameCenter::~GameCenter(){};
#endif

41
platform/iphone/gl_view.mm Executable file → Normal file
View File

@ -27,15 +27,15 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#import "gl_view.h"
#import <QuartzCore/QuartzCore.h>
#import <OpenGLES/EAGLDrawable.h>
#include "os_iphone.h"
#include "core/os/keyboard.h"
#include "core/global_config.h"
#include "core/os/keyboard.h"
#include "os_iphone.h"
#include "servers/audio_server.h"
#import "gl_view.h"
#import <OpenGLES/EAGLDrawable.h>
#import <QuartzCore/QuartzCore.h>
/*
@interface GLView (private)
@ -90,7 +90,8 @@ bool _play_video(String p_path, float p_volume, String p_audio_track, String p_s
_instance.avPlayerLayer = [AVPlayerLayer playerLayerWithPlayer:_instance.avPlayer];
[_instance.avPlayer addObserver:_instance forKeyPath:@"status" options:0 context:nil];
[[NSNotificationCenter defaultCenter] addObserver:_instance
[[NSNotificationCenter defaultCenter]
addObserver:_instance
selector:@selector(playerItemDidReachEnd:)
name:AVPlayerItemDidPlayToEndTimeNotification
object:[_instance.avPlayer currentItem]];
@ -249,8 +250,7 @@ static void clear_touches() {
//The GL view is stored in the nib file. When it's unarchived it's sent -initWithCoder:
- (id)initWithCoder:(NSCoder *)coder {
active = FALSE;
if((self = [super initWithCoder:coder]))
{
if ((self = [super initWithCoder:coder])) {
self = [self initGLES];
}
return self;
@ -262,9 +262,11 @@ static void clear_touches() {
// Configure it so that it is opaque, does not retain the contents of the backbuffer when displayed, and uses RGBA8888 color.
eaglLayer.opaque = YES;
eaglLayer.drawableProperties = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithBool:FALSE], kEAGLDrawablePropertyRetainedBacking,
kEAGLColorFormatRGBA8, kEAGLDrawablePropertyColorFormat,
eaglLayer.drawableProperties = [NSDictionary
dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:FALSE],
kEAGLDrawablePropertyRetainedBacking,
kEAGLColorFormatRGBA8,
kEAGLDrawablePropertyColorFormat,
nil];
// Create our EAGLContext, and if successful make it current and create our framebuffer.
@ -303,7 +305,6 @@ static void clear_touches() {
[self createFramebuffer];
[self drawView];
[self drawView];
}
- (BOOL)createFramebuffer {
@ -359,8 +360,7 @@ static void clear_touches() {
glDeleteRenderbuffersOES(1, &viewRenderbuffer);
viewRenderbuffer = 0;
if(depthRenderbuffer)
{
if (depthRenderbuffer) {
glDeleteRenderbuffersOES(1, &depthRenderbuffer);
depthRenderbuffer = 0;
}
@ -427,7 +427,8 @@ static void clear_touches() {
[displayLink setPaused:YES];
// Process all input events
while(CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0, TRUE) == kCFRunLoopRunHandledSource);
while (CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0, TRUE) == kCFRunLoopRunHandledSource)
;
// We are good to go, resume the CADisplayLink
[displayLink setPaused:NO];
@ -496,7 +497,6 @@ static void clear_touches() {
OSIPhone::get_singleton()->mouse_move(tid, prev_point.x * self.contentScaleFactor, prev_point.y * self.contentScaleFactor, touchPoint.x * self.contentScaleFactor, touchPoint.y * self.contentScaleFactor, first == tid);
};
};
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
@ -527,7 +527,6 @@ static void clear_touches() {
return YES;
};
- (void)open_keyboard {
//keyboard_text = p_existing;
[self becomeFirstResponder];
@ -588,14 +587,12 @@ static void clear_touches() {
}
}
// When created via code however, we get initWithFrame
- (id)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
_instance = self;
printf("after init super %p\n", self);
if(self != nil)
{
if (self != nil) {
self = [self initGLES];
printf("after init gles %p\n", self);
}
@ -603,7 +600,9 @@ static void clear_touches() {
self.multipleTouchEnabled = YES;
printf("******** adding observer for sound routing changes\n");
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(audioRouteChangeListenerCallback:)
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(audioRouteChangeListenerCallback:)
name:AVAudioSessionRouteChangeNotification
object:nil];

View File

@ -35,9 +35,10 @@
extern "C" {
#endif
#import <Foundation/Foundation.h>
#import "app_delegate.h"
#import <Foundation/Foundation.h>
#ifndef __IPHONE_9_0
};
#endif
@ -100,7 +101,6 @@ Variant nsobject_to_variant(NSObject* object) {
Dictionary result;
NSDictionary *dic = (NSDictionary *)object;
NSArray *keys = [dic allKeys];
int count = [keys count];
for (int i = 0; i < count; ++i) {
@ -191,7 +191,6 @@ NSObject* variant_to_nsobject(Variant v) {
return NULL;
}
Error ICloud::remove_key(Variant p_param) {
String param = p_param;
NSString *key = [[[NSString alloc] initWithUTF8String:param.utf8().get_data()] autorelease];
@ -302,9 +301,8 @@ ICloud::ICloud() {
instance = this;
//connected = false;
[
//[NSNotificationCenter defaultCenter] addObserverForName: @"notify"
[NSNotificationCenter defaultCenter] addObserverForName: NSUbiquitousKeyValueStoreDidChangeExternallyNotification
[[NSNotificationCenter defaultCenter]
addObserverForName:NSUbiquitousKeyValueStoreDidChangeExternallyNotification
object:[NSUbiquitousKeyValueStore defaultStore]
queue:nil
usingBlock:^(NSNotification *notification) {
@ -331,7 +329,6 @@ ICloud::ICloud() {
ret["reason"] = reason;
NSUbiquitousKeyValueStore *store = [NSUbiquitousKeyValueStore defaultStore];
NSArray *keys = [userInfo objectForKey:NSUbiquitousKeyValueStoreChangedKeysKey];
@ -351,13 +348,9 @@ ICloud::ICloud() {
ret["changed_values"] = keyValues;
pending_events.push_back(ret);
}
];
}];
}
ICloud::~ICloud() {
};
ICloud::~ICloud(){};
#endif

View File

@ -29,15 +29,15 @@
/*************************************************************************/
#ifdef STOREKIT_ENABLED
#include "in_app_store.h"
#ifdef MODULE_FUSEBOXX_ENABLED
#import "modules/fuseboxx/ios/FuseSDK.h"
#endif
#include "in_app_store.h"
extern "C" {
#import <StoreKit/StoreKit.h>
#import <Foundation/Foundation.h>
#import <StoreKit/StoreKit.h>
};
bool auto_finish_transactions = true;
@ -62,7 +62,6 @@ NSMutableDictionary* pending_transactions = [NSMutableDictionary dictionary];
}
@end
InAppStore *InAppStore::instance = NULL;
void InAppStore::_bind_methods() {
@ -76,7 +75,6 @@ void InAppStore::_bind_methods() {
};
@interface ProductsDelegate : NSObject <SKProductsRequestDelegate> {
};
@end
@ -156,7 +154,6 @@ Error InAppStore::request_product_info(Variant p_params) {
};
@interface TransObserver : NSObject <SKPaymentTransactionObserver> {
};
@end
@ -254,7 +251,6 @@ Error InAppStore::request_product_info(Variant p_params) {
@end
Error InAppStore::purchase(Variant p_params) {
ERR_FAIL_COND_V(![SKPaymentQueue canMakePayments], ERR_UNAVAILABLE);
@ -274,7 +270,6 @@ Error InAppStore::purchase(Variant p_params) {
return OK;
};
int InAppStore::get_pending_event_count() {
return pending_events.size();
};
@ -328,9 +323,6 @@ void InAppStore::set_auto_finish_transaction(bool b){
auto_finish_transactions = b;
}
InAppStore::~InAppStore() {
};
InAppStore::~InAppStore(){};
#endif

View File

@ -27,8 +27,9 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#import <UIKit/UIKit.h>
#import "app_delegate.h"
#import <UIKit/UIKit.h>
#include <stdio.h>
int gargc;
@ -47,4 +48,3 @@ int main(int argc, char *argv[]) {
[pool release];
return 0;
}

View File

@ -69,8 +69,7 @@ extern "C" {
return p_argc;
};
};
}; // extern "C"
@interface ViewController ()

View File

@ -35,7 +35,6 @@
#include <Foundation/NSString.h>
String DirAccessOSX::fix_unicode_name(const char *p_name) const {
String fname;
@ -46,6 +45,4 @@ String DirAccessOSX::fix_unicode_name(const char* p_name) const {
return fname;
}
#endif //posix_enabled

View File

@ -27,14 +27,13 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "os_osx.h"
#include "main/main.h"
#include "os_osx.h"
#include <string.h>
#include <unistd.h>
//#define main godot_main
int main(int argc, char **argv) {
int first_arg = 1;
@ -46,7 +45,6 @@ int main(int argc, char** argv) {
printf("%i: %s\n", i, argv[i]);
};
if (argc >= 1 && argv[0][0] == '/') {
//potentially launched from finder
int len = strlen(argv[0]);
@ -69,18 +67,15 @@ int main(int argc, char** argv) {
fclose(f);
chdir(path);
chdir("../Resources"); //data.pck, or just the files are here
}
free(path);
free(pathinfo);
}
}
OS_OSX os;
Error err = Main::setup(argv[0], argc - first_arg, &argv[first_arg]);
if (err != OK)
return 255;

View File

@ -27,9 +27,10 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "godot_osx.h"
#include <sys/param.h> /* for MAXPATHLEN */
#include <unistd.h>
#include "godot_osx.h"
/* For some reaon, Apple removed setAppleMenu from the headers in 10.4,
but the method still is there and works. To avoid warnings, we declare
@ -89,7 +90,6 @@ static void setApplicationMenu(void) {
title = [@"Quit " stringByAppendingString:appName];
[appleMenu addItemWithTitle:title action:@selector(terminate:) keyEquivalent:@"q"];
/* Put menu into the menubar */
menuItem = [[NSMenuItem alloc] initWithTitle:@"" action:nil keyEquivalent:@""];
[menuItem setSubmenu:appleMenu];
@ -171,7 +171,6 @@ extern int godot_main(int argc, char** argv);
#undef main
#endif
int main(int argc, char **argv) {
/* Copy the arguments into a global variable */
/* This is passed if we are launched by double-clicking */
@ -207,4 +206,3 @@ int main (int argc, char **argv) {
CustomApplicationMain(argc, argv);
return 0;
}

View File

@ -27,35 +27,32 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#import <Cocoa/Cocoa.h>
#include <Carbon/Carbon.h>
#include <IOKit/IOKitLib.h>
#include <IOKit/IOCFPlugIn.h>
#include <IOKit/hid/IOHIDLib.h>
#include <IOKit/hid/IOHIDKeys.h>
#include "sem_osx.h"
#include "servers/visual/visual_server_raster.h"
//#include "drivers/opengl/rasterizer_gl.h"
//#include "drivers/gles2/rasterizer_gles2.h"
#include "drivers/gles3/rasterizer_gles3.h"
#include "os_osx.h"
#include <stdio.h>
#include <stdlib.h>
#include "print_string.h"
#include "servers/physics/physics_server_sw.h"
// #include "drivers/gles2/rasterizer_instance_gles2.h"
// #include "servers/visual/visual_server_wrap_mt.h"
#include "dir_access_osx.h"
#include "drivers/gles3/rasterizer_gles3.h"
#include "main/main.h"
#include "os/keyboard.h"
#include "dir_access_osx.h"
#include "print_string.h"
#include "sem_osx.h"
#include "servers/physics/physics_server_sw.h"
#include "servers/visual/visual_server_raster.h"
#include <Carbon/Carbon.h>
#import <Cocoa/Cocoa.h>
#include <IOKit/IOCFPlugIn.h>
#include <IOKit/IOKitLib.h>
#include <IOKit/hid/IOHIDKeys.h>
#include <IOKit/hid/IOHIDLib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <libproc.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
//uses portions of glfw
//========================================================================
@ -93,13 +90,11 @@ static NSRect convertRectToBacking(NSRect contentRect) {
else
#endif /*MAC_OS_X_VERSION_MAX_ALLOWED*/
return contentRect;
}
static InputModifierState translateFlags(NSUInteger flags) {
InputModifierState mod;
mod.shift = (flags & NSShiftKeyMask);
mod.control = (flags & NSControlKeyMask);
mod.alt = (flags & NSAlternateKeyMask);
@ -114,7 +109,6 @@ static int prev_mouse_x = 0;
static int prev_mouse_y = 0;
static int button_mask = 0;
@interface GodotApplication : NSApplication
@end
@ -177,7 +171,6 @@ static int button_mask = 0;
@implementation GodotWindowDelegate
- (BOOL)windowShouldClose:(id)sender {
//_GodotInputWindowCloseRequest(window);
if (OS_OSX::singleton->get_main_loop())
@ -186,9 +179,6 @@ static int button_mask = 0;
return NO;
}
- (void)windowDidResize:(NSNotification *)notification {
[OS_OSX::singleton->context update];
@ -198,7 +188,6 @@ static int button_mask = 0;
OS_OSX::singleton->window_size.width = fbRect.size.width * OS_OSX::singleton->display_scale;
OS_OSX::singleton->window_size.height = fbRect.size.height * OS_OSX::singleton->display_scale;
/*
_GodotInputFramebufferSize(window, fbRect.size.width, fbRect.size.height);
_GodotInputWindowSize(window, contentRect.size.width, contentRect.size.height);
@ -279,7 +268,6 @@ static int button_mask = 0;
return self;
}
- (void)dealloc {
[trackingArea release];
[super dealloc];
@ -306,8 +294,6 @@ static int button_mask = 0;
ret.parse_utf8(utfs);
free(utfs);
files.push_back(ret);
}
if (files.size()) {
@ -318,7 +304,6 @@ static int button_mask = 0;
return NO;
}
- (BOOL)isOpaque {
return YES;
}
@ -546,7 +531,6 @@ static int button_mask = 0;
OS_OSX::singleton->main_loop->notification(MainLoop::NOTIFICATION_WM_MOUSE_ENTER);
if (OS_OSX::singleton->input)
OS_OSX::singleton->input->set_mouse_in_window(true);
}
- (void)viewDidChangeBackingProperties {
@ -564,12 +548,14 @@ static int button_mask = 0;
[trackingArea release];
}
NSTrackingAreaOptions options = NSTrackingMouseEnteredAndExited |
NSTrackingAreaOptions options =
NSTrackingMouseEnteredAndExited |
NSTrackingActiveInKeyWindow |
NSTrackingCursorUpdate |
NSTrackingInVisibleRect;
trackingArea = [[NSTrackingArea alloc] initWithRect:[self bounds]
trackingArea = [[NSTrackingArea alloc]
initWithRect:[self bounds]
options:options
owner:self
userInfo:nil];
@ -858,12 +844,12 @@ static int translateKey(unsigned int key) {
@end
@interface GodotWindow : NSWindow {}
@interface GodotWindow : NSWindow {
}
@end
@implementation GodotWindow
- (BOOL)canBecomeKeyWindow {
// Required for NSBorderlessWindowMask windows
return YES;
@ -871,7 +857,6 @@ static int translateKey(unsigned int key) {
@end
int OS_OSX::get_video_driver_count() const {
return 1;
}
@ -891,7 +876,6 @@ OS::VideoMode OS_OSX::get_default_video_mode() const {
return vm;
}
void OS_OSX::initialize_core() {
OS_Unix::initialize_core();
@ -901,7 +885,6 @@ void OS_OSX::initialize_core() {
DirAccess::make_default<DirAccessOSX>(DirAccess::ACCESS_FILESYSTEM);
SemaphoreOSX::make_default();
}
static bool keyboard_layout_dirty = true;
@ -939,7 +922,6 @@ void OS_OSX::initialize(const VideoMode& p_desired,int p_video_driver,int p_audi
unsigned int styleMask = NSTitledWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask | (p_desired.resizable ? NSResizableWindowMask : 0);
window_object = [[GodotWindow alloc]
initWithContentRect:NSMakeRect(0, 0, p_desired.width / display_scale, p_desired.height / display_scale)
styleMask:styleMask
@ -975,9 +957,13 @@ void OS_OSX::initialize(const VideoMode& p_desired,int p_video_driver,int p_audi
// Fail if a robustness strategy was requested
#define ADD_ATTR(x) { attributes[attributeCount++] = x; }
#define ADD_ATTR2(x, y) { ADD_ATTR(x); ADD_ATTR(y); }
#define ADD_ATTR(x) \
{ attributes[attributeCount++] = x; }
#define ADD_ATTR2(x, y) \
{ \
ADD_ATTR(x); \
ADD_ATTR(y); \
}
// Arbitrary array size here
NSOpenGLPixelFormatAttribute attributes[40];
@ -1022,7 +1008,6 @@ void OS_OSX::initialize(const VideoMode& p_desired,int p_video_driver,int p_audi
pixelFormat = [[NSOpenGLPixelFormat alloc] initWithAttributes:attributes];
ERR_FAIL_COND(pixelFormat == nil);
context = [[NSOpenGLContext alloc] initWithFormat:pixelFormat shareContext:nil];
ERR_FAIL_COND(context == nil);
@ -1044,7 +1029,6 @@ void OS_OSX::initialize(const VideoMode& p_desired,int p_video_driver,int p_audi
bool use_gl2 = p_video_driver != 1;
AudioDriverManager::add_driver(&audio_driver_osx);
// only opengl support here...
@ -1110,7 +1094,6 @@ void OS_OSX::initialize(const VideoMode& p_desired,int p_video_driver,int p_audi
int dpi = (displayPixelSize.width * 25.4f / displayPhysicalSize.width) * displayScale;
screen_dpi.push_back(dpi);
};
restore_rect = Rect2(get_window_position(), get_window_size());
}
@ -1134,14 +1117,12 @@ void OS_OSX::finalize() {
memdelete(physics_2d_server);
screens.clear();
}
void OS_OSX::set_main_loop(MainLoop *p_main_loop) {
main_loop = p_main_loop;
input->set_main_loop(p_main_loop);
}
void OS_OSX::delete_main_loop() {
@ -1152,7 +1133,6 @@ void OS_OSX::delete_main_loop() {
main_loop = NULL;
}
String OS_OSX::get_name() {
return "OSX";
@ -1204,11 +1184,9 @@ void OS_OSX::set_cursor_shape(CursorShape p_shape) {
}
void OS_OSX::set_mouse_show(bool p_show) {
}
void OS_OSX::set_mouse_grab(bool p_grab) {
}
bool OS_OSX::is_mouse_grab_enabled() const {
@ -1258,14 +1236,14 @@ int OS_OSX::get_mouse_button_state() const {
void OS_OSX::set_window_title(const String &p_title) {
[window_object setTitle:[NSString stringWithUTF8String:p_title.utf8().get_data()]];
}
void OS_OSX::set_icon(const Image &p_icon) {
Image img = p_icon;
img.convert(Image::FORMAT_RGBA8);
NSBitmapImageRep *imgrep= [[[NSBitmapImageRep alloc] initWithBitmapDataPlanes: NULL
NSBitmapImageRep *imgrep = [[[NSBitmapImageRep alloc]
initWithBitmapDataPlanes:NULL
pixelsWide:p_icon.get_width()
pixelsHigh:p_icon.get_height()
bitsPerSample:8
@ -1289,7 +1267,6 @@ void OS_OSX::set_icon(const Image& p_icon) {
pixels[i * 4 + 1] = (uint8_t)(((uint16_t)r[i * 4 + 1] * alpha) / 255);
pixels[i * 4 + 2] = (uint8_t)(((uint16_t)r[i * 4 + 2] * alpha) / 255);
pixels[i * 4 + 3] = alpha;
}
NSImage *nsimg = [[[NSImage alloc] initWithSize:NSMakeSize(img.get_width(), img.get_height())] autorelease];
@ -1297,7 +1274,6 @@ void OS_OSX::set_icon(const Image& p_icon) {
[nsimg addRepresentation:imgrep];
[NSApp setApplicationIconImage:nsimg];
}
MainLoop *OS_OSX::get_main_loop() const {
@ -1344,13 +1320,11 @@ String OS_OSX::get_clipboard() const {
void OS_OSX::release_rendering_thread() {
[NSOpenGLContext clearCurrentContext];
}
void OS_OSX::make_rendering_thread() {
[context makeCurrentContext];
}
Error OS_OSX::shell_open(String p_uri) {
@ -1367,7 +1341,6 @@ String OS_OSX::get_locale() const {
void OS_OSX::swap_buffers() {
[context flushBuffer];
}
void OS_OSX::wm_minimized(bool p_minimized) {
@ -1376,7 +1349,6 @@ void OS_OSX::wm_minimized(bool p_minimized) {
};
void OS_OSX::set_video_mode(const VideoMode &p_video_mode, int p_screen) {
}
OS::VideoMode OS_OSX::get_video_mode(int p_screen) const {
@ -1389,7 +1361,6 @@ OS::VideoMode OS_OSX::get_video_mode(int p_screen) const {
}
void OS_OSX::get_fullscreen_mode_list(List<VideoMode> *p_list, int p_screen) const {
}
int OS_OSX::get_screen_count() const {
@ -1432,7 +1403,6 @@ Point2 OS_OSX::get_window_position() const {
return wp;
};
void OS_OSX::set_window_position(const Point2 &p_position) {
Point2 size = p_position;
@ -1443,7 +1413,6 @@ void OS_OSX::set_window_position(const Point2& p_position) {
Size2 OS_OSX::get_window_size() const {
return window_size;
};
void OS_OSX::set_window_size(const Size2 p_size) {
@ -1514,7 +1483,6 @@ bool OS_OSX::is_window_minimized() const {
return minimized;
};
void OS_OSX::set_window_maximized(bool p_enabled) {
if (p_enabled) {
@ -1533,7 +1501,6 @@ bool OS_OSX::is_window_maximized() const {
return maximized;
};
void OS_OSX::move_window_to_foreground() {
[window_object orderFrontRegardless];
@ -1560,7 +1527,6 @@ String OS_OSX::get_executable_path() const {
return path;
}
}
// Returns string representation of keys, if they are printable.
@ -1645,10 +1611,12 @@ OS::LatinKeyboardVariant OS_OSX::get_latin_keyboard_variant() const {
void OS_OSX::process_events() {
while (true) {
NSEvent* event = [NSApp nextEventMatchingMask:NSAnyEventMask
NSEvent *event = [NSApp
nextEventMatchingMask:NSAnyEventMask
untilDate:[NSDate distantPast]
inMode:NSDefaultRunLoopMode
dequeue:YES];
if (event == nil)
break;
@ -1659,8 +1627,6 @@ void OS_OSX::process_events() {
autoreleasePool = [[NSAutoreleasePool alloc] init];
}
void OS_OSX::push_input(const InputEvent &p_event) {
InputEvent ev = p_event;
@ -1725,7 +1691,6 @@ OS::MouseMode OS_OSX::get_mouse_mode() const {
return mouse_mode;
}
String OS_OSX::get_joy_guid(int p_device) const {
return input->get_joy_guid_remapped(p_device);
}
@ -1756,7 +1721,6 @@ OS_OSX::OS_OSX() {
CGEventSourceSetLocalEventsSuppressionInterval(eventSource, 0.0);
/*
if (pthread_key_create(&_Godot.nsgl.current, NULL) != 0) {
_GodotInputError(Godot_PLATFORM_ERROR, "NSGL: Failed to create context TLS");
@ -1786,7 +1750,6 @@ OS_OSX::OS_OSX() {
ERR_FAIL_COND(!delegate);
[NSApp setDelegate:delegate];
cursor_shape = CURSOR_ARROW;
current_screen = 0;