2017-09-09 2 views
2

을 그릴하지만 난 단지이 얻을 : OpenTK 나는 C#에서 OpenGL을 간단한 원을 그리려는 투명 원

img

내가 혼합 기능을 시도하지만, 일을하지 않았다. 내 코드는 : 당신이 투명 원을 그리려는 경우 GL.Color4을 설정할 때

public static void DrawCircle(float x, float y, float radius, Color4 c) 
    { 
     GL.Enable(EnableCap.Blend); 
     GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha); 
     GL.Begin(PrimitiveType.TriangleFan); 
     GL.Color4(c); 

     GL.Vertex2(x, y); 
     for (int i = 0; i < 360; i++) 
     { 
      GL.Vertex2(x + Math.Cos(i) * radius, y + Math.Sin(i) * radius); 
     } 

     GL.End(); 
     GL.Disable(EnableCap.Blend); 
    } 
+1

어떻게 생겼습니까? 구멍? – TaW

답변

0

, 다음, 255보다 알파 ​​채널 적게 사용해야합니다. 영역을 그릴 것입니다

원시 형 PrimitiveType.TriangleFan : 당신이 원의 contur을 그리려는 경우

GL.Color4(red, green, blue, 127); // alpha = 127 for semi-transparent 


는하지만, 당신은 기본 유형을 변경해야합니다. conture를 그리려면 PrimitiveType.LineLoop을 사용하십시오.
PrimitiveTypeOpenGL Primitive을 참조하십시오.

관련 문제