nuclear@0: #ifndef SGL_H_ nuclear@0: #define SGL_H_ nuclear@0: nuclear@0: #define SGL_DOUBLE 1 nuclear@0: #define SGL_DEPTH 2 nuclear@0: #define SGL_STENCIL 4 nuclear@0: #define SGL_STEREO 8 nuclear@4: #define SGL_MULTISAMPLE 16 nuclear@0: nuclear@34: /* --- callback types --- nuclear@34: * All event callbacks are entered with the corresponding OpenGL context being current. nuclear@34: * It is safe to issue OpenGL commands in all callbacks functions, unless explicitly nuclear@34: * stated otherwise below. nuclear@34: */ nuclear@34: nuclear@34: /* Create callback is called just after a window and its OpenGL context is created */ nuclear@34: typedef void (*sgl_create_callback_t)(int window); nuclear@34: /* Close callback is called before the window and its OpenGL context is destroyed */ nuclear@34: typedef void (*sgl_close_callback_t)(int window); nuclear@34: /* The display callback is called whenever the window needs repainting. This is nuclear@34: * the only place you should perform drawing. nuclear@34: */ nuclear@6: typedef void (*sgl_display_callback_t)(void); nuclear@34: /* Reshape is called whenever the window size changes, and at least once for nuclear@34: * each newly created window, just after the call to the create callback. */ nuclear@34: typedef void (*sgl_reshape_callback_t)(int width, int height); nuclear@34: /* The keyboard callback is called whenever a key is pressed or released */ nuclear@34: typedef void (*sgl_keyboard_callback_t)(int key, int pressed); nuclear@34: /* The mouse callback is called whenever a mouse button is pressed or released nuclear@34: * over the window. The first argument is the touch id for multitouch devices. nuclear@34: * For regular mouse events it is always 0. */ nuclear@34: typedef void (*sgl_mouse_callback_t)(int id, int button, int pressed, int x, int y); nuclear@34: /* The motion callback is called when the user drags the mouse around with any nuclear@34: * mouse buttons held down. The first argument is the touch id for multitouch nuclear@34: * devices. */ nuclear@34: typedef void (*sgl_motion_callback_t)(int id, int x, int y); nuclear@34: /* Passive gets called whenever the mouse is moved without any button being nuclear@34: * held. The first argument is the touch id for multitouch devices. nuclear@34: * nuclear@34: * Avoid setting this callback unless absolutely necessary, because it will nuclear@34: * generate a huge volume of events whenever the mouse moves over the window. */ nuclear@34: typedef void (*sgl_passive_callback_t)(int id, int x, int y); nuclear@34: /* Setting the idle callback will change the behaviour of the library. Instead nuclear@34: * of blocking, to wait for events from the window system, it will poll for nuclear@34: * events and after processing them will call this idle callback. nuclear@34: * nuclear@34: * Avoid setting this callback unless absolutely necessary, because it will nuclear@34: * turn your program into busy-looping mode, consuming all possible CPU time nuclear@34: * allocated to it by the system. */ nuclear@6: typedef void (*sgl_idle_callback_t)(void); nuclear@6: nuclear@34: /* symbolic names for each callback */ nuclear@0: enum { nuclear@0: SGL_CREATE, nuclear@0: SGL_CLOSE, nuclear@0: SGL_DISPLAY, nuclear@0: SGL_RESHAPE, nuclear@0: SGL_KEYBOARD, nuclear@0: SGL_MOUSE, nuclear@0: SGL_MOTION, nuclear@0: SGL_PASSIVE, nuclear@0: SGL_IDLE, nuclear@0: nuclear@0: SGL_NUM_CALLBACKS nuclear@0: }; nuclear@0: nuclear@5: enum { nuclear@5: SGL_LEFT_BUTTON, nuclear@5: SGL_MIDDLE_BUTTON, nuclear@5: SGL_RIGHT_BUTTON nuclear@5: }; nuclear@5: nuclear@7: /* these values happen to coincide with X11 keysyms */ nuclear@7: #define SGL_KEY_LSHIFT 0xffe1 nuclear@7: #define SGL_KEY_RSHIFT 0xffe2 nuclear@7: #define SGL_KEY_LCONTROL 0xffe3 nuclear@7: #define SGL_KEY_RCONTROL 0xffe4 nuclear@7: #define SGL_KEY_LALT 0xffe9 nuclear@7: #define SGL_KEY_RALT 0xffea nuclear@7: nuclear@7: /* for the sgl_modifiers bitmask */ nuclear@7: #define SGL_MOD_SHIFT 1 nuclear@7: #define SGL_MOD_CONTROL 2 nuclear@7: #define SGL_MOD_ALT 4 nuclear@7: nuclear@1: int sgl_init(void); nuclear@5: void sgl_quit(void); nuclear@1: nuclear@4: int sgl_set_video_mode(int xsz, int ysz); nuclear@4: int sgl_get_video_mode(int *xsz, int *ysz); nuclear@0: nuclear@4: int sgl_create_window(int xsz, int ysz, unsigned int mode); nuclear@1: void sgl_close_window(int win); nuclear@0: nuclear@4: int sgl_set_active(int id); nuclear@4: int sgl_set_title(const char *str); nuclear@4: nuclear@5: void sgl_redisplay(void); nuclear@5: void sgl_swap_buffers(void); nuclear@5: nuclear@7: int sgl_modifiers(void); nuclear@7: nuclear@4: int sgl_process_events(void); nuclear@5: void sgl_event_loop(void); nuclear@4: nuclear@0: int sgl_push_callbacks(void); nuclear@0: int sgl_pop_callbacks(void); nuclear@0: void sgl_clear_callbacks(void); nuclear@4: void sgl_set_callback(int idx, void (*func)()); nuclear@4: void (*sgl_get_callback(int idx))(); nuclear@0: nuclear@6: void sgl_create_callback(sgl_create_callback_t func); nuclear@6: void sgl_close_callback(sgl_close_callback_t func); nuclear@6: void sgl_display_callback(sgl_display_callback_t func); nuclear@6: void sgl_reshape_callback(sgl_reshape_callback_t func); nuclear@6: void sgl_keyboard_callback(sgl_keyboard_callback_t func); nuclear@6: void sgl_mouse_callback(sgl_mouse_callback_t func); nuclear@6: void sgl_motion_callback(sgl_motion_callback_t func); nuclear@6: void sgl_passive_callback(sgl_passive_callback_t func); nuclear@6: void sgl_idle_callback(sgl_idle_callback_t func); nuclear@6: nuclear@0: #endif /* SGL_H_ */