示例#1
0
        private void PlatformInitialize()
        {
            _viewport = new Viewport(0, 0, PresentationParameters.BackBufferWidth, PresentationParameters.BackBufferHeight);

            // Ensure the vertex attributes are reset
            _enabledVertexAttributes.Clear();

            // Free all the cached shader programs.
            _programCache.Clear();
            _shaderProgram = null;

            if (GraphicsCapabilities.SupportsFramebufferObjectARB)
            {
                this.framebufferHelper = new FramebufferHelper(this);
            }
            #if !(GLES || MONOMAC)
            else if (GraphicsCapabilities.SupportsFramebufferObjectEXT)
            {
                this.framebufferHelper = new FramebufferHelperEXT(this);
            }
            #endif
            else
            {
                throw new PlatformNotSupportedException(
                          "MonoGame requires either ARB_framebuffer_object or EXT_framebuffer_object." +
                          "Try updating your graphics drivers.");
            }

            // Force reseting states
            this.BlendState.PlatformApplyState(this, true);
            this.DepthStencilState.PlatformApplyState(this, true);
            this.RasterizerState.PlatformApplyState(this, true);
        }
示例#2
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 (presentationParameters == null)
            {
                throw new ArgumentNullException("presentationParameters");
            }

            // Set the properties from the constructor parameters.
            Adapter = adapter;
            PresentationParameters = presentationParameters;
            GraphicsProfile        = graphicsProfile;

            // Set up the OpenGL Device. Loads entry points.
            GLDevice = new OpenGLDevice(PresentationParameters);

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

            // Initialize the Texture/Sampler state containers
            Textures      = new TextureCollection(this);
            SamplerStates = new SamplerStateCollection(this);

            // Clear constant buffers
            vertexConstantBuffers.Clear();
            pixelConstantBuffers.Clear();

            // First draw will need to set the shaders.
            vertexShaderDirty = true;
            pixelShaderDirty  = true;

            // Set the default viewport and scissor rect.
            Viewport         = new Viewport(PresentationParameters.Bounds);
            ScissorRectangle = Viewport.Bounds;

            // Free all the cached shader programs.
            programCache.Clear();
            shaderProgram = null;
        }
示例#3
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 (presentationParameters == null)
            {
                throw new ArgumentNullException("presentationParameters");
            }

            // Set the properties from the constructor parameters.
            Adapter = adapter;
            PresentationParameters = presentationParameters;
            GraphicsProfile        = graphicsProfile;

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

            // Initialize the Texture/Sampler state containers
            Textures      = new TextureCollection(OpenGLDevice.Instance.MaxTextureSlots);
            SamplerStates = new SamplerStateCollection(OpenGLDevice.Instance.MaxTextureSlots);
            Textures.Clear();
            SamplerStates.Clear();

            // Clear constant buffers
            vertexConstantBuffers.Clear();
            pixelConstantBuffers.Clear();

            // Force set the buffers and shaders on next ApplyState() call
            vertexBufferBindings = new VertexBufferBinding[OpenGLDevice.Instance.MaxVertexAttributes];

            // First draw will need to set the shaders.
            vertexShaderDirty = true;
            pixelShaderDirty  = true;

            // Set the default scissor rect.
            ScissorRectangle = Viewport.Bounds;

            // Free all the cached shader programs.
            programCache.Clear();
            shaderProgram = null;
        }
示例#4
0
        private void PlatformInitialize()
        {
            _viewport = new Viewport(0, 0, PresentationParameters.BackBufferWidth, PresentationParameters.BackBufferHeight);

            // Ensure the vertex attributes are reset
            _enabledVertexAttributes.Clear();

            // Free all the cached shader programs.
            _programCache.Clear();
            _shaderProgram = null;

            framebufferHelper = FramebufferHelper.Create(this);

            // Force resetting states
            this.PlatformApplyBlend(true);
            this.DepthStencilState.PlatformApplyState(this, true);
            this.RasterizerState.PlatformApplyState(this, true);

            // TODO: Add support for multiple vertex buffers (SetVertexBuffers).
            _maxVertexBufferSlots = 1;
        }
        private void PlatformInitialize()
        {
            _viewport = new Viewport(0, 0, PresentationParameters.BackBufferWidth, PresentationParameters.BackBufferHeight);

            // Ensure the vertex attributes are reset
            _enabledVertexAttributes.Clear();

            // Free all the cached shader programs.
            _programCache.Clear();
            _shaderProgram = null;

            framebufferHelper = FramebufferHelper.Create(this);

            // Force resetting states
            this.PlatformApplyBlend(true);
            this.DepthStencilState.PlatformApplyState(this, true);
            this.RasterizerState.PlatformApplyState(this, true);

            _bufferBindingInfos = new BufferBindingInfo[_maxVertexBufferSlots];
            for (int i = 0; i < _bufferBindingInfos.Length; i++)
            {
                _bufferBindingInfos[i] = new BufferBindingInfo(null, 0, 0, -1);
            }
        }