Hello, I've decided to use Spark2 OpenGL renderer with sfml2.
The initialization code:
mSystem = SPK::System::create(true);
mSystem->setName("Particles");
SPK::System::setClampStep(true, 0.1f);
SPK::System::useAdaptiveStep(0.001f, 0.01f);
// Load particle texture
GLuint texture = 0;
{
sf::Image image;
if (!image.LoadFromFile("Media/explosion.bmp"))
ERR("FAILED TO LOAD TEXTURE");
glGenTextures(1, &texture);
glBindTexture(GL_TEXTURE_2D, texture);
gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA, image.GetWidth(), image.GetHeight(), GL_RGBA, GL_UNSIGNED_BYTE, image.GetPixelsPtr());
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
}
// Create quad renderer
mRenderer = SPK::GL::GLQuadRenderer::create();
mRenderer->setBlendMode(SPK::BLEND_MODE_ADD);
mRenderer->enableRenderingOption(SPK::RENDERING_OPTION_DEPTH_WRITE, false);
mRenderer->setTexture(texture);
mRenderer->setTexturingMode(SPK::TEXTURE_MODE_2D);
mRenderer->setAtlasDimensions(2, 2);
And some fun with emitters:
SPK::Ref<SPK::SphericEmitter> emitter = SPK::SphericEmitter::create(SPK::Vector3D(0.0f,0.0f,-1.0f),0.0f,3.14159f / 4.0f,SPK::Point::create(),true,-1,100.0f,0.2f,0.5f);
SPK::Ref<SPK::Group> phantomGroup = mSystem->createGroup(40);
SPK::Ref<SPK::Group> trailGroup = mSystem->createGroup(1000);
SPK::Ref<SPK::Plane> ground = SPK::Plane::create(SPK::Vector3D(0.0f,-1.0f,0.0f));
phantomGroup->setName("Phantom Group");
phantomGroup->setLifeTime(5.0f,5.0f);
phantomGroup->setRadius(0.06f);
phantomGroup->addEmitter(SPK::SphericEmitter::create(SPK::Vector3D(0.0f,1.0f,0.0f),0.0f,3.14159f / 4.0f,SPK::Point::create(SPK::Vector3D(0.0f,-1.0f,0.0f)),true,-1,2.0f,1.2f,2.0f));
phantomGroup->addModifier(SPK::Gravity::create(SPK::Vector3D(0.0f,-1.0f,0.0f)));
phantomGroup->addModifier(SPK::Obstacle::create(ground,0.8f));
phantomGroup->addModifier(SPK::EmitterAttacher::create(trailGroup,emitter,true));
trailGroup->setName("Trail");
trailGroup->setLifeTime(0.5f,1.0f);
trailGroup->setRadius(0.06f);
trailGroup->setRenderer(mRenderer);
trailGroup->setColorInterpolator(SPK::ColorSimpleInterpolator::create(0xFF802080,0xFF000000));
trailGroup->setParamInterpolator(SPK::PARAM_TEXTURE_INDEX,SPK::FloatRandomInitializer::create(0.0f,4.0f));
trailGroup->setParamInterpolator(SPK::PARAM_ROTATION_SPEED,SPK::FloatRandomInitializer::create(-0.1f,1.0f));
trailGroup->setParamInterpolator(SPK::PARAM_ANGLE,SPK::FloatRandomInitializer::create(0.0f,2.0f * 3.14159f));
trailGroup->addModifier(SPK::Rotator::create());
trailGroup->addModifier(SPK::Destroyer::create(ground));
Now I want to render it, in main cycle:
mSystem->updateParticles(dSeconds)
SPK::GL::GLRenderer::saveGLStates();
glDisableClientState(GL_COLOR_ARRAY);
glDisable(GL_TEXTURE_2D);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
// Render particles and set back prev states
mSystem->renderParticles();
SPK::GL::GLRenderer::restoreGLStates();
And I see fully black screen.
When I remove code related to emitters and settings texture I see my scene but everything is white. What could it be?