85
OpenGL과 Modeling 01 OpenGL API 02 Rendering Pipeline 03 Modeling 01

01 Modeling - Sangji University3d.sangji.ac.kr/home/lectures/CG/01.pdf · 2019. 3. 7. · 01 1. OpenGL API 설치및환경설정 14. OpenGL API . 환경설정-IV : MS Visual Studio

  • Upload
    others

  • View
    16

  • Download
    0

Embed Size (px)

Citation preview

  • OpenGL과Modeling

    01 OpenGL API

    02 Rendering Pipeline

    03 Modeling

    01

  • 1. OpenGL API 설치 및 환경 설정

    2. OpenGL API 구조

    OpenGL API01

    2

  • 1. OpenGL API 설치 및 환경 설정01

    3

    OpenGL API의 상대적 위치System Memory

    Graphics Application

    Graphics API

    Graphics Library

    Graphics Memory

    GPU

    Mouse

    Keyboard

    Plotter

  • 1. OpenGL API 설치 및 환경 설정01

    4

    OpenGL API Download

    http://3d.sangji.ac.kr/ppt/CG/OpenGL_Lib.ziphttp://3d.sangji.ac.kr/ppt/CG/OpenGL_Lib.ziphttp://it.sangji.ac.kr/%7E3D/ppt/CG/OpenGL_Lib.ziphttp://it.sangji.ac.kr/%7E3D/ppt/CG/OpenGL_Lib.zip

  • 1. OpenGL API 설치 및 환경 설정01

    5

    OpenGL API 설치

  • [그림 1-2] New Project 생성 과정

    1. OpenGL API 설치 및 환경 설정01

    6

    Visual Studio 2015 이하 버전 - I

    [그림 1-3] New Project 생성을 위한환경 설정

  • 1. OpenGL API 설치 및 환경 설정01

    7

    Visual Studio 2015 이하 버전 - II

    [그림 1-5] 소스 코드의 Type 설정 및 File명 입력 과정

    [그림 1-4] New Project에 새로운 코드를 삽입하기 위한 과정

  • [그림 1-6] 소스 코드 입력을 위한 대기 상태

    1. OpenGL API 설치 및 환경 설정01

    8

    Visual Studio 2015 이하 버전 - III

    의[코드1-1]입력

    1

    [Build]▶[Build Solution]

    혹은

    2

  • 1. OpenGL API 설치 및 환경 설정01

    9

    Visual Studio 2017 Community

  • 1. OpenGL API 설치 및 환경 설정01

    10

    Visual Studio 2017 Community

  • 1. OpenGL API 설치 및 환경 설정01

    11

    OpenGL API 환경설정-I

  • 1. OpenGL API 설치 및 환경 설정01

    12

    OpenGL API 환경설정-II

  • 1. OpenGL API 설치 및 환경 설정01

    13

    OpenGL API 환경설정-III

  • 1. OpenGL API 설치 및 환경 설정01

    14

    OpenGL API 환경설정-IV : MS Visual Studio 2017 Community

    Project > Properties… Configuration Properties -> Link -> Input >> Additional Dependencies opengl32.lib glut32.lib glu32.lib glaux.lib 등 4개 파일 입력 한 줄에 한 개 파일만 입력 : 키 이용

    Include Directories C:\Program Files (x86)\Microsoft Visual Studio\

    2017\Community\VC\Tools\MSVC\14.15.xxx\include\gl Lib Directories C:\Program Files (x86)\Microsoft Visual Studio\

    2017\Community\VC\Tools\MSVC\14.15.xxx\lib\x86

  • 1. OpenGL API 설치 및 환경 설정01

    15

    OpenGL API 설치 및 환경설정 확인을 위한 Sample Code

    코드 1-1 #include #include

    void MyDisplay( ) {glClear(GL_COLOR_BUFFER_BIT);glBegin(GL_POLYGON);

    glVertex3f(-0.5, -0.5, 0.0);glVertex3f(0.5, -0.5, 0.0);glVertex3f(0.5, 0.5, 0.0);glVertex3f(-0.5, 0.5, 0.0);

    glEnd( );glFlush( );

    }int main( ) {

    glutCreateWindow("OpenGL Initialize Test");glutDisplayFunc(MyDisplay);glutMainLoop( );return 0;

    }

  • 2. OpenGL API 구조01

    16

    OpenGL API와 OpenGL API를 지원하는 Library들

  • 2. OpenGL API 구조01

    17

    OpenGL API 계층구조

  • 2. OpenGL API 구조01

    18

    OpenGL API를 지원하거나 연관된 Library들

  • 2. OpenGL API 구조01

    19

    OpenGL 함수의 기본적인 구조

    OpenGL API의 종류에 따른 함수명의 예시

  • 2. OpenGL API 구조01

    20

    OpenGL Data Type

  • 2. OpenGL API 구조01

    21

    glVertex3fv 함수의 Prototype

  • 2. OpenGL API 구조01

    22

    운영체제의 종류에 따른 OpenGL Library들

  • 2. OpenGL API 구조01

    23

    주로 많이 사용되는 GLUT 함수들 – Window 기능

  • 2. OpenGL API 구조01

    24

    glutInit, glutInitWindowPosition 함수의 Prototype

    glutInitWindowSize 함수의 Prototype

  • 2. OpenGL API 구조01

    25

    glutInitDisplayMode 함수의 Prototype

  • 2. OpenGL API 구조01

    26

    glutSetWindowTitle 함수의 Prototype

    GlutCreateWindow 함수의 Prototype

  • 2. OpenGL API 구조01

    27

    glutReshapeWindow 함수의 Prototype

    glutMainLoop 함수의 Prototype

  • 2. OpenGL API 구조01

    28

    Window 초기화 및 관리를 위해 주로 사용되는 GLUT 함수들의 사용 예시

    코드 1-2 int main(int argc, char** argv) {

    glutInit(&argc, argv);

    glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGB);

    glutInitWindowSize (500, 500);

    glutInitWindowPosition (100, 100);

    glutCreateWindow (“GLUT Sample”);

    ......

    glutMainLoop();

    return 0;

    }

  • 2. OpenGL API 구조01

    29

    주로 많이 사용되는 GLUT 함수들 – Callback 기능

  • 2. OpenGL API 구조01

    30

    Callback 기능을 수행하는 GLUT 함수들의 사용 예시

    #include

    #include

    #include

    #include

    #include

    #include

    void MyDisplay() { ...... }

    void MyReshape() { ...... }

    void MyKeyboard() { ...... }

    void MyMouse() { ...... }

    void MyMotion() { ...... }

    int main(int argc, char** argv) {

    glutInit(&argc, argv);

    glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGB);

    glutInitWindowSize (500, 500);

    glutInitWindowPosition (100, 100);

    glutCreateWindow (“OpenGL Callback Functions”);

    ......

    glutDisplayFunc(MyDisplay);

    glutReshapeFunc(MyReshape);

    glutKeyboardFunc(MyKeyboard);

    glutSpecialFunc(MySpecial);

    glutMouseFunc(MyMouse);

    glutMotionFunc(MyMotion);

    glutMainLoop();

    return 0;

    }

    코드 1-3

  • 1. OpenGL로 배우는 Graphics Pipeline

    2. 실시간(Real-time) Graphics Pipeline

    3. OpenGL Rendering Pipeline

    31

    Rendering Pipeline02

  • 32

    1. OpenGL로 배우는 Graphics Pipeline02

    OpenGL로 배우는 Graphics Pipeline

  • 33

    2. 실시간 Graphics Pipeline02

    실시간(Real-time) Graphics Pipeline

  • 34

    3. OpenGL Rendering Pipeline02

    OpenGL Rendering Pipeline

  • 1. Modeling의 종류

    2. GL Modeling

    3. GLU Modeling

    4. GLUT Modeling

    5. Outline Font를 사용한 Symbol Modeling

    35

    Modeling03

  • (A) Wire-frame Modeling (B) Surface Modeling (C) Solid Modeling

    36

    1. Modeling의 종류03

    Modeling 방법의 3가지 종류에 대한 구현 결과

  • 37

    2. GL Modeling03

    GL Library로 생성할 수 있는 Primitive들의 종류

  • 38

    2. GL Modeling03

    기하 Primitive들을 생성하기 위한 매개변수(Parameter)들

  • 39

    2. GL Modeling03

    원(Circle)을 그리기 위한 Algorithm

  • 40

    2. GL Modeling03

    점(Point)으로 생성한 Primitive코드 1-4 #include

    #include

    #define Pi 3.1415

    void MyDisplay( ) {GLfloat Size[2], Angle;glClear(GL_COLOR_BUFFER_BIT);glColor3f(0.0, 0.0, 0.0);glGetFloatv(GL_POINT_SIZE_RANGE, Size);glPointSize(Size[0] * 10);glBegin(GL_POINTS);

    for (Angle = 0.0; Angle

  • 41

    2. GL Modeling03

    glGetFloatv 함수의 Prototype

    glPointSize 함수의 Prototype

  • 42

    2. GL Modeling03

    다각형(Polygon)으로 생성한 Primitive

    코드 1-5 #include

    void MyDisplay( ) {

    glClear(GL_COLOR_BUFFER_BIT);

    glColor3f(0.5, 0.4, 0.3);

    glBegin(GL_POLYGON);

    glVertex3f( 0.0, 1.0, 0.0); glVertex3f(-1.0, 0.5, 0.0);

    glVertex3f(-1.0, -0.5, 0.0); glVertex3f( 0.0, -1.0, 0.0);

    glVertex3f( 1.0, -0.5, 0.0); glVertex3f( 1.0, 0.5, 0.0);

    glEnd();

    glFlush();

    }

  • 43

    2. GL Modeling

    정육면체의 계층적 자료구조

    03

  • 44

    2. GL Modeling

    오른손 좌표계

    03

  • 45

    2. GL Modeling

    Vertex Array를 이용한 정육면체 Modeling의 구현 결과

    03

    코드 1-6

  • 46

    2. GL Modeling

    glFrontFace 함수의 Prototype

    03

  • 47

    2. GL Modeling

    glEnableClientState 함수의 Prototype

    03

  • 48

    2. GL Modeling

    glColorPointer 함수의 Prototype

    03

  • 49

    2. GL Modeling

    glVertexPointer 함수의 Prototype

    03

  • 50

    2. GL Modeling

    glDrawElements 함수의 Prototype

    03

  • 51

    3. GLU Modeling

    Quadrics의 생성을 위한 함수

    03

    코드 1-7

  • 52

    3. GLU Modeling

    gluQuadricDrawStyle 함수의 Prototype

    03

  • 53

    3. GLU Modeling

    gluQuadricNormals 함수의 Prototype

    03

  • 54

    3. GLU Modeling

    gluQuadricOrientation 함수의 Prototype

    03

  • 55

    3. GLU Modeling

    GluQuadricTexture 함수의 Prototype

    03

  • (A) gluSphere(obj, 1.0, 5, 5); (B) gluSphere(obj, 1.0, 10, 10); (C) gluSphere(obj, 1.0, 20, 20);

    56

    3. GLU Modeling

    gluSphere 함수의 Prototype

    03

  • (A) gluCylinder(obj, 1.0, 1.0, 2.0, 20, 8); (B) gluCylinder(obj, 1.0, 1.0, 2.0, 8, 8);(C) gluCylinder(obj, 1.0, 0.3, 2.0, 20, 8); (D) gluCylinder(obj, 1.0, 0.0, 2.0, 20, 8);

    (A) (B) (C) (D)

    57

    3. GLU Modeling

    gluCylinder 함수의 Prototype

    03

  • gluDisk(obj, 0.0, 2.0, 20, 3); gluDisk(obj, 0.5, 2.0, 20, 3);

    58

    3. GLU Modeling

    gluDisk 함수의 Prototype

    03

  • gluPartialDisk(obj, 1.5, 3.0, 26, 13, 0.0, -180); gluPartialDisk(obj, 0.0, 3.0, 26, 13, 45, -145);59

    3. GLU Modeling

    gluPartialDisk 함수의 Prototype

    03

  • 60

    3. GLU Modeling

    NURBS를 이용한 Surface Modeling 구현 결과

    03

    코드 1-8

  • 61

    3. GLU Modeling

    glPointSize, glColor3ub 함수의 Prototype

    03

    gluBeginSurface 함수의 Prototype

  • 62

    3. GLU Modeling

    gluNurbsSurface 함수의 Prototype

    03

  • 63

    3. GLU Modeling

    gluEndSurface 함수의 Prototype

    03

    gluNewNurbsRender 함수의 Prototype

  • 64

    3. GLU Modeling

    gluNurbsProperty 함수의 Prototype

    03

  • 65

    3. GLU Modeling

    glNewList(s) 함수의 Prototype

    03

  • 66

    3. GLU Modeling

    glEndList, glCallList(S) 함수의 Prototype

    03

  • 코드 1-9

    67

    4. GLUT Modeling03

    GLUT Library를 이용한 3D Primitive 구현 결과

  • 68

    4. GLUT Modeling03

    glutWireSphere 및 glutSolidSphere 함수의 Prototype

  • (A) glutWireSphere(1.0, 30, 30); (B) glutSolidSphere(1.0, 30, 30);

    69

    4. GLUT Modeling03

    glutWireSphere 및 glutSolidSphere 함수의 구현 결과

  • 70

    4. GLUT Modeling03

    glutWireCube 및 glutSolidCube 함수의 Prototype

  • (A) glutWireCube(1.0); (B) glutSolidCube(1.0);

    71

    4. GLUT Modeling03

    glutWireCube 및 glutSolidCube 함수의 구현 결과

  • 72

    4. GLUT Modeling03

    glutWireTorus 및 glutSolidTorus 함수의 Prototype

  • (A) glutWireTorus(0.3, 1.5, 20, 20); (B) glutSolidTorus(0.3, 1.5, 20, 20);

    73

    4. GLUT Modeling03

    glutWireTorus 및 glutSolidTorus 함수의 구현 결과

  • 74

    4. GLUT Modeling03

    glutWireCone 및 glutSolidCone 함수의 Prototype

  • (A) glutWireCone(1.0, 1.5, 12, 12); (B) glutSolidCone(1.0, 1.5, 12, 12);

    75

    4. GLUT Modeling03

    glutWireCone 및 glutSolidCone 함수의 구현 결과

  • (A) glutWireTeapot(1.0); (B) glutSolidTeapot(1.0);

    76

    4. GLUT Modeling03

    glutWireTeapot 및 glutSolidTeapot 함수의 Prototype

  • (A) glutWireTetrahedron(); (B) glutSolidTetrahedron();

    77

    4. GLUT Modeling03

    glutWireTetrahedron 및 glutSolidTetrahedron 함수의Prototype

  • (A) glutWireOctahedron(); (B) glutSolidOctahedron();

    78

    4. GLUT Modeling03

    glutWireOctahedron 및 glutSolidOctahedron 함수의Prototype

  • (A) glutWireDodecahedron(); (B) glutSolidDodecahedron();

    79

    4. GLUT Modeling03

    glutWireDodecahedron 및 glutSolidDodecahedron함수의 Prototype

  • (A) glutWireIcosahedron(); (B) glutSolidIcosahedron();

    80

    4. GLUT Modeling03

    glutWireIconsahedron 및 glutSolidIcosahedron 함수의 Prototype

  • 81

    5. Outline Font를 사용한Symbol Modeling03

    Alphabet 대문자(A-Z)를 사용하여 구현한 Symbol Modeling 구현 결과

    Alphabet 소문자(a-z)를 사용하여 구현한 Symbol Modeling 구현 결과

    코드 1-10

  • 82

    5. Outline Font를 사용한Symbol Modeling

    03

    한글 자음(ㄱ–ㅎ)을 사용하여 구현한 Symbol Modeling 구현 결과

    한글 모음(ㅏ–ㅣ)을 사용하여 구현한 Symbol Modeling 구현 결과

  • 83

    5. Outline Font를 사용한Symbol Modeling03

    CreateFont 함수의 Prototype

  • 84

    5. Outline Font를 사용한Symbol Modeling03

    wglUseFontOutlines 함수의 Prototype

  • 85

    5. Outline Font를 사용한Symbol Modeling03

    GLYPHMETRICSFLOAT 구조체의 Prototype

    OpenGL과 Modeling슬라이드 번호 2슬라이드 번호 3슬라이드 번호 4슬라이드 번호 5슬라이드 번호 6슬라이드 번호 7슬라이드 번호 8슬라이드 번호 9슬라이드 번호 10슬라이드 번호 11슬라이드 번호 12슬라이드 번호 13슬라이드 번호 14슬라이드 번호 15슬라이드 번호 16슬라이드 번호 17슬라이드 번호 18슬라이드 번호 19슬라이드 번호 20슬라이드 번호 21슬라이드 번호 22슬라이드 번호 23슬라이드 번호 24슬라이드 번호 25슬라이드 번호 26슬라이드 번호 27슬라이드 번호 28슬라이드 번호 29슬라이드 번호 30슬라이드 번호 31슬라이드 번호 32슬라이드 번호 33슬라이드 번호 34슬라이드 번호 35슬라이드 번호 36슬라이드 번호 37슬라이드 번호 38슬라이드 번호 39슬라이드 번호 40슬라이드 번호 41슬라이드 번호 42슬라이드 번호 43슬라이드 번호 44슬라이드 번호 45슬라이드 번호 46슬라이드 번호 47슬라이드 번호 48슬라이드 번호 49슬라이드 번호 50슬라이드 번호 51슬라이드 번호 52슬라이드 번호 53슬라이드 번호 54슬라이드 번호 55슬라이드 번호 56슬라이드 번호 57슬라이드 번호 58슬라이드 번호 59슬라이드 번호 60슬라이드 번호 61슬라이드 번호 62슬라이드 번호 63슬라이드 번호 64슬라이드 번호 65슬라이드 번호 66슬라이드 번호 67슬라이드 번호 68슬라이드 번호 69슬라이드 번호 70슬라이드 번호 71슬라이드 번호 72슬라이드 번호 73슬라이드 번호 74슬라이드 번호 75슬라이드 번호 76슬라이드 번호 77슬라이드 번호 78슬라이드 번호 79슬라이드 번호 80슬라이드 번호 81슬라이드 번호 82슬라이드 번호 83슬라이드 번호 84슬라이드 번호 85