4 #include <GLFW/glfw3.h>
12 #include <unordered_map>
51 std::string
name{
"un-named mesh"};
77 std::vector<mesh_data>
loadObjects(std::string
const& filename);
92 GLenum target = GL_TEXTURE_2D,
93 GLint internal_format = GL_RGBA,
94 GLenum format = GL_RGBA,
95 GLenum type = GL_UNSIGNED_BYTE,
96 GLvoid
const* data =
nullptr);
104 bool generate_mipmap =
true);
117 std::string
const& posy, std::string
const& negy,
118 std::string
const& posz, std::string
const& negz,
119 bool generate_mipmap =
true);
129 GLuint
createProgram(std::string
const& vert_shader_source_path,
130 std::string
const& frag_shader_source_path);
154 glm::vec2
const& upper_right, GLuint texture,
155 GLuint sampler, glm::ivec4
const& swizzle,
156 glm::ivec2
const& window_size,
bool linearise =
false,
157 float nearPlane = 0.0f,
float farPlane = 0.0f);
167 GLuint
createFBO(std::vector<GLuint>
const& color_attachments,
168 GLuint depth_attachment = 0u);
174 GLuint
createSampler(std::function<
void (GLuint)>
const& setup);
GLuint world
Definition: helpers.cpp:29
GLuint thickness_scale
Definition: helpers.cpp:31
GLuint length_scale
Definition: helpers.cpp:32
Namespace containing a few helpers for the LUGG computer graphics labs.
Definition: helpers.hpp:16
GLuint loadTexture2D(std::string const &filename, bool generate_mipmap=true)
Load an image into an OpenGL 2D-texture.
Definition: helpers.cpp:385
GLuint 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.
Definition: helpers.cpp:478
void 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.
Definition: helpers.cpp:497
GLuint 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.
Definition: helpers.cpp:404
void drawFullscreen()
Draw full screen.
Definition: helpers.cpp:559
GLuint getDebugTextureID()
Retrieve the ID of a small placeholder texture.
Definition: helpers.cpp:567
void init()
Allocate some objects needed by some helper functions.
Definition: helpers.cpp:59
void changePolygonMode(enum polygon_mode_t const polygon_mode) noexcept
Call glPolygonMode for both front and back faces, with the specified polygon mode.
Definition: helpers.cpp:630
bool 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.
Definition: helpers.cpp:590
shader_bindings
Formalise mapping between an OpenGL VAO attribute binding, and the meaning of that attribute.
Definition: helpers.hpp:19
@ tangents
= 3, value of the binding point for tangents
@ binormals
= 4, value of the binding point for binormals
@ texcoords
= 2, value of the binding point for texcoords
@ normals
= 1, value of the binding point for normals
@ vertices
= 0, value of the binding point for vertices
std::unordered_map< std::string, GLuint > texture_bindings
Association of a sampler name used in GLSL to a corresponding texture ID.
Definition: helpers.hpp:29
polygon_mode_t
Definition: helpers.hpp:60
void deinit()
Deallocate objects allocated by the init() function.
Definition: helpers.cpp:72
cull_mode_t
Definition: helpers.hpp:54
GLuint 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.
Definition: helpers.cpp:359
void 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.
Definition: helpers.cpp:573
GLuint createSampler(std::function< void(GLuint)> const &setup)
Create an OpenGL sampler and set it up.
Definition: helpers.cpp:549
void changeCullMode(enum cull_mode_t const cull_mode) noexcept
Enable or disable culling, and call glCullFace with the specified cull mode.
Definition: helpers.cpp:601
std::vector< mesh_data > loadObjects(std::string const &filename)
Load objects found in an object/scene file, using assimp.
Definition: helpers.cpp:109
bool 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.
Definition: helpers.cpp:619
GLuint createFBO(std::vector< GLuint > const &color_attachments, GLuint depth_attachment=0u)
Create an OpenGL FrameBuffer Object using the specified attachments.
Definition: helpers.cpp:526
Definition: helpers.hpp:31
glm::vec3 diffuse
Definition: helpers.hpp:32
float indexOfRefraction
Definition: helpers.hpp:37
float opacity
Definition: helpers.hpp:38
float shininess
Definition: helpers.hpp:36
glm::vec3 specular
Definition: helpers.hpp:33
glm::vec3 ambient
Definition: helpers.hpp:34
glm::vec3 emissive
Definition: helpers.hpp:35
Contains the data for a mesh in OpenGL.
Definition: helpers.hpp:42
GLsizei vertices_nb
number of vertices stored in bo
Definition: helpers.hpp:46
material_data material
constant values for the material of this mesh
Definition: helpers.hpp:49
GLuint bo
OpenGL name of the Buffer Object.
Definition: helpers.hpp:44
GLsizei indices_nb
number of indices stored in ibo
Definition: helpers.hpp:47
std::string name
Name of the mesh; used for debugging purposes.
Definition: helpers.hpp:51
texture_bindings bindings
texture bindings for this mesh
Definition: helpers.hpp:48
GLuint vao
OpenGL name of the Vertex Array Object.
Definition: helpers.hpp:43
GLenum drawing_mode
OpenGL drawing mode, i.e. GL_TRIANGLES, GL_LINES, etc.
Definition: helpers.hpp:50
GLuint ibo
OpenGL name of the Buffer Object for indices.
Definition: helpers.hpp:45