beginning of suitting textures for animation

This commit is contained in:
devZoGok
2021-10-19 19:06:41 +03:00
parent 3493f1b371
commit 0741a46fe8
8 changed files with 104 additions and 89 deletions
+4 -4
View File
@@ -150,14 +150,14 @@ namespace vb01{
void Texture::update(int id){
updateFrame();
select(id);
if(numFrames > 0)
select(id + 1);
}
void Texture::updateFrame(){
if(numFrames > 0){
if(getTime() - lastUpdateTime > updateRate){
frame++;
if(frame == numFrames)
frame = 0;
frame = getNextFrame(frame);
lastUpdateTime = getTime();
}
}
@@ -165,6 +165,6 @@ namespace vb01{
void Texture::select(int id){
glActiveTexture(GL_TEXTURE0 + id);
glBindTexture(type == TEXTURE_2D ? GL_TEXTURE_2D : GL_TEXTURE_CUBE_MAP, texture[numFrames > 0 ? frame : 0]);
glBindTexture(type == TEXTURE_2D ? GL_TEXTURE_2D : GL_TEXTURE_CUBE_MAP, texture[frame]);
}
}