Go to the documentation of this file.
4 #include <GLFW/glfw3.h>
12 #include <unordered_map>
60 std::vector<mesh_data>
loadObjects(std::string
const& filename);
75 GLenum target = GL_TEXTURE_2D,
76 GLint internal_format = GL_RGBA,
77 GLenum format = GL_RGBA,
78 GLenum type = GL_UNSIGNED_BYTE,
79 GLvoid
const* data =
nullptr);
87 bool generate_mipmap =
true);
100 std::string
const& posy, std::string
const& negy,
101 std::string
const& posz, std::string
const& negz,
102 bool generate_mipmap =
true);
112 GLuint
createProgram(std::string
const& vert_shader_source_path,
113 std::string
const& frag_shader_source_path);
137 glm::vec2
const& upper_right, GLuint texture,
138 GLuint sampler, glm::ivec4
const& swizzle,
139 glm::ivec2
const& window_size,
bool linearise =
false,
140 float nearPlane = 0.0f,
float farPlane = 0.0f);
150 GLuint
createFBO(std::vector<GLuint>
const& color_attachments,
151 GLuint depth_attachment = 0u);
157 GLuint
createSampler(std::function<
void (GLuint)>
const& setup);
void deinit()
Deallocate objects allocated by the init() function.
Definition: helpers.cpp:41
GLuint createFBO(std::vector< GLuint > const &color_attachments, GLuint depth_attachment=0u)
Create an OpenGL FrameBuffer Object using the specified attachments.
Definition: helpers.cpp:409
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:361
GLuint loadTexture2D(std::string const &filename, bool generate_mipmap=true)
Load an image into an OpenGL 2D-texture.
Definition: helpers.cpp:268
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:450
@ tangents
= 3, value of the binding point for tangents
shader_bindings
Formalise mapping between an OpenGL VAO attribute binding, and the meaning of that attribute.
Definition: helpers.hpp:19
size_t indices_nb
number of indices stored in ibo
Definition: helpers.hpp:37
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:242
size_t vertices_nb
number of vertices stored in bo
Definition: helpers.hpp:36
@ texcoords
= 2, value of the binding point for texcoords
GLuint vao
OpenGL name of the Vertex Array Object.
Definition: helpers.hpp:33
GLuint createSampler(std::function< void(GLuint)> const &setup)
Create an OpenGL sampler and set it up.
Definition: helpers.cpp:432
GLuint bo
OpenGL name of the Buffer Object.
Definition: helpers.hpp:34
void drawFullscreen()
Draw full screen.
Definition: helpers.cpp:442
std::vector< mesh_data > loadObjects(std::string const &filename)
Load objects found in an object/scene file, using assimp.
Definition: helpers.cpp:69
GLenum drawing_mode
OpenGL drawing mode, i.e. GL_TRIANGLES, GL_LINES, etc.
Definition: helpers.hpp:39
Contains the data for a mesh in OpenGL.
Definition: helpers.hpp:32
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
@ binormals
= 4, value of the binding point for binormals
texture_bindings bindings
texture bindings for this mesh
Definition: helpers.hpp:38
@ normals
= 1, value of the binding point for normals
Namespace containing a few helpers for the LUGG computer graphics labs.
Definition: helpers.hpp:16
std::string name
Name of the mesh; used for debugging purposes.
Definition: helpers.hpp:40
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:461
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:380
@ vertices
= 0, value of the binding point for vertices
void init()
Allocate some objects needed by some helper functions.
Definition: helpers.cpp:31
GLuint ibo
OpenGL name of the Buffer Object for indices.
Definition: helpers.hpp:35
polygon_mode_t
Definition: helpers.hpp:43
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:287