added sample for a mesh class used for rendering an object (maybe more like a mesh component?)

This commit is contained in:
Daniel 2023-07-24 14:46:06 +02:00
parent 82649e7648
commit 6aa1460068
4 changed files with 28 additions and 1 deletions

View File

@ -153,6 +153,7 @@
<ClInclude Include="Exceptions\IOException.h" />
<ClInclude Include="Exceptions\Shaders\CreateProgramException.h" />
<ClInclude Include="Exceptions\Shaders\ShaderCompileException.h" />
<ClInclude Include="mesh\mesh.h" />
<ClInclude Include="Shaders\Enums.h" />
<ClInclude Include="Shaders\Shader.h" />
</ItemGroup>

View File

@ -41,6 +41,9 @@
<ClInclude Include="Exceptions\Shaders\CreateProgramException.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="mesh\mesh.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<CopyFileToFolders Include="Shaders\default\default.frag" />

View File

@ -6,7 +6,7 @@
#include "shaders/Shader.h"
// Continue: https://learnopengl.com/Getting-started/Shaders
// Continue: https://learnopengl.com/Getting-started/Textures
// Chapter: Not yet started
//
@ -74,6 +74,8 @@ int main()
1, 2, 3
};
// VBO == all verticies; EBO == connection of vertices (faces) and is optional although it is a bit more efficient than using VBOs;
// VAO == collection of VBOs/EBOs used for rendering
GLuint vertexBufferObject, elementBufferObject, vertexArrayObject;
glGenVertexArrays(1, &vertexArrayObject);
glGenBuffers(1, &vertexBufferObject);

21
src/Engine/mesh/mesh.h Normal file
View File

@ -0,0 +1,21 @@
#pragma once
#include <vector>
#include "../shaders/Shader.h"
namespace Nebulix {
class Mesh
{
public:
/// <summary>
/// Creates a new mesh using the default shader
/// </summary>
/// <param name="vertices">The list of vertices of this mesh</param>
/// <param name="faces">A list of faces, where each face contains the 3 indices of the given vertices used for constructing a triangle</param>
Mesh(const std::vector<GLfloat> &vertices, const std::vector<GLfloat[3]> &faces);
Mesh(const std::vector<GLfloat> &vertices, const std::vector<GLfloat[3]> &faces, Shader shader);
~Mesh();
private:
};
}