2012-02-24 12 views
0

나는 SharpGL을 WPF와 함께 사용하는 자습서 인 this code project을 따라 OpenGL을 렌더링 할 수있는 컨트롤을 만듭니다. 훌륭합니다, 모든 것이 잘 작동합니다.SharpGL 및 WPF를 사용하여 투명 배경 만들기

그러나 SharpGL WPF 컨트롤 뒤에 비디오를 렌더링하고 있으므로 렌더링의 배경이 투명해야합니다. 이 문제를 어떻게 해결할 수 있습니까?

코드 :

<Window x:Class="MyProject.MainWindow" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:sharpGL="clr-namespace:SharpGL.WPF;assembly=SharpGL.WPF" 
    Title="MainWindow" Height="600" Width="800" Loaded="Window_Loaded"> 
    <Canvas Height="580" Width="780" Name="CentreCanvas"> 
     <Image Canvas.Left="0" Canvas.Top="0" Height="565" Name="imageVideoControl" Stretch="Fill" Width="780" /> 
     <Image Canvas.Left="580" Canvas.Top="0" Height="150" Name="imageDepthControl" Stretch="Fill" Width="200" /> 
     <sharpGL:OpenGLControl OpenGLDraw="OpenGLControl_OpenGLDraw" Height="565" Width="780"></sharpGL:OpenGLControl> 
    . . . 
    </Canvas> 
</Window> 

private void OpenGLControl_OpenGLDraw(object sender, OpenGLEventArgs args) 
{ 
    // Get the OpenGL instance being pushed to us. 
    gl = args.OpenGL; 

    // Clear the colour and depth buffers. 
    gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT); 

    // Reset the modelview matrix. 
    gl.LoadIdentity(); 

    // Move the geometry into a fairly central position. 
    gl.Translate(1.5f, 0.0f, -6.0f); 

    // Draw a quad. 
    gl.Begin(OpenGL.GL_QUADS); 

     // Set colour to red. 
     gl.Color(1.0f, 0.0f, 0.0f); 

     // Draw some quad... 
     . . . 
     . . . 

    gl.End(); 
} 

답변

1

당신은하지 않습니다.

OpenGL 창은 WPF 창이 아닙니다. Win32 HWND입니다. 그리고 OpenGL에 의해 운영되는 HWND는 윈도우 투 윈도우 (window-to-window) 투명성에 참여할 수 없다.

+0

그래서 내 후속 질문을 귀하의 응답을 것 같아요 OpenGL보기 배경으로 내 비디오 출력을 렌더링 할 수있는 방법이 있습니까? – bobble14988

+0

@ bobble14988 : 비디오 이미지를 가져 와서 텍스처로 OpenGL에로드하고 GL 명령을 사용하여 그릴 수 있습니다. –