Created
August 6, 2020 20:17
-
-
Save pingpoli/dd90f8cc0b2f6bd286c087ba96a4992c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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