biped-stabilizer 1.5.0
Stabilizer for Biped Locomotion
Loading...
Searching...
No Matches
wykobi_gui.hpp
Go to the documentation of this file.
1/*
2(***********************************************************************)
3(* *)
4(* Wykobi Computational Geometry Library *)
5(* Release Version 0.0.5 *)
6(* http://www.wykobi.com *)
7(* Copyright (c) 2005-2017 Arash Partow, All Rights Reserved. *)
8(* *)
9(* The Wykobi computational geometry library and its components are *)
10(* supplied under the terms of the open source MIT License. *)
11(* The contents of the Wykobi computational geometry library and its *)
12(* components may not be copied or disclosed except in accordance with *)
13(* the terms of the MIT License. *)
14(* *)
15(* URL: https://opensource.org/licenses/MIT *)
16(* *)
17(***********************************************************************)
18*/
19
20#ifndef INCLUDE_WYKOBI_GUI
21#define INCLUDE_WYKOBI_GUI
22
23#include <GL/glut.h>
24
25#include <iostream>
26#include <string>
27
28class wykobi_window;
29static wykobi_window* handle;
30
32
34 public:
35 wykobi_window(int argc, char* argv[]) {
36 display_mode = eDisplayMode2D;
37 handle = this;
38 glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);
39 glutInitWindowSize(window_width(), window_height());
40 glutInitWindowPosition(window_position_x(), window_position_y());
41 glutInit(&argc, argv);
42 glutCreateWindow(window_title().c_str());
43 glutKeyboardFunc(glut_keyboard_handler);
44 glutSpecialFunc(glut_special_key_handler);
45 glutReshapeFunc(glut_reshape_handler);
46 glutDisplayFunc(glut_display_handler);
47 glutMouseFunc(glut_mouse_handler);
48 glutMotionFunc(glut_motion_handler);
49 glutCreateMenu(glut_menu_handler);
50 glutIdleFunc(glut_idle_handler);
51
52 if (handle->display_mode == eDisplayMode2D) {
53 glClearColor(0.0, 0.0, 0.0, 0.0);
54 gluOrtho2D(0.0, handle->window_width() - 1, handle->window_height() - 1,
55 0.0);
56 glDisable(GL_DEPTH_TEST);
57 }
58 }
59
60 virtual ~wykobi_window() {};
61
62 virtual void keyboard_handler(unsigned char key, int x, int y) {}
63 virtual void special_key_handler(int key, int x, int y) {}
64 virtual void reshape_handler(int width, int height) {}
65 virtual void display_handler(void) {}
66 virtual void mouse_handler(int button, int state, int x, int y) {}
67 virtual void motion_handler(int x, int y) {}
68 virtual void menu_handler(int menu_choice) {}
69 virtual void timmer_handler(int ms_time) {}
70 virtual void idle_handler(void) {}
71
72 virtual std::string window_title() { return std::string("Wykobi Window"); }
73 virtual int window_width() { return 700; }
74 virtual int window_height() { return 700; }
75 virtual int window_position_x() { return 10; }
76 virtual int window_position_y() { return 10; }
77 virtual int world_width() { return 700; }
78 virtual int world_height() { return 700; }
79
80 void clear_black() {
81 glClearColor(0.0, 0.0, 0.0, 0);
82 glClear(GL_COLOR_BUFFER_BIT);
83 }
84 void clear_white() {
85 glClearColor(1.0, 1.0, 1.0, 0);
86 glClear(GL_COLOR_BUFFER_BIT);
87 }
88
89 private:
90 eDisplayMode display_mode;
91
92 static void glut_keyboard_handler(unsigned char key, int x, int y) {
93 handle->keyboard_handler(key, x, y);
94 }
95 static void glut_special_key_handler(int key, int x, int y) {
96 handle->special_key_handler(key, x, y);
97 }
98 static void glut_reshape_handler(int width, int height) {
99 handle->reshape_handler(width, height);
100 }
101 static void glut_mouse_handler(int button, int state, int x, int y) {
102 handle->mouse_handler(button, state, x, y);
103 }
104 static void glut_motion_handler(int x, int y) {
105 handle->motion_handler(x, y);
106 }
107 static void glut_menu_handler(int menu_choice) {
108 handle->menu_handler(menu_choice);
109 }
110 static void glut_timmer_handler(int ms_time) {
111 handle->timmer_handler(ms_time);
112 }
113 static void glut_idle_handler(void) { handle->idle_handler(); }
114
115 static void glut_display_handler(void) {
116 glClear(GL_COLOR_BUFFER_BIT);
117 handle->display_handler();
118 glutSwapBuffers();
119 }
120};
121
122#endif
Definition wykobi_gui.hpp:33
virtual void reshape_handler(int width, int height)
Definition wykobi_gui.hpp:64
virtual void display_handler(void)
Definition wykobi_gui.hpp:65
wykobi_window(int argc, char *argv[])
Definition wykobi_gui.hpp:35
virtual void timmer_handler(int ms_time)
Definition wykobi_gui.hpp:69
virtual void special_key_handler(int key, int x, int y)
Definition wykobi_gui.hpp:63
void clear_white()
Definition wykobi_gui.hpp:84
virtual int world_height()
Definition wykobi_gui.hpp:78
virtual int window_position_y()
Definition wykobi_gui.hpp:76
virtual ~wykobi_window()
Definition wykobi_gui.hpp:60
virtual void motion_handler(int x, int y)
Definition wykobi_gui.hpp:67
virtual int window_position_x()
Definition wykobi_gui.hpp:75
virtual void mouse_handler(int button, int state, int x, int y)
Definition wykobi_gui.hpp:66
virtual int world_width()
Definition wykobi_gui.hpp:77
virtual std::string window_title()
Definition wykobi_gui.hpp:72
virtual void idle_handler(void)
Definition wykobi_gui.hpp:70
virtual void menu_handler(int menu_choice)
Definition wykobi_gui.hpp:68
virtual int window_height()
Definition wykobi_gui.hpp:74
virtual void keyboard_handler(unsigned char key, int x, int y)
Definition wykobi_gui.hpp:62
void clear_black()
Definition wykobi_gui.hpp:80
virtual int window_width()
Definition wykobi_gui.hpp:73
eDisplayMode
Definition wykobi_gui.hpp:31
@ eDisplayMode3D
Definition wykobi_gui.hpp:31
@ eDisplayMode2D
Definition wykobi_gui.hpp:31