Create glcontext_get_ptr

This commit is contained in:
twinaphex 2016-02-26 13:36:12 +01:00
parent 93e17b46bd
commit dcefb740f2
2 changed files with 14 additions and 4 deletions

View file

@ -90,6 +90,11 @@ static NSOpenGLPixelFormat* g_format;
static unsigned g_minor = 0; static unsigned g_minor = 0;
static unsigned g_major = 0; static unsigned g_major = 0;
GLContextClass *glcontext_get_ptr(void)
{
return g_context;
}
/* forward declaration */ /* forward declaration */
void *nsview_get_ptr(void); void *nsview_get_ptr(void);

View file

@ -36,6 +36,9 @@
static id apple_platform; static id apple_platform;
/* forward declaration */
GLContextClass *glcontext_get_ptr(void);
void apple_rarch_exited(void) void apple_rarch_exited(void)
{ {
[[NSApplication sharedApplication] terminate:nil]; [[NSApplication sharedApplication] terminate:nil];
@ -347,10 +350,11 @@ static void open_document_handler(NSOpenPanel *panel, NSInteger result)
} }
- (IBAction)openCore:(id)sender { - (IBAction)openCore:(id)sender {
NSOpenPanel* panel = (NSOpenPanel*)[NSOpenPanel openPanel]; GLContextClass *glc = glcontext_get_ptr();
NSOpenPanel* panel = (NSOpenPanel*)[NSOpenPanel openPanel];
settings_t *settings = config_get_ptr(); settings_t *settings = config_get_ptr();
NSString *startdir = BOXSTRING(settings->libretro_directory); NSString *startdir = BOXSTRING(settings->libretro_directory);
NSArray *filetypes = [[NSArray alloc] initWithObjects:BOXSTRING("dylib"), BOXSTRING("Core"), nil]; NSArray *filetypes = [[NSArray alloc] initWithObjects:BOXSTRING("dylib"), BOXSTRING("Core"), nil];
[panel setAllowedFileTypes:filetypes]; [panel setAllowedFileTypes:filetypes];
#if defined(MAC_OS_X_VERSION_10_6) #if defined(MAC_OS_X_VERSION_10_6)
[panel setMessage:BOXSTRING("Load Core")]; [panel setMessage:BOXSTRING("Load Core")];
@ -372,11 +376,12 @@ static void open_document_handler(NSOpenPanel *panel, NSInteger result)
if (result == 1) if (result == 1)
open_core_handler(panel, result); open_core_handler(panel, result);
#endif #endif
[g_context makeCurrentContext]; [glc makeCurrentContext];
} }
- (void)openDocument:(id)sender - (void)openDocument:(id)sender
{ {
GLContextClass *glc = glcontext_get_ptr();
NSOpenPanel* panel = (NSOpenPanel*)[NSOpenPanel openPanel]; NSOpenPanel* panel = (NSOpenPanel*)[NSOpenPanel openPanel];
settings_t *settings = config_get_ptr(); settings_t *settings = config_get_ptr();
NSString *startdir = BOXSTRING(settings->menu_content_directory); NSString *startdir = BOXSTRING(settings->menu_content_directory);
@ -403,7 +408,7 @@ static void open_document_handler(NSOpenPanel *panel, NSInteger result)
if (result == 1) if (result == 1)
open_document_handler(panel, result); open_document_handler(panel, result);
#endif #endif
[g_context makeCurrentContext]; [glc makeCurrentContext];
} }
- (void)unloadingCore - (void)unloadingCore