Graphite Version 3
An experimental 3D geometry processing program
Loading...
Searching...
No Matches
render_area.h
1/*
2 * OGF/Graphite: Geometry and Graphics Programming Library + Utilities
3 * Copyright (C) 2000 Bruno Levy
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 *
19 * If you modify this software, you should include a notice giving the
20 * name of the person performing the modification, the date of modification,
21 * and the reason for such modification.
22 *
23 * Contact: Bruno Levy
24 *
25 * levy@loria.fr
26 *
27 * ISA Project
28 * LORIA, INRIA Lorraine,
29 * Campus Scientifique, BP 239
30 * 54506 VANDOEUVRE LES NANCY CEDEX
31 * FRANCE
32 *
33 * Note that the GNU General Public License does not permit incorporating
34 * the Software into proprietary programs.
35 */
36
37#ifndef H_SKIN_IMGUI_RENDER_AREA_H
38#define H_SKIN_IMGUI_RENDER_AREA_H
39
43#include <OGF/gom/types/node.h>
44
45#include <geogram/image/color.h>
46
47struct GLUPContext;
48
49namespace OGF {
50
56 gom_class SKIN_IMGUI_API RenderArea : public Object {
57 public:
58
65
69 ~RenderArea() override;
70
79 void resize(index_t w, index_t h, index_t fb_w, index_t fb_h);
80
86 bool needs_to_redraw() const {
87 return dirty_;
88 }
89
90
91 gom_slots:
92
97 void draw();
98
103 void update();
104
109
114
128 const std::string& filename, bool make_current = true,
129 bool with_gui = false
130 );
131
137
152 Memory::pointer ptr,
153 Image::ColorEncoding color_encoding,
154 Image::ComponentEncoding component_encoding,
155 index_t width, index_t height
156 );
157
166
174 void set_center(int x, int y);
175
176 gom_properties:
181 index_t get_width() const {
182 return width_;
183 }
184
190 return height_;
191 }
192
198 return frame_buffer_width_;
199 }
200
206 return frame_buffer_height_;
207 }
208
214 void set_projection_matrix(const mat4& value);
215
222
228 void set_viewing_matrix(const mat4& value);
229
235 const mat4& get_viewing_matrix() const;
236
241 void set_background_color_1(const Color& value);
242
248
255 void set_background_color_2(const Color& value);
256
263
272 void set_background_image(const std::string& value);
273
279 const std::string& get_background_image() const;
280
288 void set_lighting_matrix(const mat4& value);
289
295 const mat4& get_lighting_matrix() const;
296
302
307 std::string get_gpu_information() const;
308
313 std::string get_gpu_extensions() const;
314
315 gom_signals:
320 void redraw_request(RenderingContext* rendering_context=nullptr);
321
330 RenderingContext* rendering_context, int width, int height
331 );
332
345 RenderingContext* rendering_context,
346 const vec2& point_ndc, const vec2& point_wc,
347 int button, bool control, bool shift
348 );
349
369 RenderingContext* rendering_context,
370 const vec2& point_ndc, const vec2& point_wc,
371 const vec2& delta_ndc, double delta_x_ndc, double delta_y_ndc,
372 const vec2& delta_wc,
373 int button, bool control, bool shift
374 );
375
388 RenderingContext* rendering_context,
389 const vec2& point_ndc, const vec2& point_wc,
390 int button, bool control, bool shift
391 );
392
399 void key_down(const std::string& value);
400
407 void key_up(const std::string& value);
408
414 void button_down(int value);
415
421 void button_up(int value);
422
429 void dropped_file(const std::string& filename);
430
431 public:
432 void mouse_button_callback(int button, int action, int mods);
433 void scroll_callback(double xoffset, double yoffset);
434
442 void cursor_pos_callback(double xf, double yf);
443 void drop_callback(int nb, const char** p);
444 void char_callback(unsigned int c);
445 void key_callback(int key, int scancode, int action, int mods);
446
447 protected:
448
453
458
459 private:
460 RenderingContext_var rendering_context_;
461 index_t width_;
462 index_t height_;
463 index_t frame_buffer_width_;
464 index_t frame_buffer_height_;
465
466 index_t button_down_;
467 bool control_is_down_;
468 bool shift_is_down_;
469 vec2 last_point_dc_;
470 vec2 last_point_ndc_;
471 vec2 last_point_wc_;
472 Color background_color_;
473 Color background_color_2_;
474 mat4 viewing_matrix_;
475 mat4 lighting_matrix_;
476 std::string background_image_;
477 GLUPContext* glup_context_;
478 bool dirty_;
479 };
480
482
483}
484
485#endif
ComponentEncoding
Indicates the datatype used to encode each component of the colors.
Definition image.h:74
ColorEncoding
Indicates how colors are encoded within the image.
Definition image.h:66
Base class for all objects in the GOM system.
Definition object.h:65
Implementation of RenderArea using ImGui.
Definition render_area.h:56
RenderArea(index_t w, index_t h, index_t fb_w, index_t fb_h)
RenderArea constructor.
void resize(index_t w, index_t h, index_t fb_w, index_t fb_h)
Resizes this RenderArea.
void GL_terminate()
Deallocates OpenGL and GLUP objects.
void set_center(int x, int y)
Sets the center.
void set_background_image(const std::string &value)
Sets the background image.
const mat4 & get_projection_matrix() const
Gets the projection matrix.
void set_projection_matrix(const mat4 &value)
Sets the projection matrix.
void mouse_down(RenderingContext *rendering_context, const vec2 &point_ndc, const vec2 &point_wc, int button, bool control, bool shift)
A signal that is triggered each time a mouse button is pushed.
void update_background_image_from_data(Memory::pointer ptr, Image::ColorEncoding color_encoding, Image::ComponentEncoding component_encoding, index_t width, index_t height)
Updates the background image from raw image data.
const Color & get_background_color_1() const
Gets the background color.
void set_background_color_1(const Color &value)
Sets the primary background color.
void key_up(const std::string &value)
A signal that is triggered each time a key is released.
void update()
Invalidates the memorized frame so that it will be updated on the next call to draw().
void mouse_move(RenderingContext *rendering_context, const vec2 &point_ndc, const vec2 &point_wc, const vec2 &delta_ndc, double delta_x_ndc, double delta_y_ndc, const vec2 &delta_wc, int button, bool control, bool shift)
A signal that is triggered when the mouse is dragged with a pushed button.
void snapshot(const std::string &filename, bool make_current=true, bool with_gui=false)
Saves a snapshot of this rendering area to an image file.
void dropped_file(const std::string &filename)
A signal that is triggered whenever a file is drag-dropped into this RenderArea.
void update_memorized_frame()
Re-generates the memorized frame.
RenderingContext * get_rendering_context() const
Gets the rendering context.
void GL_initialize()
Initializes OpenGL and GLUP objects.
const Color & get_background_color_2() const
Gets the secondary background color.
index_t get_frame_buffer_height() const
Gets the height of the window.
void key_down(const std::string &value)
A signal that is triggered each time a key is pushed.
void button_down(int value)
A signal that is triggered each time a mouse button is pressed.
const mat4 & get_lighting_matrix() const
Gets the lighting matrix.
const std::string & get_background_image() const
Gets the background image.
void cursor_pos_callback(double xf, double yf)
void mouse_up(RenderingContext *rendering_context, const vec2 &point_ndc, const vec2 &point_wc, int button, bool control, bool shift)
A signal that is triggered each time a mouse button is released.
void update_view_parameters()
Call this function if perspective mode is changed.
void set_lighting_matrix(const mat4 &value)
Sets the lighting matrix.
bool needs_to_redraw() const
Tests whether the window needs to be redrawn.
Definition render_area.h:86
std::string get_gpu_information() const
Gets the GPU information.
index_t get_frame_buffer_width() const
Gets the width of the window.
void set_background_color_2(const Color &value)
Sets the secondary background color.
const mat4 & get_viewing_matrix() const
Gets the viewing matrix.
void set_center_from_imgui_coords(int x, int y)
Sets the center.
void draw_memorized_frame()
Draws the latest memorized frame.
void button_up(int value)
A signal that is triggered each time a mouse button is released.
~RenderArea() override
RenderArea destructor.
std::string get_gpu_extensions() const
Gets GPU extensions.
void set_viewing_matrix(const mat4 &value)
Sets the viewing matrix.
index_t get_height() const
Gets the height of the window.
void resize_request(RenderingContext *rendering_context, int width, int height)
A signal that is triggered each time the render area is resized.
Helper class for OpenGL context management.
Color types.
byte * pointer
Pointer to unsigned byte(s)
Definition memory.h:104
geo_index_t index_t
The type for storing and manipulating indices.
Definition numeric.h:330
Global Graphite namespace.
Definition common.h:76
The base class for all composite objects in the GOM system.
Transformation of user input between the screen and the 3D space.
Helper class for OpenGL context management.
Definitions common to all include files in the skin_imgui library.