Example #1
0
        public static bool IsPortrait(this CCDisplayOrientation orientation)
        {
            orientation = orientation & CCDisplayOrientation.Portrait;
            orientation = orientation & CCDisplayOrientation.PortraitDown;

            return(orientation != CCDisplayOrientation.Default);
        }
Example #2
0
        internal CCDrawManager(GraphicsDeviceManager deviceManager, CCSize proposedScreenSize,
                               CCDisplayOrientation supportedOrientations)
        {
            Renderer = new CCRenderer(this);

            graphicsDeviceMgr = deviceManager;

            depthTest = true;
            allowNonPower2Textures = true;
            hasStencilBuffer       = true;
            currBlend           = CCBlendFunc.AlphaBlend;
            platformDepthFormat = CCDepthFormat.Depth24;
            transform           = Matrix.Identity;

            TmpVertices = new CCRawList <CCV3F_C4B_T2F>();
            matrixStack = new Matrix[100];
            blendStates = new Dictionary <CCBlendFunc, BlendState>();
            effectStack = new Stack <Effect>();

            rasterizerStatesCache = new List <RasterizerState>();

            hasStencilBuffer = (deviceManager.PreferredDepthStencilFormat == DepthFormat.Depth24Stencil8);


            if (deviceManager.GraphicsDevice == null)
            {
                initialProposedScreenSizeInPixels           = proposedScreenSize;
                graphicsDeviceMgr.PreferredBackBufferWidth  = (int)initialProposedScreenSizeInPixels.Width;
                graphicsDeviceMgr.PreferredBackBufferHeight = (int)initialProposedScreenSizeInPixels.Height;
                graphicsDeviceMgr.SupportedOrientations     = (DisplayOrientation)supportedOrientations;
                graphicsDeviceMgr.DeviceCreated            += GraphicsDeviceCreated;
                graphicsDeviceMgr.PreparingDeviceSettings  += PreparingDeviceSettings;
            }
        }
Example #3
0
        internal void Update(float deltaTime)
        {
            Stats.UpdateStart();

            if (EventDispatcher.IsEventListenersFor(EVENT_AFTER_UPDATE))
            {
                EventDispatcher.DispatchEvent(eventAfterUpdate);
            }

            CCDisplayOrientation orientation = CurrentDisplayOrientation;
            CCSize landscapeWindowSize       = LandscapeWindowSizeInPixels;

            foreach (CCDirector director in sceneDirectors)
            {
                if (director.NextScene != null)
                {
                    director.NextScene.Viewport.DisplayOrientation          = orientation;
                    director.NextScene.Viewport.LandscapeScreenSizeInPixels = landscapeWindowSize;
                    if (director.NextScene.Window == null)
                    {
                        director.NextScene.Window = this;
                    }
                    director.SetNextScene();
                }
            }

            Stats.UpdateEnd(deltaTime);
        }
Example #4
0
 internal CCViewport(
     CCRect exactFitLandscapeRatioIn,
     CCDisplayOrientation supportedDisplayOrientationIn,
     CCDisplayOrientation currentDisplayOrientationIn)
     : this(exactFitLandscapeRatioIn, currentDisplayOrientationIn)
 {
 }
Example #5
0
 public CCViewport(
     CCRect exactFitLandscapeRatioIn,
     CCViewportResolutionPolicy resolutionPolicyIn = CCViewportResolutionPolicy.ExactFit,
     CCDisplayOrientation displayOrientationIn     = CCDisplayOrientation.LandscapeLeft)
     : this(exactFitLandscapeRatioIn, exactFitLandscapeRatioIn, resolutionPolicyIn, displayOrientationIn)
 {
 }
Example #6
0
        void InitializeMainWindow(CCSize windowSizeInPixels, bool isFullscreen = false,
                                  CCDisplayOrientation supportedOrientations   = CCDisplayOrientation.Default)
        {
            if (isFullscreen)
            {
#if NETFX_CORE
                //  GraphicsAdapter values are not set correctly when it gets to here so we used the
                //  DeviceManager values.
                //if (xnaDeviceManager.GraphicsDevice.DisplayMode.)
                if (xnaGame.Window.CurrentOrientation == DisplayOrientation.Portrait ||
                    xnaGame.Window.CurrentOrientation == DisplayOrientation.PortraitDown)
                {
                    windowSizeInPixels.Width  = xnaDeviceManager.PreferredBackBufferHeight;
                    windowSizeInPixels.Height = xnaDeviceManager.PreferredBackBufferWidth;
                }
                else
                {
                    windowSizeInPixels.Width  = xnaDeviceManager.PreferredBackBufferWidth;
                    windowSizeInPixels.Height = xnaDeviceManager.PreferredBackBufferHeight;
                }
#else
                windowSizeInPixels.Width  = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width;
                windowSizeInPixels.Height = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height;
#endif
            }

            xnaDeviceManager.IsFullScreen = isFullscreen;

            if (CCDrawManager.SharedDrawManager == null)
            {
                CCDrawManager.SharedDrawManager = new CCDrawManager(xnaDeviceManager, windowSizeInPixels, supportedOrientations);
            }
        }
Example #7
0
 internal CCViewport(
     CCRect exactFitLandscapeRatioIn,
     CCDisplayOrientation displayOrientationIn = CCDisplayOrientation.LandscapeLeft)
     : this(exactFitLandscapeRatioIn,
            displayOrientationIn.IsLandscape() ? CCViewportResolutionPolicy.AspectFitLandscape :  CCViewportResolutionPolicy.AspectFitPortrait,
            displayOrientationIn)
 {
 }
Example #8
0
 void UpdateDisplayOrientation()
 {
     // Make sure chosen orientation is supported
     if ((currentDisplayOrientation & SupportedDisplayOrientations) != currentDisplayOrientation)
     {
         currentDisplayOrientation = CCDisplayOrientation.Default;
     }
 }
Example #9
0
        internal CCApplication(CCGame game, bool isFullScreen             = true, CCSize?mainWindowSizeInPixels = null,
                               CCDisplayOrientation supportedOrientations = CCDisplayOrientation.Default)
            : base(game)
        {
            GameTime = new CCGameTime();
            xnaGame  = game;

            Scheduler     = new CCScheduler();
            ActionManager = new CCActionManager();
            Scheduler.Schedule(ActionManager, CCSchedulePriority.System, false);

            priorGamePadState = new Dictionary <PlayerIndex, GamePadState>();
            gamePadConnection = new CCEventGamePadConnection();
            gamePadButton     = new CCEventGamePadButton();
            gamePadDPad       = new CCEventGamePadDPad();
            gamePadStick      = new CCEventGamePadStick();
            gamePadTrigger    = new CCEventGamePadTrigger();

            IGraphicsDeviceService service = (IGraphicsDeviceService)Game.Services.GetService(typeof(IGraphicsDeviceService));

            if (service == null)
            {
                service = new GraphicsDeviceManager(game);

                // if we still do not have a service after creating the GraphicsDeviceManager
                // we need to stop somewhere and issue a warning.
                if (Game.Services.GetService(typeof(IGraphicsDeviceService)) == null)
                {
                    Game.Services.AddService(typeof(IGraphicsDeviceService), service);
                }
            }

            xnaDeviceManager = (GraphicsDeviceManager)service;

            Content = game.Content;
            HandleMediaStateAutomatically = true;

            game.IsFixedTimeStep = true;

            TouchPanel.EnabledGestures = GestureType.Tap;

            game.Activated   += GameActivated;
            game.Deactivated += GameDeactivated;
            game.Exiting     += GameExiting;
            game.Window.OrientationChanged += OrientationChanged;

            game.Components.Add(this);

            gameWindows = new List <CCWindow>();

            InitializeMainWindow((mainWindowSizeInPixels.HasValue) ? mainWindowSizeInPixels.Value : CCSize.Zero,
                                 isFullScreen, supportedOrientations);
        }
Example #10
0
        public CCViewport(
            CCRect exactFitLandscapeRatioIn, CCRect exactFitPortraitRatioIn,
            CCDisplayOrientation displayOrientationIn = CCDisplayOrientation.LandscapeLeft)
        {
            if (exactFitPortraitRatioIn == default(CCRect))
            {
                exactFitPortraitRatioIn = exactFitLandscapeRatioIn;
            }

            displayOrientation     = displayOrientationIn;
            exactFitLandscapeRatio = exactFitLandscapeRatioIn;
            exactFitPortraitRatio  = exactFitPortraitRatioIn;
        }
Example #11
0
        public CCViewport(
            CCRect exactFitLandscapeRatioIn, CCRect exactFitPortraitRatioIn,
            CCViewportResolutionPolicy resolutionPolicyIn = CCViewportResolutionPolicy.ExactFit,
            CCDisplayOrientation displayOrientationIn     = CCDisplayOrientation.LandscapeLeft)
        {
            if (exactFitPortraitRatioIn == default(CCRect))
            {
                exactFitPortraitRatioIn = exactFitLandscapeRatioIn;
            }

            resolutionPolicy       = resolutionPolicyIn;
            displayOrientation     = displayOrientationIn;
            exactFitLandscapeRatio = exactFitLandscapeRatioIn;
            exactFitPortraitRatio  = exactFitPortraitRatioIn;
        }
Example #12
0
        void InitializeMainWindow(CCSize windowSizeInPixels, bool isFullscreen = false,
                                  CCDisplayOrientation supportedOrientations   = CCDisplayOrientation.Default)
        {
            if (isFullscreen)
            {
                windowSizeInPixels.Width  = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width;
                windowSizeInPixels.Height = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height;
            }

            xnaDeviceManager.IsFullScreen = isFullscreen;

            if (CCDrawManager.SharedDrawManager == null)
            {
                CCDrawManager.SharedDrawManager = new CCDrawManager(xnaDeviceManager, windowSizeInPixels, supportedOrientations);
            }
        }
Example #13
0
		public CCViewport(
			CCRect exactFitLandscapeRatioIn, 
			CCViewportResolutionPolicy resolutionPolicyIn=CCViewportResolutionPolicy.ExactFit, 
			CCDisplayOrientation displayOrientationIn=CCDisplayOrientation.LandscapeLeft)
			: this (exactFitLandscapeRatioIn, exactFitLandscapeRatioIn, resolutionPolicyIn, displayOrientationIn)
		{	}
Example #14
0
        public CCViewport(
			CCRect exactFitLandscapeRatioIn, CCRect exactFitPortraitRatioIn, 
            CCViewportResolutionPolicy resolutionPolicyIn=CCViewportResolutionPolicy.ExactFit, 
            CCDisplayOrientation displayOrientationIn=CCDisplayOrientation.LandscapeLeft)
        {
            if(exactFitPortraitRatioIn == default(CCRect))
            {
                exactFitPortraitRatioIn = exactFitLandscapeRatioIn;
            }

            resolutionPolicy = resolutionPolicyIn;
            displayOrientation = displayOrientationIn;
            exactFitLandscapeRatio = exactFitLandscapeRatioIn;
            exactFitPortraitRatio = exactFitPortraitRatioIn;
        }
Example #15
0
        public CCViewport(
            CCRect exactFitLandscapeRatioIn, CCRect exactFitPortraitRatioIn, 
            CCDisplayOrientation displayOrientationIn=CCDisplayOrientation.LandscapeLeft)
        {
            if(exactFitPortraitRatioIn == default(CCRect))
            {
                exactFitPortraitRatioIn = exactFitLandscapeRatioIn;
            }

            displayOrientation = displayOrientationIn;
            exactFitLandscapeRatio = exactFitLandscapeRatioIn;
            exactFitPortraitRatio = exactFitPortraitRatioIn;
        }
Example #16
0
 public CCViewport(
     CCRect exactFitLandscapeRatioIn,
     CCDisplayOrientation displayOrientationIn = CCDisplayOrientation.LandscapeLeft)
     : this(exactFitLandscapeRatioIn, exactFitLandscapeRatioIn, displayOrientationIn)
 {
 }
Example #17
0
 public CCViewport(
     CCRect exactFitLandscapeRatioIn, 
     CCDisplayOrientation displayOrientationIn=CCDisplayOrientation.LandscapeLeft)
     : this (exactFitLandscapeRatioIn, exactFitLandscapeRatioIn, displayOrientationIn)
 {   }
Example #18
0
		void InitializeMainWindow(CCSize windowSizeInPixels, bool isFullscreen = false,
			CCDisplayOrientation supportedOrientations = CCDisplayOrientation.Default)
		{
			if (isFullscreen)
			{
				windowSizeInPixels.Width = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width;
				windowSizeInPixels.Height = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height;
			}

			xnaDeviceManager.IsFullScreen = isFullscreen;

			if (CCDrawManager.SharedDrawManager == null)
			{
				CCDrawManager.SharedDrawManager = new CCDrawManager(xnaDeviceManager, windowSizeInPixels, supportedOrientations);
			}

		}
Example #19
0
		CCApplication(CCGame game, bool isFullScreen = true, CCSize? mainWindowSizeInPixels = null,
			CCDisplayOrientation supportedOrientations = CCDisplayOrientation.Default)
			: base(game)
		{
			GameTime = new CCGameTime();
			xnaGame = game;

			Scheduler = new CCScheduler();
			ActionManager = new CCActionManager();
			Scheduler.Schedule(ActionManager, CCSchedulePriority.System, false);

			priorGamePadState = new Dictionary<PlayerIndex, GamePadState>();
			gamePadConnection = new CCEventGamePadConnection();
			gamePadButton = new CCEventGamePadButton();
			gamePadDPad = new CCEventGamePadDPad();
			gamePadStick = new CCEventGamePadStick();
			gamePadTrigger = new CCEventGamePadTrigger();

			IGraphicsDeviceService service = (IGraphicsDeviceService)Game.Services.GetService(typeof(IGraphicsDeviceService));

			if (service == null)
			{
				service = new GraphicsDeviceManager(game);

				// if we still do not have a service after creating the GraphicsDeviceManager
				// we need to stop somewhere and issue a warning.
				if (Game.Services.GetService(typeof(IGraphicsDeviceService)) == null)
				{
					Game.Services.AddService(typeof(IGraphicsDeviceService), service);
				}
			}

			xnaDeviceManager = (GraphicsDeviceManager)service;

			Content = game.Content;
			HandleMediaStateAutomatically = true;

			game.IsFixedTimeStep = true;

			TouchPanel.EnabledGestures = GestureType.Tap;

			game.Activated += GameActivated;
			game.Deactivated += GameDeactivated;
			game.Exiting += GameExiting;
			game.Window.OrientationChanged += OrientationChanged;

			game.Components.Add(this);

			gameWindows = new List<CCWindow>();

			InitializeMainWindow((mainWindowSizeInPixels.HasValue) ? mainWindowSizeInPixels.Value : CCSize.Zero,
				isFullScreen, supportedOrientations);
		}
Example #20
0
 internal CCViewport(
     CCRect exactFitLandscapeRatioIn,
     CCDisplayOrientation supportedDisplayOrientationIn,
     CCDisplayOrientation currentDisplayOrientationIn)
     : this(exactFitLandscapeRatioIn, currentDisplayOrientationIn)
 {
 }
Example #21
0
        public static bool IsLandscape(this CCDisplayOrientation orientation)
        {
            orientation = orientation & (CCDisplayOrientation.LandscapeLeft | CCDisplayOrientation.LandscapeRight);

            return(orientation != CCDisplayOrientation.Default);
        }
Example #22
0
		void InitializeMainWindow(CCSize windowSizeInPixels, bool isFullscreen = false,
			CCDisplayOrientation supportedOrientations = CCDisplayOrientation.Default)
		{
			if (isFullscreen)
			{
#if NETFX_CORE
                //  GraphicsAdapter values are not set correctly when it gets to here so we used the
                //  DeviceManager values.
                //if (xnaDeviceManager.GraphicsDevice.DisplayMode.)
                if (xnaGame.Window.CurrentOrientation == DisplayOrientation.Portrait
                    || xnaGame.Window.CurrentOrientation == DisplayOrientation.PortraitDown)
                {
                    windowSizeInPixels.Width = xnaDeviceManager.PreferredBackBufferHeight;
                    windowSizeInPixels.Height = xnaDeviceManager.PreferredBackBufferWidth;
                }
                else
                {
                    windowSizeInPixels.Width = xnaDeviceManager.PreferredBackBufferWidth;
                    windowSizeInPixels.Height = xnaDeviceManager.PreferredBackBufferHeight;

                }
#else
                windowSizeInPixels.Width = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width;
                windowSizeInPixels.Height = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height;
#endif
			}

			xnaDeviceManager.IsFullScreen = isFullscreen;

			if (CCDrawManager.SharedDrawManager == null)
			{
				CCDrawManager.SharedDrawManager = new CCDrawManager(xnaDeviceManager, windowSizeInPixels, supportedOrientations);
			}

		}