Compare commits

..

No commits in common. "master" and "v0.2" have entirely different histories.
master ... v0.2

4 changed files with 4 additions and 26 deletions

View File

@ -9,7 +9,6 @@
"functional": "cpp", "functional": "cpp",
"tuple": "cpp", "tuple": "cpp",
"type_traits": "cpp", "type_traits": "cpp",
"utility": "cpp", "utility": "cpp"
"new": "cpp"
} }
} }

View File

@ -2,7 +2,6 @@
#define MODEL_H #define MODEL_H
#include "Buffers.h" #include "Buffers.h"
#include "Texture.h"
#include <GLM/glm.hpp> #include <GLM/glm.hpp>
#include <GLM/gtc/quaternion.hpp> #include <GLM/gtc/quaternion.hpp>
@ -66,7 +65,6 @@ class Model : public Node
void load_indices(GLuint* indices, GLuint count); // Загрузка индексов в буфер void load_indices(GLuint* indices, GLuint count); // Загрузка индексов в буфер
void load_texCoords(glm::vec2* texCoords, GLuint count); // Загрузка текстурных координат в буфер void load_texCoords(glm::vec2* texCoords, GLuint count); // Загрузка текстурных координат в буфер
void set_index_range(size_t first_byteOffset, size_t count); // Ограничение диапазона из буфера индексов void set_index_range(size_t first_byteOffset, size_t count); // Ограничение диапазона из буфера индексов
void set_texture(Texture& texture); // Привязка текстуры к модели
private: private:
VAO vao; VAO vao;
@ -74,7 +72,6 @@ class Model : public Node
BO texCoords_vbo; // буфер с текстурными координатами BO texCoords_vbo; // буфер с текстурными координатами
GLuint verteces_count; // Количество вершин GLuint verteces_count; // Количество вершин
size_t first_index_byteOffset, indices_count; // Сдвиг в байтах для первого и количество индексов size_t first_index_byteOffset, indices_count; // Сдвиг в байтах для первого и количество индексов
Texture texture_diffuse; // Диффузная текстура
}; };
#endif // MODEL_H #endif // MODEL_H

View File

@ -211,8 +211,7 @@ vertex_vbo(VERTEX), index_vbo(ELEMENT), texCoords_vbo(VERTEX)
Model::Model(const Model& copy) : Node(copy), Model::Model(const Model& copy) : Node(copy),
vao(copy.vao), vao(copy.vao),
verteces_count(copy.verteces_count), first_index_byteOffset(copy.first_index_byteOffset), indices_count(copy.indices_count), verteces_count(copy.verteces_count), first_index_byteOffset(copy.first_index_byteOffset), indices_count(copy.indices_count),
vertex_vbo(copy.vertex_vbo), index_vbo(copy.index_vbo), texCoords_vbo(copy.texCoords_vbo), vertex_vbo(copy.vertex_vbo), index_vbo(copy.index_vbo), texCoords_vbo(copy.texCoords_vbo)
texture_diffuse(copy.texture_diffuse)
{ {
} }
@ -231,8 +230,6 @@ Model& Model::operator=(const Model& other)
index_vbo = other.index_vbo; index_vbo = other.index_vbo;
texCoords_vbo = other.texCoords_vbo; texCoords_vbo = other.texCoords_vbo;
texture_diffuse = other.texture_diffuse;
return *this; return *this;
} }
@ -247,9 +244,6 @@ void Model::render(const GLuint &model_uniform)
// Загрузим матрицу трансформации // Загрузим матрицу трансформации
glUniformMatrix4fv(model_uniform, 1, GL_FALSE, &getTransformMatrix()[0][0]); glUniformMatrix4fv(model_uniform, 1, GL_FALSE, &getTransformMatrix()[0][0]);
// Подключаем текстуры
texture_diffuse.use();
// Подключаем VAO // Подключаем VAO
vao.use(); vao.use();
// Если есть индексы - рисуем с их использованием // Если есть индексы - рисуем с их использованием
@ -339,15 +333,3 @@ void Model::set_index_range(size_t first_byteOffset, size_t count)
first_index_byteOffset = first_byteOffset; first_index_byteOffset = first_byteOffset;
indices_count = count; indices_count = count;
} }
// Привязка текстуры к модели
void Model::set_texture(Texture& texture)
{
GLuint type = texture.getType();
switch(type)
{
case TEX_DIFFUSE:
texture_diffuse = texture;
break;
};
}

View File

@ -220,7 +220,6 @@ int main(void)
// Текстура травы // Текстура травы
Texture grass(TEX_DIFFUSE, "../resources/textures/grass.png"); Texture grass(TEX_DIFFUSE, "../resources/textures/grass.png");
rectangle.set_texture(grass);
// Установка цвета очистки буфера цвета // Установка цвета очистки буфера цвета
glClearColor(0.0f, 0.0f, 0.0f, 1.0f); glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
@ -241,6 +240,7 @@ int main(void)
glClear(GL_COLOR_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT);
// Тут производится рендер // Тут производится рендер
grass.use(); // Привязка текстуры как активной
rectangle.render(model_uniform); rectangle.render(model_uniform);
// Представление содержимого буфера цепочки показа на окно // Представление содержимого буфера цепочки показа на окно