]> icculus.org git repositories - icculus/iodoom3.git/blob - neo/sys/osx/macosx_sys.h
hello world
[icculus/iodoom3.git] / neo / sys / osx / macosx_sys.h
1 #import "../posix/posix_public.h"
2
3 #import <Foundation/NSGeometry.h>
4 @class NSEvent, NSOpenGLContext, NSWindow;
5
6 #import <ApplicationServices/ApplicationServices.h>
7 #import <OpenGL/CGLTypes.h>
8
9 // sys
10
11 const char *macosx_scanForLibraryDirectory(void);
12
13 // In macosx_input.m
14 void Sys_InitInput(void);
15 void Sys_ShutdownInput(void);
16 CGDirectDisplayID Sys_DisplayToUse(void);
17 //extern void osxQuit();
18 void SetProgramPath(char *path);
19 void Sys_SetMouseInputRect(CGRect newRect);
20
21 void Sys_AnnoyingBanner();
22
23 // In macosx_glimp.m
24 bool Sys_Hide();
25 bool Sys_Unhide();
26
27 typedef struct {
28     CGDirectDisplayID     display;
29     CGTableCount          tableSize;
30     CGGammaValue         *red;
31     CGGammaValue         *blue;
32     CGGammaValue         *green;
33 } glwgamma_t;
34
35 typedef struct
36 {
37     CGDirectDisplayID   display;
38     NSDictionary                *desktopMode;
39     NSDictionary                *gameMode;
40
41     CGDisplayCount              displayCount;
42     glwgamma_t                  *originalDisplayGammaTables;
43     glwgamma_t                  inGameTable;
44     glwgamma_t                  tempTable;
45     
46     NSOpenGLContext             *_ctx;
47     CGLContextObj               _cgl_ctx;
48     bool                                _ctx_is_current;
49     NSWindow                    *window;
50     
51     FILE                                *log_fp;
52     
53     unsigned int                bufferSwapCount;
54     unsigned int                glPauseCount;
55 } glwstate_t;
56
57 extern glwstate_t glw_state;
58
59 #define OSX_SetGLContext(context) \
60 do { \
61     NSOpenGLContext *_context = (context); \
62     glw_state._ctx = _context; \
63     glw_state._cgl_ctx = [_context cglContext]; \
64 } while (0)
65
66 #define OSX_GetNSGLContext() glw_state._ctx
67 #define OSX_GetCGLContext() glw_state._cgl_ctx
68
69 #define OSX_GLContextIsCurrent() glw_state._ctx_is_current
70 #define OSX_GLContextSetCurrent() \
71 do { \
72   [glw_state._ctx makeCurrentContext]; \
73   glw_state._ctx_is_current = (glw_state._ctx != nil); \
74 } while (0)
75
76 #define OSX_GLContextClearCurrent() \
77 do { \
78   [NSOpenGLContext clearCurrentContext]; \
79   glw_state._ctx_is_current = NO; \
80 } while (0)
81
82
83 void Sys_PauseGL();
84 void Sys_ResumeGL();