McS*_*ens 1 c# opengl multithreading opentk
有没有办法在另一个线程中使用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创建的同一个线程中工作,但不是从另一个线程调用时.
我能够将OpenGL接受的线程与此代码交换
thread = new Thread(() =>
{
IGraphicsContext context = new GraphicsContext(GraphicsMode.Default, window.WindowInfo);
context.MakeCurrent(window.WindowInfo);
//Render code here
}).Start();
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1510 次 |
| 最近记录: |