summaryrefslogtreecommitdiffstatshomepage
path: root/3rdparty/bgfx/examples/common/entry/entry_ios.mm
diff options
context:
space:
mode:
author Miodrag Milanovic <mmicko@gmail.com>2017-12-01 13:22:27 +0100
committer Miodrag Milanovic <mmicko@gmail.com>2017-12-01 13:22:27 +0100
commit39176274946d70ff520f265dee8fbd16d5fe0000 (patch)
tree318801d93146752050c9a492654ae3738820e3b9 /3rdparty/bgfx/examples/common/entry/entry_ios.mm
parent6829ecb3b037d6bfbe0b84e818d17d712f71bce6 (diff)
Updated GENie, BGFX, BX, added BIMG since it is separated now, updated all shader binaries and MAME part of code to support new interfaces [Miodrag Milanovic]
Diffstat (limited to '3rdparty/bgfx/examples/common/entry/entry_ios.mm')
-rw-r--r--3rdparty/bgfx/examples/common/entry/entry_ios.mm37
1 files changed, 25 insertions, 12 deletions
diff --git a/3rdparty/bgfx/examples/common/entry/entry_ios.mm b/3rdparty/bgfx/examples/common/entry/entry_ios.mm
index c2dbdce65e1..d781089fb63 100644
--- a/3rdparty/bgfx/examples/common/entry/entry_ios.mm
+++ b/3rdparty/bgfx/examples/common/entry/entry_ios.mm
@@ -27,9 +27,9 @@ namespace entry
struct MainThreadEntry
{
int m_argc;
- char** m_argv;
+ const char* const* m_argv;
- static int32_t threadFunc(void* _userData);
+ static int32_t threadFunc(bx::Thread* _thread, void* _userData);
};
static WindowHandle s_defaultWindow = { 0 };
@@ -38,9 +38,9 @@ namespace entry
{
Context(uint32_t _width, uint32_t _height)
{
- static const char* argv[1] = { "ios" };
+ const char* const argv[1] = { "ios" };
m_mte.m_argc = 1;
- m_mte.m_argv = const_cast<char**>(argv);
+ m_mte.m_argv = argv;
m_eventQueue.postSizeEvent(s_defaultWindow, _width, _height);
@@ -63,19 +63,22 @@ namespace entry
static Context* s_ctx;
- int32_t MainThreadEntry::threadFunc(void* _userData)
+ int32_t MainThreadEntry::threadFunc(bx::Thread* _thread, void* _userData)
{
+ BX_UNUSED(_thread);
+
CFBundleRef mainBundle = CFBundleGetMainBundle();
- if ( mainBundle != nil )
+ if (mainBundle != nil)
{
CFURLRef resourcesURL = CFBundleCopyResourcesDirectoryURL(mainBundle);
- if ( resourcesURL != nil )
+ if (resourcesURL != nil)
{
char path[PATH_MAX];
- if (CFURLGetFileSystemRepresentation(resourcesURL, TRUE, (UInt8 *)path, PATH_MAX) )
+ if (CFURLGetFileSystemRepresentation(resourcesURL, TRUE, (UInt8*)path, PATH_MAX) )
{
chdir(path);
}
+
CFRelease(resourcesURL);
}
}
@@ -247,6 +250,8 @@ static void* m_device = NULL;
BX_UNUSED(touches);
UITouch *touch = [[event allTouches] anyObject];
CGPoint touchLocation = [touch locationInView:self];
+ touchLocation.x *= self.contentScaleFactor;
+ touchLocation.y *= self.contentScaleFactor;
s_ctx->m_eventQueue.postMouseEvent(s_defaultWindow, touchLocation.x, touchLocation.y, 0);
s_ctx->m_eventQueue.postMouseEvent(s_defaultWindow, touchLocation.x, touchLocation.y, 0, MouseButton::Left, true);
@@ -257,6 +262,9 @@ static void* m_device = NULL;
BX_UNUSED(touches);
UITouch *touch = [[event allTouches] anyObject];
CGPoint touchLocation = [touch locationInView:self];
+ touchLocation.x *= self.contentScaleFactor;
+ touchLocation.y *= self.contentScaleFactor;
+
s_ctx->m_eventQueue.postMouseEvent(s_defaultWindow, touchLocation.x, touchLocation.y, 0, MouseButton::Left, false);
}
@@ -265,6 +273,9 @@ static void* m_device = NULL;
BX_UNUSED(touches);
UITouch *touch = [[event allTouches] anyObject];
CGPoint touchLocation = [touch locationInView:self];
+ touchLocation.x *= self.contentScaleFactor;
+ touchLocation.y *= self.contentScaleFactor;
+
s_ctx->m_eventQueue.postMouseEvent(s_defaultWindow, touchLocation.x, touchLocation.y, 0);
}
@@ -273,6 +284,9 @@ static void* m_device = NULL;
BX_UNUSED(touches);
UITouch *touch = [[event allTouches] anyObject];
CGPoint touchLocation = [touch locationInView:self];
+ touchLocation.x *= self.contentScaleFactor;
+ touchLocation.y *= self.contentScaleFactor;
+
s_ctx->m_eventQueue.postMouseEvent(s_defaultWindow, touchLocation.x, touchLocation.y, 0, MouseButton::Left, false);
}
@@ -312,8 +326,7 @@ static void* m_device = NULL;
[m_window makeKeyAndVisible];
- //float scaleFactor = [[UIScreen mainScreen] scale]; // should use this, but needs to further pass the value to the `nvgBeginFrame()` call's `devicePixelRatio` parameter in `ExampleNanoVG` class' `update()` method so it can actually work properly.
- float scaleFactor = 1.0f;
+ float scaleFactor = [[UIScreen mainScreen] scale];
[m_view setContentScaleFactor: scaleFactor ];
s_ctx = new Context((uint32_t)(scaleFactor*rect.size.width), (uint32_t)(scaleFactor*rect.size.height));
@@ -361,10 +374,10 @@ static void* m_device = NULL;
@end
-int main(int _argc, char* _argv[])
+int main(int _argc, const char* const* _argv)
{
NSAutoreleasePool* pool = [ [NSAutoreleasePool alloc] init];
- int exitCode = UIApplicationMain(_argc, _argv, @"UIApplication", NSStringFromClass([AppDelegate class]) );
+ int exitCode = UIApplicationMain(_argc, (char**)_argv, @"UIApplication", NSStringFromClass([AppDelegate class]) );
[pool release];
return exitCode;
}