31 namespace visualization {
130 glColor4f(r, g, b, a);
132 glBegin(GL_LINE_STRIP);
135 glVertex2i((
int) x1, (
int) y1);
136 glVertex2i((
int) x1, (
int) y2);
137 glVertex2i((
int) x2, (
int) y2);
138 glVertex2i((
int) x2, (
int) y1);
139 glVertex2i((
int) x1, (
int) y1);
147 GLint h = glutGet(GLUT_WINDOW_HEIGHT);
148 GLint w = glutGet(GLUT_WINDOW_WIDTH);
150 float scale_x = (float) w / (
float) (cells_h);
151 float scale_y = (float) h / (
float) (cells_v);
153 glColor4f(r, g, b, a);
154 glLineWidth(line_width_);
157 for (
unsigned i = 1; i < cells_h; i++) {
159 glVertex2i((
int) ((
float) i * scale_x), 0);
160 glVertex2i((
int) ((
float) i * scale_x), (GLint) h);
164 for (
unsigned i = 1; i < cells_v; i++) {
166 glVertex2i(0, (
int) ((
float) i * scale_y));
167 glVertex2i((GLint) w, (
int) ((
float) i * scale_y));
182 draw_plus(x, y, size, line_width, r, g, b, a);
186 draw_cross(x, y, size, line_width, r, g, b, a);
199 glColor4f(r, g, b, a);
200 glLineWidth(line_width);
201 glBegin(GL_LINE_STRIP);
202 for (
float angle = 0.0f; angle <= 360.0f; angle += 30.0f) {
203 glVertex2f((x + sinf((angle * (
float) M_PI) / 180.0f) * radius), (y + cosf((angle * (
float) M_PI) / 180.0f) * radius));
209 glColor4f(r, g, b, a);
210 glLineWidth(line_width);
212 glVertex2i((
int) x, (
int) (y - radius));
213 glVertex2i((
int) x, (
int) (y + radius));
215 glVertex2i((
int) (x - radius), (
int) y);
216 glVertex2i((
int) (x + radius), (
int) y);
223 glColor4f(r, g, b, a);
225 glLineWidth(line_width);
229 glVertex2i((
int) (x - radius), (
int) (y - radius));
230 glVertex2i((
int) (x + radius), (
int) (y + radius));
232 glVertex2i((
int) (x + radius), (
int) (y - radius));
233 glVertex2i((
int) (x - radius), (
int) (y + radius));
241 glColor4f(r, g, b, a);
243 glLineWidth(line_width);
245 glBegin(GL_LINE_STRIP);
247 glVertex2i((
int) (x - radius), (
int) (y - radius));
248 glVertex2i((
int) (x + radius), (
int) (y - radius));
249 glVertex2i((
int) (x + radius), (
int) (y + radius));
250 glVertex2i((
int) (x - radius), (
int) (y + radius));
251 glVertex2i((
int) (x - radius), (
int) (y - radius));
259 glColor4f(r, g, b, a);
261 glLineWidth(line_width);
263 glBegin(GL_LINE_STRIP);
265 glNormal3f(0.0f, 0.0f, 1.0f);
266 glVertex3f(-radius, -radius, 0.0f);
267 glVertex3f(radius, -radius, 0.0f);
268 glVertex3f(radius, radius, 0.0f);
269 glVertex3f(-radius, radius, 0.0f);
270 glVertex3f(-radius, -radius, 0.0f);
278 glColor4f(r, g, b, a);
280 glLineWidth(line_width);
284 glNormal3f(0.0f, 0.0f, 1.0f);
285 glVertex3f(-radius, -radius, 0.0f);
286 glVertex3f(radius, -radius, 0.0f);
287 glVertex3f(radius, radius, 0.0f);
288 glVertex3f(-radius, radius, 0.0f);
296 glColor4f(r, g, b, a);
298 glLineWidth(line_width);
302 glNormal3f(0.0f, 0.0f, 1.0f);
303 glVertex3f(-radius_x, -radius_y, 0.0f);
304 glVertex3f(radius_x, -radius_y, 0.0f);
305 glVertex3f(radius_x, radius_y, 0.0f);
306 glVertex3f(-radius_x, radius_y, 0.0f);
314 glColor4f(r, g, b, a);
316 glLineWidth(line_width);
320 glVertex3f(-radius, -radius, height);
321 glVertex3f(radius, -radius, height);
322 glVertex3f(radius, radius, height);
323 glVertex3f(-radius, radius, height);
327 glNormal3f(-1.0f, 0.0f, 0.0f);
328 glVertex3f(-radius, -radius, 0.0f);
329 glVertex3f(-radius, -radius, height);
330 glVertex3f(-radius, radius, height);
331 glVertex3f(-radius, radius, 0.0f);
335 glNormal3f(1.0f, 0.0f, 0.0f);
336 glVertex3f(radius, -radius, 0.0f);
337 glVertex3f(radius, -radius, height);
338 glVertex3f(radius, radius, height);
339 glVertex3f(radius, radius, 0.0f);
343 glNormal3f(0.0f, 1.0f, 0.0f);
344 glVertex3f(-radius, radius, 0.0f);
345 glVertex3f(-radius, radius, height);
346 glVertex3f(radius, radius, height);
347 glVertex3f(radius, radius, 0.0f);
351 glNormal3f(0.0f, -1.0f, 0.0f);
352 glVertex3f(-radius, -radius, 0.0f);
353 glVertex3f(-radius, -radius, height);
354 glVertex3f(radius, -radius, height);
355 glVertex3f(radius, -radius, 0.0f);
365 glNormal3f(0.0f, 0.0f, 1.0f);
366 glTexCoord2f(0.0f, 0.0f);
367 glVertex3f(-radius, -radius, 0.0f);
368 glTexCoord2f(1.0f, 0.0f);
369 glVertex3f(radius, -radius, 0.0f);
370 glTexCoord2f(1.0f, 1.0f);
371 glVertex3f(radius, radius, 0.0f);
372 glTexCoord2f(0.0f, 1.0f);
373 glVertex3f(-radius, radius, 0.0f);
387 glColor4f(r, g, b, a);
392 glVertex2i((
int) (x), (
int) (y));
393 glVertex2i((
int) (x + w), (
int) (y));
394 glVertex2i((
int) (x + w), (
int) (y + h));
395 glVertex2i((
int) (x), (
int) (y + h));
403 glColor4f(r, g, b, a);
405 glBegin(GL_LINE_STRIP);
408 glVertex2i((
int) (x), (
int) (y));
409 glVertex2i((
int) (x + w), (
int) (y));
410 glVertex2i((
int) (x + w), (
int) (y + h));
411 glVertex2i((
int) (x), (
int) (y + h));
412 glVertex2i((
int) (x), (
int) (y));
422 glColor4f(r, g, b, a);
424 glRasterPos2i((
int) x, (
int) y);
426 len = (size_t) strlen(
string);
428 for (i = 0; i < len; i++)
429 glutBitmapCharacter(font,
string[i]);
437 glColor4f(r, g, b, a);
438 glRasterPos3i((
int) x, (
int) y, (
int) z);
440 len = (int) strlen(
string);
442 for (i = 0; i < len; i++)
443 glutBitmapCharacter(font,
string[i]);
451 sprintf(str,
"[%.3f, %.3f]", x, y);
453 draw_text(x, y, str, r, g, b, a, GLUT_BITMAP_HELVETICA_10);
458 return degrees * (float) (M_PI / 180.0f);
void draw_circle(float x, float y, float size, float line_width, float r, float g, float b, float a)
void draw_filled_rectangle(float x, float y, float h, float w, float r, float g, float b, float a)
void draw_text(float x, float y, char *string, float r, float g, float b, float a, void *font)
void draw_filled_square(float x, float y, float size, float r, float g, float b, float a)
Declaration of a class encapsulating methods for drawing in OpenGL windows.
float to_radians(float degrees)
void draw_square_in_place(float size, float line_width, float r, float g, float b, float a)
void draw_text_3i(float x, float y, float z, char *string, float r, float g, float b, float a, void *font)
void draw_square(float x, float y, float size, float line_width, float r, float g, float b, float a)
void draw_plus(float x, float y, float size, float line_width, float r, float g, float b, float a)
void draw_mark(mark m, float x, float y, float size, float line_width, float r, float g, float b, float a)
void draw_filled_square_in_place(float radius, float line_width, float r, float g, float b, float a)
void draw_texture_in_place(float size)
mark
Different types of marks drawn on chars.
void draw_cuboid(float radius, float line_width, float height, float r, float g, float b, float a)
void draw_cross(float x, float y, float size, float line_width, float r, float g, float b, float a)
void draw_cursor(float x, float y, float r, float g, float b, float a)
void draw_filled_rectangle_in_place(float radius_x, float radius_y, float line_width, float r, float g, float b, float a)
void draw_rectangle(float x, float y, float h, float w, float r, float g, float b, float a)
void draw_frame(float x1, float y1, float x2, float y2, float r, float g, float b, float a)
void draw_grid(float r, float g, float b, float a, float cells_h, float cells_v, float line_width_=1.0)