예제 #1
0
        internal void Initialize()
        {
            GraphicsCapabilities.Initialize(this);

            PlatformInitialize();

            // Force set the default render states.
            _blendStateDirty  = _depthStencilStateDirty = _rasterizerStateDirty = true;
            BlendState        = BlendState.Opaque;
            DepthStencilState = DepthStencilState.Default;
            RasterizerState   = RasterizerState.CullCounterClockwise;

            // Clear the texture and sampler collections forcing
            // the state to be reapplied.
            Textures.Clear();
            SamplerStates.Clear();

            // Clear constant buffers
            _vertexConstantBuffers.Clear();
            _pixelConstantBuffers.Clear();

            // Force set the buffers and shaders on next ApplyState() call
            _indexBufferDirty  = true;
            _vertexBufferDirty = true;
            _vertexShaderDirty = true;
            _pixelShaderDirty  = true;

            // Set the default scissor rect.
            _scissorRectangleDirty = true;
            ScissorRectangle       = _viewport.Bounds;

            // Set the default render target.
            ApplyRenderTargets(null);
        }
예제 #2
0
 internal GraphicsDevice()
 {
     PresentationParameters = new PresentationParameters();
     PresentationParameters.DepthStencilFormat = DepthFormat.Depth24;
     Setup();
     GraphicsCapabilities = new GraphicsCapabilities(this);
     Initialize();
 }
예제 #3
0
 internal GraphicsDevice(GraphicsDeviceInformation gdi)
 {
     if (gdi.PresentationParameters == null)
     {
         throw new ArgumentNullException("presentationParameters");
     }
     PresentationParameters = gdi.PresentationParameters;
     Setup();
     GraphicsCapabilities = new GraphicsCapabilities(this);
     GraphicsProfile      = gdi.GraphicsProfile;
     Initialize();
 }
예제 #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GraphicsDevice" /> class.
 /// </summary>
 /// <param name="adapter">The graphics adapter.</param>
 /// <param name="graphicsProfile">The graphics profile.</param>
 /// <param name="presentationParameters">The presentation options.</param>
 /// <exception cref="ArgumentNullException">
 /// <paramref name="presentationParameters"/> is <see langword="null"/>.
 /// </exception>
 public GraphicsDevice(GraphicsAdapter adapter, GraphicsProfile graphicsProfile, PresentationParameters presentationParameters)
 {
     Adapter = adapter;
     if (presentationParameters == null)
     {
         throw new ArgumentNullException("presentationParameters");
     }
     PresentationParameters = presentationParameters;
     Setup();
     GraphicsCapabilities = new GraphicsCapabilities(this);
     GraphicsProfile      = graphicsProfile;
     Initialize();
 }
예제 #5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GraphicsDevice" /> class.
        /// </summary>
        /// <param name="adapter">The graphics adapter.</param>
        /// <param name="graphicsProfile">The graphics profile.</param>
        /// <param name="presentationParameters">The presentation options.</param>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="presentationParameters"/> is <see langword="null"/>.
        /// </exception>
        public GraphicsDevice(GraphicsAdapter adapter, GraphicsProfile graphicsProfile, PresentationParameters presentationParameters, IntPtr hnw)
        {
            windowsHandle    = hnw;
            windowsHandleSet = true;

            Adapter = adapter;
            if (presentationParameters == null)
            {
                throw new ArgumentNullException("presentationParameters");
            }
            PresentationParameters = presentationParameters;
            Setup();
            GraphicsCapabilities = new GraphicsCapabilities(this);
            GraphicsProfile      = graphicsProfile;
            Initialize();
        }
예제 #6
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GraphicsDevice" /> class.
        /// </summary>
        /// <param name="adapter">The graphics adapter.</param>
        /// <param name="graphicsProfile">The graphics profile.</param>
        /// <param name="presentationParameters">The presentation options.</param>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="presentationParameters"/> is <see langword="null"/>.
        /// </exception>
        public GraphicsDevice(GraphicsAdapter adapter, GraphicsProfile graphicsProfile, PresentationParameters presentationParameters)
        {
            if (adapter == null)
            {
                throw new ArgumentNullException("adapter");
            }
            if (!adapter.IsProfileSupported(graphicsProfile))
            {
                throw new NoSuitableGraphicsDeviceException(String.Format("Adapter '{0}' does not support the {1} profile.", adapter.Description, graphicsProfile));
            }
            if (presentationParameters == null)
            {
                throw new ArgumentNullException("presentationParameters");
            }
            Adapter = adapter;
            PresentationParameters = presentationParameters;
            _graphicsProfile       = graphicsProfile;
            Setup();
            GraphicsCapabilities = new GraphicsCapabilities();
            GraphicsCapabilities.Initialize(this);

            Initialize();
        }
예제 #7
0
 internal void Initialize()
 {
     GraphicsCapabilities.Initialize(this);
     this._viewport         = new Viewport(0, 0, this.PresentationParameters.BackBufferWidth, this.PresentationParameters.BackBufferHeight);
     this._blendStateDirty  = this._depthStencilStateDirty = this._rasterizerStateDirty = true;
     this.BlendState        = BlendState.Opaque;
     this.DepthStencilState = DepthStencilState.Default;
     this.RasterizerState   = RasterizerState.CullCounterClockwise;
     this.Textures.Clear();
     this.SamplerStates.Clear();
     this._vertexConstantBuffers.Clear();
     this._pixelConstantBuffers.Clear();
     GraphicsDevice._enabledVertexAttributes.Clear();
     this._indexBufferDirty      = true;
     this._vertexBufferDirty     = true;
     this._vertexShaderDirty     = true;
     this._pixelShaderDirty      = true;
     this._scissorRectangleDirty = true;
     this.ScissorRectangle       = this._viewport.Bounds;
     this.ApplyRenderTargets((RenderTargetBinding[])null);
     this._programCache.Clear();
     this._shaderProgram = -1;
 }