ShaprGL / WPF / FBO / Shaders / REALLY LOW FPS

Jul 3, 2013 at 11:00 AM
as part of my work I was given a task to implement OpenGL functionality in Windows Presentation Foundation (WPF). The choice of environment was not up to me so i just have to live with it. My question is however this: I've foucsed on using SharpGL - i implemented it hosted in the WinForms container, set Rendering to FBO and got a simple shader to compile...

It all runs but... when rendering to FBO i get less than 10 FPS in full screen mode... small window gets 30-35 FPS... If i switch to DIBSection rendering then i get constant 35-40 FPS (normal or maximized window).

I've tried different settings, updated libraries... no improvement. Is it possible this is my graphics card problem ? My graphics card has openGL 3.3 support.

I'm pretty sure there's no errors in code (it compiles just fine) but maybe i'm missing something about SharpGL configuration and init ? I know in software mode it renders staff to image and then displays it in the WPF.. is there a way to disable it and render directly into WinForms host container ?

Any advice ? below gl init code and drawing method:
this.glControl.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
                    | System.Windows.Forms.AnchorStyles.Left)
                    | System.Windows.Forms.AnchorStyles.Right)));
        this.glControl.DrawFPS = false;
        this.glControl.FrameRate = 60;
        this.glControl.Location = new System.Drawing.Point(12, 12);
        this.glControl.Name = "openGLControl1";
        this.glControl.RenderContextType = SharpGL.RenderContextType.FBO;
        this.glControl.Size = new System.Drawing.Size(768, 410);
        this.glControl.TabIndex = 0;
        this.glControl.OpenGLDraw += new SharpGL.RenderEventHandler(this.openGLControl_OpenGLDraw);
        this.glControl.OpenGLInitialized += new System.EventHandler(this.openGLControl_OpenGLInitialized);
        this.glControl.Resized += new System.EventHandler(this.openGLControl_Resized);
and drawing function:
 OpenGL gl = glControl.OpenGL;
        gl.ClearColor(0.0f, 0.0f, 0.0f, 0.0f);
        gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT);

        gl.UseProgram(theProgram);


        gl.BindBuffer(OpenGL.GL_ARRAY_BUFFER, positionBufferObject);
        gl.EnableVertexAttribArray(0);
        gl.VertexAttribPointer(0, 4, OpenGL.GL_FLOAT, false, 0, IntPtr.Zero);

        gl.DrawArrays(OpenGL.GL_TRIANGLES, 0, 3);

        gl.DisableVertexAttribArray(0);
        gl.UseProgram(0);

        gl.Flush();
Be happy for any advice... cheers
Jul 13, 2013 at 9:33 AM
Show me please your Opengl Initialization function.
Aug 13, 2013 at 12:02 PM
In my simple applications, even FBO is still very slow with modest hardware. Using NativeWindow might help, see - https://sharpgl.codeplex.com/discussions/439223