CG_Labs  2021.2
Classes | Namespaces | Typedefs | Enumerations | Functions
helpers.hpp File Reference
#include <glad/glad.h>
#include <GLFW/glfw3.h>
#include <glm/glm.hpp>
#include "core/FPSCamera.h"
#include <functional>
#include <string>
#include <vector>
#include <unordered_map>

Go to the source code of this file.

Classes

struct  bonobo::material_data
 
struct  bonobo::mesh_data
 Contains the data for a mesh in OpenGL. More...
 

Namespaces

 bonobo
 Namespace containing a few helpers for the LUGG computer graphics labs.
 

Typedefs

using bonobo::texture_bindings = std::unordered_map< std::string, GLuint >
 Association of a sampler name used in GLSL to a corresponding texture ID. More...
 

Enumerations

enum class  bonobo::shader_bindings : unsigned int {
  bonobo::vertices = 0u , bonobo::normals , bonobo::texcoords , bonobo::tangents ,
  bonobo::binormals
}
 Formalise mapping between an OpenGL VAO attribute binding, and the meaning of that attribute. More...
 
enum class  bonobo::cull_mode_t : unsigned int { bonobo::disabled = 0u , bonobo::back_faces , bonobo::front_faces }
 
enum class  bonobo::polygon_mode_t : unsigned int { bonobo::fill = 0u , bonobo::line , bonobo::point }
 

Functions

void bonobo::init ()
 Allocate some objects needed by some helper functions. More...
 
void bonobo::deinit ()
 Deallocate objects allocated by the init() function. More...
 
std::vector< mesh_data > bonobo::loadObjects (std::string const &filename)
 Load objects found in an object/scene file, using assimp. More...
 
GLuint bonobo::createTexture (uint32_t width, uint32_t height, GLenum target=GL_TEXTURE_2D, GLint internal_format=GL_RGBA, GLenum format=GL_RGBA, GLenum type=GL_UNSIGNED_BYTE, GLvoid const *data=nullptr)
 Creates an OpenGL texture without any content nor parameters. More...
 
GLuint bonobo::loadTexture2D (std::string const &filename, bool generate_mipmap=true)
 Load an image into an OpenGL 2D-texture. More...
 
GLuint bonobo::loadTextureCubeMap (std::string const &posx, std::string const &negx, std::string const &posy, std::string const &negy, std::string const &posz, std::string const &negz, bool generate_mipmap=true)
 Load six images into an OpenGL cubemap-texture. More...
 
GLuint bonobo::createProgram (std::string const &vert_shader_source_path, std::string const &frag_shader_source_path)
 Create an OpenGL program consisting of a vertex and a fragment shader. More...
 
void bonobo::displayTexture (glm::vec2 const &lower_left, glm::vec2 const &upper_right, GLuint texture, GLuint sampler, glm::ivec4 const &swizzle, glm::ivec2 const &window_size, bool linearise=false, float nearPlane=0.0f, float farPlane=0.0f)
 Display the current texture in the specified rectangle. More...
 
GLuint bonobo::createFBO (std::vector< GLuint > const &color_attachments, GLuint depth_attachment=0u)
 Create an OpenGL FrameBuffer Object using the specified attachments. More...
 
GLuint bonobo::createSampler (std::function< void(GLuint)> const &setup)
 Create an OpenGL sampler and set it up. More...
 
void bonobo::drawFullscreen ()
 Draw full screen. More...
 
GLuint bonobo::getDebugTextureID ()
 Retrieve the ID of a small placeholder texture. More...
 
void bonobo::renderBasis (float thickness_scale, float length_scale, glm::mat4 const &view_projection, glm::mat4 const &world=glm::mat4(1.0f))
 Render a right-hand orthonormal basis. More...
 
bool bonobo::uiSelectCullMode (std::string const &label, enum cull_mode_t &cull_mode) noexcept
 Add a combo box to the current ImGUI window, to choose a cull mode. More...
 
void bonobo::changeCullMode (enum cull_mode_t const cull_mode) noexcept
 Enable or disable culling, and call glCullFace with the specified cull mode. More...
 
bool bonobo::uiSelectPolygonMode (std::string const &label, enum polygon_mode_t &polygon_mode) noexcept
 Add a combo box to the current ImGUI window, to choose a polygon mode. More...
 
void bonobo::changePolygonMode (enum polygon_mode_t const polygon_mode) noexcept
 Call glPolygonMode for both front and back faces, with the specified polygon mode. More...