Continual Active Learning for Efficient Adaptation of Machine LearningModels ...
Open gl
1. 3. More Drawing Tool
1.The Mapping from the Window to the Viewport
윈도우와 뷰포트 매핑
world coordinates(세계좌표)
오브젝트가 실제로 놓여진 공간
world window(세계윈도우)
화면에 그려지는 윈도우
viewport(뷰포트)
클리핑영역이 스크린에 적용되는 영역
2. 3. More Drawing Tool
1.The Mapping from the Window to the Viewport
3. 3. More Drawing Tool
1.The Mapping from the Window to the Viewport
*viewport: 디폴트로 전체윈도우
scaling과 shifting을 통해 매핑
(0,0)
4. 1.The Mapping from the Window to the Viewport
Distortion(왜곡)을 피하려면
1)윈도우크기조절
2)윈도우내부 뷰포트의 종횡비조절
300
glViewport(0,0,150,150)
world window
300
glViewport(0,0,300,150)
glInitWindowSize(300,300)
5. 3. More Drawing Tool
1.The Mapping from the Window to the Viewport
screen window
viewport
world window는 left,top,right,bottom (W.l,W.t,W.r,W.b)경계로 기술.
viewport는 V. l,V.t,V.r,V.b 픽셀단위로 측정되는 스크린 윈도우의 좌표계로 기술.
6. 3. More Drawing Tool
1.The Mapping from the Window to the Viewport
선형변환을 통한 매핑
sx =Ax+C, sy =By+D
A , B는 scale 값
C , D는 shift(or translate)값
7. sx =Ax+c, sy =By+d
A and B scale the x,y coordinates,
C and D shift(or translate)
A= V.r-V.l C= V.l-AW.l B= V.t-V.b D= V.b-BW.b
W.r-W.l W.t-W.b
9. Tiling the screen window with the dinosaur motif
a)setWindow(0, 640.0, 0, 440.0); // set a fixed window
for(int i=0; i < 5; i++) // for each column
for (int j=0; j < 5; j++) // for each row
{
glViewport(i * 64, j * 44, 64,44) // set the next viewport
drawPolylineFile(dino.dat") ; // draw it again
}
10. Tiling the screen window with the dinosaur motif
b)for(int i = 0; i<5;i++)
for (int j = 0;=0; j<5;j++)
{
if((i+j) % 2 == O //if (i+j) is even
setWindow (0.0 , 640.0, 0.0, 440.0) // right - side-up window
else
setWindow(0.0, 640.0, 440.0, 0.0); // upside-down window
glViewport(i * 64, j * 44, 64, 44); // set the next viewport
drawPolylineFile("dino.dat"); //draw it again
}
11. 3. More Drawing Tool
1.The Mapping from the Window to the Viewport
-Zooming and Roaming
float cx = 0.3, cy = 0.2; //center of the window
float H, W = 1.2, aspect = 0.7; // window properties
set the viewport
for(int frame = 0; frame < NumFrames; frame++) // for each frame
{
clearthescreen // erase the previous figure
W*-0.7; // reduce the window width
H = W * aspect; // maintain the same aspect ratio
setWindow(cx - W, cx + W,. cy._- H, cy + H) ; //set the next window
hexSwirl(); // draw the object
zooming효과를 만들기 위해 매 프레임마다 윈도우의 크기를 줄여서
화면에 표시한다.
center와 aspect ratio(R)은 고정된 채 같은 크기의 뷰포트 안에 그려진다.
12. 3. More Drawing Tool
1.The Mapping from the Window to the Viewport
-Zooming and Roaming
부드러운 애니메이션 만들기
Double buffering
새로운 윈도우를 다른 어딘가에 미리 그려둔 후 완벽하게
그려진 그림을 사용자디스플레이에 즉시 바꿔치기 함.
glutSwapBuffer
메모리에 있는 그림을 사용자가 볼 수 있도록 스크린 윈도우로 내보냄
초기화작업
더블버퍼링을 위해서 초기화모듈에 다음을 추가
glutlintDisplayMode(GLUT_DOUBLE l GLUT_RGB)
-hexSwirl()다음에 glutSwapBuffers()를 추가함
13. 3. More Drawing Tool
2.Setting the Window and Viewport Automatically
-setting of the window
오브젝트의 범위(또는 바운딩박스)구하기
All the endpoints of the object's lines
are stored in an array
pt[i]
i=0, 2.....,n-1
extreme value of x, y
범위를 얻기 위해 두번의 pass수행
pass 1: 그리기 루틴을 실행하지만
실제 그리지는 않고 범위만을 계산.
pass 2: 얻어진 범위를 가지고 실제 그림.
14. 3. More Drawing Tool
2.Setting the Window and Viewport Automatically
-automatic setting of the viewport to preserve the aspect ratio
전체그림을 화면에 넣고자 할 때
a) world window 의 종횡비가 screen window의 종횡비보다 큰 경우 R>W/H
b) world window 의 종횡비가 screen window의 종횡비보다 작은 경우 R<W/H
15. 3. More Drawing Tool
2.Setting the Window and Viewport Automatically
-automatic setting of the viewport to preserve the aspect ratio
a)setViewport(0,W,0,W/R) b)setViewport(0,H*R,0,H)
16. 3. More Drawing Tool
2.Setting the Window and Viewport Automatically
-automatic setting of the viewport to preserve the aspect ratio
ex)R=1.6, H=200, W=360
W/H=1.8
case b)에 해당
setViewport()?
setViewport(0,320,0,200)
a)setViewport(0,W,0,W/R) b)setViewport(0,H*R,0,H)
17. 3. More Drawing Tool
2.Setting the Window and Viewport Automatically
-Resizing the Screen Window: the Resize Event
윈도의 크기가 변경때 호출되는 콜백함수
glReshapeFunc(myReshape);
//specifies the funtion called
//on a resize event
void myshape(GLsize W, GLsize H);
{
if (R>W/H) //use window aspect ratio
setViewport(0, W, 0,W/R)
drag else
setViewport(0, H*R, 0, H)
}
drag: resize event발생