问题
How to plot a simple graph (x=y) in C# using OpenTK ? both at Windws Form Application and at console App ?? What methods do use to plot that graph ?I'm new to this tool so a a good link or toutorial will help me a lot ....
回答1:
Hey Carlos Oliveira,
Step 1: You should start with this link ( 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
game.RenderFrame += (sender, 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
来源:https://stackoverflow.com/questions/24629056/plot-a-graph-x-y-in-c-sharp-using-opentk