sharpgl icon indicating copy to clipboard operation
sharpgl copied to clipboard

Multiple OpenGLControl on the same form

Open davidedec opened this issue 9 years ago • 5 comments

Hi. I found an issue when we have multiple OpenGLControl on the same form, but I think generally on the same thread. I can see that the situation is already handled within the PreGLCall, that does the MakeCurrent in case it is needed. The problem I have, with FBO RenderContext, is that when the control is resized (OnSizeChanged) strange things happens. For example the area is clipped and not all the area is usable.

I think the problem is that in the OnSizeChanged there is an OpenGL.SetDimensions called before any MakeCurrent. I tried to MakeCurrent before it and everything works.

Hope to be helpful. Davide

davidedec avatar Oct 13 '15 17:10 davidedec

Hi Davide, could you, please post your code modifications? running into the same issue here.

Regards, Chris

ChrisFof avatar May 18 '16 11:05 ChrisFof

I found this issue as well--application always crashes when I attempt to use more than one OpenGL control. Happens on WPF, not sure about WinForms.

Yaazarai avatar May 18 '16 14:05 Yaazarai

Have the same issue here - does anybody have a solution / code for this?

These a four SharpGL-controls in the mainwindow. Each control should exactly show the same model...: bug

Stone1974 avatar May 21 '16 19:05 Stone1974

I run into this problem too. It's difficult to solve this. Try to use glViewportArrayv(GLuint first, GLsizei count, const GLfloat * v); to avoid this problem.

bitzhuwei avatar May 22 '16 01:05 bitzhuwei

I have an application that has two OpenGLControls on the same winform. where I call updatedata1(), draw1(), updatedata2(), draw2() to render the real-time charts. Despite synchronous calls, there is a leak from openGlcontrol1 to openGLcontrol2.

After some investigations, I found out that the leak occurs during the VAO, VBO and VIO binding and the reason behind is that there is no PreGLCall() to make context current (or upload data to the correct context) when calling gl.BindBuffer(). To solve the issue, you may want to insert the following code in bind() method of vertexbufferarray, vertexbuffer, indexbuffer class.

        public void Bind(OpenGL gl)
        {
            if (Win32.wglGetCurrentContext() != gl.RenderContextProvider.RenderContextHandle)
                gl.MakeCurrent();
            gl.BindBuffer(OpenGL.GL_ARRAY_BUFFER, vertexBufferObject);
        }

Note that the operation of switching render context is expensive, so we call gl.MakeCurrent() sparingly.

weelihl avatar Feb 19 '18 23:02 weelihl