Esempio n. 1
0
/*************************************************************************
	Create a new window of the specified type
*************************************************************************/
Window* WindowManager::createWindow(const String& type, const String& name)
{
    String finalName(name.empty() ? generateUniqueWindowName() : name);

	if (isWindowPresent(finalName))
	{
		throw AlreadyExistsException("WindowManager::createWindow - A Window object with the name '" + finalName +"' already exists within the system.");
	}

    WindowFactoryManager& wfMgr = WindowFactoryManager::getSingleton();
    WindowFactory* factory = wfMgr.getFactory(type);

    Window* newWindow = factory->createWindow(finalName);
    Logger::getSingleton().logEvent("Window '" + finalName +"' of type '" + type + "' has been created.", Informative);

    // see if we need to assign a look to this window
    if (wfMgr.isFalagardMappedType(type))
    {
        // this was a mapped type, so assign a look to the window so it can finalise
        // its initialisation
        newWindow->setLookNFeel(type, wfMgr.getMappedLookForType(type));
    }

    // perform initialisation step
    newWindow->initialise();

	d_windowRegistry[finalName] = newWindow;

	return newWindow;
}
Esempio n. 2
0
void WindowManager::cleanDeadPool(void)
{
    WindowVector::reverse_iterator curr = d_deathrow.rbegin();
    for (; curr != d_deathrow.rend(); ++curr)
    {
// in debug mode, log what gets cleaned from the dead pool (insane level)
#if defined(DEBUG) || defined (_DEBUG)
        CEGUI_LOGINSANE("Window '" + (*curr)->getName() + "' about to be finally destroyed from dead pool.");
#endif

        WindowFactory* factory = WindowFactoryManager::getSingleton().getFactory((*curr)->getType());
        factory->destroyWindow(*curr);
    }

    // all done here, so clear all pointers from dead pool
    d_deathrow.clear();
}
Esempio n. 3
0
File: test.cpp Progetto: otita/cg
int main(int argc, const char *argv[]) {
  using namespace std;
  using namespace otita::cg;

  WindowFactory *wFactory = WindowFactory::getInstance();
  Window *window = wFactory->createWindowOrDie(640, 480, "Test");
  WindowFactory::deleteInstance();

  window->setKeyboardDelegate(new MyKeyDelegate);

  World *world = new World();
  ObjectFactory *oFactory = ObjectFactory::getInstance();
//  world->addObject(
//    oFactory->createTriangle(
//      {
//      -0.6, -0.4,
//      0.6,  -0.4,
//      0.,    0.6,
//      }
//    )
//  );
  world->addObject(
    oFactory->createCircle(
      {
      0., 0.,
      },
      1.
    )
  );
  ObjectFactory::deleteInstance();

  window->setWorld(world);

  while (!window->shouldClose()) {
    window->clear();
    window->draw();
    window->swapBuffers();
  }

  delete world;
  delete window;

  return 0;
}
/*************************************************************************
	Create a new window of the specified type
*************************************************************************/
Window* WindowManager::createWindow(const String& type, const String& name)
{
    // only allow creation of Window objects if we are in unlocked state
    if (isLocked())
        CEGUI_THROW(InvalidRequestException(
            "WindowManager is in the locked state."));

    String finalName(name.empty() ? generateUniqueWindowName() : name);

    WindowFactoryManager& wfMgr = WindowFactoryManager::getSingleton();
    WindowFactory* factory = wfMgr.getFactory(type);

    Window* newWindow = factory->createWindow(finalName);

    char addr_buff[32];
    sprintf(addr_buff, "(%p)", static_cast<void*>(newWindow));
    Logger::getSingleton().logEvent("Window '" + finalName +"' of type '" +
        type + "' has been created. " + addr_buff, Informative);

    // see if we need to assign a look to this window
    if (wfMgr.isFalagardMappedType(type))
    {
        const WindowFactoryManager::FalagardWindowMapping& fwm = wfMgr.getFalagardMappingForType(type);
        // this was a mapped type, so assign a look to the window so it can finalise
        // its initialisation
        newWindow->d_falagardType = type;
        newWindow->setWindowRenderer(fwm.d_rendererType);
        newWindow->setLookNFeel(fwm.d_lookName);

        initialiseRenderEffect(newWindow, fwm.d_effectName);
    }

	d_windowRegistry.push_back(newWindow);

    // fire event to notify interested parites about the new window.
    WindowEventArgs args(newWindow);
    fireEvent(EventWindowCreated, args, EventNamespace);
    
	return newWindow;
}