Would you like to react to this message? Create an account in a few clicks or log in to continue.



 
HomeHome  Latest imagesLatest images  SearchSearch  RegisterRegister  Log inLog in  

 

 Using SPARK with SFML

Go down 
2 posters
AuthorMessage
EralpB




Messages : 7
Date d'inscription : 2010-12-13

Using SPARK with SFML Empty
PostSubject: Using SPARK with SFML   Using SPARK with SFML Icon_minitimeTue Dec 14, 2010 4:57 am

Hello, thanks for this great particle engine, screenshots are awesome especially on the irrlicht forums :p
I'd like to integrate this to my 2D side-scrolling-shooter game but there is one thing.
I can make the SPARK call either the draw calls of SFML or pure OpenGL. What are the cons and pros of these two things? I haven't looked much but it doesnt seem it is easier to make it call SFML draw calls, so why would I want that ? performance with pure openGL should be far more higher


Thanks again
Back to top Go down
Juff
Developer



Messages : 539
Date d'inscription : 2009-07-14
Age : 41

Using SPARK with SFML Empty
PostSubject: Re: Using SPARK with SFML   Using SPARK with SFML Icon_minitimeTue Dec 14, 2010 6:12 am

Hi, using the SFMLDrawableRenderer will be a lot slower you're right. It is only there because it will allow to render particle as any SFML drawable (sf::strings for example or customs ones). This adds flexibility in some way.

For perfomance, using the SFML or the GL renderers will be more or less identical but the SFML renderers are more designed to integrate and be used in 2D with SFML while the GL renderers are more generic.

So my advice would be, if youre using particle only in a 2D context to use the SFMLRenderers (the quad renderer is the most useful).

Finally note that spark is not compatible with SFML 2.0, it uses SFML 1.6.
Back to top Go down
http://spark.developpez.com
EralpB




Messages : 7
Date d'inscription : 2010-12-13

Using SPARK with SFML Empty
PostSubject: Re: Using SPARK with SFML   Using SPARK with SFML Icon_minitimeTue Dec 14, 2010 5:50 pm

Juff wrote:

So my advice would be, if youre using particle only in a 2D context to use the SFMLRenderers (the quad renderer is the most useful).

Thanks for your advice , I decided on going that way Smile

I am trying to compile tuto2 and in car.cpp I am getting an error
Code:
   
// Creates the emitters
   SPK::SphericEmitter* leftSmokeEmitter = SPK::SphericEmitter::create(SPK::Vector3D(0.0f,0.0f,1.0f),0.0f,1.1f * PI);
   leftSmokeEmitter->setZone(leftTire);
   leftSmokeEmitter->setName("left wheel emitter"); ->> here I am getting error

setZone works but setName doesnt work.. leftSmokeEmitter is a valid pointer when I debug but I can't figure out what might be the problem, any help ?


edit: more information

Code:

   SPK::RandomEmitter* az = new SPK::RandomEmitter();
   az->setName("asdasd");
   SPK::SphericEmitter* a = new SPK::SphericEmitter(SPK::Vector3D(0,0,0),0,0);
   a->setName("asd");

these two doesnt work neither. When I debug I can see those pointers are initialized correctly but when I go to sub-class registerable, the name pointer is "bad pointer" that is the problem I am facing but I don't know the reason, how can that happen? Only one pointer is not initialized correctly and the rest is correct
Back to top Go down
Juff
Developer



Messages : 539
Date d'inscription : 2009-07-14
Age : 41

Using SPARK with SFML Empty
PostSubject: Re: Using SPARK with SFML   Using SPARK with SFML Icon_minitimeWed Dec 15, 2010 8:36 am

Hi, yest there is a problem in debug mode with this demo. The stack gets messed up at some point, it is not due to the call to setName. Try compiling in release mode, it should work. I will investigate whether it is from spark, sfml or the demo code (i dont think its from spark though). Compiling with static libs instead of dynamic ones may solve the problem as well.
Back to top Go down
http://spark.developpez.com
EralpB




Messages : 7
Date d'inscription : 2010-12-13

Using SPARK with SFML Empty
PostSubject: Re: Using SPARK with SFML   Using SPARK with SFML Icon_minitimeThu Dec 16, 2010 8:57 pm

Hello again, Tell me if I should create a new thread Smile

I had the time today to implement a very basic particle manager class wrapper on SPARK but I faced a problem now.

When I examine your source codes I always see that at the beginning you make a baseclass and store its ID somewhere, and copy that class everytime you need a new explosion, or effect. And I thought it was a right way to go while using SPARK. It works fine with explosions, but when I try to create a flow two times I get an error.

I mean I can't copy that base system when an instance is already running, flowing, emitting. I made setshared(false) for every thing in my base system but that didn't solve the problem.

Well my code is basicly :

Code:

void particleManager::createFlow(float x,float y)
{
   SFML::SFMLSystem* buff = SPK_Copy(SPK::SFML::SFMLSystem,BaseFlowSystemID);
   buff->SetPosition(x,y);
   particleSystems.push_back(buff);
}

In the first line I get a memory exception error. when I try to have the same effect at 2 places AT THE SAME TIME. but it is okey, I can create explosions when something is flowing. because they have different base classes I guess.

Thanks
Back to top Go down
Juff
Developer



Messages : 539
Date d'inscription : 2009-07-14
Age : 41

Using SPARK with SFML Empty
PostSubject: Re: Using SPARK with SFML   Using SPARK with SFML Icon_minitimeFri Dec 17, 2010 4:36 am

Can you provide me with the whole particle manager code, and I will take a closer look at it. thanks
Back to top Go down
http://spark.developpez.com
EralpB




Messages : 7
Date d'inscription : 2010-12-13

Using SPARK with SFML Empty
PostSubject: Re: Using SPARK with SFML   Using SPARK with SFML Icon_minitimeFri Dec 17, 2010 6:46 am

oh, I caught a point.

I was doing something like

SPK::Group* sparkGroup = SPK::Group::create(sparkModel,5000000);

because I didn't want to limit number of particles for the test phase. But the factory cannot copy this two times. I can't guess the reason but yeah thats it and I made this something like


SPK::Group* sparkGroup = SPK::Group::create(sparkModel,50000);

It can copy two times, but then I tested the following.

SFML::SFMLSystem* buff = SPK_Copy(SPK::SFML::SFMLSystem,BaseFlowSystemID);
for(int i = 0;i<15;i++)
buff = SPK_Copy(SPK::SFML::SFMLSystem,BaseFlowSystemID);

then at some point this gave me error( say i = 10 ie.)

I guess there is some kind of mechanism that doesnt allow copying systems when their total allowedparticle number is above something..

But I don't want to limit the nb of particles, and I don't know how much explosion will be in my game(fast paced side-scrolling shooter). How should I handle this? Thanks Smile
Back to top Go down
Juff
Developer



Messages : 539
Date d'inscription : 2009-07-14
Age : 41

Using SPARK with SFML Empty
PostSubject: Re: Using SPARK with SFML   Using SPARK with SFML Icon_minitimeFri Dec 17, 2010 9:05 am

I advise you dont do that. When specifying 5 millions particles as the capacity, the group will allocate space in memory to handle 5 millions particles. By copying the groups you can easily go out of ram and crash all the application.

What you need is to allocate the correct max number of particles. The max number of particles can be gotten easily with a simple formula :
maximum life time of particles * sum of the flows of the emitter in the group.

Regarding the fact that you dont know how much explosions will be in the game, if an explosion is a system, there is no problem as the capacity is defined by explosions. If all explosions shared the same system, you need to decide a maximum number of explosions to compute the capacity and never copy the system.
Back to top Go down
http://spark.developpez.com
Sponsored content





Using SPARK with SFML Empty
PostSubject: Re: Using SPARK with SFML   Using SPARK with SFML Icon_minitime

Back to top Go down
 
Using SPARK with SFML
Back to top 
Page 1 of 1
 Similar topics
-
» Spark v2 - SFML v2.0
» Spark with SFML and VC++ 2010
» SPARK & SFML no Window?
» SFML 1.6 and SPARK -- Freezing Issue
» Problems compiling SPARK with SFML on VC++ 2008 EE

Permissions in this forum:You cannot reply to topics in this forum
 :: English Forum :: Questions (en)-
Jump to: