コード例 #1
0
        private static uint ToOpenTKBufferType(GraphicsBufferType value)
        {
            switch (value)
            {
            case GraphicsBufferType.Vertex: return(WebGLRenderingContextBase.ARRAY_BUFFER);

            case GraphicsBufferType.Index: return(WebGLRenderingContextBase.ELEMENT_ARRAY_BUFFER);
            }

            return(WebGLRenderingContextBase.ARRAY_BUFFER);
        }
コード例 #2
0
ファイル: NativeGraphicsBuffer.cs プロジェクト: pyneer/case
        private static BufferTarget ToOpenTKBufferType(GraphicsBufferType value)
        {
            switch (value)
            {
            case GraphicsBufferType.Vertex: return(BufferTarget.ArrayBuffer);

            case GraphicsBufferType.Index: return(BufferTarget.ElementArrayBuffer);
            }

            return(BufferTarget.ArrayBuffer);
        }
コード例 #3
0
ファイル: NativeGraphicsBuffer.cs プロジェクト: pyneer/case
        public static void Bind(GraphicsBufferType type, NativeGraphicsBuffer buffer)
        {
            if (GetBound(type) == buffer)
            {
                return;
            }
            SetBound(type, buffer);

            BufferTarget target = ToOpenTKBufferType(type);

            GL.BindBuffer(target, buffer != null ? buffer.Handle : 0);
        }
コード例 #4
0
ファイル: NativeGraphicsBuffer.cs プロジェクト: pyneer/case
 private static NativeGraphicsBuffer GetBound(GraphicsBufferType type)
 {
     if (type == GraphicsBufferType.Vertex)
     {
         return(boundVertex);
     }
     else if (type == GraphicsBufferType.Index)
     {
         return(boundIndex);
     }
     else
     {
         return(null);
     }
 }
コード例 #5
0
ファイル: NativeGraphicsBuffer.cs プロジェクト: pyneer/case
 private static void SetBound(GraphicsBufferType type, NativeGraphicsBuffer buffer)
 {
     if (type == GraphicsBufferType.Vertex)
     {
         boundVertex = buffer;
     }
     else if (type == GraphicsBufferType.Index)
     {
         boundIndex = buffer;
     }
     else
     {
         return;
     }
 }
コード例 #6
0
        private static ClearBufferMask GetClearFlags(GraphicsBufferType bufferMask)
        {
            ClearBufferMask clearFlags = 0;

            if ((bufferMask & GraphicsBufferType.Color) != 0)
            {
                clearFlags |= ClearBufferMask.ColorBufferBit;
            }
            if ((bufferMask & GraphicsBufferType.Depth) != 0)
            {
                clearFlags |= ClearBufferMask.DepthBufferBit;
            }
            if ((bufferMask & GraphicsBufferType.Stencil) != 0)
            {
                clearFlags |= ClearBufferMask.StencilBufferBit;
            }

            return(clearFlags);
        }
コード例 #7
0
        /// <summary>
        /// Clear surface buffers.
        /// </summary>
        /// <param name="ctx">
        /// A <see cref="GraphicsContext"/> used for clearing buffers.
        /// </param>
        /// <param name="bufferMask">
        /// A <see cref="GraphicsBuffersFormat.GraphicsBufferType"/> indicating which buffers to clear.
        /// </param>
        public void Clear(GraphicsContext ctx, GraphicsBufferType bufferMask)
        {
            // Update clear values (only what is necessary)
            if ((bufferMask & GraphicsBufferType.Color) != 0)
            {
                Gl.ClearColor(mClearColor.Red, mClearColor.Green, mClearColor.Blue, mClearColor.Alpha);
            }
            if ((bufferMask & GraphicsBufferType.Depth) != 0)
            {
                Gl.ClearDepth(mClearDepth);
            }
            if ((bufferMask & GraphicsBufferType.Stencil) != 0)
            {
                Gl.ClearStencil(mClearStencil);
            }

            // Clear
            Gl.Clear(GetClearFlags(bufferMask));
        }
コード例 #8
0
ファイル: NativeGraphicsBuffer.cs プロジェクト: pyneer/case
 public NativeGraphicsBuffer(GraphicsBufferType type)
 {
     this.handle = GL.GenBuffer();
     this.type   = type;
 }
コード例 #9
0
ファイル: GraphicsBackend.cs プロジェクト: ozgun-kara/jazz2
 INativeGraphicsBuffer IGraphicsBackend.CreateBuffer(GraphicsBufferType type)
 {
     return(new NativeGraphicsBuffer(type));
 }
コード例 #10
0
 public NativeGraphicsBuffer(GraphicsBufferType type)
 {
     this.handle = GraphicsBackend.GL.CreateBuffer();
     this.type   = type;
 }
コード例 #11
0
 public DummyNativeGraphicsBuffer(GraphicsBufferType type)
 {
     this.type = type;
 }
コード例 #12
0
ファイル: GraphicsBuffer.cs プロジェクト: zcyemi/RigelSharp
 public GraphicsBuffer(GraphicsBufferType bufferType = GraphicsBufferType.Default)
 {
     this.bufferType = bufferType;
 }
コード例 #13
0
 public NativeGraphicsBuffer(GraphicsBufferType type)
 {
     GL.GenBuffers(1, out this.handle);
     this.type = type;
 }
コード例 #14
0
        /// <summary>
        /// Confirm pixel format assigned to this surface. XXX
        /// </summary>
        /// <param name="pixelFormat">
        /// A <see cref="DevicePixelFormat"/> defining the available surface buffers
        /// and their definitions.
        /// </param>
        /// <remarks>
        /// This routine shall be called after a successfull call to SetPixelFormat.
        /// </remarks>
        public void SetBufferConfiguration(DevicePixelFormat pixelFormat)
        {
            _SurfaceBuffers = 0;

            if (pixelFormat.ColorBits > 0)
            {
                if (pixelFormat.SRGBCapable == false)
                {
                    _SurfaceBuffers |= GraphicsBufferType.Color;
                }
                else
                {
                    _SurfaceBuffers |= GraphicsBufferType.ColorSRGB;
                }
            }

            if (pixelFormat.DoubleBuffer)
            {
                _SurfaceBuffers |= GraphicsBufferType.Double;
            }
            if (pixelFormat.DepthBits > 0)
            {
                _SurfaceBuffers |= GraphicsBufferType.Depth;
            }
            if (pixelFormat.StencilBits > 0)
            {
                _SurfaceBuffers |= GraphicsBufferType.Stencil;
            }
            if (pixelFormat.MultisampleBits > 0)
            {
                _SurfaceBuffers |= GraphicsBufferType.Multisample;
            }

            switch (pixelFormat.ColorBits)
            {
            case 8:
                _ColorType = PixelLayout.RGB8;
                break;

            case 16:
                _ColorType = PixelLayout.RGB16;
                break;

            case 24:
                _ColorType = PixelLayout.RGB24;
                break;

            case 32:
                _ColorType = PixelLayout.RGBA32;
                break;

            default:
                throw new InvalidOperationException("invalid pixel format composed by " + pixelFormat.ColorBits + " bits");
            }

            _DepthBits = (uint)pixelFormat.DepthBits;

            _StencilBits = (uint)pixelFormat.StencilBits;

            _MultisampleBits = (uint)pixelFormat.MultisampleBits;
        }