FS2_Open
Open source remastering of the Freespace 2 engine
osapi.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) Volition, Inc. 1999. All rights reserved.
3  *
4  * All source code herein is the property of Volition, Inc. You may not sell
5  * or otherwise commercially exploit the source or things you created based on the
6  * source.
7  *
8 */
9 
10 
11 #ifndef _OSAPI_H
12 #define _OSAPI_H
13 
14 #include "globalincs/pstypes.h"
15 #include "osapi/osregistry.h"
16 
17 // --------------------------------------------------------------------------------------------------
18 // OSAPI DEFINES/VARS
19 //
20 
21 // set if running under MsDev - done after os_init(...) has returned
22 extern int Os_debugger_running;
23 
24 // game-wide
25 //#define THREADED
26 
27 #ifdef THREADED
28 #ifdef _WIN32
29  #define INITIALIZE_CRITICAL_SECTION(csc) do { InitializeCriticalSection(&csc); } while(0)
30  #define DELETE_CRITICAL_SECTION(csc) do { DeleteCriticalSection(&csc); } while(0)
31  #define ENTER_CRITICAL_SECTION(csc) do { EnterCriticalSection(&csc); } while(0)
32  #define LEAVE_CRITICAL_SECTION(csc) do { LeaveCriticalSection(&csc); } while(0)
33 #else
34  #define INITIALIZE_CRITICAL_SECTION(csc) do { csc = SDL_CreateMutex(); } while(0)
35  #define DELETE_CRITICAL_SECTION(csc) do { SDL_DestroyMutex(csc); } while(0)
36  #define ENTER_CRITICAL_SECTION(csc) do { SDL_LockMutex(csc); } while(0)
37  #define LEAVE_CRITICAL_SECTION(csc) do { SDL_UnlockMutex(csc); } while(0)
38 #endif // _WIN32
39 #else
40  #define INITIALIZE_CRITICAL_SECTION(csc) do { } while(0)
41  #define DELETE_CRITICAL_SECTION(csc) do { } while(0)
42  #define ENTER_CRITICAL_SECTION(csc) do { } while(0)
43  #define LEAVE_CRITICAL_SECTION(csc) do { } while(0)
44 #endif
45 
46 // --------------------------------------------------------------------------------------------------
47 // OSAPI FUNCTIONS
48 //
49 
50 // initialization/shutdown functions -----------------------------------------------
51 
52 // detect the home/base/writable directory to use
53 extern const char *detect_home(void);
54 
55 // If app_name is NULL or ommited, then TITLE is used
56 // for the app name, which is where registry keys are stored.
57 void os_init(const char * wclass, const char * title, const char *app_name=NULL, const char *version_string=NULL );
58 
59 // set the main window title
60 void os_set_title( const char * title );
61 
62 // call at program end
63 void os_cleanup();
64 
65 
66 // window management ---------------------------------------------------------------
67 
68 // toggle window size between full screen and windowed
70 
71 // Returns 1 if app is not the foreground app.
72 int os_foreground();
73 
74 // Returns the handle to the main window
75 #ifdef _WIN32
77 #else
78 #define os_get_window() NULL
79 #endif // _WIN32
80 
81 void os_set_window(uint new_handle);
82 
83 
84 // process management --------------------------------------------------------------
85 
86 // call to process windows messages. only does something in non THREADED mode
87 void os_poll();
88 
89 // Sleeps for n milliseconds or until app becomes active.
90 void os_sleep(int ms);
91 
92 // Used to stop message processing
93 void os_suspend();
94 
95 // resume message processing
96 void os_resume();
97 
98 #endif // _OSAPI_H
99 
100 
101 // Goober5000
102 
103 #ifdef _WIN32
104 void disableWindowsKey();
105 void enableWindowsKey();
106 #endif // _WIN32
void os_cleanup()
Definition: osapi.cpp:181
void os_set_window(uint new_handle)
Definition: osapi.cpp:223
int os_foreground()
Definition: osapi.cpp:202
void os_set_title(const char *title)
Definition: osapi.cpp:172
unsigned int uint
Definition: pstypes.h:64
const char * detect_home(void)
Definition: osapi.cpp:101
#define os_get_window()
Definition: osapi.h:78
void os_suspend()
Definition: osapi.cpp:238
void os_toggle_fullscreen()
void os_poll()
Definition: osapi.cpp:748
int Os_debugger_running
Definition: osapi.cpp:68
void os_sleep(int ms)
Definition: osapi.cpp:232
void os_resume()
Definition: osapi.cpp:244
void os_init(const char *wclass, const char *title, const char *app_name=NULL, const char *version_string=NULL)
Definition: osapi.cpp:134