macosx_local.h (3518B)
1 /* 2 =========================================================================== 3 Copyright (C) 1999-2005 Id Software, Inc. 4 5 This file is part of Quake III Arena source code. 6 7 Quake III Arena source code is free software; you can redistribute it 8 and/or modify it under the terms of the GNU General Public License as 9 published by the Free Software Foundation; either version 2 of the License, 10 or (at your option) any later version. 11 12 Quake III Arena source code is distributed in the hope that it will be 13 useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 GNU General Public License for more details. 16 17 You should have received a copy of the GNU General Public License 18 along with Foobar; if not, write to the Free Software 19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 =========================================================================== 21 */ 22 #ifndef __macosx_local_h 23 #define __macosx_local_h 24 25 #include "qcommon.h" 26 27 #ifdef __cplusplus 28 typedef void NSDictionary; 29 typedef void NSOpenGLContext; 30 typedef void NSWindow; 31 32 extern "C" { 33 #else 34 #import <Foundation/NSGeometry.h> 35 @class NSEvent, NSOpenGLContext, NSWindow; 36 #endif 37 38 #include <ApplicationServices/ApplicationServices.h> 39 #include <OpenGL/CGLTypes.h> 40 41 // In macosx_input.m 42 extern void Sys_InitInput(void); 43 extern void Sys_ShutdownInput(void); 44 extern void Sys_SetMouseInputRect(CGRect newRect); 45 extern CGDirectDisplayID Sys_DisplayToUse(void); 46 47 // In macosx_sys.m 48 extern void Sys_QueEvent(int time, sysEventType_t type, int value, int value2, int ptrLength, void *ptr); 49 extern void Sys_AnnoyingBanner(); 50 51 // In macosx_glimp.m 52 extern qboolean Sys_IsHidden; 53 extern qboolean Sys_Hide(); 54 extern qboolean Sys_Unhide(); 55 56 typedef struct { 57 CGDirectDisplayID display; 58 CGTableCount tableSize; 59 CGGammaValue *red; 60 CGGammaValue *blue; 61 CGGammaValue *green; 62 } glwgamma_t; 63 64 typedef struct 65 { 66 CGDirectDisplayID display; 67 NSDictionary *desktopMode; 68 NSDictionary *gameMode; 69 70 CGDisplayCount displayCount; 71 glwgamma_t *originalDisplayGammaTables; 72 glwgamma_t inGameTable; 73 glwgamma_t tempTable; 74 75 NSOpenGLContext *_ctx; 76 CGLContextObj _cgl_ctx; 77 qboolean _ctx_is_current; 78 NSWindow *window; 79 80 FILE *log_fp; 81 82 unsigned int bufferSwapCount; 83 unsigned int glPauseCount; 84 } glwstate_t; 85 86 extern glwstate_t glw_state; 87 88 #define OSX_SetGLContext(context) \ 89 do { \ 90 NSOpenGLContext *_context = (context); \ 91 glw_state._ctx = _context; \ 92 glw_state._cgl_ctx = [_context cglContext]; \ 93 } while (0) 94 95 #define OSX_GetNSGLContext() glw_state._ctx 96 #define OSX_GetCGLContext() glw_state._cgl_ctx 97 98 #define OSX_GLContextIsCurrent() glw_state._ctx_is_current 99 #define OSX_GLContextSetCurrent() \ 100 do { \ 101 [glw_state._ctx makeCurrentContext]; \ 102 glw_state._ctx_is_current = (glw_state._ctx != nil); \ 103 } while (0) 104 105 #define OSX_GLContextClearCurrent() \ 106 do { \ 107 [NSOpenGLContext clearCurrentContext]; \ 108 glw_state._ctx_is_current = NO; \ 109 } while (0) 110 111 112 extern void Sys_PauseGL(); 113 extern void Sys_ResumeGL(); 114 115 116 #import "macosx_timers.h" 117 118 #ifdef OMNI_TIMER 119 extern OTStampList glThreadStampList; 120 #define GLSTAMP(name, data) OTStampListAddStamp(glThreadStampList, name, data) 121 #else 122 #define GLSTAMP(name, data) 123 #endif 124 125 #ifdef __cplusplus 126 } 127 #endif 128 129 #endif // __macosx_local_h