Exemplo n.º 1
0
int SDL_WM_DeleteTempContext() {

  SDL_SysWMinfo info;
  SDL_VERSION(&info.version);
  if (SDL_GetWMInfo(&info) == -1) {
    // Could not get SDL version info
    return 1;
  }

  if (!wglShareLists(temp_context, info.hglrc)) {
    // Could share lists with OpenGL context
    return 2;
  }

  if (!wglDeleteContext(temp_context)) {
    // Could delete OpenGL context
    return 3;
  }
  
  return 0;
}
Exemplo n.º 2
0
    void SDLHandler::PrintSoftwareVersions()
    {
        cout << "GLEW version: " << glewGetString(GLEW_VERSION) << endl << endl;

        SDL_version compiled;
        SDL_version linked;

        SDL_VERSION(&compiled);
        SDL_GetVersion(&linked);
        cout << "Compiled against SDL version "  << static_cast<int>(compiled.major) << "." << 
                                                     static_cast<int>(compiled.minor)  << "." <<  
                                                     static_cast<int>(compiled.patch) << endl;
        cout << "Linked against SDL version "  << static_cast<int>(linked.major) << "." << 
                                                   static_cast<int>(linked.minor)  << "." <<  
                                                   static_cast<int>(linked.patch) << endl << endl;

        cout << "OpenGL vendor: " << glGetString(GL_VENDOR) << endl;
        cout << "OpenGL renderer: " << glGetString(GL_RENDERER) << endl;
        cout << "OpenGL version: " << glGetString(GL_VERSION) << endl;
        cout << "GLSL version: " << glGetString(GL_SHADING_LANGUAGE_VERSION) << endl << endl;
    }
Exemplo n.º 3
0
void * SDLWindow::getHandle() {
	
#if ARX_PLATFORM == ARX_PLATFORM_WIN32
	
	SDL_SysWMinfo wmi;
	SDL_VERSION(&wmi.version);
	
	if(!SDL_GetWMInfo(&wmi)) {
		return NULL;
	}
	
	return wmi.window;
	
#else
	
	// TODO X11 needs more than one pointer (display+window)
	return NULL;
	
#endif
	
}
Exemplo n.º 4
0
void OSystem_Win32::setupIcon() {
	HMODULE handle = GetModuleHandle(NULL);
	HICON   ico    = LoadIcon(handle, MAKEINTRESOURCE(1001 /* IDI_ICON */));
	if (ico) {
		SDL_SysWMinfo  wminfo;
		SDL_VERSION(&wminfo.version);
		if (SDL_GetWMInfo(&wminfo)) {
			// Replace the handle to the icon associated with the window class by our custom icon
			SetClassLongPtr(wminfo.window, GCLP_HICON, (ULONG_PTR)ico);

			// Since there wasn't any default icon, we can't use the return value from SetClassLong
			// to check for errors (it would be 0 in both cases: error or no previous value for the
			// icon handle). Instead we check for the last-error code value.
			if (GetLastError() == ERROR_SUCCESS)
				return;
		}
	}

	// If no icon has been set, fallback to default path
	OSystem_SDL::setupIcon();
}
Exemplo n.º 5
0
static void* sdlNativeWindowHandle(SDL_Window* _window)
{
	SDL_SysWMinfo wmi;
	SDL_VERSION(&wmi.version);
	if (!SDL_GetWindowWMInfo(_window, &wmi))
	{
		return nullptr;
	}

#   if BX_PLATFORM_LINUX || BX_PLATFORM_BSD
	return (void*)wmi.info.x11.window;
#   elif BX_PLATFORM_OSX
	return wmi.info.cocoa.window;
#   elif BX_PLATFORM_WINDOWS
	return wmi.info.win.window;
#   elif BX_PLATFORM_STEAMLINK
	return wmi.info.vivante.window;
#   elif BX_PLATFORM_EMSCRIPTEN
	return nullptr;
#   endif // BX_PLATFORM_
}
Exemplo n.º 6
0
static void sdl2_gfx_set_handles(sdl2_video_t *vid)
{
   // SysWMinfo headers are broken on OSX. :(
#if defined(_WIN32) || defined(HAVE_X11)
   SDL_SysWMinfo info;
   SDL_VERSION(&info.version);

   if (SDL_GetWindowWMInfo(vid->window, &info) == 1)
   {
#if defined(_WIN32)
      driver.display_type  = RARCH_DISPLAY_WIN32;
      driver.video_display = 0;
      driver.video_window  = (uintptr_t)info.info.win.window;
#elif defined(HAVE_X11)
      driver.display_type  = RARCH_DISPLAY_X11;
      driver.video_display = (uintptr_t)info.info.x11.display;
      driver.video_window  = (uintptr_t)info.info.x11.window;
#endif
   }
#endif
}
Exemplo n.º 7
0
static void sdl2_gfx_set_handles(sdl2_video_t *vid)
{
   /* SysWMinfo headers are broken on OSX. */
#if defined(_WIN32) || defined(HAVE_X11)
   SDL_SysWMinfo info;
   SDL_VERSION(&info.version);

   if (SDL_GetWindowWMInfo(vid->window, &info) != 1)
      return;

#if defined(_WIN32)
   video_driver_display_type_set(RARCH_DISPLAY_WIN32);
   video_driver_display_set(0);
   video_driver_window_set((uintptr_t)info.info.win.window);
#elif defined(HAVE_X11)
   video_driver_display_type_set(RARCH_DISPLAY_X11);
   video_driver_display_set((uintptr_t)info.info.x11.display);
   video_driver_window_set((uintptr_t)info.info.x11.window);
#endif
#endif
}
Exemplo n.º 8
0
//drag and drop support, call after window was initialized
void system_window_init(){

	//drag and drop
	#if TARGET_OS == WIN
		SDL_SysWMinfo wmInfo;

		//set SDL version to WMinfo struct
		//-> maybe problems when not calling this macro before
		SDL_VERSION(&wmInfo.version);  

		if(SDL_GetWMInfo(&wmInfo) != SDL_TRUE) {
			cerr << "Error on getting WMInfo" << endl;
			return;
		}

		SDL_EventState(SDL_SYSWMEVENT, SDL_ENABLE);
		DragAcceptFiles(wmInfo.window, true); //afxwin.h
	#endif
	
	//other OS ...
}
Exemplo n.º 9
0
// --- Functions ---
bool the_Game::Init( std::string _title )
{
  // Initializing_SDL2:
  if( SDL_Init( SDL_INIT_EVERYTHING ) == -1 ) {
    std::cout << "GAME :: !! Failed to initialize SDL : " << SDL_GetError() << " !!\n";  
    return false;
  }

  m_display_ptr = SDL_CreateWindow( _title.c_str(), SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
				    the_World::Instance().Get_display_width(), 
				    the_World::Instance().Get_display_height(), 
				    SDL_WINDOW_RESIZABLE );
  if ( m_display_ptr == nullptr ) {
    std::cout << "GAME :: !! Failed to create window : " << SDL_GetError() << " !!\n";  
    return false;
  }

  m_renderer_ptr = SDL_CreateRenderer( m_display_ptr, -1, SDL_RENDERER_ACCELERATED );
  if ( m_renderer_ptr == nullptr ) {
    std::cout << "GAME :: !! Failed to create renderer : " << SDL_GetError() << " !!\n";  
    return false;
  }

  // SDL Version:
  SDL_version compiled, linked;
  SDL_VERSION( &compiled );
  SDL_GetVersion( &linked );
  std::cout <<"GAME :: We compiled against SDL version: "
	    << (int)compiled.major <<"."<< (int)compiled.minor <<"."<< (int)compiled.patch <<"\n";
  std::cout <<"GAME :: But we are linking against SDL version: " 
	    << (int)linked.major <<"."<< (int)linked.minor <<"."<< (int)linked.patch << "\n";

  // Opening Inputh Handler:
  the_Input_handler::Instance().Initialise_joysticks();

  // The Game State Machine:
  m_state_machine.To_do( SMF_parameters( SMF::CREATE_AT_FRONT, "State1", "", "" ));

  return true;
}
Exemplo n.º 10
0
void	CoreEngine::StartUp()
{

	m_run=true;

	SDL_Init(0);
	SDL_version compiled;
	SDL_version linked;

	SDL_VERSION(&compiled);

	SDL_GetVersion(&linked);





	//CREO ELS SUBSISTEMES EN ORDRE
	m_logmngr 	= new LogManager();
	m_logmngr->m_IsLogEnabled = LOG_ENABLED;
	m_logmngr->StartUp();
	m_rendermngr = new RenderManager();
	m_rendermngr->StartUp();
	//		m_soundmngr = new SoundManager();
	//		m_soundmngr->StartUp();
	//		m_inputmngr = new InputManager();
	//		m_inputmngr->StartUp();
	m_game = new GameManager();
	m_game->StartUp();
	m_timermngr = new CTimer();
	m_timermngr->StartUp();

	m_logmngr->INFO_LOG(LOG_ENGINE,"We compiled against SDL version %i.%i.%i",(unsigned int) compiled.major,(unsigned int) compiled.minor,(unsigned int) compiled.patch);
	m_logmngr->INFO_LOG(LOG_ENGINE,"And we are linking against SDL version %i.%i.%i",(unsigned int)linked.major,(unsigned int)linked.minor,(unsigned int) linked.patch);



	m_logmngr->INFO_LOG(LOG_ENGINE,"Start all subsystems OK");

}
Exemplo n.º 11
0
static int bgd_get_desktop_size( INSTANCE * my, int * params )
{
#ifdef WIN32
    RECT Rect;

    if ( GetClientRect( GetDesktopWindow(), &Rect ) )
    {
        *(( int * )( params[0] ) ) = Rect.right - Rect.left;
        *(( int * )( params[1] ) ) = Rect.bottom - Rect.top;
    }
#elif __linux
#ifdef SDL_VIDEO_DRIVER_X11
    int res ;
    Window root, parent, *children = NULL;
    XWindowAttributes wattr;
    unsigned int children_count;

    SDL_SysWMinfo wminfo ;

    SDL_VERSION( &wminfo.version );
    if ( SDL_GetWMInfo( &wminfo ) != 1 ) return -1 ;

    wminfo.info.x11.lock_func();
    if ( XQueryTree(wminfo.info.x11.display, wminfo.info.x11.window, &root, &parent, &children, &children_count ) != BadWindow )
    {
        if ( children ) XFree( children );

        res = XGetWindowAttributes( wminfo.info.x11.display, root, &wattr );
        if ( res != BadDrawable && res != BadWindow )
        {
            if ( params[0] ) *(( int * )( params[0] ) ) = wattr.width;
            if ( params[1] ) *(( int * )( params[1] ) ) = wattr.height;
        }
    }
    wminfo.info.x11.unlock_func();
#endif
#endif

    return 1 ;
}
Exemplo n.º 12
0
void InitSDL(SDL_Window **outSdlWindow) {
	auto currentDirectoryRead = GetCurrentDirectoryA(_countof(GWorkingDir), GWorkingDir);
	Check(currentDirectoryRead > 0 && currentDirectoryRead < _countof(GWorkingDir));
	for (auto i = 0u; i < GWorkingDirLength; ++i) {
		GWorkingDir[i] = tolower(GWorkingDir[i]);
	}
	GWorkingDirLength = currentDirectoryRead;

	SDL_Init(SDL_INIT_EVERYTHING);
	auto sdlWindow = SDL_CreateWindow(GDisplaySettings.window_title,
		SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
		GDisplaySettings.resolution.x, GDisplaySettings.resolution.y,
		SDL_WINDOW_INPUT_FOCUS | SDL_WINDOW_RESIZABLE);

	SDL_SysWMinfo info = {};
	SDL_VERSION(&info.version);
	auto getwininfo_ok = SDL_GetWindowWMInfo(sdlWindow, &info);
	SDL_assert(getwininfo_ok);

	GDisplaySettings.hwnd = info.info.win.window;
	*outSdlWindow = sdlWindow;
}
Exemplo n.º 13
0
int
pygame_scrap_init (void)
{
    SDL_SysWMinfo info;
    int retval = 0;

    /* Grab the window manager specific information */
    SDL_SetError ("SDL is not running on known window manager");

    SDL_VERSION (&info.version);
    if (SDL_GetWMInfo (&info))
    {
        /* Save the information for later use */
        SDL_Window = info.window;
        retval = 1;
    }
    if (retval)
        _scrapinitialized = 1;
    
    _format_MIME_PLAIN = RegisterClipboardFormat (PYGAME_SCRAP_TEXT);
    return retval;
}
Exemplo n.º 14
0
bool    ImGui_ImplSdlGL3_Init(SDL_Window* window)
{
    ImGuiIO& io = ImGui::GetIO();
    io.KeyMap[ImGuiKey_Tab] = SDLK_TAB;                     // Keyboard mapping. ImGui will use those indices to peek into the io.KeyDown[] array.
    io.KeyMap[ImGuiKey_LeftArrow] = SDL_SCANCODE_LEFT;
    io.KeyMap[ImGuiKey_RightArrow] = SDL_SCANCODE_RIGHT;
    io.KeyMap[ImGuiKey_UpArrow] = SDL_SCANCODE_UP;
    io.KeyMap[ImGuiKey_DownArrow] = SDL_SCANCODE_DOWN;
    io.KeyMap[ImGuiKey_PageUp] = SDL_SCANCODE_PAGEUP;
    io.KeyMap[ImGuiKey_PageDown] = SDL_SCANCODE_PAGEDOWN;
    io.KeyMap[ImGuiKey_Home] = SDL_SCANCODE_HOME;
    io.KeyMap[ImGuiKey_End] = SDL_SCANCODE_END;
    io.KeyMap[ImGuiKey_Delete] = SDLK_DELETE;
    io.KeyMap[ImGuiKey_Backspace] = SDLK_BACKSPACE;
    io.KeyMap[ImGuiKey_Enter] = SDLK_RETURN;
    io.KeyMap[ImGuiKey_Escape] = SDLK_ESCAPE;
    io.KeyMap[ImGuiKey_A] = SDLK_a;
    io.KeyMap[ImGuiKey_C] = SDLK_c;
    io.KeyMap[ImGuiKey_V] = SDLK_v;
    io.KeyMap[ImGuiKey_X] = SDLK_x;
    io.KeyMap[ImGuiKey_Y] = SDLK_y;
    io.KeyMap[ImGuiKey_Z] = SDLK_z;

    io.RenderDrawListsFn = ImGui_ImplSdlGL3_RenderDrawLists;   // Alternatively you can set this to NULL and call ImGui::GetDrawData() after ImGui::Render() to get the same ImDrawData pointer.
    io.SetClipboardTextFn = ImGui_ImplSdlGL3_SetClipboardText;
    io.GetClipboardTextFn = ImGui_ImplSdlGL3_GetClipboardText;
    io.ClipboardUserData = NULL;

#ifdef _WIN32
    SDL_SysWMinfo wmInfo;
    SDL_VERSION(&wmInfo.version);
    SDL_GetWindowWMInfo(window, &wmInfo);
    io.ImeWindowHandle = wmInfo.info.win.window;
#else
    (void)window;
#endif

    return true;
}
Exemplo n.º 15
0
void Window::requestAttention(bool continuous)
{
#if defined(LOVE_WINDOWS) && !defined(LOVE_WINDOWS_UWP)

	if (hasFocus())
		return;

	SDL_SysWMinfo wminfo = {};
	SDL_VERSION(&wminfo.version);

	if (SDL_GetWindowWMInfo(window, &wminfo))
	{
		FLASHWINFO flashinfo = {};
		flashinfo.cbSize = sizeof(FLASHWINFO);
		flashinfo.hwnd = wminfo.info.win.window;
		flashinfo.uCount = 1;
		flashinfo.dwFlags = FLASHW_ALL;

		if (continuous)
		{
			flashinfo.uCount = 0;
			flashinfo.dwFlags |= FLASHW_TIMERNOFG;
		}

		FlashWindowEx(&flashinfo);
	}

#elif defined(LOVE_MACOSX)

	love::macosx::requestAttention(continuous);

#else

	LOVE_UNUSED(continuous);
	
#endif
	
	// TODO: Linux?
}
Exemplo n.º 16
0
int
main(int argc, char *argv[])
{
    SDL_version compiled;
    SDL_version linked;

#if SDL_VERSION_ATLEAST(1, 3, 0)
    printf("Compiled with SDL 1.3 or newer\n");
#else
    printf("Compiled with SDL older than 1.3\n");
#endif
    SDL_VERSION(&compiled);
    printf("Compiled version: %d.%d.%d.%d (%s)\n",
           compiled.major, compiled.minor, compiled.patch,
           SDL_REVISION_NUMBER, SDL_REVISION);
    SDL_GetVersion(&linked);
    printf("Linked version: %d.%d.%d.%d (%s)\n",
           linked.major, linked.minor, linked.patch,
           SDL_GetRevisionNumber(), SDL_GetRevision());
    SDL_Quit();
    return (0);
}
Exemplo n.º 17
0
void cInputManager::init()
{
	try{
		cSDL2DRenderManager* g_RenderManager = cSDL2DRenderManager::GetSDL2DRenderManager();

		OIS::ParamList pl;
		std::ostringstream windowHndStr;

		SDL_SysWMinfo wmi;
		SDL_Window* window = g_RenderManager->m_Window;
		SDL_VERSION(&wmi.version);

		if (!SDL_GetWindowWMInfo(window, &wmi))
			return;

		size_t handle = (size_t)wmi.info.win.window;
		//g_RenderManager->m_WindowHandle;
		windowHndStr << handle;
		pl.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str()));
		m_OISInputManager = OIS::InputManager::createInputSystem(pl);

		//If there is a keyboard
		if (m_OISInputManager->getNumberOfDevices(OIS::OISKeyboard) > 0)
		{
			m_Keyboard = static_cast<OIS::Keyboard*>(m_OISInputManager->createInputObject(OIS::OISKeyboard, true));
			m_Keyboard->setEventCallback(this);
		}

		//If there is a mouse
		if (m_OISInputManager->getNumberOfDevices(OIS::OISMouse) > 0)
		{
			m_Mouse = static_cast<OIS::Mouse*>(m_OISInputManager->createInputObject(OIS::OISMouse, true));
			m_Mouse->setEventCallback(this);
		}

	}
	catch (...){ ; }
}
Exemplo n.º 18
0
	value lime_window_alert (value message, value title) {
		
		#ifdef NME_SDL2
		
		SDL_Window* sdlWindow = SDL_GL_GetCurrentWindow ();
		if (!sdlWindow) return alloc_null ();
		
		#ifdef HX_WINDOWS
		
		int count = 0;
		int speed = 0;
		bool stopOnForeground = true;
		
		SDL_SysWMinfo info;
		SDL_VERSION (&info.version);
		SDL_GetWindowWMInfo (sdlWindow, &info);
		
		FLASHWINFO fi;
		fi.cbSize = sizeof (FLASHWINFO);
		fi.hwnd = info.info.win.window;
		fi.dwFlags = stopOnForeground ? FLASHW_ALL | FLASHW_TIMERNOFG : FLASHW_ALL | FLASHW_TIMER;
		fi.uCount = count;
		fi.dwTimeout = speed;
		FlashWindowEx (&fi);
		
		#endif
		
		if (!val_is_null (message)) {
			
			SDL_ShowSimpleMessageBox (SDL_MESSAGEBOX_INFORMATION, val_is_null (title) ? "" : val_string (title), val_string (message), sdlWindow);
			
		}
		
		#endif
		
		return alloc_null ();
		
	}
Exemplo n.º 19
0
static void sdl2_gfx_set_handles(sdl2_video_t *vid)
{
   driver_t *driver = driver_get_ptr();

   /* SysWMinfo headers are broken on OSX. */
#if defined(_WIN32) || defined(HAVE_X11)
   SDL_SysWMinfo info;
   SDL_VERSION(&info.version);

   if (SDL_GetWindowWMInfo(vid->window, &info) != 1)
      return;

#if defined(_WIN32)
   driver->display_type  = RARCH_DISPLAY_WIN32;
   driver->video_display = 0;
   driver->video_window  = (uintptr_t)info.info.win.window;
#elif defined(HAVE_X11)
   driver->display_type  = RARCH_DISPLAY_X11;
   driver->video_display = (uintptr_t)info.info.x11.display;
   driver->video_window  = (uintptr_t)info.info.x11.window;
#endif
#endif
}
Exemplo n.º 20
0
bool CClipboard::Init ()
{
	SDL_SysWMinfo info;
	SDL_VERSION(&info.version);
	if (SDL_GetWMInfo(&info) && info.subsystem == SDL_SYSWM_X11) {
		display = info.info.x11.display;
		window = info.info.x11.window;
		LockDisplay = info.info.x11.lock_func;
		UnlockDisplay = info.info.x11.unlock_func;
		xa.utf8_string = Dyn::XInternAtom(display, "UTF8_STRING", False);
		xa.clipboard = Dyn::XInternAtom(display, "CLIPBOARD", False);
		//xa.clipboard = XA_PRIMARY;
		xa.targets = Dyn::XInternAtom(display, "TARGETS", False);

		//Enable SDL clipboard passing
		SDL_SetEventFilter(ClipboardFilter);
		SDL_EventState(SDL_SYSWMEVENT, SDL_ENABLE);
		return true;
	} else {
		display = NULL;   //No need to init the rest in this case
		return false;
	}
}
Exemplo n.º 21
0
void copy_to_clipboard(const char* text)
{
	SDL_SysWMinfo info;

	if (text == NULL)
		return;

	SDL_VERSION (&info.version);
	if (SDL_GetWindowWMInfo (el_gl_window, &info))
	{
		if (OpenClipboard (info.info.win.window))
		{
			HGLOBAL hCopy = GlobalAlloc (GMEM_MOVEABLE, 1+strlen (text));
			char* copy = GlobalLock (hCopy);
			strcpy (copy, text);
			GlobalUnlock (hCopy);

			EmptyClipboard ();
			SetClipboardData (CF_TEXT, hCopy);
			CloseClipboard ();
		}
	}
}
Exemplo n.º 22
0
void finishpaste(XSelectionEvent event)
{
	Display * dpy;
	Window window;
	SDL_SysWMinfo wminfo;

	SDL_VERSION(&wminfo.version);
	if (SDL_GetWMInfo(&wminfo) && wminfo.subsystem==SDL_SYSWM_X11)
	{
		wminfo.info.x11.lock_func();

		dpy=wminfo.info.x11.display;
		window=wminfo.info.x11.window;

		if (event.property == None)
		{
			fprintf(stderr,"%s\n",not_ascii);
			return;
		}
		processpaste(dpy, window, event.property);
		wminfo.info.x11.unlock_func();
	}
}
Exemplo n.º 23
0
bool MaemoSdlGraphicsManager::loadGFXMode() {
	bool success = SurfaceSdlGraphicsManager::loadGFXMode();

	// fix the problematic zoom key capture in Maemo5/N900
	SDL_SysWMinfo info;
	SDL_VERSION(&info.version);
	if (SDL_GetWMInfo(&info)) {
		Display *dpy = info.info.x11.display;
		Window win;
		unsigned long val = 1;
		Atom atom_zoom = XInternAtom(dpy, "_HILDON_ZOOM_KEY_ATOM", 0);
		info.info.x11.lock_func();
		win = info.info.x11.fswindow;
		if (win)
			XChangeProperty(dpy, win, atom_zoom, XA_INTEGER, 32, PropModeReplace, (unsigned char *) &val, 1); // grab zoom keys
		win = info.info.x11.wmwindow;
		if (win)
			XChangeProperty(dpy, win, atom_zoom, XA_INTEGER, 32, PropModeReplace, (unsigned char *) &val, 1); // grab zoom keys
		info.info.x11.unlock_func();
	}

	return success;
}
Exemplo n.º 24
0
//==============================================================================
Error GrManagerImpl::initSurface(const GrManagerInitInfo& init)
{
	SDL_SysWMinfo wminfo;
	SDL_VERSION(&wminfo.version);
	if(!SDL_GetWindowWMInfo(init.m_window->getNative().m_window, &wminfo))
	{
		ANKI_LOGE("SDL_GetWindowWMInfo() failed");
		return ErrorCode::NONE;
	}

#if ANKI_OS == ANKI_OS_LINUX
	VkXcbSurfaceCreateInfoKHR ci = {};
	ci.sType = VK_STRUCTURE_TYPE_XCB_SURFACE_CREATE_INFO_KHR;
	ci.connection = XGetXCBConnection(wminfo.info.x11.display);
	ci.window = wminfo.info.x11.window;

	ANKI_VK_CHECK(vkCreateXcbSurfaceKHR(m_instance, &ci, nullptr, &m_surface));
#else
#error TODO
#endif

	return ErrorCode::NONE;
}
Exemplo n.º 25
0
	void SDLDirect3D11Window::SetScreenSize(const Graphics::PresentationParameters& pp)
	{
		assert(m_device != nullptr);

        SDL_SetHint( "SDL_HINT_ORIENTATIONS", "LandscapeLeft LandscapeRight" );

        PreferredBackBufferWidth(pp.BackBufferWidth);
		PreferredBackBufferHeight(pp.BackBufferHeight);
        
        int flags = SDL_WINDOW_SHOWN;

		if (pp.IsFullScreen)
			flags |= SDL_WINDOW_FULLSCREEN;
        
		m_window = SDL_CreateWindow("CNK", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 
			PreferredBackBufferWidth(), PreferredBackBufferHeight(), flags);

		if (m_window == nullptr)
			throw Exception(SDL_GetError());
        
		int width, height;
        SDL_GetWindowSize((SDL_Window*)m_window, &width, &height);
        
        PreferredBackBufferWidth(width);
        PreferredBackBufferHeight(height);
       
		SDL_SysWMinfo info;
		SDL_VERSION(&info.version);
		SDL_GetWindowWMInfo((SDL_Window*)m_window, &info);
		static_cast<Nxna::Graphics::Direct3D11::Direct3D11Device*>(m_device)->OnWindowCreated(info.info.win.window, pp);

		m_device->SetViewport(Nxna::Graphics::Viewport(0, 0, PreferredBackBufferWidth(), PreferredBackBufferHeight()));

		// tell the touch panel the display size
		Input::Touch::TouchPanel::SetDisplayWidth(width);
		Input::Touch::TouchPanel::SetDisplayHeight(height);
	}
Exemplo n.º 26
0
void sg_SetIcon()
{
#ifndef DEDICATED
#ifndef MACOSX
#ifdef  WIN32
    SDL_SysWMinfo	info;
    HICON			icon;
    // get the HWND handle
    SDL_VERSION( &info.version );
    if( SDL_GetWMInfo( &info ) )
    {
        icon = LoadIcon( GetModuleHandle( NULL ), MAKEINTRESOURCE( 1 ) );
        SetClassLong( info.window, GCL_HICON, (LONG) icon );
    }
#else
    rSurface tex( "desktop/icons/medium/armagetronad.png" );
    //    SDL_Surface *tex=IMG_Load( tDirectories::Data().GetReadPath( "textures/icon.png" ) );

    if (tex.GetSurface())
        SDL_WM_SetIcon(tex.GetSurface(),NULL);
#endif
#endif
#endif
}
Exemplo n.º 27
0
Error GrManagerImpl::initSurface(const GrManagerInitInfo& init)
{
	SDL_SysWMinfo wminfo;
	SDL_VERSION(&wminfo.version);
	if(!SDL_GetWindowWMInfo(init.m_window->getNative().m_window, &wminfo))
	{
		ANKI_LOGE("SDL_GetWindowWMInfo() failed");
		return ErrorCode::NONE;
	}

#if ANKI_OS == ANKI_OS_LINUX
	VkXcbSurfaceCreateInfoKHR ci = {};
	ci.sType = VK_STRUCTURE_TYPE_XCB_SURFACE_CREATE_INFO_KHR;
	ci.connection = XGetXCBConnection(wminfo.info.x11.display);
	ci.window = wminfo.info.x11.window;

	ANKI_VK_CHECK(vkCreateXcbSurfaceKHR(m_instance, &ci, nullptr, &m_surface));
#elif ANKI_OS == ANKI_OS_WINDOWS
	Array<TCHAR, 512> className;
	GetClassName(wminfo.info.win.window, &className[0], className.getSize());

	WNDCLASS wce = {};
	GetClassInfo(GetModuleHandle(NULL), &className[0], &wce);

	VkWin32SurfaceCreateInfoKHR ci = {};
	ci.sType = VK_STRUCTURE_TYPE_WIN32_SURFACE_CREATE_INFO_KHR;
	ci.hinstance = wce.hInstance;
	ci.hwnd = wminfo.info.win.window;

	ANKI_VK_CHECK(vkCreateWin32SurfaceKHR(m_instance, &ci, nullptr, &m_surface));
#else
#error TODO
#endif

	return ErrorCode::NONE;
}
Exemplo n.º 28
0
static int check_for_evdev(void)
{
    SDL_SysWMinfo info;
    XkbDescPtr desc = NULL;
    int has_evdev = 0;
    char *keycodes = NULL;

    SDL_VERSION(&info.version);
    if (!SDL_GetWMInfo(&info)) {
        return 0;
    }
    desc = XkbGetMap(info.info.x11.display,
                     XkbGBN_AllComponentsMask,
                     XkbUseCoreKbd);
    if (desc &&
        (XkbGetNames(info.info.x11.display,
                     XkbKeycodesNameMask, desc) == Success)) {
        keycodes = XGetAtomName(info.info.x11.display, desc->names->keycodes);
        if (keycodes == NULL) {
            fprintf(stderr, "could not lookup keycode name\n");
        } else if (strstart(keycodes, "evdev", NULL)) {
            has_evdev = 1;
        } else if (!strstart(keycodes, "xfree86", NULL)) {
            fprintf(stderr, "unknown keycodes `%s', please report to "
                    "[email protected]\n", keycodes);
        }
    }

    if (desc) {
        XkbFreeKeyboard(desc, XkbGBN_AllComponentsMask, True);
    }
    if (keycodes) {
        XFree(keycodes);
    }
    return has_evdev;
}
Exemplo n.º 29
0
//
// RawWin32Mouse::debug
//
void RawWin32Mouse::debug() const
{
	// get a handle to the window
	SDL_SysWMinfo wminfo;
	SDL_VERSION(&wminfo.version)
	SDL_GetWMInfo(&wminfo);
	HWND cur_window = wminfo.window;

	// determine the hwndTarget parameter of the registered rawinput device
	HWND hwndTarget = NULL;

	RAWINPUTDEVICE device;
	if (getMouseRawInputDevice(device))
	{
		hwndTarget = device.hwndTarget;
	}

	Printf(PRINT_HIGH, "RawWin32Mouse: Current Window Address: 0x%x, mWindow: 0x%x, RAWINPUTDEVICE Window: 0x%x\n",
			cur_window, mWindow, hwndTarget);

	WNDPROC wndproc = (WNDPROC)GetWindowLongPtr(cur_window, GWLP_WNDPROC);
	Printf(PRINT_HIGH, "RawWin32Mouse: windowProcWrapper Address: 0x%x, Current Window WNDPROC Address: 0x%x\n",
			RawWin32Mouse::windowProcWrapper, wndproc);
}
Exemplo n.º 30
0
Arquivo: sdl_init.c Projeto: robn/cake
static int sdl_hidd_init(LIBBASETYPEPTR LIBBASE) {
    SDL_version cver, *rver;
    int i, ret;
    char *err;

    D(bug("[sdl] hidd init\n"));

    SDL_VERSION(&cver);
    rver = S(SDL_Linked_Version);

    kprintf("sdl.hidd: using SDL version %d.%d.%d\n", rver->major, rver->minor, rver->patch);

    if (cver.major != rver->major || cver.minor != rver->minor || cver.patch != rver->patch) {
        kprintf("WARNING: sdl.hidd was compiled against SDL version %d.%d.%d\n", cver.major, cver.minor, cver.patch);
        kprintf("         You may experience problems\n");
    }

    InitSemaphore(&LIBBASE->lock);

    /* start sdl. we don't catch any signals with a debug build as it plays
     * havoc with the debugger */
#if DEBUG
    ret = S(SDL_Init, SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE);
#else
    ret = S(SDL_Init, SDL_INIT_VIDEO);
#endif

    if (ret != 0) {
        D(bug("[sdl] couldn't initialise SDL\n"));
        return FALSE;
    }

    S(SDL_ShowCursor, SDL_DISABLE);
    
    return TRUE;
}