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

application/025_recursive_cube/resources.hpp

Copyright Matus Chochlik. Distributed under the Boost Software License, Version 1.0. See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt

#ifndef OGLPLUS_EXAMPLE_RESOURCES_HPP // NOLINT(llvm-header-guard)
#define OGLPLUS_EXAMPLE_RESOURCES_HPP
#include <oglplus/gl.hpp>
//------------------------------------------------------------------------------
// program
//------------------------------------------------------------------------------
class cube_program {
public:
void init(execution_context&, video_context&);
void clean_up(video_context&);
void set_texture(video_context&, oglp::gl_types::int_type);
void set_projection(video_context&, const oglp::tmat<float, 4, 4, true>&);
void update(execution_context&, video_context&);
void bind_position_location(video_context&, oglp::vertex_attrib_location);
void bind_normal_location(video_context&, oglp::vertex_attrib_location);
void bind_tex_coord_location(video_context&, oglp::vertex_attrib_location);
private:
oglp::uniform_location projection_loc;
oglp::uniform_location modelview_loc;
oglp::uniform_location light_pos_loc;
oglp::uniform_location cube_tex_loc;
radians_t<float> rad{0.F};
};
//------------------------------------------------------------------------------
// geometry
//------------------------------------------------------------------------------
class cube_geometry {
public:
void init(execution_context&, video_context&);
void clean_up(video_context&);
void draw(video_context&);
static auto position_loc() noexcept {
}
static auto normal_loc() noexcept {
}
static auto tex_coord_loc() noexcept {
}
private:
oglp::owned_buffer_name positions;
oglp::owned_buffer_name normals;
oglp::owned_buffer_name tex_coords;
oglp::owned_buffer_name indices;
std::vector<oglp::shape_draw_operation> ops;
};
//------------------------------------------------------------------------------
// draw buffers
//------------------------------------------------------------------------------
class cube_draw_buffers {
public:
void init(execution_context&, video_context&);
void clean_up(video_context&);
auto back_fbo() const noexcept {
return oglp::framebuffer_name{objs.back().fbo};
}
auto front_tex_unit() const noexcept {
return objs.front().tex_unit;
}
auto side() const noexcept {
return tex_side;
}
void swap() {
objs.swap();
}
private:
const oglp::gl_types::sizei_type tex_side{512};
struct _buffer_objects {
};
double_buffer<_buffer_objects> objs{};
};
//------------------------------------------------------------------------------
} // namespace eagine::application
#endif
Application harness / wrapper code is placed in this namespace.
Definition: eagine.hpp:72
GLsizei sizei_type
Signed integer size type.
Definition: config.hpp:88
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< renderbuffer_tag > owned_renderbuffer_name
Alias for owned GL renderbuffer object handle.
Definition: object_name.hpp:198
gl_owned_object_name< texture_tag > owned_texture_name
Alias for owned GL texture object handle.
Definition: object_name.hpp:213
gl_object_name< framebuffer_tag > framebuffer_name
Alias for GL framebuffer object handle.
Definition: object_name.hpp:118
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
gl_owned_object_name< framebuffer_tag > owned_framebuffer_name
Alias for owned GL framebuffer object handle.
Definition: object_name.hpp:178

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