mirror of
https://github.com/ApfelTeeSaft/vb01.git
synced 2026-08-26 19:33:45 +00:00
method to update vertices
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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;}
|
||||
|
||||
Reference in New Issue
Block a user