Files
escape-the-dawn/Escape-the-Dawn/Model.cpp
T
Tobias Dahl 54a5a7a113 WIP
2014-03-04 15:49:35 +01:00

80 lines
2.0 KiB
C++

#include "Model.h"
Model::Model()
{
temp_CreateModelShit();
CreateBuffers(Vertices, Normals, TextureCoords);
}
void Model::temp_CreateModelShit()
{
Vertices.push_back(0.0f);
Vertices.push_back(0.0f);
Vertices.push_back(2.0f);
Vertices.push_back(0.0f);
Vertices.push_back(1.0f);
Vertices.push_back(2.0f);
Vertices.push_back(1.0f);
Vertices.push_back(0.0f);
Vertices.push_back(2.0f);
Colors.push_back(1.0f);
Colors.push_back(1.0f);
Colors.push_back(1.0f);
Colors.push_back(1.0f);
Colors.push_back(1.0f);
Colors.push_back(1.0f);
Colors.push_back(1.0f);
Colors.push_back(1.0f);
Colors.push_back(1.0f);
Colors.push_back(1.0f);
Colors.push_back(1.0f);
Colors.push_back(1.0f);
}
void Model::CreateBuffers( std::vector<float> _Vertices, std::vector<float> _Normals, std::vector<float> _TextureCoords )
{
glGenBuffers(1, &VertBuffer);
glBindBuffer(GL_ARRAY_BUFFER, VertBuffer);
glBufferData(GL_ARRAY_BUFFER, Vertices.size()*sizeof(float), Vertices.data(), GL_STATIC_DRAW);
GLERROR("GLEW: BufferFail1");
glGenBuffers(1, &Colorbuffer);
glBindBuffer(GL_ARRAY_BUFFER, Colorbuffer);
glBufferData(GL_ARRAY_BUFFER, Colors.size()*sizeof(float), Colors.data(), GL_STATIC_DRAW);
GLERROR("GLEW: BufferFail2");
// glGenBuffers(1, &TextureCoordBuffer);
// glBindBuffer(GL_ARRAY_BUFFER, TextureCoordBuffer);
// glBufferData(GL_ARRAY_BUFFER, TextureCoords.size()*sizeof(float), TextureCoords.data(), GL_STATIC_DRAW);
// GLERROR("GLEW: BufferFail3");
glGenVertexArrays(1, &VAO);
glBindVertexArray(VAO);
GLERROR("GLEW: BufferFail4");
glBindBuffer(GL_ARRAY_BUFFER, VertBuffer);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
GLERROR("GLEW: BufferFail5");
glBindBuffer(GL_ARRAY_BUFFER, Colorbuffer);
glVertexAttribPointer(1, 4, GL_FLOAT, GL_FALSE, 0, 0);
// glBindBuffer(GL_ARRAY_BUFFER, TextureCoordBuffer);
// glVertexAttribPointer(2, 2, GL_FLOAT, GL_FALSE, 0, 0);
glEnableVertexAttribArray(0);
glEnableVertexAttribArray(1);
/* glEnableVertexAttribArray(2);*/
GLERROR("GLEW: BufferFail5");
}