method to update vertices

This commit is contained in:
devZoGok
2023-01-04 11:14:52 +02:00
parent a6db8e1492
commit 84e0a87ba4
2 changed files with 9 additions and 2 deletions
+7 -1
View File
@@ -73,6 +73,7 @@ namespace vb01{
glBindFramebuffer(GL_FRAMEBUFFER, *Root::getSingleton()->getFBO());
}
//TODO allow to init meshes to be drawn statically or dynamically
void Mesh::initMesh(){
glGenVertexArrays(1, &VAO);
glGenBuffers(1, &VBO);
@@ -82,7 +83,7 @@ namespace vb01{
glBindVertexArray(VAO);
glBindBuffer(GL_ARRAY_BUFFER, VBO);
glBufferData(GL_ARRAY_BUFFER, 3 * meshBase.numTris * size, meshBase.vertices, GL_STATIC_DRAW);
glBufferData(GL_ARRAY_BUFFER, 3 * meshBase.numTris * size, meshBase.vertices, GL_DYNAMIC_DRAW);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, EBO);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, 3 * meshBase.numTris * sizeof(u32), meshBase.indices, GL_STATIC_DRAW);
@@ -107,6 +108,11 @@ namespace vb01{
}
}
void Mesh::updateVerts(MeshData meshData){
glBindBuffer(GL_ARRAY_BUFFER, VBO);
glBufferSubData(GL_ARRAY_BUFFER, 0, 3 * sizeof(MeshData::Vertex) * meshBase.numTris, meshData.vertices);
}
void Mesh::update(){
Root *root = Root::getSingleton();
Camera *cam = root->getCamera();
+2 -1
View File
@@ -21,9 +21,10 @@ namespace vb01{
Mesh(MeshData);
~Mesh();
void construct();
void updateVerts(MeshData);
virtual void update();
void render();
void setMaterial(Material *mat){this->material = mat;}
inline void setMaterial(Material *mat){this->material = mat;}
inline void setCastShadow(bool castShadow){this->castShadow = castShadow;}
inline void setReflect(bool r){this->reflect = r;}
inline void setReflective(bool r){this->reflective = r;}