Exemplo n.º 1
0
        internal override void Initialize(GameContext gameContext)
        {
            GameContext = gameContext;

            paradoxGameForm = (AndroidParadoxGameView)gameContext.Control;
            nativeWindow = new WindowHandle(AppContextType.Android, paradoxGameForm);

            paradoxGameForm.Load += gameForm_Resume;
            paradoxGameForm.OnPause += gameForm_OnPause;
            paradoxGameForm.Unload += gameForm_Unload;
            paradoxGameForm.RenderFrame += gameForm_RenderFrame;

            // Setup the initial size of the window
            var width = gameContext.RequestedWidth;
            if (width == 0)
            {
                width = paradoxGameForm.Width;
            }

            var height = gameContext.RequestedHeight;
            if (height == 0)
            {
                height = paradoxGameForm.Height;
            }

            // Transmit requested back buffer and depth stencil formats to OpenTK
            paradoxGameForm.RequestedBackBufferFormat = gameContext.RequestedBackBufferFormat;
            paradoxGameForm.RequestedDepthStencilFormat = PixelFormat.None;
            paradoxGameForm.RequestedGraphicsProfile = gameContext.RequestedGraphicsProfile;

            paradoxGameForm.Size = new Size(width, height);

            //paradoxGameForm.Resize += OnClientSizeChanged;
        }
Exemplo n.º 2
0
        internal override void Initialize(GameContext gameContext)
        {
            this.GameContext = gameContext;

            gameForm = (OpenTK.GameWindow)gameContext.Control;
            nativeWindow = new WindowHandle(AppContextType.DesktopOpenTK, gameForm);

            // Setup the initial size of the window
            var width = gameContext.RequestedWidth;
            if (width == 0)
            {
                width = gameForm.Width;
            }

            var height = gameContext.RequestedHeight;
            if (height == 0)
            {
                height = gameForm.Height;
            }

            gameForm.ClientSize = new System.Drawing.Size(width, height);

            gameForm.MouseEnter += GameWindowForm_MouseEnter;
            gameForm.MouseLeave += GameWindowForm_MouseLeave;

            gameForm.Resize += OnClientSizeChanged;
        }
Exemplo n.º 3
0
        internal override void Initialize(GameContext gameContext)
        {
            GameContext = gameContext;

            gameForm = gameContext.GameView;
            nativeWindow = new WindowHandle(AppContextType.iOS, gameForm);

            gameForm.Load += gameForm_Load;
            gameForm.Unload += gameForm_Unload;
            gameForm.RenderFrame += gameForm_RenderFrame;
            
            // get the OpenGL ES version
            var contextAvailable = false;
            foreach (var version in OpenGLUtils.GetGLVersions(gameContext.RequestedGraphicsProfile))
            {
                var contextRenderingApi = MajorVersionTOEAGLRenderingAPI(version);
                EAGLContext contextTest = null;
                try
                {
                    contextTest = new EAGLContext(contextRenderingApi);

                    // delete extra context
                    if (contextTest != null)
                        contextTest.Dispose();

                    gameForm.ContextRenderingApi = contextRenderingApi;
                    contextAvailable = true;
                }
                catch (Exception)
                {
                    // TODO: log message
                }
            }

            if (!contextAvailable)
                throw new Exception("Graphics context could not be created.");

            gameForm.LayerColorFormat = MonoTouch.OpenGLES.EAGLColorFormat.RGBA8;
            //gameForm.LayerRetainsBacking = false;

            // Setup the initial size of the window
            var width = gameContext.RequestedWidth;
            if (width == 0)
            {
                width = (int)(gameForm.Size.Width * gameForm.ContentScaleFactor);
            }

            var height = gameContext.RequestedHeight;
            if (height == 0)
            {
                height = (int)(gameForm.Size.Height * gameForm.ContentScaleFactor);
            }

            gameForm.Size = new Size(width, height);

            //gameForm.Resize += OnClientSizeChanged;
        }
Exemplo n.º 4
0
        internal override void Initialize(GameContext gameContext)
        {
            GameContext = gameContext;

            gameForm = gameContext.GameView;
            nativeWindow = new WindowHandle(AppContextType.iOS, gameForm);

            gameForm.Load += gameForm_Load;
            gameForm.Unload += gameForm_Unload;
            gameForm.RenderFrame += gameForm_RenderFrame;
            
            // get the OpenGL ES version
            var contextAvailable = false;
            foreach (var version in OpenGLUtils.GetGLVersions(gameContext.RequestedGraphicsProfile))
            {
                var contextRenderingApi = MajorVersionTOEAGLRenderingAPI(version);
                EAGLContext contextTest = null;
                try
                {
                    contextTest = new EAGLContext(contextRenderingApi);

                    // delete extra context
                    if (contextTest != null)
                        contextTest.Dispose();

                    gameForm.ContextRenderingApi = contextRenderingApi;
                    contextAvailable = true;
                    break;
                }
                catch (Exception)
                {
                    // TODO: log message
                }
            }

            if (!contextAvailable)
                throw new Exception("Graphics context could not be created.");

            gameForm.LayerColorFormat = EAGLColorFormat.RGBA8;
            //gameForm.LayerRetainsBacking = false;
        }
Exemplo n.º 5
0
        internal override void Initialize(GameContext gameContext)
        {
            this.GameContext = gameContext;

            Control = (Control)gameContext.Control;

            // Setup the initial size of the window
            var width = gameContext.RequestedWidth;
            if (width == 0)
            {
                width = Control is Form ? GraphicsDeviceManager.DefaultBackBufferWidth : Control.ClientSize.Width;
            }

            var height = gameContext.RequestedHeight;
            if (height == 0)
            {
                height = Control is Form ? GraphicsDeviceManager.DefaultBackBufferHeight : Control.ClientSize.Height;
            }

            windowHandle = new WindowHandle(AppContextType.Desktop, Control);

            Control.ClientSize = new System.Drawing.Size(width, height);

            Control.MouseEnter += GameWindowForm_MouseEnter;
            Control.MouseLeave += GameWindowForm_MouseLeave;

            form = Control as Form;
            var gameForm = Control as GameForm;
            if (gameForm != null)
            {
                //gameForm.AppActivated += OnActivated;
                //gameForm.AppDeactivated += OnDeactivated;
                gameForm.UserResized += OnClientSizeChanged;
            }
            else
            {
                Control.Resize += OnClientSizeChanged;
            }
        }
        internal override void Initialize(GameContext windowContext)
        {
            if (windowContext != null)
            {
                swapChainPanel = windowContext.Control as SwapChainPanel;
                if (swapChainPanel == null)
                {
                    throw new NotSupportedException(string.Format("Unsupported window context [{0}]. Only SwapChainPanel",  windowContext.Control.GetType().FullName));
                }
                windowHandle = new WindowHandle(AppContextType.WindowsRuntime, swapChainPanel);

                //clientBounds = new DrawingRectangle(0, 0, (int)swapChainPanel.ActualWidth, (int)swapChainPanel.ActualHeight);
                swapChainPanel.SizeChanged += swapChainPanel_SizeChanged;
                swapChainPanel.CompositionScaleChanged += swapChainPanel_CompositionScaleChanged;
            }
        }
Exemplo n.º 7
0
        public void Recreate(GraphicsAdapter adapter, GraphicsProfile[] profile, DeviceCreationFlags deviceCreationFlags, WindowHandle windowHandle)
        {
            if (adapter == null)
            {
                throw new ArgumentNullException("adapter");
            }
            if (profile == null)
            {
                throw new ArgumentNullException("profile");
            }

            Adapter     = adapter;
            IsDebugMode = (deviceCreationFlags & DeviceCreationFlags.Debug) != 0;

            // Initialize this instance
            InitializePlatformDevice(profile, deviceCreationFlags, windowHandle);

            InitializeFactories();

            // Create a new graphics device
            Features = new GraphicsDeviceFeatures(this);

            SamplerStates      = new SamplerStateFactory(this);
            BlendStates        = new BlendStateFactory(this);
            RasterizerStates   = new RasterizerStateFactory(this);
            DepthStencilStates = new DepthStencilStateFactory(this);

            currentState = null;
            allocatedStates.Clear();
            currentStateIndex = -1;
            PushState();

            Begin();
            ClearState();
            End();
        }
Exemplo n.º 8
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="GraphicsDevice" /> class.
        /// </summary>
        /// <param name="adapter">The graphics adapter.</param>
        /// <param name="profile">The graphics profile.</param>
        /// <param name="deviceCreationFlags">The device creation flags.</param>
        /// <param name="windowHandle">The window handle.</param>
        protected GraphicsDevice(GraphicsAdapter adapter, GraphicsProfile[] profile, DeviceCreationFlags deviceCreationFlags, WindowHandle windowHandle)
        {
            RootDevice = this;

            // Setup IsDeferred to false for the main device
            isDeferred = false;

            // Create shared data
            sharedDataPerDevice = new Dictionary <object, IDisposable>();

            Recreate(adapter, profile, deviceCreationFlags, windowHandle);

            // Helpers
            primitiveQuad = new PrimitiveQuad(this);
        }
Exemplo n.º 9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GraphicsDevice" /> class.
 /// </summary>
 /// <param name="adapter">The adapter.</param>
 /// <param name="creationFlags">The creation flags.</param>
 /// <param name="windowHandle">The window handle.</param>
 /// <param name="graphicsProfiles">The graphics profiles.</param>
 /// <returns>An instance of <see cref="GraphicsDevice" /></returns>
 public static GraphicsDevice New(GraphicsAdapter adapter, DeviceCreationFlags creationFlags = DeviceCreationFlags.None, WindowHandle windowHandle = null, params GraphicsProfile[] graphicsProfiles)
 {
     return(new GraphicsDevice(adapter ?? GraphicsAdapterFactory.Default, graphicsProfiles, creationFlags, windowHandle));
 }
        internal override void Initialize(GameContext windowContext)
        {
            if (windowContext != null)
            {
                swapChainPanel = windowContext.Control as SwapChainPanel;
                if (swapChainPanel == null)
                {
                    throw new NotSupportedException(string.Format("Unsupported window context [{0}]. Only SwapChainPanel",  windowContext.Control.GetType().FullName));
                }
                windowHandle = new WindowHandle(AppContextType.WindowsRuntime, swapChainPanel);

#if SILICONSTUDIO_PLATFORM_WINDOWS_10
                var appView = ApplicationView.GetForCurrentView();
                if (appView != null && windowContext.RequestedWidth != 0 && windowContext.RequestedHeight != 0)
                    appView.TryResizeView(new Size(windowContext.RequestedWidth, windowContext.RequestedHeight));
#endif

                //clientBounds = new DrawingRectangle(0, 0, (int)swapChainPanel.ActualWidth, (int)swapChainPanel.ActualHeight);
                swapChainPanel.SizeChanged += swapChainPanel_SizeChanged;
                swapChainPanel.CompositionScaleChanged += swapChainPanel_CompositionScaleChanged;
            }
        }