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 
18 
19 namespace eagine::application {
20 //------------------------------------------------------------------------------
21 // program
22 //------------------------------------------------------------------------------
23 class surface_program {
24 public:
25  void init(execution_context&, video_context&);
26  void clean_up(video_context&);
27  void prepare_frame(video_context&, orbiting_camera& camera, float t);
28 
29  void bind_position_location(video_context&, oglp::vertex_attrib_location);
30  void bind_normal_location(video_context&, oglp::vertex_attrib_location);
31 
32 private:
34  oglp::uniform_location _model_loc;
35  oglp::uniform_location _view_loc;
36  oglp::uniform_location _projection_loc;
37 };
38 //------------------------------------------------------------------------------
39 class halo_program {
40 public:
41  void init(execution_context&, video_context&);
42  void clean_up(video_context&);
43  void prepare_frame(video_context&, orbiting_camera& camera, float t);
44 
45  void bind_position_location(video_context&, oglp::vertex_attrib_location);
46  void bind_normal_location(video_context&, oglp::vertex_attrib_location);
47 
48 private:
50  oglp::uniform_location _model_loc;
51  oglp::uniform_location _view_loc;
52  oglp::uniform_location _projection_loc;
53  oglp::uniform_location _camera_pos_loc;
54 };
55 //------------------------------------------------------------------------------
56 // geometry
57 //------------------------------------------------------------------------------
58 class shape_geometry {
59 public:
60  shape_geometry(std::shared_ptr<shapes::generator> gen)
61  : _gen{std::move(gen)} {}
62 
63  void init(execution_context&, video_context&);
64  void clean_up(video_context&);
65  void draw(execution_context&, video_context&);
66 
67  static auto position_loc() noexcept {
69  }
70 
71  static auto normal_loc() noexcept {
73  }
74 
75 private:
76  std::shared_ptr<shapes::generator> _gen;
78 
79  oglp::owned_buffer_name _positions;
80  oglp::owned_buffer_name _normals;
81  oglp::owned_buffer_name _indices;
82 
83  std::vector<oglp::shape_draw_operation> _ops;
84 };
85 //------------------------------------------------------------------------------
86 } // namespace eagine::application
87 
88 #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
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
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).