How to use HiddenWindowRenderContextProvider?

Apr 17, 2015 at 1:02 AM
Edited Apr 17, 2015 at 1:03 AM
Hi, all.
I have a question.
I want to use the HiddenWidnowRenderContextProvider with WFP.
Is it possible?
I don't know how to use it.

I changed "RenderContextType" to "HiddenWindow".
And then, I chandged OnApplyTemplate() function as belows:

public override void OnApplyTemplate()
  {
     //  Call the base.
     base.OnApplyTemplate();

     //  Lock on OpenGL.
     lock (gl)
     {
        switch (RenderContextType)
        {
           case RenderContextType.HiddenWindow:
              gl.Create(OpenGLVersion, RenderContextType, 1, 1, 32, null);
              break;
           default:
              break;
        }
     }

     //  Create our fast event args.
     eventArgsFast = new OpenGLEventArgs(gl);

     //  Set the most basic OpenGL styles.

     //  Fire the OpenGL initialised event.
     var handler = OpenGLInitialized;
     if (handler != null)
        handler(this, eventArgsFast);
}
And then, I implemented timer_tick() function as belows:
  void timer_Tick(object sender, EventArgs e)
  {
     lock (gl)
     {
        stopwatch.Restart();

        gl.MakeCurrent();

        var handler = OpenGLDraw;
        if (handler != null)
           handler(this, eventArgsFast);
        else
           gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT);

        if (DrawFPS)
        {
           gl.DrawText(5, 5, 1.0f, 0.0f, 0.0f, "Courier New", 12.0f, string.Format("Draw Time: {0:0.0000} ms ~ {1:0.0} FPS", frameTime, 1000.0 / frameTime));
           gl.Flush();
        }

        //  Render.
        switch (RenderContextType)
        {
           case RenderContextType.HiddenWindow:
              {
                  var provider = gl.RenderContextProvider as HiddenWindowRenderContextProvider;
                  gl.Blit(provider.DeviceContextHandle);
              }
              break;
           default:
              break;
        }

        stopwatch.Stop();

        frameTime = stopwatch.Elapsed.TotalMilliseconds;
     }
  }
I think the hidden window was creaged successfully and Blit() function is working correctly.
But I can't show any opengl drawing.

Best regards.