Exemplo n.º 1
0
 /// <summary>Sets the logical OR of the flag that represents whether or not each graphics feature is enabled</summary>
 /// <param name="mode">Logical OR of the flag that represents whether or not each graphics feature is enabled</param>
 public void SetEnableMode(EnableMode mode)
 {
     if ((mode & ~(EnableMode.ScissorTest | EnableMode.CullFace | EnableMode.Blend | EnableMode.DepthTest | EnableMode.PolygonOffsetFill | EnableMode.StencilTest | EnableMode.Dither)) != EnableMode.None)
     {
         throw new ArgumentException();
     }
     if (this.state.Enable != mode)
     {
         this.state.Enable             = mode;
         GraphicsContext.notifyUpdate |= GraphicsUpdate.Enable;
     }
 }
Exemplo n.º 2
0
        public void SwapBuffers()
        {
            if (this.virtualScreen != null)
            {
                this.virtualScreen.Present(this, this.deviceScreen);
            }
            int errorCode = PsmGraphicsContext.SwapBuffers(this.handle);

            if (errorCode != 0)
            {
                Error.ThrowNativeException(errorCode);
            }
            GraphicsContext.notifyUpdate |= GraphicsUpdate.Viewport;
        }
Exemplo n.º 3
0
        /// <summary>Enables or disables the specified graphics feature</summary>
        /// <param name="mode">Graphics feature to enable or disable</param>
        /// <param name="status">Specify true to enable</param>
        public void Enable(EnableMode mode, bool status)
        {
            EnableMode enableMode = this.state.Enable;

            if ((mode & ~(EnableMode.ScissorTest | EnableMode.CullFace | EnableMode.Blend | EnableMode.DepthTest | EnableMode.PolygonOffsetFill | EnableMode.StencilTest | EnableMode.Dither)) != EnableMode.None)
            {
                throw new ArgumentException();
            }
            enableMode = (status ? (enableMode | mode) : (enableMode & ~mode));
            if (this.state.Enable != enableMode)
            {
                this.state.Enable             = enableMode;
                GraphicsContext.notifyUpdate |= GraphicsUpdate.Enable;
            }
        }
Exemplo n.º 4
0
 private void CheckUpdate()
 {
     if (this.shaderProgram != null)
     {
         this.shaderProgram.UpdateShader();
     }
     if (GraphicsContext.notifyUpdate != GraphicsUpdate.None)
     {
         if ((GraphicsContext.notifyUpdate & GraphicsUpdate.ShaderProgram) != GraphicsUpdate.None)
         {
             this.handles[0] = ((this.shaderProgram == null) ? 0 : this.shaderProgram.handle);
         }
         PsmGraphicsContext.Update(this.handle, GraphicsContext.notifyUpdate, ref this.state, this.handles);
         GraphicsContext.notifyUpdate = GraphicsUpdate.None;
     }
 }
Exemplo n.º 5
0
        public GraphicsContext(int width, int height, PixelFormat colorFormat, PixelFormat depthFormat, MultiSampleMode multiSampleMode)
        {
            int errorCode = PsmGraphicsContext.Create(width, height, colorFormat, depthFormat, multiSampleMode, out this.handle);

            if (errorCode != 0)
            {
                Error.ThrowNativeException(errorCode);
            }
            this.caps   = new GraphicsCaps(this);
            this.screen = (this.deviceScreen = new FrameBuffer(this));
            if (ScreenBuffer.NeedVirtualScreen(this.screen, ref width, ref height))
            {
                this.screen = (this.virtualScreen = new ScreenBuffer(this, this.deviceScreen, width, height, colorFormat, depthFormat, multiSampleMode));
                GraphicsContext.notifyUpdate |= (GraphicsUpdate)6U;
            }
            this.SetFrameBuffer(null);
            this.state.Reset(this.screen);
            GraphicsContext.notifyUpdate |= GraphicsUpdate.Viewport;
        }
Exemplo n.º 6
0
 /// <summary>Sets back-face culling</summary>
 /// <param name="face">Structure representing back-face culling</param>
 public void SetCullFace(CullFace face)
 {
     this.state.CullFace           = face;
     GraphicsContext.notifyUpdate |= GraphicsUpdate.CullFace;
 }
Exemplo n.º 7
0
 /// <summary>Sets the stencil value to be used for clearing the frame buffer</summary>
 /// <param name="stencil">Stencil value (0-255)</param>
 public void SetClearStencil(int stencil)
 {
     this.state.ClearStencil       = (int)((byte)stencil);
     GraphicsContext.notifyUpdate |= GraphicsUpdate.ClearStencil;
 }
Exemplo n.º 8
0
 /// <summary>Sets a shader program</summary>
 /// <param name="program">Shader program (release when NULL)</param>
 public void SetShaderProgram(ShaderProgram program)
 {
     this.shaderProgram            = program;
     GraphicsContext.notifyUpdate |= GraphicsUpdate.ShaderProgram;
 }
Exemplo n.º 9
0
 /// <summary>Sets the line width</summary>
 /// <param name="width">Line width</param>
 public void SetLineWidth(float width)
 {
     this.state.LineWidth          = width;
     GraphicsContext.notifyUpdate |= GraphicsUpdate.LineWidth;
 }
Exemplo n.º 10
0
 /// <summary>Sets the stencil test operation (for the back surface)</summary>
 /// <param name="op">Structure representing the stencil test operation</param>
 public void SetStencilOpBack(StencilOp op)
 {
     this.state.StencilOpBack      = op;
     GraphicsContext.notifyUpdate |= GraphicsUpdate.StencilOp;
 }
Exemplo n.º 11
0
 /// <summary>Sets the polygon offset</summary>
 /// <param name="offset">Structure representing the polygon offset</param>
 public void SetPolygonOffset(PolygonOffset offset)
 {
     this.state.PolygonOffset      = offset;
     GraphicsContext.notifyUpdate |= GraphicsUpdate.PolygonOffset;
 }
Exemplo n.º 12
0
 /// <summary>Sets the frame buffer</summary>
 /// <param name="buffer">Frame buffer (release when NULL)</param>
 public void SetFrameBuffer(FrameBuffer buffer)
 {
     this.frameBuffer              = ((buffer != null) ? buffer : this.screen);
     this.handles[1]               = this.frameBuffer.handle;
     GraphicsContext.notifyUpdate |= GraphicsUpdate.FrameBuffer;
 }
Exemplo n.º 13
0
 /// <summary>Sets the texture</summary>
 /// <param name="index">Texture number (0-7)</param>
 /// <param name="texture">Texture (release when NULL)</param>
 public void SetTexture(int index, Texture texture)
 {
     this.textures[index]          = texture;
     this.handles[8 + index]       = ((texture == null) ? 0 : texture.handle);
     GraphicsContext.notifyUpdate |= ((index == 0) ? GraphicsUpdate.Texture0 : ((GraphicsUpdate)2147483648U));
 }
Exemplo n.º 14
0
 /// <summary>Sets the vertex buffer</summary>
 /// <param name="index">Vertex buffer number (0-3)</param>
 /// <param name="buffer">Vertex buffer (release when NULL)</param>
 public void SetVertexBuffer(int index, VertexBuffer buffer)
 {
     this.vertexBuffers[index]     = buffer;
     this.handles[4 + index]       = ((buffer == null) ? 0 : buffer.handle);
     GraphicsContext.notifyUpdate |= ((index == 0) ? GraphicsUpdate.VertexBuffer0 : GraphicsUpdate.VertexBufferN);
 }
Exemplo n.º 15
0
 /// <summary>Sets the alpha-blending function (for the alpha channel)</summary>
 /// <param name="func">Structure representing the alpha-blending function</param>
 public void SetBlendFuncAlpha(BlendFunc func)
 {
     this.state.BlendFuncAlpha     = func;
     GraphicsContext.notifyUpdate |= GraphicsUpdate.BlendFunc;
 }
Exemplo n.º 16
0
 /// <summary>Sets the depth test function</summary>
 /// <param name="func">Structure representing the depth test function</param>
 public void SetDepthFunc(DepthFunc func)
 {
     this.state.DepthFunc          = func;
     GraphicsContext.notifyUpdate |= GraphicsUpdate.DepthFunc;
 }
Exemplo n.º 17
0
 /// <summary>Sets the rectangle for the scissor test</summary>
 /// <param name="rectangle">Rectangle for the scissor test</param>
 public void SetScissor(ImageRect rectangle)
 {
     this.state.Scissor            = rectangle;
     GraphicsContext.notifyUpdate |= GraphicsUpdate.Scissor;
 }
Exemplo n.º 18
0
 /// <summary>Sets the stencil test function (for the back surface)</summary>
 /// <param name="func">Structure representing the stencil test function</param>
 public void SetStencilFuncBack(StencilFunc func)
 {
     this.state.StencilFuncBack    = func;
     GraphicsContext.notifyUpdate |= GraphicsUpdate.StencilFunc;
 }
Exemplo n.º 19
0
 /// <summary>Sets the rectangle of the viewport</summary>
 /// <param name="rectangle">Viewport rectangle</param>
 public void SetViewport(ImageRect rectangle)
 {
     this.state.Viewport           = rectangle;
     GraphicsContext.notifyUpdate |= GraphicsUpdate.Viewport;
 }
Exemplo n.º 20
0
 /// <summary>Sets the color write mask</summary>
 /// <param name="mask">Color write mask</param>
 public void SetColorMask(ColorMask mask)
 {
     this.state.ColorMask          = mask;
     GraphicsContext.notifyUpdate |= GraphicsUpdate.ColorMask;
 }
Exemplo n.º 21
0
 /// <summary>Sets the range for the depth value</summary>
 /// <param name="range">Depth value range</param>
 public void SetDepthRange(Vector2 range)
 {
     this.state.DepthRange         = range;
     GraphicsContext.notifyUpdate |= GraphicsUpdate.DepthRange;
 }
Exemplo n.º 22
0
 internal static void NotifyUpdate(GraphicsUpdate update)
 {
     GraphicsContext.notifyUpdate |= update;
 }
Exemplo n.º 23
0
 /// <summary>Sets the color to be used for clearing the frame buffer</summary>
 /// <param name="color">Color</param>
 public void SetClearColor(Vector4 color)
 {
     this.state.ClearColor         = color;
     GraphicsContext.notifyUpdate |= GraphicsUpdate.ClearColor;
 }
Exemplo n.º 24
0
 public static extern int Update(int handle, GraphicsUpdate update, ref GraphicsState state, int[] handles);
Exemplo n.º 25
0
 /// <summary>Sets the depth value to be used for clearing the frame buffer</summary>
 /// <param name="depth">Depth value (0.0f-1.0f)</param>
 public void SetClearDepth(float depth)
 {
     this.state.ClearDepth         = depth;
     GraphicsContext.notifyUpdate |= GraphicsUpdate.ClearDepth;
 }