Пример #1
0
void ParticleSystem::add( ci::Vec2f pos, ci::Vec2f velocity, ci::ColorA color, ci::Rectf srcCoords, ci::Rectf destRect ) {
	Particle p = { verts.size(), velocity, pos, pos };
	particles.push_back( p );

	// Vertices
	verts.push_back( destRect.getX1() ); verts.push_back( destRect.getY2() ); verts.push_back(0);
	verts.push_back( destRect.getX2() ); verts.push_back( destRect.getY2() ); verts.push_back(0);
	verts.push_back( destRect.getX2() ); verts.push_back( destRect.getY1() ); verts.push_back(0);
	verts.push_back( destRect.getX1() ); verts.push_back( destRect.getY2() ); verts.push_back(0);
	verts.push_back( destRect.getX2() ); verts.push_back( destRect.getY1() ); verts.push_back(0);
	verts.push_back( destRect.getX1() ); verts.push_back( destRect.getY1() ); verts.push_back(0);

	// Texture coords
	color.a = Constants::Particles::ALPHA;
	texCoords.push_back( srcCoords.getX1() ); texCoords.push_back( srcCoords.getY2() );
	texCoords.push_back( srcCoords.getX2() ); texCoords.push_back( srcCoords.getY2() );
	texCoords.push_back( srcCoords.getX2() ); texCoords.push_back( srcCoords.getY1() );
	texCoords.push_back( srcCoords.getX1() ); texCoords.push_back( srcCoords.getY2() );
	texCoords.push_back( srcCoords.getX2() ); texCoords.push_back( srcCoords.getY1() );
	texCoords.push_back( srcCoords.getX1() ); texCoords.push_back( srcCoords.getY1() );

	// Colors
//	ci::ColorA color = ci::ColorA(ci::CM_HSV, _debugColor, 1.0, 1.0, 1.0);
	colors.push_back( color ); colors.push_back( color ); colors.push_back( color );
	colors.push_back( color ); colors.push_back( color ); colors.push_back( color );
	colors.push_back( color ); colors.push_back( color ); colors.push_back( color );
	colors.push_back( color ); colors.push_back( color ); colors.push_back( color );
	colors.push_back( color ); colors.push_back( color ); colors.push_back( color );
	colors.push_back( color ); colors.push_back( color ); colors.push_back( color );
}
Пример #2
0
void Draw(const Movable& DrawData, const Texture& Tex) // @Remove second param
{
    using namespace ci;

    gl::pushModelView();

    gl::translate(DrawData.GetCenterPos());
    // gl::drawStrokedRect( ToRect(DrawData.GetAABB()) );
    gl::rotate(DrawData.GetAngle());
    gl::scale(DrawData.GetScale().x, DrawData.GetScale().y);
    gl::translate(-Tex.getSize() / 2.f);

    glEnableClientState(GL_VERTEX_ARRAY);
    GLfloat verts[8];
    glVertexPointer(2, GL_FLOAT, 0, verts);
    glEnableClientState(GL_TEXTURE_COORD_ARRAY);
    GLfloat texCoords[8];
    glTexCoordPointer(2, GL_FLOAT, 0, texCoords);

    const ci::Rectf destRect = Tex.getCleanBounds();
    verts[0 * 2 + 0] = destRect.getX2();
    verts[0 * 2 + 1] = destRect.getY1();
    verts[1 * 2 + 0] = destRect.getX1();
    verts[1 * 2 + 1] = destRect.getY1();
    verts[2 * 2 + 0] = destRect.getX2();
    verts[2 * 2 + 1] = destRect.getY2();
    verts[3 * 2 + 0] = destRect.getX1();
    verts[3 * 2 + 1] = destRect.getY2();

    const ci::Rectf srcCoords = Tex.getAreaTexCoords(Tex.getCleanBounds());
    texCoords[0 * 2 + 0] = srcCoords.getX2();
    texCoords[0 * 2 + 1] = srcCoords.getY1();
    texCoords[1 * 2 + 0] = srcCoords.getX1();
    texCoords[1 * 2 + 1] = srcCoords.getY1();
    texCoords[2 * 2 + 0] = srcCoords.getX2();
    texCoords[2 * 2 + 1] = srcCoords.getY2();
    texCoords[3 * 2 + 0] = srcCoords.getX1();
    texCoords[3 * 2 + 1] = srcCoords.getY2();

    glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);

    gl::popModelView();
}