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  

 

 SPARK & SFML no Window?

Go down 
AuthorMessage
Jack




Messages : 11
Date d'inscription : 2011-10-12

SPARK & SFML no Window? Empty
PostSubject: SPARK & SFML no Window?   SPARK & SFML no Window? Icon_minitimeWed Oct 12, 2011 2:04 pm

Hello,

I have a problem with my first touch with SPARK and SFML...
The Problem is that if i open the program only the Console is opened and no Window...
I have described the Problem in a german Forum but i think its better if i ask here too.
The Code of the Program:

Code:
#include <SFML/System.hpp>
#include <SFML/Graphics.hpp>
#include <SPK.h>
#include <SPK_SFML.h>
#include <GL/gl.h>
#include <GL/glu.h>
#include <iostream>

#if defined(WIN32) || defined(_WIN32)
#include <windows.h>
#endif

//Use namespace
using namespace std;

//ID
SPK::SPK_ID BaseSparkSystemID = SPK::NO_ID;

//Main
int main(int argc, char *argv[])
{
   cout << "cout" << endl;

   //App
   sf::RenderWindow App(sf::VideoMode(800, 600, 32), "SPARK Test");

   //Settings
   App.UseVerticalSync(false);
   App.ShowMouseCursor(false);
   App.EnableKeyRepeat(false);
   App.Clear();
   App.Display();
   
   //Random seed
   SPK::randomSeed = static_cast<unsigned int>(time(NULL));

   //Sets the update step
   SPK::System::setClampStep(true, 0.1f);      
   SPK::System::useAdaptiveStep(0.001f, 0.01f);

   //Event
   sf::Event Event;

   //Create Model
   SPK::Model *Model = SPK::Model::create(SPK::FLAG_BLUE | SPK::FLAG_GREEN | SPK::FLAG_BLUE | SPK::FLAG_GREEN,
                                SPK::FLAG_ALPHA,
                                SPK::FLAG_RED  | SPK::FLAG_GREEN | SPK::FLAG_BLUE);

   //Set Parameter
   Model->setParam(SPK::PARAM_BLUE, 0.2f, 0.5f);

   //Set Lifetime
   Model->setLifeTime(1.0f, 2.0f);

   //Create our SFML Renderer
   SPK::SFML::SFMLPointRenderer* Renderer = SPK::SFML::SFMLPointRenderer::create();
   Renderer->setBlendMode(sf::Blend::Add);
   Renderer->setGroundCulling(true);

   //Zone where the Particles are
   SPK::Point *Point = SPK::Point::create(SPK::Vector3D(400.0f, 300.0f, 0.0f));

   //The Emitter
   SPK::RandomEmitter *Emitter = SPK::RandomEmitter::create();

   //Set Force
   Emitter->setForce(2.0f, 2.2f);

   //Set Zone
   Emitter->setZone(Point);

   //Set Tank
   Emitter->setTank(300);

   //Set Flow
   Emitter->setFlow(-1);

   //Create a Group
   SPK::Group *Group = SPK::Group::create(Model, 500);

   //Set Renderer
   Group->setRenderer(Renderer);

   //Set Emitter for the Group
   Group->addEmitter(Emitter);

   //Set Gravity
   Group->setGravity(SPK::Vector3D(0.0f, -1.0f, 0.0f));

   //Set Friction
   Group->setFriction(2.0f);

   //Create SFML System
   SPK::SFML::SFMLSystem *System = SPK::SFML::SFMLSystem::create();

   //Add Group
   System->addGroup(Group);

   //Set Render Target
   System->setRenderTarget(&App);

   //Set Shared
   Model->setShared(true);
   Renderer->setShared(true);

   //Set Z Factor
   SPK::SFML::SFMLRenderer::setZFactor(1.0f);

   //Set the Camera Position
   SPK::SFML::setCameraPosition(SPK::SFML::CAMERA_CENTER, SPK::SFML::CAMERA_BOTTOM, static_cast<float>(600), 0.0f);

   //Set the ID
   BaseSparkSystemID = System->getSPKID();

   //Create the real Particle System
   SPK::SFML::SFMLSystem* sparkSystem = SPK_Copy(SPK::SFML::SFMLSystem, BaseSparkSystemID);

   //Spark Factory
   SPK::SPKFactory::getInstance().traceAll();

   //Loop
   while(App.IsOpened())
   {
      while(App.GetEvent(Event))
      {
         if(Event.Type == sf::Event::Closed)
         {
            App.Close();
         }
      }

      //Update System
      sparkSystem->update(0.001f);

      //Clear
      App.Clear();

      //Draw
      sparkSystem->render();

      //Display
      App.Display();
   }

   //Destroy
   SPK_Destroy(System);

   //Set
   System = NULL;

   //Return
   return EXIT_SUCCESS;
}
The Compiler runs nothing of the Code, really nothing, the debugger says that he doesnt call the Main function
and the Cout dont issued. So i commented the Code bit by bit and i've found that the Problem is by the
System, Group and Render Object, if i commented they out it worked fine, but it does not really help me...

I hope that someone can help me to fix this strange Problem.
And sorry for my bad english. Razz
Back to top Go down
Jack




Messages : 11
Date d'inscription : 2011-10-12

SPARK & SFML no Window? Empty
PostSubject: Re: SPARK & SFML no Window?   SPARK & SFML no Window? Icon_minitimeThu Oct 13, 2011 3:18 am

I have solved the Problem...
Compiled the whole Libary for Microsoft Visual C++ 2010 and it works fine. cheers
Back to top Go down
 
SPARK & SFML no Window?
Back to top 
Page 1 of 1
 Similar topics
-
» Using SPARK with SFML
» SFML 1.6 supported?
» Spark with SFML and VC++ 2010
» 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: