/// <summary>
        /// Gets a reference to the singleton instance.
        /// </summary>
        public static GraphicsDeviceService AddRef(IntPtr windowHandle,
                                                   int width, int height)
        {
            // Increment the "how many controls sharing the device" reference count.
            if (Interlocked.Increment(ref referenceCount) == 1)
            {
                // If this is the first control to start using the
                // device, we must create the singleton instance.
                singletonInstance = new GraphicsDeviceService(windowHandle,
                                                              width, height);
            }

            return(singletonInstance);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Initializes the control.
        /// </summary>
        protected override void OnCreateControl()
        {
            // Don't initialize the graphics device if we are running in the designer.
            if (!DesignMode)
            {
                graphicsDeviceService = GraphicsDeviceService.AddRef(Handle,
                                                                     ClientSize.Width,
                                                                     ClientSize.Height);

                // Register the service, so components like ContentManager can find it.
                services.AddService <IGraphicsDeviceService>(graphicsDeviceService);

                // Give derived classes a chance to initialize themselves.
                Initialize();
            }

            base.OnCreateControl();
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Constructs the main form.
        /// </summary>
        public Line2dDemoForm()
        {
            InitializeComponent();

            // Don't initialize the graphics device if we are running in the designer.
            if (!DesignMode)
            {
                graphicsDeviceService = GraphicsDeviceService.AddRef(Handle,
                                                                     ClientSize.Width,
                                                                     ClientSize.Height);

                // Register the service, so components like ContentManager can find it.
                services.AddService <IGraphicsDeviceService>(graphicsDeviceService);
            }

            ProjectNameNode = projectContentTV.Nodes["ProjectNameNode"];
            /// Automatically bring up the "Load Model" dialog when we are first shown.
            //this.Shown += OpenMenuClicked;
        }
Ejemplo n.º 4
0
        public void Initialize(IntPtr handle, int width, int height)
        {
            graphicsDeviceService = GraphicsDeviceService.AddRef(handle,
                                                                 width,
                                                                 height);

            // Register the service, so components like ContentManager can find it.
            services.AddService <IGraphicsDeviceService>(graphicsDeviceService);

            contentBuilder = new ContentBuilder(ProjectContentFolder, false);

            contentManager = new ContentManager(this.Services,
                                                contentBuilder.OutputDirectory);

            modelManager = new XnaModelManager(contentBuilder, contentManager, OriginalContentFolder);

            texture2dManager = new XnaTexture2dManager(contentBuilder, contentManager, OriginalContentFolder);

            fontManager = new XnaFontManager(contentBuilder, contentManager, OriginalContentFolder);

            effectManager = new XnaEffectManager(contentBuilder, contentManager, OriginalContentFolder);

            spriterManager = new XnaSpriterManager(contentBuilder, contentManager, OriginalContentFolder);

            RefreshLists();

            FyriEffect roundlineEffect = effectManager.GetEffect("RoundLine");
            FyriFont   roundlineFont   = fontManager.GetFont("SpriteFont");

            roundLineManager = new RoundLineManager();
            roundLineManager.Init(this.graphicsDeviceService.GraphicsDevice, roundlineEffect.Effect);

            lineBatch = new XnaLine2dBatch();
            lineBatch.Init(this.graphicsDeviceService.GraphicsDevice, roundlineEffect.Effect);

            drawingContext = new XnaDrawingContext(this.graphicsDeviceService.GraphicsDevice);

            IsInitialized = true;
        }