HomeHome  CalendarCalendar  FAQFAQ  SearchSearch  MemberlistMemberlist  UsergroupsUsergroups  RegisterRegister  Log inLog in  

Share | 
 

 SPARK & SFML no Window?

View previous topic View next topic Go down 
AuthorMessage
Jack



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

PostSubject: SPARK & SFML no Window?   Wed 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
View user profile
Jack



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

PostSubject: Re: SPARK & SFML no Window?   Thu 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
View user profile
 
SPARK & SFML no Window?
View previous topic View next topic Back to top 
Page 1 of 1
 Similar topics
-
» Focus on New Window
» Window Makeover Contest
» How to record when a link is opening in a new window or pop-up window
» Alternate to getEval("window.document.readyState")
» How to recognize the pop up window during running script

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