void BulletSpheresApp::createBuffers() { gl::VboMesh::Layout layout; layout.attrib( geom::POSITION, 4 ).attrib( geom::NORMAL, 3 ).attrib( geom::TEX_COORD_0, 2 ); mAttributes = gl::VboMesh::create( geom::Sphere().subdivisions( 16 ), {{ layout, nullptr }} ); mMatrices = gl::Vbo::create( GL_ARRAY_BUFFER, (NUM_PARTICLES-2)*sizeof(mat4) ); auto bufferLayout = geom::BufferLayout(); bufferLayout.append( geom::CUSTOM_0, geom::FLOAT, 16, sizeof(mat4), 0, 1 ); mAttributes->appendVbo( bufferLayout , mMatrices ); mRenderSphere = gl::Batch::create( mAttributes, mRenderGlsl ); mShadowSphere = gl::Batch::create( mAttributes, mShadowGlsl ); }
void RandomSpawn::setupParticles() { mPointsParticles.clear(); mDataInstance_P = gl::Vbo::create(GL_ARRAY_BUFFER, mPointsParticles, GL_DYNAMIC_DRAW); mAttribsInstance_P.append(geom::CUSTOM_0, 16, sizeof(CloudParticle), offsetof(CloudParticle, PModelMatrix), 1); mAttribsInstance_P.append(geom::CUSTOM_1, 1, sizeof(CloudParticle), offsetof(CloudParticle, PSize), 1); mAttribsInstance_P.append(geom::CUSTOM_2, 4, sizeof(CloudParticle), offsetof(CloudParticle, PColor), 1); mMesh_P = gl::VboMesh::create(geom::Icosahedron()); mMesh_P->appendVbo(mAttribsInstance_P, mDataInstance_P); mShader_P = gl::GlslProg::create(loadAsset("shaders/particle.vert"), loadAsset("shaders/particle.frag")); mBatch_P = gl::Batch::create(mMesh_P, mShader_P, { { geom::CUSTOM_0, "iModelMatrix" }, { geom::CUSTOM_1, "iSize" }, { geom::CUSTOM_2, "iColor" } }); mPerlin = Perlin(); }