简体   繁体   English

使用OpenTK在C#中绘制图形(x = y)?

[英]Plot a graph (x = y) in C# using OpenTK?

How to plot a simple graph (x=y) in C# using OpenTK ? 如何使用OpenTK在C#中绘制简单图形(x = y)? both at Windws Form Application and at console App ?? 在Windws Form Application和控制台App上都可以? What methods do use to plot that graph ?I'm new to this tool so aa good link or toutorial will help me a lot .... 我使用什么方法来绘制图形?我是这个工具的新手,所以一个好的链接或教程将对我有很大帮助。

Hey Carlos Oliveira, 嘿Carlos Oliveira,

Step 1: You should start with this link ( http://www.opentk.com/doc/chapter/0 )[1] 步骤1:您应该先从以下链接开始( http://www.opentk.com/doc/chapter/0)[1 ]

Step 2: For a simple x=y graph , copy-paste the code snippet provided in the link[1] and remove the game.RenderFrame part and replace with code snippet pasted just below 步骤2:对于简单的x = y图,复制并粘贴link [1]中提供的代码段,然后删除game.RenderFrame部分,并替换为下面粘贴的代码段

game.RenderFrame += (sender, e) => game.RenderFrame + =(发送者,e)=>

            {
                GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);

                GL.Begin(PrimitiveType.Lines);
                GL.Color3(Color.White);
                //YAxis
                GL.Vertex2(0.0f, 2.0f);
                GL.Vertex2(0.0f, -2.0f);

                //X-Axis
                GL.Vertex2(2.0f, 0.0f);
                GL.Vertex2(-2.0f, 0.0f);
                GL.End();

                GL.Begin(PrimitiveType.Points);
        // Plotting the Graph
                GL.Color3(Color.DeepSkyBlue);
                for(float i=0;i<2.0;i=(float) (i+0.001))
                {
                    GL.Vertex2(i,i);
                }
                GL.End();
                game.SwapBuffers();
            };

Thanks, Hope it helps 谢谢,希望对你有帮助

Also like Christos mentioned a simple search would have landed you on the initial chapters of openTK 就像克里斯托斯(Christos)提到的那样,简单的搜索就可以使您进入openTK的初始章节。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM