1
Vote

RenderContentType=FBO failure

description

Hi,

After trial and error, I have concluded that RenderContentType = FBO is faster than RenderContentType = NativeWindow.

I have modified the ModernOpenGLSample app to the following:

this.openGLControl1.OpenGLVersion = SharpGL.Version.OpenGLVersion.OpenGL2_1; this.openGLControl1.RenderContextType = SharpGL.RenderContextType.FBO;

More than 50% of the times i run the app, the opengl control is black. In the console, errors appear. The first one says:

OpenGL Error: "Unknown Error", when calling function SharpGL.Clear

It is generated during the following call in openGLControl1_OpenGLDraw:

openGLControl1.OpenGL.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT | OpenGL.GL_STENCIL_BUFFER_BIT);

Is this a bug in SharpGL or am I missing something here?

comments

D4Water wrote Jan 23 at 12:27 PM

It's the fact that you are telling the control to use a new control instead of reusing the previous currently running control.

Change this...
        openGLControl1.OpenGL.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT | OpenGL.GL_STENCIL_BUFFER_BIT);
to this..
        gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT | OpenGL.GL_STENCIL_BUFFER_BIT);
the "gl" has already been asigned durring the initialized function when the program first starts. So all it does from that point is pass the info to the gl variable.

In the initialize method.. you will see this...
    public void Initialise(OpenGL gl, float width, float height)
Notice.. OpenGL gl..... that is where the program assigns the gl variable. It's gathering this info from the FormDesigner CS file, which it sends to the scene file.

Look at the Example "FormModernOpenGLSample" and you will see how it all works together.