I'm working on a 3D object viewer, a really basic opengl program i think. But i'm new to opengl and i find a problem that i can't resolve.
The last tutorial that i used is here : LearnOpenGL So the code than i'll show is from there (Model Loading part), i use Assimp to load the object.
There is some code:
Mesh Setup:
struct Vertex {
glm::vec3 position;
glm::vec3 normal;
glm::vec2 texCoords;
};
glGenVertexArrays(1, &this->m_VAO);
glGenBuffers(1, &this->m_VBO);
glGenBuffers(1, &this->m_EBO);
glBindVertexArray(this->m_VAO);
glBindBuffer(GL_ARRAY_BUFFER, this->m_VBO);
glBufferData(GL_ARRAY_BUFFER, this->m_vertices.size() * sizeof(Vertex),
&this->m_vertices[0], GL_STATIC_DRAW);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, this->m_EBO);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, this->m_indices.size() * sizeof(GLuint),
&this->m_indices[0], GL_STATIC_DRAW);
// Vertex Positions
glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex),
(GLvoid*)0);
// Vertex Normals
glEnableVertexAttribArray(1);
glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex),
(GLvoid*)offsetof(Vertex, normal));
// Vertex Texture Coords
glEnableVertexAttribArray(2);
glVertexAttribPointer(2, 2, GL_FLOAT, GL_FALSE, sizeof(Vertex),
(GLvoid*)offsetof(Vertex, texCoords));
glBindVertexArray(0);
You can check the whole code on the site.
Draw :
// Draw mesh
glBindVertexArray(model.get_VAO());
glDrawElements(GL_TRIANGLES, model.get_Indices_Size(), GL_UNSIGNED_INT, 0);
glBindVertexArray(0);
Shaders :
Vertex ->
#version 130
in vec4 gxl3d_Position;
in vec4 gxl3d_Color;
smooth out vec4 VertexColor;
void main() {
gl_Position = gxl3d_Position;
VertexColor = vec4(0.5f, 0.0f, 0.0f, 1.0f);
}
Fragment ->
#version 130
smooth in vec4 VertexColor;
void main() {
gl_FragColor = VertexColor;
}
When i run this, i can check than the last vertex from Assimp is not the same when i read the .obj directly, maybe it's normal?
So in the end i reach a "nouveau failed idel channel 0xcccc0000 Xorg 677"
If someone have any idea, Thanks!