Go to the documentation of this file.
20 #ifndef INCLUDE_WYKOBI_GRAPHICS_OPENGL
21 #define INCLUDE_WYKOBI_GRAPHICS_OPENGL
39 {0.0 / 255.0, 0.0 / 255.0, 0.0 / 255.0},
40 {255.0 / 255.0, 0.0 / 255.0, 0.0 / 255.0},
41 {0.0 / 255.0, 255.0 / 255.0, 0.0 / 255.0},
42 {0.0 / 255.0, 0.0 / 255.0, 255.0 / 255.0},
43 {255.0 / 255.0, 0.0 / 255.0, 255.0 / 255.0},
44 {0.0 / 255.0, 255.0 / 255.0, 255.0 / 255.0},
45 {0.0 / 255.0, 0.0 / 255.0, 255.0 / 255.0},
46 {255.0 / 255.0, 255.0 / 255.0, 0.0 / 255.0},
47 {0.0 / 255.0, 255.0 / 255.0, 255.0 / 255.0},
48 {255.0 / 255.0, 192.0 / 255.0, 64.0 / 255.0},
49 {255.0 / 255.0, 0.0 / 255.0, 255.0 / 255.0},
50 {255.0 / 255.0, 0.0 / 255.0, 0.0 / 255.0},
51 {255.0 / 255.0, 255.0 / 255.0, 255.0 / 255.0},
52 {255.0 / 255.0, 255.0 / 255.0, 0.0 / 255.0}};
68 inline void set_color(
const unsigned int& _red,
const unsigned int& _green,
69 const unsigned int& _blue) {
70 red = (1.0 * _red) / 256.0;
71 green = (1.0 * _green) / 256.0;
72 blue = (1.0 * _blue) / 256.0;
81 inline void set_color(
const unsigned int& color_index) {
93 inline void draw_text(
const T& x,
const T& y,
const std::string& text) {}
97 glVertex2d(
double(x),
double(y));
101 inline void draw_pixel(
const T& x,
const T& y,
const T& z)
const {
103 glVertex3d(
double(x),
double(y),
double(z));
110 glVertex2d(
double(x1),
double(y1));
111 glVertex2d(
double(x2),
double(y2));
115 inline void draw_segment(
const T& x1,
const T& y1,
const T& z1,
const T& x2,
116 const T& y2,
const T& z2)
const {
118 glVertex3d(x1, y1, z1);
119 glVertex3d(x2, y2, z2);
123 inline void draw_triangle(
const T& x1,
const T& y1,
const T& x2,
const T& y2,
124 const T& x3,
const T& y3)
const {
125 switch (drawing_mode) {
127 glBegin(GL_TRIANGLES);
130 glBegin(GL_LINE_LOOP);
135 glVertex2d(
double(x1),
double(y1));
136 glVertex2d(
double(x2),
double(y2));
137 glVertex2d(
double(x3),
double(y3));
141 inline void draw_triangle(
const T& x1,
const T& y1,
const T& z1,
const T& x2,
142 const T& y2,
const T& z2,
const T& x3,
const T& y3,
144 switch (drawing_mode) {
146 glBegin(GL_TRIANGLES);
149 glBegin(GL_LINE_LOOP);
154 glVertex3d(
double(x1),
double(y1),
double(z1));
155 glVertex3d(
double(x2),
double(y2),
double(z2));
156 glVertex3d(
double(x3),
double(y3),
double(z3));
160 inline void draw_quadix(
const T& x1,
const T& y1,
const T& x2,
const T& y2,
161 const T& x3,
const T& y3,
const T& x4,
163 switch (drawing_mode) {
168 glBegin(GL_LINE_LOOP);
173 glVertex2d(
double(x1),
double(y1));
174 glVertex2d(
double(x2),
double(y2));
175 glVertex2d(
double(x3),
double(y3));
176 glVertex2d(
double(x4),
double(y4));
180 inline void draw_quadix(
const T& x1,
const T& y1,
const T& z1,
const T& x2,
181 const T& y2,
const T& z2,
const T& x3,
const T& y3,
182 const T& z3,
const T& x4,
const T& y4,
184 switch (drawing_mode) {
189 glBegin(GL_LINE_LOOP);
194 glVertex3d(
double(x1),
double(y1),
double(z1));
195 glVertex3d(
double(x2),
double(y2),
double(z2));
196 glVertex3d(
double(x3),
double(y3),
double(z3));
197 glVertex3d(
double(x4),
double(y4),
double(z4));
206 inline void draw_circle(
const T& x,
const T& y,
const T& radius)
const {
209 switch (drawing_mode) {
211 glBegin(GL_TRIANGLE_FAN);
214 glBegin(GL_LINE_LOOP);
219 if (drawing_mode ==
eSolid) {
220 glVertex2d(
double(_polygon[0].x),
double(_polygon[0].y));
222 for (std::size_t i = (drawing_mode ==
eSolid) ? 1 : 0; i < _polygon.
size();
224 glVertex2d(
double(_polygon[i].x),
double(_polygon[i].y));
229 inline void draw_sphere(
const T& x,
const T& y,
const T& radius)
const {}
252 point3.
x, point3.
y, point3.
z);
266 point3.
x, point3.
y, point3.
z, point4.
x, point4.
y, point4.
z);
279 for (std::size_t i = 0; i < point_list.size() - 1; ++i) {
285 for (std::size_t i = 0; i < point_list.size() - 1; ++i) {
290 inline void clear() { glClear(GL_COLOR_BUFFER_BIT); }
332 switch (drawing_mode) {
337 glBegin(GL_LINE_LOOP);
359 const std::size_t& point_count) {
360 std::vector<point2d<T> > point_list;
366 const std::size_t& point_count) {
367 std::vector<point2d<T> > point_list;
373 const std::size_t& point_count) {
374 std::vector<point2d<T> > point_list;
380 const std::size_t& point_count) {
381 std::vector<point2d<T> > point_list;
388 unsigned int _height;
void set_color(const unsigned int &_red, const unsigned int &_green, const unsigned int &_blue)
Definition: wykobi_graphics_opengl.hpp:68
circle< T > make_circle(const T &x, const T &y, const T &radius)
Definition: wykobi.hpp:263
T radius
Definition: wykobi.hpp:428
Definition: wykobi.hpp:468
void draw_sphere(const T &x, const T &y, const T &radius) const
Definition: wykobi_graphics_opengl.hpp:229
T x
Definition: wykobi.hpp:435
void draw_triangle(const T &x1, const T &y1, const T &x2, const T &y2, const T &x3, const T &y3) const
Definition: wykobi_graphics_opengl.hpp:123
void draw_triangle(const point2d< T > &point1, const point2d< T > &point2, const point2d< T > &point3) const
Definition: wykobi_graphics_opengl.hpp:244
@ eSolid
Definition: wykobi_graphics_opengl.hpp:36
Definition: wykobi.hpp:426
void draw_quadix(const point3d< T > &point1, const point3d< T > &point2, const point3d< T > &point3, const point3d< T > &point4) const
Definition: wykobi_graphics_opengl.hpp:262
void draw_polyline(std::vector< point3d< T > > point_list)
Definition: wykobi_graphics_opengl.hpp:284
Definition: wykobi.hpp:383
T radius
Definition: wykobi.hpp:435
void draw_segment(const point2d< T > &point1, const point2d< T > &point2) const
Definition: wykobi_graphics_opengl.hpp:239
Definition: wykobi.hpp:335
void draw(const triangle< T, 3 > &triangle)
Definition: wykobi_graphics_opengl.hpp:313
void draw_segment(const T &x1, const T &y1, const T &x2, const T &y2) const
Definition: wykobi_graphics_opengl.hpp:107
void draw_polyline(std::vector< point2d< T > > point_list)
Definition: wykobi_graphics_opengl.hpp:278
void draw(const quadix< T, 3 > &quadix)
Definition: wykobi_graphics_opengl.hpp:316
std::size_t size() const
Definition: wykobi.hpp:412
void draw_quadix(const point2d< T > &point1, const point2d< T > &point2, const point2d< T > &point3, const point2d< T > &point4) const
Definition: wykobi_graphics_opengl.hpp:255
void draw_pixel(const T &x, const T &y, const T &z) const
Definition: wykobi_graphics_opengl.hpp:101
DrawingMode
Definition: wykobi_graphics_opengl.hpp:36
void draw_rectangle(const point2d< T > &point1, const point2d< T > &point2) const
Definition: wykobi_graphics_opengl.hpp:269
void draw_pixel(const point3d< T > &point) const
Definition: wykobi_graphics_opengl.hpp:235
void draw_triangle(const point3d< T > &point1, const point3d< T > &point2, const point3d< T > &point3) const
Definition: wykobi_graphics_opengl.hpp:249
T y
Definition: wykobi.hpp:104
void draw(const triangle< T, 2 > &triangle)
Definition: wykobi_graphics_opengl.hpp:296
Definition: wykobi_graphics_opengl.hpp:55
@ eNoDraw
Definition: wykobi_graphics_opengl.hpp:36
void draw_text(const T &x, const T &y, const std::string &text)
Definition: wykobi_graphics_opengl.hpp:93
void draw(const circle< T > &circle)
Definition: wykobi_graphics_opengl.hpp:305
T x
Definition: wykobi.hpp:428
void draw(const quadix< T, 2 > &quadix)
Definition: wykobi_graphics_opengl.hpp:302
Definition: wykobi.hpp:74
void clear()
Definition: wykobi_graphics_opengl.hpp:290
void draw_quadix(const T &x1, const T &y1, const T &x2, const T &y2, const T &x3, const T &y3, const T &x4, const T &y4) const
Definition: wykobi_graphics_opengl.hpp:160
T y
Definition: wykobi.hpp:428
void draw_triangle(const T &x1, const T &y1, const T &z1, const T &x2, const T &y2, const T &z2, const T &x3, const T &y3, const T &z3) const
Definition: wykobi_graphics_opengl.hpp:141
void draw(const segment< T, 3 > &segment)
Definition: wykobi_graphics_opengl.hpp:310
void draw(const rectangle< T > &rectangle)
Definition: wykobi_graphics_opengl.hpp:299
void draw(const quadratic_bezier< T, 3 > &bezier, const std::size_t &point_count)
Definition: wykobi_graphics_opengl.hpp:379
void draw(const point3d< T > &point)
Definition: wykobi_graphics_opengl.hpp:309
void set_color(const unsigned int &color_index)
Definition: wykobi_graphics_opengl.hpp:81
void draw(const point2d< T > &point)
Definition: wykobi_graphics_opengl.hpp:292
void draw_pixel(const point2d< T > &point) const
Definition: wykobi_graphics_opengl.hpp:231
void draw(const sphere< T > &sphere)
Definition: wykobi_graphics_opengl.hpp:319
polygon< T, D > make_polygon(const InputIterator begin, const InputIterator end)
Definition: wykobi.hpp:359
@ eOutLine
Definition: wykobi_graphics_opengl.hpp:36
Definition: wykobi.hpp:311
void draw(const segment< T, 2 > &segment)
Definition: wykobi_graphics_opengl.hpp:293
void draw_segment(const T &x1, const T &y1, const T &z1, const T &x2, const T &y2, const T &z2) const
Definition: wykobi_graphics_opengl.hpp:115
void draw(const polygon< T, 2 > &polygon, const bool convex=false)
Definition: wykobi_graphics_opengl.hpp:323
void draw(const polygon< T, 3 > &polygon)
Definition: wykobi_graphics_opengl.hpp:349
void draw(const cubic_bezier< T, 2 > &bezier, const std::size_t &point_count)
Definition: wykobi_graphics_opengl.hpp:358
void draw_circle(const T &x, const T &y, const T &radius) const
Definition: wykobi_graphics_opengl.hpp:206
Definition: wykobi.hpp:32
T x
Definition: wykobi.hpp:104
Definition: wykobi.hpp:493
T z
Definition: wykobi.hpp:135
void draw_pixel(const T &x, const T &y) const
Definition: wykobi_graphics_opengl.hpp:95
void draw_rectangle(const T &x1, const T &y1, const T &x2, const T &y2) const
Definition: wykobi_graphics_opengl.hpp:201
void generate_bezier(const quadratic_bezier< T, 2 > &bezier, OutputIterator out, const std::size_t &point_count=1000)
~wykobi_graphics_opengl()
Definition: wykobi_graphics_opengl.hpp:66
T y
Definition: wykobi.hpp:135
const GLfloat basic_color[14][3]
Definition: wykobi_graphics_opengl.hpp:38
Definition: wykobi.hpp:433
void draw_circle(const point2d< T > &point, const T &radius) const
Definition: wykobi_graphics_opengl.hpp:274
Definition: wykobi.hpp:108
void draw(const cubic_bezier< T, 3 > &bezier, const std::size_t &point_count)
Definition: wykobi_graphics_opengl.hpp:365
T y
Definition: wykobi.hpp:435
T x
Definition: wykobi.hpp:135
wykobi_graphics_opengl(const unsigned int &w, const unsigned int &h, DrawingMode dm)
Definition: wykobi_graphics_opengl.hpp:57
void draw_quadix(const T &x1, const T &y1, const T &z1, const T &x2, const T &y2, const T &z2, const T &x3, const T &y3, const T &z3, const T &x4, const T &y4, const T &z4) const
Definition: wykobi_graphics_opengl.hpp:180
void draw(const quadratic_bezier< T, 2 > &bezier, const std::size_t &point_count)
Definition: wykobi_graphics_opengl.hpp:372