A cube is rendered with the new system!
This commit is contained in:
parent
02b0f6a67a
commit
511b2da319
@ -10,14 +10,20 @@
|
||||
#include <vector>
|
||||
|
||||
struct Mesh {
|
||||
explicit Mesh(std::vector<float> vertices) : vertices(vertices), vertex_count(vertices.size() / 5) {
|
||||
explicit Mesh(const std::vector<float> &_vertices) : vertex_count(_vertices.size()) {
|
||||
// Copy the vertices into a local classic float array. Nothing was displayed without this, maybe
|
||||
// due to weird hidden type incompatibility or out of scope issues?
|
||||
float vertices[vertex_count];
|
||||
std::copy(_vertices.begin(), _vertices.end(), vertices);
|
||||
|
||||
glGenVertexArrays(1, &VAO);
|
||||
glGenBuffers(1, &VBO);
|
||||
|
||||
// bind the Vertex Array Object first, then bind and set vertex buffer(s), and then configure vertex attributes(s).
|
||||
glBindVertexArray(VAO);
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, VBO);
|
||||
glBufferData(GL_ARRAY_BUFFER, sizeof(&vertices), &vertices, GL_STATIC_DRAW);
|
||||
glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);
|
||||
|
||||
// position attribute
|
||||
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 5 * sizeof(float), (void*)0);
|
||||
@ -37,9 +43,6 @@ private:
|
||||
unsigned int VBO;
|
||||
unsigned int VAO;
|
||||
unsigned int vertex_count;
|
||||
|
||||
/// Vertices in the format x, y, z, u, v
|
||||
std::vector<float> vertices;
|
||||
};
|
||||
|
||||
#endif //ECSGAME_MESH_H
|
||||
|
@ -1,6 +1,6 @@
|
||||
#version 320 es
|
||||
layout (location = 0) in vec3 aPos;
|
||||
layout (location = 1) in vec3 uvPos;
|
||||
layout (location = 1) in vec2 uvPos;
|
||||
|
||||
uniform mat4 model;
|
||||
uniform mat4 view;
|
||||
|
Loading…
x
Reference in New Issue
Block a user