有没有办法在另一个线程中使用OpenTK/OpenGL绘制到屏幕上?我试图使用的代码是
GL.Clear(ClearBufferMask.ColorBufferBit);
GL.ClearColor(Color.Black);
GL.Begin(PrimitiveType.Quads);
GL.Color3(Color.FromArgb(255, 0, 0));
GL.Vertex2(-1, 1);
GL.Color3(Color.FromArgb(0, 255, 0));
GL.Vertex2(1, 1);
GL.Color3(Color.FromArgb(0, 0, 255));
GL.Vertex2(1, -1);
GL.Color3(Color.FromArgb(0, 255, 255));
GL.Vertex2(-1, -1f);
GL.End();
SwapBuffers();
Run Code Online (Sandbox Code Playgroud)
上面的代码在GameWindow创建的同一个线程中工作,但不是从另一个线程调用时.
如何创建生成的对象名称?例如:
ObjectEx "name" = new ObjectEx();
Run Code Online (Sandbox Code Playgroud)
编辑:
该对象将由用户输入命名.代码将是:
Console.Write("Input new user's name: ");
string newUsersName = Console.ReadLine();
(Create ObjectEx)
Run Code Online (Sandbox Code Playgroud)
EDIT2:
我有一个处理所有s 的Dictionaryfor ObjectEx(Person)ObjectEx.
Person是真正的类名,抱歉制作示例对象ObjectEx.
public static List<Person> persons = new List<Person>();
Run Code Online (Sandbox Code Playgroud)