Ejemplo n.º 1
0
GHOST_IWindow *GHOST_SystemSDL::createWindow(const STR_String &title,
                                             GHOST_TInt32 left,
                                             GHOST_TInt32 top,
                                             GHOST_TUns32 width,
                                             GHOST_TUns32 height,
                                             GHOST_TWindowState state,
                                             GHOST_TDrawingContextType type,
                                             GHOST_GLSettings glSettings,
                                             const bool exclusive,
                                             const GHOST_TEmbedderWindowID parentWindow)
{
  GHOST_WindowSDL *window = NULL;

  window = new GHOST_WindowSDL(this,
                               title,
                               left,
                               top,
                               width,
                               height,
                               state,
                               parentWindow,
                               type,
                               ((glSettings.flags & GHOST_glStereoVisual) != 0),
                               exclusive);

  if (window) {
    if (GHOST_kWindowStateFullScreen == state) {
      SDL_Window *sdl_win = window->getSDLWindow();
      SDL_DisplayMode mode;

      static_cast<GHOST_DisplayManagerSDL *>(m_displayManager)->getCurrentDisplayModeSDL(mode);

      SDL_SetWindowDisplayMode(sdl_win, &mode);
      SDL_ShowWindow(sdl_win);
      SDL_SetWindowFullscreen(sdl_win, SDL_TRUE);
    }

    if (window->getValid()) {
      m_windowManager->addWindow(window);
      pushEvent(new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowSize, window));
    }
    else {
      delete window;
      window = NULL;
    }
  }
  return window;
}
Ejemplo n.º 2
0
GHOST_WindowSDL *
GHOST_SystemSDL::findGhostWindow(SDL_Window *sdl_win)
{
	if (sdl_win == NULL) return NULL;

	// It is not entirely safe to do this as the backptr may point
	// to a window that has recently been removed.
	// We should always check the window manager's list of windows
	// and only process events on these windows.

	std::vector<GHOST_IWindow *> & win_vec = m_windowManager->getWindows();

	std::vector<GHOST_IWindow *>::iterator win_it = win_vec.begin();
	std::vector<GHOST_IWindow *>::const_iterator win_end = win_vec.end();

	for (; win_it != win_end; ++win_it) {
		GHOST_WindowSDL *window = static_cast<GHOST_WindowSDL *>(*win_it);
		if (window->getSDLWindow() == sdl_win) {
			return window;
		}
	}
	return NULL;
}