Skip to content

Instantly share code, notes, and snippets.

@pingpoli
Created August 6, 2020 20:17
Show Gist options
  • Save pingpoli/dd90f8cc0b2f6bd286c087ba96a4992c to your computer and use it in GitHub Desktop.
Save pingpoli/dd90f8cc0b2f6bd286c087ba96a4992c to your computer and use it in GitHub Desktop.
void SimpleEmitter::draw()
{
glEnableVertexAttribArray( 0 );
glEnableVertexAttribArray( 4 );
// update the position buffer
glBindBuffer( GL_ARRAY_BUFFER , this->positionBuffer );
glBufferSubData( GL_ARRAY_BUFFER , 0 , this->particles.size()*4*sizeof(float) , this->positions );
// vertex buffer
glBindBuffer( GL_ARRAY_BUFFER , this->vertexBuffer );
glVertexAttribPointer( 0 , 3 , GL_FLOAT , GL_FALSE , 0 , nullptr );
// position buffer
glBindBuffer( GL_ARRAY_BUFFER , this->positionBuffer );
glVertexAttribPointer( 4 , 4 , GL_FLOAT , GL_FALSE , 0 , nullptr );
glVertexAttribDivisor( 4 , 1 );
// draw triangles
lglDrawArraysInstanced( GL_TRIANGLE_STRIP , 0 , 4 , this->particles.size() );
glDisableVertexAttribArray( 0 );
glDisableVertexAttribArray( 4 );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment