OpenTK multiple GLControl with a single Context

生来就可爱ヽ(ⅴ<●) 提交于 2020-02-03 08:29:05

问题


Im working on a program which should have multiple views of a model. I would like to use multipleGLControls` for that.

Is there any possibility to create multiple GLControl which use the same GraphicsContext?

I successfully created this on a multithreaded enviroment, but the contexts are not shared then. So I have to load the model for each context, which is bad.

My pseudocode for a single threaded enviroment looks something like this:

glControl1.MakeCurrent();
// Render here
glControl1.SwapBuffers();
glControl2.MakeCurrent();
// Render here too
glControl2.SwapBuffers();

I tried this by creating multiple contexts on the thread but it crashed with

Error: 170" at "MakeCurrent()

of glControl2. (Even glControl2.Context.MakeCurrent(null) before switching the context didn`t work)

Maybe you have some hints which can help me.


回答1:


Right after I posted this question I found the solution.

I created a new GraphicsContext on the thread I want to render my stuff.

//Here does a new thread start->
IGraphicsContext control2Context = new GraphicsContext(GraphicsMode.Default,glControl2.WindowInfo);
while(true)
{
    glControl1.MakeCurrent()
    //render
    GL.Flush();
    glControl1.SwapBuffers();

    control2Context.MakeCurrent(glControl2.WindowInfo);
    //render
    GL.Flush();
    glControl2.SwapBuffers();
}

As you can see, I'm not using glControl2.MakeCurrent(). Instead I created this new context control2Context.

Maybe this can help someone who is facing the same problem.



来源:https://stackoverflow.com/questions/40578910/opentk-multiple-glcontrol-with-a-single-context

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!