当前位置: 首页>>代码示例>>C++>>正文


C++ SDL_GetWindowFlags函数代码示例

本文整理汇总了C++中SDL_GetWindowFlags函数的典型用法代码示例。如果您正苦于以下问题:C++ SDL_GetWindowFlags函数的具体用法?C++ SDL_GetWindowFlags怎么用?C++ SDL_GetWindowFlags使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了SDL_GetWindowFlags函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: SDL_ToggleFS

int SDL_ToggleFS(SDL_Window *win, Level* level)
{   
	static int orig_w, orig_h;

	Uint32 flags = (SDL_GetWindowFlags(win) ^ SDL_WINDOW_FULLSCREEN_DESKTOP);
    bool fullscreen = (SDL_GetWindowFlags(win) & SDL_WINDOW_FULLSCREEN_DESKTOP); 

	if (!fullscreen){
        SDL_GetWindowSize(win, &orig_w, &orig_h);
	}

	// NOTE: SDL_SetWindowFullscreen takes FLAGS as the second param, NOT true/false!
	if (SDL_SetWindowFullscreen(win, flags) < 0){
		return -1; 
	}

	int w, h;

	if(!fullscreen){
		SDL_GetWindowSize(win, &w, &h);
	} else {
		w = orig_w;
		h = orig_h;
	}
	glViewport(0,0,w,h);

    level->update_proj_mat( (float)w/h );

	cout << "window W: " << w << " H: " << h << endl; 

	return 0;
}
开发者ID:DarkDefender,项目名称:SDL_project,代码行数:32,代码来源:game.cpp

示例2: defined

    bool window::is_open() const
    {
        // On macOS we'll need to check for the minimized flag - the window will
        // be marked as hidden when it's minimized, even if it is still open.

        // We can't do this on Windows since hiding fullscreen windows will
        // minimize them.

#if defined(__APPLE__)
        if (SDL_GetWindowFlags(handle.get()) & SDL_WINDOW_MINIMIZED)
        {
            return true;
        }
#endif

        if (SDL_GetWindowFlags(handle.get()) & SDL_WINDOW_HIDDEN)
        {
            return false;
        }

        if (SDL_GetWindowFlags(handle.get()) & SDL_WINDOW_SHOWN)
        {
            return true;
        }

        return false;
    }
开发者ID:aleksijuvani,项目名称:polygonist,代码行数:27,代码来源:window.cpp

示例3: ToggleFullScreen

// Toggle fullscreen
void _Graphics::ToggleFullScreen(const glm::ivec2 &WindowSize, const glm::ivec2 &FullscreenSize) {

	if(SDL_GetWindowFlags(Window) & SDL_WINDOW_FULLSCREEN) {
		Graphics.ChangeWindowSize(WindowSize);
	}
	else {
		Graphics.ChangeWindowSize(FullscreenSize);
	}

	if(SDL_SetWindowFullscreen(Window, SDL_GetWindowFlags(Window) ^ SDL_WINDOW_FULLSCREEN_DESKTOP) != 0) {
		// failed
	}
}
开发者ID:aadarshasubedi,项目名称:choria,代码行数:14,代码来源:graphics.cpp

示例4: configure

void PlasmacoreView::redraw ()
{
  configure();
  if (!window) return;
  if (!gl_context) return;
  auto flags = SDL_GetWindowFlags(window);
  if (flags & SDL_WINDOW_MINIMIZED) return;
  if (!(flags & SDL_WINDOW_SHOWN)) return;

  if (SDL_GL_MakeCurrent(window, gl_context))
  {
    fprintf( stderr, "SDL_GL_MakeCurrent() failed: %s\n", SDL_GetError() );
    return;
  }

  int display_width, display_height;
  SDL_GetWindowSize(window, &display_width, &display_height);
  auto m = PlasmacoreMessage( "Display.on_render" );
  m.set( "window_id", pwindowID ).set( "display_name", name );
  m.set( "display_width",  display_width );
  m.set( "display_height", display_height );
  m.set( "viewport_width",  display_width );
  m.set( "viewport_height", display_height );
  m.send();
  SDL_GL_SwapWindow(window);
}
开发者ID:AbePralle,项目名称:Plasmacore,代码行数:26,代码来源:PlasmacoreView.cpp

示例5: SDL_GetWindowFlags

bool Graphics::WindowVisible()
{
	Uint32 flags = SDL_GetWindowFlags(window);

	return (flags & SDL_WINDOW_SHOWN) && !(flags & SDL_WINDOW_MINIMIZED) // SDL_APPACTIVE
		&& (flags & SDL_WINDOW_INPUT_FOCUS);                              // SDL_APPINPUTFOCUS 
}
开发者ID:CliffsDover,项目名称:NXEngine-iOS,代码行数:7,代码来源:graphics.cpp

示例6: mSDLWindow

InputWrapper::InputWrapper(SDL_Window* window, osg::ref_ptr<osgViewer::Viewer> viewer, bool grab) :
        mSDLWindow(window),
        mViewer(viewer),
        mMouseListener(NULL),
        mKeyboardListener(NULL),
        mWindowListener(NULL),
        mConListener(NULL),
        mWarpX(0),
        mWarpY(0),
        mWarpCompensate(false),
        mWrapPointer(false),
        mAllowGrab(grab),
        mWantMouseVisible(false),
        mWantGrab(false),
        mWantRelative(false),
        mGrabPointer(false),
        mMouseRelative(false),
        mFirstMouseMove(true),
        mMouseZ(0),
        mMouseX(0),
        mMouseY(0),
        mWindowHasFocus(true),
        mMouseInWindow(true)
    {
        _setupOISKeys();

        Uint32 flags = SDL_GetWindowFlags(mSDLWindow);
        mWindowHasFocus = (flags & SDL_WINDOW_INPUT_FOCUS);
        mMouseInWindow = (flags & SDL_WINDOW_MOUSE_FOCUS);
    }
开发者ID:Allofich,项目名称:openmw,代码行数:30,代码来源:sdlinputwrapper.cpp

示例7: ImGui_ImplSdlGL3_CreateDeviceObjects

void GUIEnvironment::ImGui_NewFrame()
{
	if (!g_FontTexture)
		ImGui_ImplSdlGL3_CreateDeviceObjects();

	ImGuiIO& io = ImGui::GetIO();

	int w, h;
	SDL_GetWindowSize(g_Window, &w, &h);
	io.DisplaySize = ImVec2((float)w, (float)h);
	io.DisplayFramebufferScale = ImVec2(1.0f, 1.0f);

	int mx, my;
	Uint32 mouseMask = SDL_GetMouseState(&mx, &my);
	if (SDL_GetWindowFlags(g_Window) & SDL_WINDOW_MOUSE_FOCUS)
		io.MousePos = ImVec2((float)mx, (float)my);
	else
		io.MousePos = ImVec2(-1, -1);

	io.MouseDown[0] = g_MousePressed[0] || (mouseMask & SDL_BUTTON(SDL_BUTTON_LEFT)) != 0;
	io.MouseDown[1] = g_MousePressed[1] || (mouseMask & SDL_BUTTON(SDL_BUTTON_RIGHT)) != 0;
	io.MouseDown[2] = g_MousePressed[2] || (mouseMask & SDL_BUTTON(SDL_BUTTON_MIDDLE)) != 0;
	g_MousePressed[0] = g_MousePressed[1] = g_MousePressed[2] = false;

	io.MouseWheel = g_MouseWheel;
	g_MouseWheel = 0.0f;

	SDL_ShowCursor(io.MouseDrawCursor ? 0 : 1);

	ImGui::NewFrame();
}
开发者ID:AdrienBourgois,项目名称:ModelViewer,代码行数:31,代码来源:GUIEnvironnement.cpp

示例8: video_getWindowFlags

/**
 * @brief Tests the functionality of the SDL_GetWindowFlags function
 */
int
video_getWindowFlags(void *arg)
{
  SDL_Window* window;
  const char* title = "video_getWindowFlags Test Window";
  int x, y, w, h;
  SDL_WindowFlags flags;
  Uint32 actualFlags;
  
  /* Standard window */
  x = SDLTest_RandomIntegerInRange(1, 100);
  y = SDLTest_RandomIntegerInRange(1, 100);
  w = SDLTest_RandomIntegerInRange(320, 1024);
  h = SDLTest_RandomIntegerInRange(320, 768);
  
  /* Reliable flag */
  flags = SDL_WINDOW_SHOWN;
  
  window = SDL_CreateWindow(title, x, y, w, h, flags);
  SDLTest_AssertPass("Call to SDL_CreateWindow('Title',%d,%d,%d,%d,%d)", x, y, w, h, flags);
  SDLTest_AssertCheck(window != NULL, "Validate that returned window struct is not NULL");
  if (window != NULL) {
      actualFlags = SDL_GetWindowFlags(window);
      SDLTest_AssertPass("Call to SDL_GetWindowFlags");
      SDLTest_AssertCheck((flags & actualFlags) == flags, "Verify returned value has flags %d set, got: %d", flags, actualFlags);
      SDL_DestroyWindow(window);
      SDLTest_AssertPass("Call to SDL_DestroyWindow");  
  }

  return TEST_COMPLETED;
}
开发者ID:Plombo,项目名称:SDL,代码行数:34,代码来源:testautomation_video.c

示例9: SetScreenParmsFullscreen

static bool SetScreenParmsFullscreen( glimpParms_t parms )
{
	SDL_DisplayMode m = {0};
	int displayIdx = ScreenParmsHandleDisplayIndex( parms );
	if( displayIdx < 0 )
		return false;
		
	// get current mode of display the window should be full-screened on
	SDL_GetCurrentDisplayMode( displayIdx, &m );
	
	// change settings in that display mode according to parms
	// FIXME: check if refreshrate, width and height are supported?
	// m.refresh_rate = parms.displayHz;
	m.w = parms.width;
	m.h = parms.height;
	
	// set that displaymode
	if( SDL_SetWindowDisplayMode( window, &m ) < 0 )
	{
		common->Warning( "Couldn't set window mode for fullscreen, reason: %s", SDL_GetError() );
		return false;
	}
	
	// if we're currently not in fullscreen mode, we need to switch to fullscreen
	if( !( SDL_GetWindowFlags( window ) & SDL_WINDOW_FULLSCREEN ) )
	{
		if( SDL_SetWindowFullscreen( window, SDL_TRUE ) < 0 )
		{
			common->Warning( "Couldn't switch to fullscreen mode, reason: %s!", SDL_GetError() );
			return false;
		}
	}
	return true;
}
开发者ID:OpenTechEngine,项目名称:OpenTechBFG,代码行数:34,代码来源:sdl_glimp.cpp

示例10: SDL_GetWindowFlags

 const Uint32 Window::getFlags() const
 {
     if(isLoaded())
         return flags = SDL_GetWindowFlags(win);
     else
         return flags;
 }
开发者ID:JERlabs,项目名称:JERonimo,代码行数:7,代码来源:Window.cpp

示例11: IN_Frame

/*
===============
IN_Frame
===============
*/
void IN_Frame(void)
{
	qboolean        loading;

	IN_JoyMove();
	IN_ProcessEvents();

	// If not DISCONNECTED (main menu) or ACTIVE (in game), we're loading
	loading = (cls.state != CA_DISCONNECTED && cls.state != CA_ACTIVE);

	if(!cls.glconfig.isFullscreen && (Key_GetCatcher() & KEYCATCH_CONSOLE))
	{
		// Console is down in windowed mode
		IN_DeactivateMouse();
	}
	else if(!cls.glconfig.isFullscreen && loading)
	{
		// Loading in windowed mode
		IN_DeactivateMouse();
	}
	else if(!( SDL_GetWindowFlags(SDL_window) & SDL_WINDOW_INPUT_FOCUS))
	{
		// Window not got focus
		IN_DeactivateMouse();
	}
	else
		IN_ActivateMouse();

	// In case we had to delay actual restart of video system
	if( ( vidRestartTime != 0 ) && ( vidRestartTime < Sys_Milliseconds( ) ) )
	{
		vidRestartTime = 0;
		Cbuf_AddText( "vid_restart\n" );
	}
}
开发者ID:otty,项目名称:cake3,代码行数:40,代码来源:sdl_input.c

示例12: IN_Frame

void IN_Frame (void) {
	qboolean loading;

	IN_JoyMove( );

	// If not DISCONNECTED (main menu) or ACTIVE (in game), we're loading
	loading = (qboolean)( cls.state != CA_DISCONNECTED && cls.state != CA_ACTIVE );

	if( !cls.glconfig.isFullscreen && ( Key_GetCatcher( ) & KEYCATCH_CONSOLE ) )
	{
		// Console is down in windowed mode
		IN_DeactivateMouse( );
	}
	else if( !cls.glconfig.isFullscreen && loading )
	{
		// Loading in windowed mode
		IN_DeactivateMouse( );
	}
	else if( !( SDL_GetWindowFlags( SDL_window ) & SDL_WINDOW_INPUT_FOCUS ) )
	{
		// Window not got focus
		IN_DeactivateMouse( );
	}
	else
		IN_ActivateMouse( );

	IN_ProcessEvents( );
}
开发者ID:metivett,项目名称:OpenJK,代码行数:28,代码来源:sdl_input.cpp

示例13: IN_Init

/*
===============
IN_Init
===============
*/
void IN_Init( void *windowData )
{
    int appState;

    if( !SDL_WasInit( SDL_INIT_VIDEO ) )
    {
        Com_Error( ERR_FATAL, "IN_Init called before SDL_Init( SDL_INIT_VIDEO )" );
        return;
    }

    SDL_window = (SDL_Window *)windowData;

    Com_DPrintf( "\n------- Input Initialization -------\n" );

    in_keyboardDebug = Cvar_Get( "in_keyboardDebug", "0", CVAR_ARCHIVE );

    // mouse variables
    in_mouse = Cvar_Get( "in_mouse", "1", CVAR_ARCHIVE );
    in_nograb = Cvar_Get( "in_nograb", "0", CVAR_ARCHIVE );

    in_joystick = Cvar_Get( "in_joystick", "0", CVAR_ARCHIVE|CVAR_LATCH );
    in_joystickThreshold = Cvar_Get( "joy_threshold", "0.15", CVAR_ARCHIVE );

    SDL_StartTextInput( );

    mouseAvailable = ( in_mouse->value != 0 );
    IN_DeactivateMouse( );

    appState = SDL_GetWindowFlags( SDL_window );
    Cvar_SetValue( "com_unfocused",	!( appState & SDL_WINDOW_INPUT_FOCUS ) );
    Cvar_SetValue( "com_minimized", appState & SDL_WINDOW_MINIMIZED );

    IN_InitJoystick( );
    Com_DPrintf( "------------------------------------\n" );
}
开发者ID:MAN-AT-ARMS,项目名称:iortcw-archive,代码行数:40,代码来源:sdl_input.c

示例14: UpdateGrab

//
// SDLVideoDriver::FinishUpdate
//
// Push the newest frame to the display.
//
void SDLVideoDriver::FinishUpdate()
{
   // haleyjd 10/08/05: from Chocolate DOOM:
   UpdateGrab(window);

   // Don't update the screen if the window isn't visible.
   // Not doing this breaks under Windows when we alt-tab away 
   // while fullscreen.   
   if(!(SDL_GetWindowFlags(window) & SDL_WINDOW_SHOWN))
      return;

   if(setpalette)
   {
      if(primary_surface)
         SDL_SetPaletteColors(primary_surface->format->palette, colors, 0, 256);

      setpalette = false;
   }

   // haleyjd 11/12/09: blit *after* palette set improves behavior.
   if(primary_surface)
   {
      // Don't bother checking for errors. It should just cancel itself in that case.
      SDL_BlitSurface(primary_surface, nullptr, rgba_surface, nullptr);
      SDL_UpdateTexture(sdltexture, nullptr, rgba_surface->pixels, rgba_surface->pitch);
      SDL_RenderCopy(renderer, sdltexture, nullptr, destrect);
   }

   // haleyjd 11/12/09: ALWAYS update. Causes problems with some video surface
   // types otherwise.
   SDL_RenderPresent(renderer);
}
开发者ID:Altazimuth,项目名称:eternity,代码行数:37,代码来源:i_sdlvideo.cpp

示例15: IN_DeactivateMouse

/*
===============
IN_DeactivateMouse
===============
*/
static void IN_DeactivateMouse( void )
{
    if( !SDL_WasInit( SDL_INIT_VIDEO ) )
        return;

    // Always show the cursor when the mouse is disabled,
    // but not when fullscreen
    if( !Cvar_VariableIntegerValue("r_fullscreen") )
        SDL_ShowCursor( 1 );

    if( !mouseAvailable )
        return;

    if( mouseActive )
    {
        IN_GobbleMotionEvents( );

        SDL_SetWindowGrab( SDL_window, 0 );
        SDL_SetRelativeMouseMode( SDL_FALSE );

        // Don't warp the mouse unless the cursor is within the window
        if( SDL_GetWindowFlags( SDL_window ) & SDL_WINDOW_MOUSE_FOCUS )
            SDL_WarpMouseInWindow( SDL_window, cls.glconfig.vidWidth / 2, cls.glconfig.vidHeight / 2 );

        mouseActive = qfalse;
    }
}
开发者ID:MAN-AT-ARMS,项目名称:iortcw-archive,代码行数:32,代码来源:sdl_input.c


注:本文中的SDL_GetWindowFlags函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。