2014-04-12 4 views
0

을 쉐이더를 적용하고 난 표면 객체에 셰이더를 적용하기 위해 노력하고있어 :표면 (텍스처)에 내가 조금 OpenTK 기반의 2D 그래픽 라이브러리에서 일하고 있어요

public void ApplyTo(Surface surface) 
    { 
     using (Surface pong = new Surface()) 
     { 
      pong.Create(surface.Width, surface.Height); 
      pong.Clear(0, 0, 0, 0); 

      GL.Viewport(0, 0, surface.Width, surface.Height); 
      GL.LoadIdentity(); 
      GL.Ortho(0, 1.0, 1.0, 0.0, 0.0, 4.0); 

      GL.UseProgram(0); 
      surface.BindTexture(); 
      pong.BindFramebuffer(); 


      GL.Begin(PrimitiveType.Quads); 
      GL.TexCoord2(0.0f, 1.0f); 
      GL.Vertex3(0, 0, 0); 
      GL.TexCoord2(0.0f, 0.0f); 
      GL.Vertex3(0, 1, 0); 
      GL.TexCoord2(1.0f, 0.0f); 
      GL.Vertex3(1, 1, 0); 
      GL.TexCoord2(1.0f, 1.0f); 
      GL.Vertex3(1, 0, 0); 
      GL.End(); 

      Use(); // calls GL.UseProgram() 
      pong.BindTexture(); 
      surface.BindFramebuffer(); 

      GL.Begin(PrimitiveType.Quads); 
      GL.TexCoord2(0.0f, 1.0f); 
      GL.Vertex3(0, 0, 0); 
      GL.TexCoord2(0.0f, 0.0f); 
      GL.Vertex3(0, 1, 0); 
      GL.TexCoord2(1.0f, 0.0f); 
      GL.Vertex3(1, 1, 0); 
      GL.TexCoord2(1.0f, 1.0f); 
      GL.Vertex3(1, 0, 0); 
      GL.End(); 

      GL.BindTexture(TextureTarget.Texture2D, 0); 
      GL.BindFramebuffer(FramebufferTarget.Framebuffer, 0); 
     } 
    } 

이 어떻게 든 표면을 대신 웁니다 셰이더 적용하기. 내 의심은 내가 뷰포트/투영과 관련하여 뭔가 잘못하고 있다는 것이지만 무엇입니까? 제공된 코드가 충분하기를 바랍니다.

쿼드에 전체 화면 렌더링을위한

답변

0

, 나는 투사 것을 사용하여 정점 가까운면에 정확히 어딘가 때

OpenTK.Matrix4 ortho = OpenTK.Matrix4.CreateOrthographicOffCenter(-1, 1, -1, 1, 1, -1); 

0으로 나누기 Theres는, 당신은 또한 Z에 조금 더 이동할 수 있습니다 중심선.