OGLplus  (0.59.0) a C++ wrapper for rendering APIs

resources.hpp
1 
9 #ifndef OGLPLUS_EXAMPLE_RESOURCES_HPP // NOLINT(llvm-header-guard)
10 #define OGLPLUS_EXAMPLE_RESOURCES_HPP
11 
12 #include <oglplus/gl.hpp>
13 #include <oglplus/gl_api.hpp>
14 
16 #include <eagine/cleanup_group.hpp>
17 #include <eagine/quantities.hpp>
20 
21 namespace eagine::application {
22 //------------------------------------------------------------------------------
23 // programs
24 //------------------------------------------------------------------------------
25 class depth_program {
26 public:
27  void init(execution_context&, video_context&, cleanup_group&);
28  void set_camera(video_context& ctx, orbiting_camera& camera);
29  void update(video_context&);
30 
31  void bind_position_location(video_context&, oglp::vertex_attrib_location);
32 
33 private:
35 
36  oglp::uniform_location camera_loc;
37 };
38 //------------------------------------------------------------------------------
39 class draw_program {
40 public:
41  void init(execution_context&, video_context&, cleanup_group&);
42  void set_depth_texture(video_context& ctx, oglp::gl_types::int_type);
43  void set_camera(video_context&, orbiting_camera& camera);
44  void update(execution_context&, video_context&);
45 
46  void bind_position_location(video_context&, oglp::vertex_attrib_location);
47  void bind_normal_location(video_context& ctx, oglp::vertex_attrib_location);
48 
49 private:
51 
52  oglp::uniform_location camera_loc;
53  oglp::uniform_location light_pos_loc;
54  oglp::uniform_location depth_tex_loc;
55 
56  radians_t<float> rad{0.F};
57 };
58 //------------------------------------------------------------------------------
59 // geometry
60 //------------------------------------------------------------------------------
61 class arrow_geometry {
62 public:
63  void init(execution_context&, video_context&, cleanup_group&);
64  void draw(video_context&);
65 
66  auto bounding_sphere() noexcept {
67  return bound_sphere;
68  }
69 
70  static auto position_loc() noexcept {
72  }
73 
74  static auto normal_loc() noexcept {
76  }
77 
78 private:
80 
81  oglp::owned_buffer_name positions;
82  oglp::owned_buffer_name normals;
83  oglp::owned_buffer_name indices;
84 
85  std::vector<oglp::shape_draw_operation> ops;
86 
87  oglp::sphere bound_sphere;
88 };
89 //------------------------------------------------------------------------------
90 class depth_texture {
91 public:
92  void init(execution_context&, video_context&, cleanup_group&);
93  void reshape(video_context&);
94  void copy_from_fb(video_context&);
95 
96  auto texture_unit() const noexcept {
97  return tex_unit;
98  }
99 
100 private:
101  oglp::gl_types::int_type tex_unit{0};
103 };
104 //------------------------------------------------------------------------------
105 } // namespace eagine::application
106 
107 #endif
Application harness / wrapper code is placed in this namespace.
Definition: eagine.hpp:72
prog_var_location< EAGINE_ID_V(Uniform)> uniform_location
Alias for shader program uniform location wrapper.
Definition: prog_var_loc.hpp:115
GLint int_type
Signed integer type.
Definition: config.hpp:70
gl_owned_object_name< texture_tag > owned_texture_name
Alias for owned GL texture object handle.
Definition: object_name.hpp:213
gl_owned_object_name< vertex_array_tag > owned_vertex_array_name
Alias for owned GL vertex array object handle.
Definition: object_name.hpp:224
prog_var_location< EAGINE_ID_V(VertexAttr)> vertex_attrib_location
Alias for program vertex attribute location wrapper.
Definition: prog_var_loc.hpp:104
basic_sphere< T, 3, V > sphere
Alias for spheres in 3D space.
Definition: primitives.hpp:148
gl_owned_object_name< program_tag > owned_program_name
Alias for owned GL program object handle.
Definition: object_name.hpp:188

Copyright © 2015-2021 Matúš Chochlík.
<chochlik -at -gmail.com>
Documentation generated on Tue Apr 13 2021 by Doxygen (version 1.8.17).