OpenGL에서 알파 마스크를 사용하여 흰색 (1) = 표시 및 검정 (0) = 숨김으로하고 싶습니다.OpenGL을 사용하는 알파 마스크
그래서 내가 무엇을합니까 프레임 버퍼의 알파 구성 요소에 glColorMask(False, False, False, True)
(나는 파이썬을 사용하고있어, 당신을 사용하여)을 작성하고 블렌딩을 사용하여 그 위에 일부 기하학을 그립니다.
하지만 작동하지 않습니다. 알파 버퍼를 0으로 채우고 그 다음 보이지 않아야하는 일부 지오메트리를 그려 봅니다. 하지만 항상 나타납니다, 알파 버퍼 completly 무시됩니다.
# Clear alpha buffer to 0, and clear color buffer.
# After this, the alpha buffer should probaby be filled with 0.
glClearColor(0, 0, 0, 0)
glClear(GL_COLOR_BUFFER_BIT)
# Disable blending.
glDisable(GL_BLEND)
# Disable color writing.
glColorMask(False, False, False, True)
# Set color to a white with alpha 0.
glColor4f(1, 1, 1, 0)
# Now draw a fullscreen quad.
# After this, the alpha buffer should really be filled with 0.
# Shouldn't it?
glBegin(GL_QUADS)
glVertex2f(0, 0)
glVertex2f(320, 0)
glVertex2f(320, 480)
glVertex2f(0, 480)
glEnd()
# Enable color writing.
glColorMask(True, True, True, True)
# Enable blending so that incoming fragments are multiplied
# by alpha values already in the buffer.
glEnable(GL_BLEND)
glBlendFunc(GL_DST_ALPHA, GL_ONE)
# Set color to a white with alpha 1.
glColor4f(1, 1, 1, 1)
# Now draw a triangle.
# It should not be visible because alpha in framebuffer is 0
# and 0 * 1 = 0.
glBegin(GL_TRIANGLES)
glVertex2f(20, 50)
glVertex2f(300, 50)
glVertex2f(160, 210)
glEnd()
(예, 프로젝션 행렬 그래서 내 화면이 240분의 320로 0/0 범위 맞다.)
, 내가 무슨 짓을 삼각형이 표시되지해야합니까?
최종 결과는 검은 색 바탕에 흰색 삼각형입니까? 나는 너의 계단에 결함이 있는지 보지 않는다. – Bahbar