public override void Render(NkHandle Userdata, GL_Texture Texture, NkRect ClipRect, uint Offset, uint Count)
        {
            float[] vert   = new float[Count * 2];
            float[] uvs    = new float[Count * 2];
            float[] colors = new float[Count * 4];

            for (int i = 0; i < Count; i++)
            {
                NkVertex V = Verts[Inds[Offset + i]];
                vert[i * 2]     = V.Position.X;
                vert[i * 2 + 1] = V.Position.Y;

                uvs[i * 2]     = V.UV.X;
                uvs[i * 2 + 1] = V.UV.Y;

                NkColor color = V.Color;
                colors[i * 4]     = color.R;
                colors[i * 4 + 1] = color.G;
                colors[i * 4 + 2] = color.B;
                colors[i * 4 + 3] = color.A;
            }



            var vertexDataBuffer = new VertexBuffer();

            vertexDataBuffer.Create(gl);
            vertexDataBuffer.Bind(gl);


            vertexDataBuffer.SetDataV2F(gl, 0, rawData, NkVertex.SIZE * (int)Count, false, 3);

            //    vertexDataBuffer.SetData(gl, 0, vert, false, 2);

            var colourDataBuffer = new VertexBuffer();

            colourDataBuffer.Create(gl);
            colourDataBuffer.Bind(gl);
            colourDataBuffer.SetData(gl, 1, colors, false, 4);

            var uvDataBuffer = new VertexBuffer();

            uvDataBuffer.Create(gl);
            uvDataBuffer.Bind(gl);
            uvDataBuffer.SetData(gl, 2, uvs, false, 2);

            gl.ActiveTexture(OpenGL.GL_TEXTURE0);
            gl.BindTexture(OpenGL.GL_TEXTURE_2D, Texture.TextureName);
            glScissor2(window.DisplayHeight, (int)ClipRect.X, (int)ClipRect.Y, (int)ClipRect.W, (int)ClipRect.H);
            gl.DrawArrays(OpenGL.GL_TRIANGLES, 0, (int)Count);

            vertexDataBuffer.Unbind(gl);
            //  colourDataBuffer.Unbind(gl);
            //  uvDataBuffer.Unbind(gl);
        }
Esempio n. 2
0
        public override void Render(nk_handle Userdata, Texture Texture, nk_rect ClipRect, uint Offset, uint Count, NkVertex[] Verts, ushort[] Inds)
        {
            Vertex[] SfmlVerts = new Vertex[Count];

            for (int i = 0; i < Count; i++)
            {
                NkVertex V = Verts[Inds[Offset + i]];
                SfmlVerts[i] = new Vertex(new Vector2f(V.Position.X, V.Position.Y), new Color(V.Color.R, V.Color.G, V.Color.B, V.Color.A), new Vector2f(V.UV.X, V.UV.Y));
            }

            Texture.Bind(Texture);

            GayGL.glEnable(GayGL.GL_SCISSOR_TEST);
            GayGL.glScissor2((int)RWind.Size.Y, (int)ClipRect.x, (int)ClipRect.y, (int)ClipRect.w, (int)ClipRect.h);
            RWind.Draw(SfmlVerts, PrimitiveType.Triangles);
            GayGL.glDisable(GayGL.GL_SCISSOR_TEST);
        }
Esempio n. 3
0
        public override void Render(NkHandle Userdata, Texture Texture, NkRect ClipRect, uint Offset, uint Count)
        {
            Vertex[] SfmlVerts = new Vertex[Count];

            for (int i = 0; i < Count; i++)
            {
                NkVertex V = Verts[Inds[Offset + i]];
                SfmlVerts[i] = new Vertex(new Vector2f(V.Position.X, V.Position.Y), new Color(V.Color.R, V.Color.G, V.Color.B, V.Color.A), new Vector2f(V.UV.X, V.UV.Y));
            }

            Texture.Bind(Texture);

            OpenGL.glEnable(OpenGL.GL_SCISSOR_TEST);
            OpenGL.glScissor2((int)RWind.Size.Y, (int)ClipRect.X, (int)ClipRect.Y, (int)ClipRect.W, (int)ClipRect.H);

            //RWind.Draw(SfmlVerts, PrimitiveType.Triangles);
            RT.Draw(SfmlVerts, PrimitiveType.Triangles);

            OpenGL.glDisable(OpenGL.GL_SCISSOR_TEST);
        }
Esempio n. 4
0
        public override void Render(NkHandle Userdata, Texture2D Texture, NkRect ClipRect, uint Offset, uint Count)
        {
            VertexPositionColorTexture[] MonoVerts = new VertexPositionColorTexture[Count];

            for (int i = 0; i < Count; i++)
            {
                NkVertex V = _verts[_inds[Offset + i]];
                MonoVerts[i] = new VertexPositionColorTexture(new Vector3(V.Position.X, V.Position.Y, 0), new Color(V.Color.R, V.Color.G, V.Color.B, V.Color.A), new Vector2(V.UV.X, V.UV.Y));
            }

            _vertexBuffer = new VertexBuffer(_graphics, typeof(VertexPositionColorTexture), (int)Count, BufferUsage.WriteOnly);
            _vertexBuffer.SetData <VertexPositionColorTexture>(MonoVerts);
            _graphics.SetVertexBuffer(_vertexBuffer);

            _basicEffect.Texture = Texture;

            foreach (EffectPass pass in _basicEffect.CurrentTechnique.Passes)
            {
                pass.Apply();
                _graphics.DrawPrimitives(PrimitiveType.TriangleList, 0, (int)Count);
            }
        }
Esempio n. 5
0
        public override void Render(NkHandle Userdata, TextureBrush Texture, NkRect ClipRect, uint Offset, uint Count)
        {
            GraphicsPath Pth = new GraphicsPath();

            for (int i = 1; i < Count; i++)
            {
                NkVertex Vtx1 = Verts[Inds[Offset + i - 1]];
                NkVertex Vtx2 = Verts[Inds[Offset + i]];

                Pth.AddLine(Vtx1.Position.X, Vtx1.Position.Y, Vtx2.Position.X, Vtx2.Position.Y);

                if ((i + 1) % 3 == 0)
                {
                    Pth.CloseFigure();
                }
            }

            Gfx.SetClip(new RectangleF(ClipRect.X, ClipRect.Y, ClipRect.W, ClipRect.H));

            Gfx.DrawPath(Pens.White, Pth);
            //Gfx.FillPath(Texture, Pth);

            Gfx.ResetClip();
        }