OpenGL 프로그래밍 가이드 : OpenGL 1.2 공식 학습 가이드 제3판

Similar documents
OpenGL 프로그래밍 가이드 제4판

chapter2.hwp

PowerPoint 프레젠테이션

컴퓨터그래픽스 소프트웨어

(Microsoft PowerPoint - FZBDPQDCSHAN.ppt [\310\243\310\257 \270\360\265\345])

Microsoft PowerPoint - lecture3-ch2.ppt

Microsoft PowerPoint - lecture2-opengl.ppt [호환 모드]

04_오픈지엘API.key

Microsoft PowerPoint - lecture2-opengl.ppt

Microsoft PowerPoint - lecture2-opengl.ppt [호환 모드]

<4D F736F F F696E74202D204347C3E2BCAEBCF6BEF D315FC4C4C7BBC5CDB1D7B7A1C7C8BDBA20B0B3B0FC2E >

Microsoft PowerPoint - lecture4-ch2.ppt

Microsoft PowerPoint cg01.ppt

Microsoft Word - cg09-midterm.doc

초보자를 위한 자바 2 21일 완성 - 최신개정판

ShaderX2: DirectX 9 셰이더 프로그래밍 팁 & 트릭

초보자를 위한 C++

(Microsoft PowerPoint - JXQEUPXIEBNZ.ppt [\310\243\310\257 \270\360\265\345])

(Microsoft PowerPoint - JXEUOAACMYBW.ppt [\310\243\310\257 \270\360\265\345])

Microsoft PowerPoint - 13prac.pptx

歯Lecture2.PDF

untitled

Microsoft PowerPoint - lecture18-ch8

초보자를 위한 C# 21일 완성

Open GL

서강대학교 공과대학 컴퓨터공학과 CSE4170 기초 컴퓨터 그래픽스 중간고사 (1/8) [CSE4170: 기초 컴퓨터 그래픽스] 중간고사 (담당교수: 임 인 성) 답은 연습지가 아니라 답안지에 기술할 것. 있는 변환 행렬은 일반적으로 어떤 좌표계 에서 어떤 좌표계로의

2005CG01.PDF

PCServerMgmt7

Microsoft PowerPoint - lecture17-ch8.ppt

[ReadyToCameral]RUF¹öÆÛ(CSTA02-29).hwp

歯PLSQL10.PDF

(72) 발명자 오인환 서울 노원구 중계로 195, 101동 803호 (중계동, 신 안동진아파트) 서혜리 서울 종로구 평창14길 23, (평창동) 한훈식 서울 강남구 언주로71길 25-5, 301호 (역삼동, 영 훈하이츠) 이 발명을 지원한 국가연구개발사업 과제고유번호

Microsoft PowerPoint - lecture5-ch3 [호환 모드]

Microsoft Word - cg09-final-answer.doc

프로덕트 아이덴티티의 유형별 특성에 관한 연구

Microsoft Word - cg07-final.doc

K&R2 Reference Manual 번역본

Microsoft PowerPoint - lecture11-ch4.ppt

(Microsoft PowerPoint - ADEFNJKEPXSQ.ppt [\310\243\310\257 \270\360\265\345])

Microsoft PowerPoint - lecture15-ch6.ppt

서피스셰이더프로그램 셰이더개발을쉽게! Thursday, April 12, 12

Microsoft PowerPoint D View Class.pptx

Microsoft PowerPoint - lecture11-ch4

PowerPoint 프레젠테이션

Ⅱ. Embedded GPU 모바일 프로세서의 발전방향은 저전력 고성능 컴퓨팅이다. 이 러한 목표를 달성하기 위해서 모바일 프로세서 기술은 멀티코 어 형태로 발전해 가고 있다. 예를 들어 NVIDIA의 최신 응용프 로세서인 Tegra3의 경우 쿼드코어 ARM Corte

Windows 시스템 프로그래밍 제3판

(Microsoft PowerPoint - CNVZNGWAIYSE.ppt [\310\243\310\257 \270\360\265\345])

Open GL

목차 제 1 장 inexio Touch Driver소개 소개 및 주요 기능 제품사양... 4 제 2 장 설치 및 실행 설치 시 주의사항 설치 권고 사양 프로그램 설치 하드웨

lecture4(6.범용IO).hwp

untitled

Beginning Linux Programming 제3판

thesis

0503중간고사.dvi

9

Orcad Capture 9.x

강의10

초보자를 위한 C++

PowerPoint 프레젠테이션

UML

Microsoft PowerPoint - [2009] 02.pptx

01-OOPConcepts(2).PDF


FMX M JPG 15MB 320x240 30fps, 160Kbps 11MB View operation,, seek seek Random Access Average Read Sequential Read 12 FMX () 2

Microsoft PowerPoint - lecture16-ch8.ppt [호환 모드]

Open GL

PowerPoint 프레젠테이션

Microsoft PowerPoint - 06-Body Data Class.pptx

C# Programming Guide - Types

untitled

63-69±è´ë¿µ

, ( ) 1) *.. I. (batch). (production planning). (downstream stage) (stockout).... (endangered). (utilization). *

DocsPin_Korean.pages

,,,,,, (41) ( e f f e c t ), ( c u r r e n t ) ( p o t e n t i a l difference),, ( r e s i s t a n c e ) 2,,,,,,,, (41), (42) (42) ( 41) (Ohm s law),

01....b

2007백서-001-특집

00목차

(291)본문7

¾Ë·¹¸£±âÁöħ¼�1-ÃÖÁ¾

Chap7.PDF

교재

105È£4fš

Nikon KeyMission 360. KeyMission 360 ( 1.5) SnapBridge 360/170 ( 1.1). SnapBridge 360/170., SnapBridge 360/170 OS.. KeyMission 360/ SnapBridge 360/170

Microsoft PowerPoint - lecture16-ch6

(Asynchronous Mode) ( 1, 5~8, 1~2) & (Parity) 1 ; * S erial Port (BIOS INT 14H) - 1 -

0503중간고사.dvi

초판 1쇄 발행 2013년 10월 25일 지은이 박승제 펴낸이 장성두 펴낸곳 제이펍 출판신고 2009년 11월 10일 제 호 주소 경기도 파주시 문발동 파주출판도시 뮤즈빌딩 403호 전화 / 팩스

슬라이드 1

Java 3D Programming

(......).hwp

T100MD+

fl 2

10.

Microsoft PowerPoint - 3ÀÏ°_º¯¼ö¿Í »ó¼ö.ppt

5-03-Â÷¼¼´ëÀ¥Iš

Microsoft PowerPoint - lecture3-ch2.ppt [호환 모드]

MAX+plus II Getting Started - 무작정따라하기

4. #include <stdio.h> #include <stdlib.h> int main() { functiona(); } void functiona() { printf("hihi\n"); } warning: conflicting types for functiona

#SC


Transcription:

OpenGL, (OpenGL GL, Graphics Library ). OpenGL 3.,,. OpenGL. 14. 3. 1, OpenGL OpenGL., OpenGL. 2, 3. 3, 3 2.. 4,.

26 Ope ngl Progra mming Guide - OpenGL 1.2 5,, (, ). 3 3. 3. OpenGL.. 6,,,.,,. 7, OpenGL. OpenGL. 8,,,, 2.. 9, 1 2 3.. 10, OpenGL.,,,, DOF. 11, GLU(OpenGL Utility Library). 12, NURBS.

27 13, OpenGL.,, OpenGL. 14, OpenGL. OpenGL OpenGL IRIS Graphics Library.,. A, OpenGL,. B, OpenGL,. C, OpenGL OpenGL. X Window System Apple Macintosh, IBM OS/2, MS Windows NT, Windows 95. D, GLUT OpenGL. GLUT,. E,. F,. G, OpenGL OpenGL. H, OpenGL OpenGL, OpenGL.

28 Ope ngl Progra mming Guide - OpenGL 1.2 OpenGL 3. OpenGL 1.2 - - rescaling - (packed BGRA) - 3D,, LOD, specular highlights OpenGL 1.2 - OpenGL - GLU(OpenGL Utility Library) 1.3 GLX(OpenGL Extension to the X Window System) 1.3 2 C, (,,,, ).,.,. Computer Graphics : Principles and Practices, James D. Foley, Andries van Dam, Steven K. Feiner, John F. Hughes (Reading, MA: Addison-Wesley, 1990) -.,. 3D Computer Graphics : A User's Guide f or Artists and Designers, Andrew S. Glassner (New York: Design Press, 1989) -

29.,. OpenGL OpenGL., FAQ,. OpenGL. ht t p :/ / www.opengl.org OpenGL OpenGL ARB OpenGL Reference Manual ( Addison-Wesley ). Reference Manual OpenGL., OpenGL (,, ). OpenGL., OpenGL. OpenGL OpenGL. OpenGL. (, )., OpenGL,,,,. OpenGL. Mark Kilgard GLUT(OpenGL Utility Toolkit). GLUT Mark Kilgard OpenGL Programming for the X Window System (Reading, MA: Addison-Wesley Developers Press, 1996). 1 OpenGL D GLUT. GLUT ftp.

30 Ope ngl Progra mming Guide - OpenGL 1.2. ft p :/ / ft p.sgi.com/ opengl / opengl 12.t ar.z ft p :/ / ft p.sgi.com/ opengl / opengl 12. zi p (MS Windows 95/98/NT X Window System ) GLUT GLUT. ht t p :/ / www.opengl.org/ devel oper s/ document at i on/ gl ut / OpenGL. OpenGL OpenGL. OpenGL. Na te Robins Ope ngl OpenGL Nate Robins (OpenGL Tutors).,.,,. GLUT,. ht t p :/ / www. cs.ut ah.edu/ ~nar obi ns/ opengl.ht ml. (errata). ht t p :/ / www.woo. com/ er rat a.ht ml.,.

31. - -,,, -, (brace). glcommand s, i, f, d, GLshort, GLint, GLfloat, GLdouble. glcommand TYPE. void g lco mmand{sifd}(type x1, TYPE y1, TYPE x2, TYPE y2);

1 Ope ngl OpenGL OpenGL OpenGL OpenGL OpenGL

34 Ope ngl Progra mming Guide - OpenGL 1.2 OpenGL 6. OpenGL? OpenGL, OpenGL. OpenGL OpenGL,. OpenGL OpenGL. OpenGL OpenGL. OpenGL. OpenGL OpenGL, GLUT(Graphics Library Utility Toolkit).. Ope ngl? OpenGL 3 250 (200 OpenGL, 50 OpenGL Utility Library ). OpenGL., OpenGL.., OpenGL 3.,,, OpenGL,,. GLU(OpenGL Utility Library), OpenGL. GLU NURBS. GLU OpenGL., (Fahrenheit Scene Graph, FSG) OpenGL

Chapter 1 Ope ngl 35, OpenGL ( OpenGL ). OpenGL., OpenGL.. OpenGL. OpenGL.. 1 (wireframe).,. (, ).,..,.,,,.. 2 (depth-cue).. OpenGL ( (fog) ). 3 (antialias ing). (pixel, picture element ),..

36 Ope ngl Progra mming Guide - OpenGL 1.2 4 (lighting) (flat-s hading).... 5, (smooth-shading). 3. 6 5 (shadow) (texture). OpenGL, 14. 2 3..,,. 7 (motion-blur). ( ). 8. 3. 9 2. 2. 10 DOF(depth-of-field)... OpenGL. OpenGL ( OpenGL ). 1.., (OpenGL,,,, ).

Chapter 1 Ope ngl 37 2. 3,. 3..,,,. 4.. (rasterization)..,,. X Window System OpenGL., OpenGL,. OpenGL ( ) OpenGL. OpenGL,. Ope ngl OpenGL.., OpenGL,. OpenGL,. (rendering). (model) (vertice) (,, ).

38 Ope ngl Progra mming Guide - OpenGL 1.2. (pixel),.. (bitplane),..,., OpenGL. [ 1-1] [ 1-1]. 1-1 1-1 OpenGL #i ncl ude <what everyouneed.h> mai n () { Ini t i al i zeawi ndowpl ease (); gl Cl earcol or (0. 0, 0. 0, 0. 0, 0. 0); gl Cl ear (GL_COLOR_BUFFER_BI T); gl Col or 3f (1. 0, 1. 0, 1. 0); gl Ort ho (0. 0, 1. 0, 0. 0, 1. 0, - 1. 0, 1. 0);

Chapter 1 Ope ngl 39 } glbegin(gl_ POLYGON); gl Vert ex3f (0.25, 0.25, 0. 0); gl Vert ex3f (0.75, 0.25, 0. 0); gl Vert ex3f (0.75, 0.75, 0. 0); gl Vert ex3f (0.25, 0.75, 0. 0); gl End (); gl Fl ush (); Updat ethewi ndowandcheckforevent s (); main() ( ) (window). InitializeAWindowPlease() OpenGL. OpenGL. glclearcolor(), glclear(). glclear()., glcolor3f() ( ).. OpenGL glortho(), (coordinate system) OpenGL., glbegin() glend().. glvertex3f(). (x, y, z), z=0., glflush() (buff er). UpdateTheWindowAndCheckForEvents(). OpenGL.,., InitializeAWindowPlease() UpdateTheWindowAndCheckForEvents() [ 1-1].

40 Ope ngl Progra mming Guide - OpenGL 1.2 Ope ngl glclearcolor() OpenGL gl (prefix). GL_,, _ (, GL_COLOR_BUFFER_BIT)., glcolor3f() glvertex3f() 3f (suffix). glcolor3f() Color OpenGL, OpenGL., 3., Color. f (floating-point). OpenGL. OpenGL 8. [ 1-1] ISO C OpenGL OpenGL. C++ Ada OpenGL. 1-1 C OpenGL b 8 integer signed char GLbyte s 16 integer short GLshort i 32 integer int long GLint, GLsizei f 32 floating-point float GLfloat, GLclampf d 64 floating-point double GLdouble, GLclampd ub 8 unsigned integer unsigned char GLubyte, GLboolean us 16 unsigned integer unsigned short GLushort ui 32 unsigned integer unsigned int unsigned long GLuint, GLenum, GLbitfield

Chapter 1 Ope ngl 41, gl Ver t ex2i (1, 3); gl Ver t ex2f (1. 0, 3. 0); (vertex) 32 integer, (single-precision floating-point). NOTE OpenGL C OpenGL. OpenGL. OpenGL v, ( ).,,.. gl Col or 3f (1. 0, 0. 0, 0. 0); GLfloat col or_array [] = {1. 0, 0. 0, 0. 0}; glcol or3fv (color_array);, OpenGL GLvoid. OpenGL. OpenGL, (*)., glcolor*().., glvertex*v(). Ope ngl OpenGL (state machine)...,

42 Ope ngl Progra mming Guide - OpenGL 1.2. OpenGL,,,,,,,,. glenable() gldisable().,. glgetbooleanv(), glgetdoublev(), glgetfloatv(), glgetintegerv(), glgetpointerv(), glisenabled().. (, glgetlight*(), glgeterror(), glgetpolygonstipple())., glpushattrib(), glpushclientattrib(), glpopattrib() glpopclientattrib().. B OpenGL. glget*(). Ope ngl OpenGL OpenGL (OpenGL Rendering Pipeline). [ 1-2] OpenGL, OpenGL. 3,. OpenGL.,, (evaluator) pre-vertex,,,.

Chapter 1 Ope ngl 43 ( per-fragment, per-fragment ),. 1-2, OpenGL., (display list) (, (immediate mode) ). ( 7 ).. (basis function). (evaluator)

44 Ope ngl Progra mming Guide - OpenGL 1.2. (polynomial mapping),,,, ( 12 ). Per-Vertex, (per-vertex Operation). 4 4. 3D (projection) ( 3 )..,.,,,,.. (clipping),.,,. (perspective division)., (viewport) (depth, z- ). (culling). (2 ).,,,,.

Chapter 1 Ope ngl 45 OpenGL,.,. (scale), (bias)., (clamp), (8 ).,, (mapping), (clamping) (pixel-transfer operation).,..,. OpenGL.. OpenGL. (9 ). (rasterization) (f ragment).,. (filled polygon),,,, (coverage)..

46 Ope ngl Progra mming Guide - OpenGL 1.2,.. (texturing) (texel, texture element)., (scissor),,, ( )..,,,, (6 10 ).,,. Ope ngl OpenGL,., OpenGL.. OpenGL (GLU, OpenGL Utility Library) OpenGL, (tessellation),. OpenGL. GLU OpenGL Ref erence Manual. GLU 11 12 GLU NURBS. GLU glu. OpenGL. X Window System, GLX (OpenGL Extension to the X Window System) OpenGL. GLX glx. MS Windows 95/98/NT, OpenGL WGL. WGL wgl., IBM OS/2 PGL(Presentation Manager to OpenGL

Chapter 1 Ope ngl 47 interface), pgl. Apple, AGL, agl. C. GLX OpenGL Ref erence Manual. OpenGL (GLUT, OpenGL Utility Toolkit) Mark Kilgard API. GLUT, Mark Kilgard OpenGL Programming for the X Window System (ISBN 0-201-48359-9). GLUT glut. GLUT. (FSG, Fahrenheit Scene Graph) OpenGL 3. FSG C++, 3,. FSG OpenGL. include, OpenGL gl.h., OpenGL GLU glu.h., OpenGL. #i ncl ude <GL/ gl.h> #i ncl ude <GL/ gl u.h> MS Windows, MS Windows gl.h glu.h windows.h windows.h gl.h glu.h., GLX, AGL, PGL, WGL., GLX.

48 Ope ngl Progra mming Guide - OpenGL 1.2 #i ncl ude <X11/ Xl i b.h> #i ncl ude <GL/ gl x.h> MS Windows WGL. #i ncl ude <wi ndows.h> GLUT. #i ncl ude <GL/ gl ut.h> NOTE glut.h gl.h glu.h include. glut.h MS Windows,. GLUT glut.h, gl.h glu.h., OpenGL C. #i ncl ude <st dl i b.h> #i ncl ude <st di o.h> GLUT - OpenGL OpenGL., OpenGL.,,, Windows., GLUT. OpenGL GLUT., OpenGL,, GLUT, 3.

Chapter 1 Ope ngl 49 (OpenGL (GLU) GLUT, 3 ). OpenGL GLUT, OpenGL. GLUT ( GLUT D Kilgard OpenGL Programming for the X Window System 4 5 ).. glutinit(int *argc, char **argv) - GLUT (X Window System, -display -geometry ). GLUT glutinit(). glutinitdisplaymode (uns igned int mode) - RGBA,.,, ( glutsetcolor() ).,,., RGBA,, glutinitdisplaymode (GLUT_DOUBLE GLUT_RGB GLUT_DEPTH). glutinitwindowpos ition(int x, int y) -. glutinitwindowsize (int width, int size) -. int glutcreatewindow(char *string) - OpenGL.. glutmainloop().

50 Ope ngl Progra mming Guide - OpenGL 1.2 glutdisplayfunc(void (*f unc)(void)). GLUT.,. glutmainloop() glutpostredisplay(). glutmainloop(void)..,.. [ 1-2] GLUT [ 1-1].. init(). display(), GLUT. 1-2 GLUT OpenGL : hello.c #i ncl ude <GL/ gl ut.h> #i ncl ude <st dl i b.h> voi d di spl ay (voi d ) { / *. */ gl Cl ear (GL_COLOR_BUFFER_BI T) ; / * (0. 25, 0. 25, 0. 0) (0 75, 0.75, 0. 0) * ( ). */ gl Col or 3f (1. 0, 1. 0, 1. 0) ;

Chapter 1 Ope ngl 51 gl Begi n (GL_POLYGON) ; gl Vert ex3f (0.25, 0.25, 0. 0) ; glvert ex3f (0 75, 0.25, 0. 0) ; gl Vert ex3f (0.75, 0.75, 0. 0) ; gl vert ex3f (0.25, 0.75, 0. 0) ; gl End () ; / *, * OpenGL. */ gl Fl ush (); } voi d i ni t (voi d ) { / *. */ gl Cl ear Col or (0. 0, 0. 0, 0. 0, 0. 0) ; / *. */ glmat r i xmode (GL_PROJECTION) ; gl LoadIdent i t y () ; glort ho (0. 0, 1. 0, 0. 0, 1. 0, - 1. 0, 1. 0) ; } / *, ( RGBA ). * "hel l o".. *. *,. */ i nt mai n (i nt argc, char ** argv ) { gl ut Ini t (&argc, argv ) ; glutinitdisplaymode (GLUT_SINGLE GLUT_RGB) ; gl ut I ni t Wi ndowsi ze (250, 250) ; gl ut Ini twi ndowposi t i on (100, 100) ; gl ut Creat ewi ndow("hel l o" ) ; i ni t () ; gl ut Di spl ayfunc (di spl ay ) ; glutmai nloop () ; r et ur n 0; / * I SO C mai n i nt. */ }

52 Ope ngl Progra mming Guide - OpenGL 1.2. glutreshape Func(void (*func)(int w, int h)) -. glutkeyboardfunc (void (*func)(unsigned char key, int x, int y)) -. glutmouse Func (void (*func)(int button, int state, int x, int y)) -. glutmotionfunc(void (*func)(int x, int y)) -., (idle) glutidlefunc(void (*f unc)(void)).. NULL. 3 GLUT 3. (cone) (cube) 12 (dodecahedron) 20 (icosahedron) 8 (octahedron) (sphere) (teapot) (tetrahedron) (torus),.,. void gl utwi recube (GLdouble si ze ); void gl ut Sol i dcube (GLdouble si ze ); void gl utwi resphere (GLdouble radi us, GLint sl i ces, GLint s t acks ); void gl ut Sol i dsphere (GLdouble radi us, GLint sl i ces, GLint s tacks );

Chapter 1 Ope ngl 53 ( D )..,,. 24... 1 24, ( 16 ). 60 76 (refresh), 120. 30 60 60 120. 120... open_wi ndow(); for (i = 0; i < 1000000; i ++) { cl ear_t he_wi ndow(); draw_fr ame (i ); wai t _unt i l_a_24t h_of_a_second_i s_over (); }, 1/24. 1/24,

54 Ope ngl Progra mming Guide - OpenGL 1.2. 1/24.,. OpenGL (double-buff ering)..,,..,.,... open_wi ndow_i n_doubl e_buf fer_mode (); for (i = 0; i < 1000000; i ++) { cl ear_t he_wi ndow(); dr aw_f rame (i ); swap_t he_buf fer s (); } OpenGL, swap_the_buffers().,. 60 60fps(frames per second), 1/60. 1/60,., 1/45, 30fps 1/30-1/45=1/90.

Chapter 1 Ope ngl 55,., 1/60, 60fps, 30fps, 20fps, 15fps, 12fps (60/1, 60/2, 60/3, 60/4, 60/5,...)., 60fps, 1/60 60fps 30fps. 1/30 30 20fps. (1/60, 2/60, 3/60 ),,.,.. = +.,. 3.., (viewpoint),,.. swap_the_buffers(). swap_the_buffers(), OpenGL., X Window System, GLX. voi d gl xswapbuf fers (Di spl ay *dpy, Wi ndow wi ndow);

56 Ope ngl Progra mming Guide - OpenGL 1.2 ( C.) GLUT,. voi d gl ut SwapBuffer s (void ); [ 1-3] [ 1-3] glutswapbuffers()., GLUT idle.. 1-3 1-3 : double.c #i ncl ude <st dl i b.h> #i ncl ude <GL/ gl ut.h> st at i c GLfl oat spi n = 0. 0; voi d i ni t (voi d ) { gl Cl earcol or (0. 0, 0. 0, 0. 0, 0. 0) ; gl ShadeModel (GL_ FLAT) ; } voi d di spl ay (voi d ) { gl Cl ear (GL_COLOR_BUFFER_BI T) ; gl PushMat r i x () ; gl Rot at ef (spi n, 0. 0, 0. 0, 1. 0) ; gl Col or 3f (1. 0, 1. 0, 1. 0) ; } gl Rect f (- 25. 0, - 25. 0, 25. 0, 25. 0) ; gl PopMat r i x () ; gl ut SwapBuf fer s () ;