00001
00002
00003
00004
00005 #pragma once
00006
00007 #ifdef __cplusplus
00008 extern "C" {
00009 #endif
00010
00011 void osInit(int width, int height, unsigned int flags, int *attribs);
00012 void osQuit();
00013 int osGetScreenWidth();
00014 int osGetScreenHeight();
00015 void osWaitVsync(int);
00016 unsigned int osGetMilliseconds();
00017 int osPollEvent(struct OS_EventRec *e);
00018 void osSwapBuffers();
00019 int osIsKeyDown(int);
00020 int osShowCursor(int);
00021
00022 #ifdef WIN32
00023 #include <windows.h>
00024 #undef min
00025 #undef max
00026 void fatalf(const char *format, ...);
00027 void debugf(const char *format, ...);
00028 #else
00029 #define fatalf(...) { fprintf(stderr, __VA_ARGS__); exit(1); }
00030 #define debugf(...) { fprintf(stdout, __VA_ARGS__); }
00031 #endif
00032
00033 #include <GL/gl.h>
00034
00035 #define OSK_ESCAPE 0x1B
00036 #define OSK_LEFT 0x25
00037 #define OSK_RIGHT 0x27
00038 #define OSK_SHIFT 0xA0
00039 #define OSK_UP 0x26
00040 #define OSK_DOWN 0x28
00041
00042 #define OSKS_UP 0
00043 #define OSKS_DOWN 1
00044
00045 #define OS_BUTTON_LEFT 1
00046 #define OS_BUTTON_MIDDLE 2
00047 #define OS_BUTTON_RIGHT 3
00048
00049 #define OS_QUERY -1
00050 #define OS_IGNORE 0
00051 #define OS_DISABLE 0
00052 #define OS_ENABLE 1
00053 #define OS_FULLSCREEN 0x80000000
00054 #define OS_RESIZABLE 0x00000010
00055
00056 typedef enum
00057 {
00058 OS_NOEVENT,
00059 OS_KEYDOWN,
00060 OS_KEYUP,
00061 OS_MOUSEMOTION,
00062 OS_MOUSEBUTTONDOWN,
00063 OS_MOUSEBUTTONUP,
00064 OS_QUIT,
00065 OS_RESIZE,
00066 } OS_EventType;
00067
00068 typedef struct OS_KeyboardEventRec
00069 {
00070 unsigned char state;
00071 unsigned char key;
00072 } OS_KeyboardEvent;
00073
00074 typedef struct OS_MouseEventRec
00075 {
00076 unsigned char button;
00077 unsigned short x, y;
00078 } OS_MouseEvent;
00079
00080 typedef struct OS_ResizeEventRec
00081 {
00082 int width;
00083 int height;
00084 } OS_ResizeEvent;
00085
00086 typedef struct OS_EventRec
00087 {
00088 OS_EventType type;
00089 struct OS_EventRec *next;
00090 union
00091 {
00092 OS_KeyboardEvent key;
00093 OS_MouseEvent mouse;
00094 OS_ResizeEvent resize;
00095 };
00096 } OS_Event;
00097
00098 typedef enum
00099 {
00100 OS_GL_RED_SIZE,
00101 OS_GL_GREEN_SIZE,
00102 OS_GL_BLUE_SIZE,
00103 OS_GL_ALPHA_SIZE,
00104 OS_GL_BUFFER_SIZE,
00105 OS_GL_DOUBLEBUFFER,
00106 OS_GL_DEPTH_SIZE,
00107 OS_GL_STENCIL_SIZE,
00108 OS_GL_ACCUM_RED_SIZE,
00109 OS_GL_ACCUM_GREEN_SIZE,
00110 OS_GL_ACCUM_BLUE_SIZE,
00111 OS_GL_ACCUM_ALPHA_SIZE,
00112 OS_GL_STEREO,
00113 OS_GL_MULTISAMPLEBUFFERS,
00114 OS_GL_MULTISAMPLESAMPLES,
00115 OS_GL_ACCELERATED_VISUAL,
00116 OS_GL_SWAP_CONTROL
00117 } OS_GLattr;
00118
00119 #ifdef __cplusplus
00120 }
00121 #endif