32 lines
743 B
C++
32 lines
743 B
C++
|
#include <GL/glew.h>
|
||
|
#include <glm/mat4x4.hpp>
|
||
|
#include <glm/gtc/type_ptr.hpp>
|
||
|
|
||
|
#include <graphics.hpp>
|
||
|
#include <modelpart.hpp>
|
||
|
|
||
|
#include <iostream>
|
||
|
|
||
|
ModelPart::ModelPart() {
|
||
|
}
|
||
|
|
||
|
ModelPart::ModelPart(const char* texPath, GLuint transUniformNum) {
|
||
|
//create vbo, ebo, vao
|
||
|
initBuffers(&vao);
|
||
|
//create texture
|
||
|
initTexture(&tex, texPath);
|
||
|
|
||
|
transUniform = transUniformNum;
|
||
|
}
|
||
|
|
||
|
void ModelPart::bindAndDraw() {
|
||
|
glBindVertexArray(vao);
|
||
|
glBindTexture(GL_TEXTURE_2D, tex);
|
||
|
glUniformMatrix4fv(transUniform, 1, GL_FALSE, glm::value_ptr(transMatrix));
|
||
|
glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0);
|
||
|
}
|
||
|
|
||
|
void ModelPart::setPosition(glm::vec2 position) {
|
||
|
transMatrix = glm::translate(glm::mat4(1.0f), glm::vec3(position.x, position.y, 0.0f));
|
||
|
}
|