amino  1.0-beta2
Lightweight Robot Utility Library
scene_sdl.h
Go to the documentation of this file.
1 /* -*- mode: C; c-basic-offset: 4; -*- */
2 /* ex: set shiftwidth=4 tabstop=4 expandtab: */
3 /*
4  * Copyright (c) 2015, Rice University
5  * All rights reserved.
6  *
7  * Author(s): Neil T. Dantam <ntd@rice.edu>
8  *
9  * Redistribution and use in source and binary forms, with or
10  * without modification, are permitted provided that the following
11  * conditions are met:
12  * * Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  * * Redistributions in binary form must reproduce the above
15  * copyright notice, this list of conditions and the following
16  * disclaimer in the documentation and/or other materials provided
17  * with the distribution.
18  * * Neither the name of copyright holder the names of its
19  * contributors may be used to endorse or promote products derived
20  * from this software without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
23  * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
24  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
25  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
27  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
30  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
31  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
33  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34  * POSSIBILITY OF SUCH DAMAGE.
35  *
36  */
37 
38 #ifndef AMINO_RX_SCENE_SDL_H
39 #define AMINO_RX_SCENE_SDL_H
40 
46 #include <SDL.h>
47 
48 struct aa_gl_globals;
49 
72 AA_API void aa_sdl_init( void );
73 
78  SDL_Window* window,
79  struct aa_gl_globals * globals,
80  aa_sdl_display_fun display,
81  void *context );
82 
83 
88  const char* title,
89  int x_pos,
90  int y_pos,
91  int width,
92  int height,
93  Uint32 flags,
94  SDL_Window **pwindow,
95  SDL_GLContext *p_glcontext );
96 
100 AA_API const struct timespec *
102 
106 AA_API const struct timespec *
108 
112 AA_API const struct timespec *
114 
118 AA_API int
120 
124 AA_API void
126 
130 AA_API void
132 
136 AA_API int
138 
139 
143 const SDL_Event *
145 
150 typedef int
151 (*aa_sdl_handler_function) ( void *cx,
152  struct aa_sdl_display_params *params);
153 
157 AA_API void
158 aa_sdl_bind_event( SDL_EventType event_type,
159  aa_sdl_handler_function handler,
160  void *cx );
161 
165 AA_API void
166 aa_sdl_bind_key( SDL_Keycode key,
167  aa_sdl_handler_function handler,
168  void *cx );
169 
170 #endif /*AMINO_RX_SCENE_SDL_H*/
#define AA_API
calling and name mangling convention for functions
Definition: amino.h:95
int(* aa_sdl_display_fun)(void *context, struct aa_sdl_display_params *params)
Display handler function to call in SDL loop.
Definition: rxtype.h:112
AA_API const struct timespec * aa_sdl_display_params_get_time_initial(struct aa_sdl_display_params *params)
Return the initial time step.
AA_API const struct timespec * aa_sdl_display_params_get_time_now(struct aa_sdl_display_params *params)
Return the current time step.
AA_API void aa_sdl_bind_key(SDL_Keycode key, aa_sdl_handler_function handler, void *cx)
Bind a handler function for an SDL key press.
AA_API void aa_sdl_display_params_set_quit(struct aa_sdl_display_params *params)
Indicate a quit (window close) request.
const SDL_Event * aa_sdl_display_params_get_event(struct aa_sdl_display_params *params)
Retrieve the most recent SDL event.
AA_API void aa_sdl_display_loop(SDL_Window *window, struct aa_gl_globals *globals, aa_sdl_display_fun display, void *context)
Run the display loop function.
AA_API void aa_sdl_gl_window(const char *title, int x_pos, int y_pos, int width, int height, Uint32 flags, SDL_Window **pwindow, SDL_GLContext *p_glcontext)
Create an SDL window with an OpenGL context.
AA_API void aa_sdl_bind_event(SDL_EventType event_type, aa_sdl_handler_function handler, void *cx)
Bind a handler function for an SDL event.
AA_API int aa_sdl_display_params_is_first(struct aa_sdl_display_params *params)
Check if this is the fist display call.
int(* aa_sdl_handler_function)(void *cx, struct aa_sdl_display_params *params)
An event handler.
Definition: scene_sdl.h:151
AA_API const struct timespec * aa_sdl_display_params_get_time_last(struct aa_sdl_display_params *params)
Return the previous time step.
AA_API int aa_sdl_display_params_get_update(struct aa_sdl_display_params *params)
Return whether to update the display.
AA_API void aa_sdl_init(void)
Initialize SDL library and options.
AA_API void aa_sdl_display_params_set_update(struct aa_sdl_display_params *params)
Indicate a display update is needed.
Parameters for SDL display function.
Definition: rxtype.h:95