SlideShare uma empresa Scribd logo
1 de 17
3. More Drawing Tool

1.The Mapping from the Window to the Viewport
 윈도우와 뷰포트 매핑

             world coordinates(세계좌표)
              오브젝트가 실제로 놓여진 공간




             world window(세계윈도우)
               화면에 그려지는 윈도우




                viewport(뷰포트)
            클리핑영역이 스크린에 적용되는 영역
3. More Drawing Tool

1.The Mapping from the Window to the Viewport
3. More Drawing Tool

1.The Mapping from the Window to the Viewport
*viewport: 디폴트로 전체윈도우
        scaling과 shifting을 통해 매핑




                                           (0,0)
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)
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 픽셀단위로 측정되는 스크린 윈도우의 좌표계로 기술.
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)값
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
sx =Ax+c, sy =By+d
•(W. l,W.t,W.r,W.b)=(0, 2.0, 0, 1.0)
•(V. l,V.t,V.r,V.b)=(40,400,60,300)

•sx=180x+40                       glMatrixMode(GL_PROJECTION);
•sy=240y+60                       glLoadIdentity();
                                  gluOrtho2D(0, 2.0, 0, 1.0);//윈도우설정
                                  glViewport(40,400,60,300);//viewport설정
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
        }
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
        }
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)은 고정된 채 같은 크기의 뷰포트 안에 그려진다.
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()를 추가함
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: 얻어진 범위를 가지고 실제 그림.
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
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)
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)
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발생

Mais conteúdo relacionado

Mais procurados

[NDC14] 라이브중인 2D게임에 시스템 변경 없이 본 애니메이션 도입하기[던전앤파이터]
[NDC14] 라이브중인 2D게임에 시스템 변경 없이 본 애니메이션 도입하기[던전앤파이터][NDC14] 라이브중인 2D게임에 시스템 변경 없이 본 애니메이션 도입하기[던전앤파이터]
[NDC14] 라이브중인 2D게임에 시스템 변경 없이 본 애니메이션 도입하기[던전앤파이터]SeungWon Lee
 
TestSDS2018-1(answer)
TestSDS2018-1(answer)TestSDS2018-1(answer)
TestSDS2018-1(answer)Yong Heui Cho
 
배워봅시다 머신러닝 with TensorFlow
배워봅시다 머신러닝 with TensorFlow배워봅시다 머신러닝 with TensorFlow
배워봅시다 머신러닝 with TensorFlowJang Hoon
 
ALS WS에 대한 이해 자료
ALS WS에 대한 이해 자료ALS WS에 대한 이해 자료
ALS WS에 대한 이해 자료beom kyun choi
 
Html5 canvas animation
Html5 canvas animationHtml5 canvas animation
Html5 canvas animationSangHun Lee
 

Mais procurados (7)

[NDC14] 라이브중인 2D게임에 시스템 변경 없이 본 애니메이션 도입하기[던전앤파이터]
[NDC14] 라이브중인 2D게임에 시스템 변경 없이 본 애니메이션 도입하기[던전앤파이터][NDC14] 라이브중인 2D게임에 시스템 변경 없이 본 애니메이션 도입하기[던전앤파이터]
[NDC14] 라이브중인 2D게임에 시스템 변경 없이 본 애니메이션 도입하기[던전앤파이터]
 
[Week8]R_ggplot2
[Week8]R_ggplot2[Week8]R_ggplot2
[Week8]R_ggplot2
 
TestSDS2018-1(answer)
TestSDS2018-1(answer)TestSDS2018-1(answer)
TestSDS2018-1(answer)
 
배워봅시다 머신러닝 with TensorFlow
배워봅시다 머신러닝 with TensorFlow배워봅시다 머신러닝 with TensorFlow
배워봅시다 머신러닝 with TensorFlow
 
ALS WS에 대한 이해 자료
ALS WS에 대한 이해 자료ALS WS에 대한 이해 자료
ALS WS에 대한 이해 자료
 
Html5 canvas animation
Html5 canvas animationHtml5 canvas animation
Html5 canvas animation
 
Butter android views
Butter android viewsButter android views
Butter android views
 

Semelhante a Open gl

c++ opencv tutorial
c++ opencv tutorialc++ opencv tutorial
c++ opencv tutorialTaeKang Woo
 
PiCANet, Pytorch Implementation (Korean)
PiCANet, Pytorch Implementation (Korean)PiCANet, Pytorch Implementation (Korean)
PiCANet, Pytorch Implementation (Korean)JaehoonYoo5
 
NDC11_슈퍼클래스
NDC11_슈퍼클래스NDC11_슈퍼클래스
NDC11_슈퍼클래스noerror
 
Java project master
Java project masterJava project master
Java project masterssuseref9237
 
이미지프로세싱
이미지프로세싱이미지프로세싱
이미지프로세싱일규 최
 
안드로이드스터디 7
안드로이드스터디 7안드로이드스터디 7
안드로이드스터디 7jangpd007
 
RUCK 2017 Shiny의 또 다른 활용: RStudio addin 함수 및 패키지의 제작
RUCK 2017 Shiny의 또 다른 활용: RStudio addin 함수 및 패키지의 제작RUCK 2017 Shiny의 또 다른 활용: RStudio addin 함수 및 패키지의 제작
RUCK 2017 Shiny의 또 다른 활용: RStudio addin 함수 및 패키지의 제작r-kor
 
Shiny의 또 다른 활용
Shiny의 또 다른 활용Shiny의 또 다른 활용
Shiny의 또 다른 활용건웅 문
 
3D 컴퓨터 그래픽스 기초
3D 컴퓨터 그래픽스 기초3D 컴퓨터 그래픽스 기초
3D 컴퓨터 그래픽스 기초Seung Joon Choi
 
[IGC2018] 퍼니파우 최재영 - 감성을 위한 개발요소
[IGC2018] 퍼니파우 최재영 - 감성을 위한 개발요소[IGC2018] 퍼니파우 최재영 - 감성을 위한 개발요소
[IGC2018] 퍼니파우 최재영 - 감성을 위한 개발요소강 민우
 
7가지 동시성 모델 - 데이터 병렬성
7가지 동시성 모델 - 데이터 병렬성7가지 동시성 모델 - 데이터 병렬성
7가지 동시성 모델 - 데이터 병렬성HyeonSeok Choi
 
Bs webgl소모임001 uniform버전
Bs webgl소모임001 uniform버전Bs webgl소모임001 uniform버전
Bs webgl소모임001 uniform버전Seonki Paik
 
파이썬+Operator+이해하기 20160409
파이썬+Operator+이해하기 20160409파이썬+Operator+이해하기 20160409
파이썬+Operator+이해하기 20160409Yong Joon Moon
 
[NDC17] Unreal.js - 자바스크립트로 쉽고 빠른 UE4 개발하기
[NDC17] Unreal.js - 자바스크립트로 쉽고 빠른 UE4 개발하기[NDC17] Unreal.js - 자바스크립트로 쉽고 빠른 UE4 개발하기
[NDC17] Unreal.js - 자바스크립트로 쉽고 빠른 UE4 개발하기현철 조
 
SGL : 소프트웨어 3D 렌더링 엔진
SGL : 소프트웨어 3D 렌더링 엔진SGL : 소프트웨어 3D 렌더링 엔진
SGL : 소프트웨어 3D 렌더링 엔진SUNGCHEOL KIM
 
[NEXT] Android 개발 경험 프로젝트 1일차 (Widget, Linear Layout)
[NEXT] Android  개발 경험 프로젝트 1일차 (Widget, Linear Layout) [NEXT] Android  개발 경험 프로젝트 1일차 (Widget, Linear Layout)
[NEXT] Android 개발 경험 프로젝트 1일차 (Widget, Linear Layout) YoungSu Son
 
Vue.js 기초 실습.pptx
Vue.js 기초 실습.pptxVue.js 기초 실습.pptx
Vue.js 기초 실습.pptxwonyong hwang
 
(NEMO-UX) WAYLAND 기반 윈도우 매니저 소개
(NEMO-UX) WAYLAND 기반 윈도우 매니저 소개(NEMO-UX) WAYLAND 기반 윈도우 매니저 소개
(NEMO-UX) WAYLAND 기반 윈도우 매니저 소개nemoux
 

Semelhante a Open gl (20)

c++ opencv tutorial
c++ opencv tutorialc++ opencv tutorial
c++ opencv tutorial
 
PiCANet, Pytorch Implementation (Korean)
PiCANet, Pytorch Implementation (Korean)PiCANet, Pytorch Implementation (Korean)
PiCANet, Pytorch Implementation (Korean)
 
NDC11_슈퍼클래스
NDC11_슈퍼클래스NDC11_슈퍼클래스
NDC11_슈퍼클래스
 
Java project master
Java project masterJava project master
Java project master
 
Java project
Java projectJava project
Java project
 
이미지프로세싱
이미지프로세싱이미지프로세싱
이미지프로세싱
 
안드로이드스터디 7
안드로이드스터디 7안드로이드스터디 7
안드로이드스터디 7
 
RUCK 2017 Shiny의 또 다른 활용: RStudio addin 함수 및 패키지의 제작
RUCK 2017 Shiny의 또 다른 활용: RStudio addin 함수 및 패키지의 제작RUCK 2017 Shiny의 또 다른 활용: RStudio addin 함수 및 패키지의 제작
RUCK 2017 Shiny의 또 다른 활용: RStudio addin 함수 및 패키지의 제작
 
Shiny의 또 다른 활용
Shiny의 또 다른 활용Shiny의 또 다른 활용
Shiny의 또 다른 활용
 
3D 컴퓨터 그래픽스 기초
3D 컴퓨터 그래픽스 기초3D 컴퓨터 그래픽스 기초
3D 컴퓨터 그래픽스 기초
 
[IGC2018] 퍼니파우 최재영 - 감성을 위한 개발요소
[IGC2018] 퍼니파우 최재영 - 감성을 위한 개발요소[IGC2018] 퍼니파우 최재영 - 감성을 위한 개발요소
[IGC2018] 퍼니파우 최재영 - 감성을 위한 개발요소
 
7가지 동시성 모델 - 데이터 병렬성
7가지 동시성 모델 - 데이터 병렬성7가지 동시성 모델 - 데이터 병렬성
7가지 동시성 모델 - 데이터 병렬성
 
Bs webgl소모임001 uniform버전
Bs webgl소모임001 uniform버전Bs webgl소모임001 uniform버전
Bs webgl소모임001 uniform버전
 
파이썬+Operator+이해하기 20160409
파이썬+Operator+이해하기 20160409파이썬+Operator+이해하기 20160409
파이썬+Operator+이해하기 20160409
 
[NDC17] Unreal.js - 자바스크립트로 쉽고 빠른 UE4 개발하기
[NDC17] Unreal.js - 자바스크립트로 쉽고 빠른 UE4 개발하기[NDC17] Unreal.js - 자바스크립트로 쉽고 빠른 UE4 개발하기
[NDC17] Unreal.js - 자바스크립트로 쉽고 빠른 UE4 개발하기
 
SGL : 소프트웨어 3D 렌더링 엔진
SGL : 소프트웨어 3D 렌더링 엔진SGL : 소프트웨어 3D 렌더링 엔진
SGL : 소프트웨어 3D 렌더링 엔진
 
2. widget
2. widget2. widget
2. widget
 
[NEXT] Android 개발 경험 프로젝트 1일차 (Widget, Linear Layout)
[NEXT] Android  개발 경험 프로젝트 1일차 (Widget, Linear Layout) [NEXT] Android  개발 경험 프로젝트 1일차 (Widget, Linear Layout)
[NEXT] Android 개발 경험 프로젝트 1일차 (Widget, Linear Layout)
 
Vue.js 기초 실습.pptx
Vue.js 기초 실습.pptxVue.js 기초 실습.pptx
Vue.js 기초 실습.pptx
 
(NEMO-UX) WAYLAND 기반 윈도우 매니저 소개
(NEMO-UX) WAYLAND 기반 윈도우 매니저 소개(NEMO-UX) WAYLAND 기반 윈도우 매니저 소개
(NEMO-UX) WAYLAND 기반 윈도우 매니저 소개
 

Último

Console API (Kitworks Team Study 백혜인 발표자료)
Console API (Kitworks Team Study 백혜인 발표자료)Console API (Kitworks Team Study 백혜인 발표자료)
Console API (Kitworks Team Study 백혜인 발표자료)Wonjun Hwang
 
Merge (Kitworks Team Study 이성수 발표자료 240426)
Merge (Kitworks Team Study 이성수 발표자료 240426)Merge (Kitworks Team Study 이성수 발표자료 240426)
Merge (Kitworks Team Study 이성수 발표자료 240426)Wonjun Hwang
 
캐드앤그래픽스 2024년 5월호 목차
캐드앤그래픽스 2024년 5월호 목차캐드앤그래픽스 2024년 5월호 목차
캐드앤그래픽스 2024년 5월호 목차캐드앤그래픽스
 
A future that integrates LLMs and LAMs (Symposium)
A future that integrates LLMs and LAMs (Symposium)A future that integrates LLMs and LAMs (Symposium)
A future that integrates LLMs and LAMs (Symposium)Tae Young Lee
 
Continual Active Learning for Efficient Adaptation of Machine LearningModels ...
Continual Active Learning for Efficient Adaptation of Machine LearningModels ...Continual Active Learning for Efficient Adaptation of Machine LearningModels ...
Continual Active Learning for Efficient Adaptation of Machine LearningModels ...Kim Daeun
 
MOODv2 : Masked Image Modeling for Out-of-Distribution Detection
MOODv2 : Masked Image Modeling for Out-of-Distribution DetectionMOODv2 : Masked Image Modeling for Out-of-Distribution Detection
MOODv2 : Masked Image Modeling for Out-of-Distribution DetectionKim Daeun
 

Último (6)

Console API (Kitworks Team Study 백혜인 발표자료)
Console API (Kitworks Team Study 백혜인 발표자료)Console API (Kitworks Team Study 백혜인 발표자료)
Console API (Kitworks Team Study 백혜인 발표자료)
 
Merge (Kitworks Team Study 이성수 발표자료 240426)
Merge (Kitworks Team Study 이성수 발표자료 240426)Merge (Kitworks Team Study 이성수 발표자료 240426)
Merge (Kitworks Team Study 이성수 발표자료 240426)
 
캐드앤그래픽스 2024년 5월호 목차
캐드앤그래픽스 2024년 5월호 목차캐드앤그래픽스 2024년 5월호 목차
캐드앤그래픽스 2024년 5월호 목차
 
A future that integrates LLMs and LAMs (Symposium)
A future that integrates LLMs and LAMs (Symposium)A future that integrates LLMs and LAMs (Symposium)
A future that integrates LLMs and LAMs (Symposium)
 
Continual Active Learning for Efficient Adaptation of Machine LearningModels ...
Continual Active Learning for Efficient Adaptation of Machine LearningModels ...Continual Active Learning for Efficient Adaptation of Machine LearningModels ...
Continual Active Learning for Efficient Adaptation of Machine LearningModels ...
 
MOODv2 : Masked Image Modeling for Out-of-Distribution Detection
MOODv2 : Masked Image Modeling for Out-of-Distribution DetectionMOODv2 : Masked Image Modeling for Out-of-Distribution Detection
MOODv2 : Masked Image Modeling for Out-of-Distribution Detection
 

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
  • 8. sx =Ax+c, sy =By+d •(W. l,W.t,W.r,W.b)=(0, 2.0, 0, 1.0) •(V. l,V.t,V.r,V.b)=(40,400,60,300) •sx=180x+40 glMatrixMode(GL_PROJECTION); •sy=240y+60 glLoadIdentity(); gluOrtho2D(0, 2.0, 0, 1.0);//윈도우설정 glViewport(40,400,60,300);//viewport설정
  • 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발생