본문으로 바로가기

Outline 그리기

category 블로그 (Blog)/개발로그 (Devlogs) 2024. 3. 12. 14:05

opengl 에서 outline을 그리는 몇가지 방법중의 하나..
바로 stencil buffer 를 이용함.

glPushAttrib(GL_ALL_ATTRIB_BITS);
 
glClearStencil(0);
glClear(GL_STENCIL_BUFFER_BIT);
glEnable(GL_STENCIL_TEST);
// Set the stencil buffer to write a 1 in every time
// a pixel is written to the screen
glStencilFunc(GL_ALWAYS, 1, 0xFFFF);
glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
glColor3f(1.0f, 0.0f, 0.0f);
 
...draw primitive...
 
glStencilFunc(GL_NOTEQUAL, 1, 0xFFFF);
glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
// Draw the object with thick lines
glLineWidth(4.0f);
glDisable (GL_LINE_SMOOTH);
glDisable(GL_LIGHTING);
 
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
glColor3f(1.0f, 1.0f, 1.0f);
 
...draw primitive...
 
glPopAttrib();

'블로그 (Blog) > 개발로그 (Devlogs)' 카테고리의 다른 글

ReactPhysics3D 의 광선 교차 테스트  (0) 2024.03.12
스트링 offset 파싱 속도 비교  (0) 2024.03.12
가장 근접 거리의 포인트 검색  (0) 2024.03.12
KD-Tree 예제  (0) 2024.03.12
Line to Quad shader  (0) 2024.03.12