Пример #1
0
        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);
        }
Пример #2
0
        public override void Render(NkHandle Userdata, Texture Texture, NkRect ClipRect, uint Offset, uint Count)
        {
            Camera.ActiveCamera = Camera.GUICamera;

            Texture.BindTextureUnit();
            //Shader.UpdateCamera(GUICam);
            Shader.SetModelMatrix(Matrix4.Identity);
            Shader.Bind();

            Gl.Enable(EnableCap.ScissorTest);
            Gl.Scissor((int)ClipRect.X, (int)Camera.GUICamera.ViewportSize.Y - (int)ClipRect.Y - (int)ClipRect.H, (int)ClipRect.W, (int)ClipRect.H);

            VertexArray.DrawElements((int)(Offset * sizeof(ushort)), (int)Count);

            Gl.Disable(EnableCap.ScissorTest);
        }
Пример #3
0
        public static void NuklearDraw(int X, int Y)
        {
            const NkPanelFlags Flags         = NkPanelFlags.BorderTitle | NkPanelFlags.MovableScalable | NkPanelFlags.ClosableMinimizable;
            const string       ConWindowName = "GConsole";

            if (Open)
            {
                NuklearAPI.Window(ConWindowName, X, Y, 600, 400, Flags, () => {
                    NkRect Bounds = NuklearAPI.WindowGetBounds();
                    if (Bounds.H > 85)
                    {
                        NuklearAPI.LayoutRowDynamic(Bounds.H - 85);

                        NuklearAPI.Group("Console_OutBufferGroup", 0, () => {
                            NuklearAPI.LayoutRowDynamic(12);

                            for (int i = 0; i < OutBuffer.Length; i++)
                            {
                                GConsoleEntry E = OutBuffer[i];
                                if (E.Msg != null)
                                {
                                    NuklearAPI.LabelColored(E.Msg, E.Clr);
                                }
                            }
                        });
                    }

                    NuklearAPI.LayoutRowDynamic();
                    if (NuklearAPI.EditString(NkEditTypes.Field, InBuffer).HasFlag(NkEditEvents.Active) && NuklearAPI.IsKeyPressed(NkKeys.Enter))
                    {
                        SendInput(InBuffer.ToString());
                        InBuffer.Clear();
                    }
                });

                if (NuklearAPI.WindowIsHidden(ConWindowName))
                {
                    NuklearAPI.WindowClose(ConWindowName);
                    Open = false;
                }
            }
        }
Пример #4
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);
        }
Пример #5
0
        static void ConsoleThing(int X, int Y, StringBuilder OutBuffer, StringBuilder InBuffer)
        {
            const NkPanelFlags Flags = NkPanelFlags.BorderTitle | NkPanelFlags.MovableScalable | NkPanelFlags.Minimizable;

            NuklearAPI.Window("Console", X, Y, 300, 300, Flags, () => {
                NkRect Bounds = NuklearAPI.WindowGetBounds();
                NuklearAPI.LayoutRowDynamic(Bounds.H - 85);
                NuklearAPI.EditString(NkEditTypes.Editor | (NkEditTypes)(NkEditFlags.GotoEndOnActivate), OutBuffer);

                NuklearAPI.LayoutRowDynamic();
                if (NuklearAPI.EditString(NkEditTypes.Field, InBuffer).HasFlag(NkEditEvents.Active) && NuklearAPI.IsKeyPressed(NkKeys.Enter))
                {
                    string Txt = InBuffer.ToString().Trim();
                    InBuffer.Clear();

                    if (Txt.Length > 0)
                    {
                        OutBuffer.AppendLine(Txt);
                    }
                }
            });
        }
Пример #6
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);
            }
        }
Пример #7
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();
        }