amino
Lightweight Robot Utility Library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
scene_gl.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_GL_H
39 #define AMINO_RX_SCENE_GL_H
40 
46 /* DESIGN
47  * ======
48  *
49  * - Per-frame GL arrays
50  * - vertices
51  * - colors
52  * - indices
53  * - Initially create per-frame VBOs
54  * - Initially compile shaders
55  *
56  *
57  */
58 
59 
61 //struct aa_rx_sg;
62 
66 struct aa_gl_globals;
67 
68 
77 AA_API void
78 aa_rx_sg_gl_init( struct aa_rx_sg *sg );
79 
96 AA_API void
98  const struct aa_rx_sg *scenegraph,
99  const struct aa_gl_globals *globals,
100  size_t n_TF, const double *TF_abs, size_t ld_TF);
101 
105 AA_API void
106 aa_gl_qutr2glmat( const double E[AA_RESTRICT 7],
107  GLfloat M[AA_RESTRICT 16] );
108 
112 AA_API void
113 aa_gl_tfmat2glmat( const double T[AA_RESTRICT 12],
114  GLfloat M[AA_RESTRICT 16] );
115 
119 AA_API void
120 aa_gl_mat_perspective( double fovy,
121  double aspect,
122  double znear, double zfar,
123  GLfloat M[16] );
124 
129  GLenum shader_type, const char* source );
130 
131 
135 AA_API GLuint aa_gl_create_program(GLuint vert_shader, GLuint frag_shader);
136 
137 
141 AA_API void aa_gl_init();
142 
143 
148 AA_API struct aa_gl_globals *
150 
155 AA_API void
156 aa_gl_globals_destroy( struct aa_gl_globals *globals );
157 
161 AA_API void
163  struct aa_gl_globals *globals,
164  const double world_E_camera[7]);
165 
169 AA_API void
171  struct aa_gl_globals *globals,
172  const double world_E_camera_home[7]);
173 
177 AA_API void
179  struct aa_gl_globals *globals );
180 
184 AA_API void
186  struct aa_gl_globals *globals,
187  const double world_v_light[3]);
188 
192 AA_API void
194  struct aa_gl_globals *globals,
195  double aspect );
196 
200 AA_API void
202  struct aa_gl_globals *globals,
203  double fovy,
204  double aspect,
205  double znear,
206  double zfar );
207 
211 AA_API void
213  struct aa_gl_globals *globals,
214  const double color[3] );
215 
219 AA_API void
221  struct aa_gl_globals *globals,
222  double power );
223 
227 AA_API void
229  struct aa_gl_globals *globals,
230  const double ambient[3] );
231 
235 AA_API void
237  struct aa_gl_globals *globals,
238  int show_visual );
239 
243 AA_API void
245  struct aa_gl_globals *globals,
246  int show_collision );
247 
251 AA_API void
252 aa_gl_globals_unmask_all( struct aa_gl_globals *globals );
253 
258 AA_API int
259 aa_gl_globals_is_masked( const struct aa_gl_globals *globals, size_t i );
260 
266 AA_API void
267 aa_gl_globals_mask( struct aa_gl_globals *globals, size_t i, int value );
268 
269 
273 struct aa_sg_gl_buffers;
274 
279  struct aa_rx_geom *geom
280  );
281 
282 struct aa_gl_buffers;
283 
290 AA_API void
291 aa_gl_buffers_destroy( struct aa_gl_buffers *buffers );
292 
298 AA_API void
299 aa_gl_buffers_schedule_destroy( struct aa_gl_buffers *buffers );
300 
307 AA_API void
308 aa_gl_buffers_cleanup( void );
309 
310 
314 AA_API const char *
315 aa_gl_error_string( GLenum error );
316 
317 #endif /*AMINO_RX_SCENE_GL_H*/
AA_API void aa_gl_globals_set_camera(struct aa_gl_globals *globals, const double world_E_camera[7])
Set the camera transform.
AA_API GLuint aa_gl_create_program(GLuint vert_shader, GLuint frag_shader)
Create a GLSL program and attach shaders.
AA_API void aa_gl_globals_set_light_color(struct aa_gl_globals *globals, const double color[3])
Set the color of the light.
AA_API void aa_gl_mat_perspective(double fovy, double aspect, double znear, double zfar, GLfloat M[16])
Create a OpenGL matrix for a perspective transform.
Container for scene geometry.
Definition: rxtype.h:56
AA_API void aa_gl_qutr2glmat(const double E[AA_RESTRICT 7], GLfloat M[AA_RESTRICT 16])
Convert a quaternion-translation to an OpenGL matrix.
AA_API void aa_gl_globals_set_show_collision(struct aa_gl_globals *globals, int show_collision)
Set flag to enable render of collision geometry.
AA_API void aa_gl_globals_unmask_all(struct aa_gl_globals *globals)
Set the display mask value of all frames to false.
AA_API const char * aa_gl_error_string(GLenum error)
Return a string describing the error.
AA_API void aa_gl_globals_destroy(struct aa_gl_globals *globals)
Destroy a aa_gl_globals struct.
AA_API void aa_geom_gl_buffers_init(struct aa_rx_geom *geom)
Initialize OpenGL buffers for geometry object.
AA_API void aa_rx_sg_gl_init(struct aa_rx_sg *sg)
Initialize OpenGL objects in scene graph.
AA_API void aa_gl_globals_set_light_power(struct aa_gl_globals *globals, double power)
Set the power (intensity) of the light.
AA_API void aa_gl_globals_home_camera(struct aa_gl_globals *globals)
Set the camera transform to its "home" value.
AA_API void aa_gl_globals_set_show_visual(struct aa_gl_globals *globals, int show_visual)
Set flag to enable render of visual geometry.
AA_API void aa_gl_globals_set_light_position(struct aa_gl_globals *globals, const double world_v_light[3])
Set the position of the light.
Opaque type for a scene_graph.
AA_API GLuint aa_gl_create_shader(GLenum shader_type, const char *source)
Compile a shader from a text string.
AA_API int aa_gl_globals_is_masked(const struct aa_gl_globals *globals, size_t i)
Return the display mask value of the i'th frame.
AA_API void aa_gl_init()
Initialize GL engine.
#define AA_RESTRICT
Defined restrict keyword based on language flavor.
Definition: amino.h:99
AA_API struct aa_gl_globals * aa_gl_globals_create()
Container for globals rendering info (Forward declaration)
AA_API void aa_gl_globals_set_camera_home(struct aa_gl_globals *globals, const double world_E_camera_home[7])
Set the camera "home" transform.
AA_API void aa_gl_buffers_cleanup(void)
Destroy previously schedule OpenGL buffers.
#define AA_API
calling and name mangling convention for functions
Definition: amino.h:95
AA_API void aa_gl_globals_set_perspective(struct aa_gl_globals *globals, double fovy, double aspect, double znear, double zfar)
Set the camera perspective matrix.
AA_API void aa_rx_sg_render(const struct aa_rx_sg *scenegraph, const struct aa_gl_globals *globals, size_t n_TF, const double *TF_abs, size_t ld_TF)
Render the scene graph to the current GL context.
AA_API void aa_gl_buffers_destroy(struct aa_gl_buffers *buffers)
Destroy OpenGL buffers.
AA_API void aa_gl_globals_set_ambient(struct aa_gl_globals *globals, const double ambient[3])
Set the light ambient color.
AA_API void aa_gl_globals_set_aspect(struct aa_gl_globals *globals, double aspect)
Set the camera aspect ratio.
AA_API void aa_gl_tfmat2glmat(const double T[AA_RESTRICT 12], GLfloat M[AA_RESTRICT 16])
Convert a condensed transformation matrix to an OpenGL matrix.
AA_API void aa_gl_globals_mask(struct aa_gl_globals *globals, size_t i, int value)
Set the display mask value of the i'th frame to `value'.
AA_API void aa_gl_buffers_schedule_destroy(struct aa_gl_buffers *buffers)
Schedule destruction of OpenGL buffers.