슬라이드 1

Similar documents
Microsoft PowerPoint - 4-UI 애플리케이션

iOS4_13

Microsoft PowerPoint - 2-Objective-C 기초

2ndWeek_Introduction to iPhone OS.key

자바 웹 프로그래밍

PowerPoint 프레젠테이션

歯Lecture2.PDF

K&R2 Reference Manual 번역본

À©µµ³×Æ®¿÷ÇÁ·Î±×·¡¹Ö4Àå_ÃÖÁ¾

슬라이드 1

untitled

PowerPoint 프레젠테이션

05-06( )_¾ÆÀÌÆù_ÃÖÁ¾

Open GL

Microsoft Word - cg09-midterm.doc

<4D F736F F F696E74202D20C1A63034B0AD202D20C7C1B7B9C0D3B8AEBDBAB3CABFCD20B9ABB9F6C6DBC0D4B7C2>

Microsoft PowerPoint - 13prac.pptx

Łø·ŸÕ=¤ ¬ ÇX±xÒ¸ 06 - Èpº– 1

Microsoft PowerPoint - chap13-입출력라이브러리.pptx

자바 프로그래밍

PowerPoint 프레젠테이션

Microsoft PowerPoint - lecture4-ch2.ppt

chap10.PDF

Chapter_02-3_NativeApp

PowerPoint 프레젠테이션

프로그램을 학교 등지에서 조금이라도 배운 사람들을 위한 프로그래밍 노트 입니다. 저 역시 그 사람들 중 하나 입니다. 중고등학교 시절 학교 도서관, 새로 생긴 시립 도서관 등을 다니며 책을 보 고 정리하며 어느정도 독학으르 공부하긴 했지만, 자주 안하다 보면 금방 잊어

OSP-SLP Architectural Specification: Io

<4D F736F F F696E74202D B3E22032C7D0B1E220C0A9B5B5BFECB0D4C0D3C7C1B7CEB1D7B7A1B9D620C1A638B0AD202D20C7C1B7B9C0D320BCD3B5B5C0C720C1B6C0FD>

슬라이드 1

Microsoft PowerPoint - IP11.pptx

Microsoft PowerPoint - [2009] 02.pptx

01-OOPConcepts(2).PDF

( )부록

쉽게 풀어쓴 C 프로그래밍

03장.스택.key

< E20C6DFBFFEBEEE20C0DBBCBAC0BB20C0A7C7D12043BEF0BEEE20492E707074>

chapter2.hwp

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

No Slide Title

untitled

05-class.key

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

Microsoft PowerPoint - ch09 - 연결형리스트, Stack, Queue와 응용 pm0100

The Pocket Guide to TCP/IP Sockets: C Version

untitled

쉽게 풀어쓴 C 프로그래밍

PowerPoint Presentation

untitled

chap7.key

gnu-lee-oop-kor-lec06-3-chap7

Modern Javascript

Something that can be seen, touched or otherwise sensed

교육지원 IT시스템 선진화

Microsoft Word - cg09-final-answer.doc

어댑터뷰

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

- 목차 - - ios 개발환경및유의사항. - 플랫폼 ios Project. - Native Controller와플랫폼화면연동. - 플랫폼 Web(js)-Native 간데이터공유. - 플랫폼확장 WN Interface 함수개발. - Network Manager clas

C++ Programming

; struct point p[10] = {{1, 2, {5, -3, {-3, 5, {-6, -2, {2, 2, {-3, -3, {-9, 2, {7, 8, {-6, 4, {8, -5; for (i = 0; i < 10; i++){ if (p[i].x > 0 && p[i

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

IAP-Guide

금오공대 컴퓨터공학전공 강의자료

, ( ),, ( ), 3, int kor[5]; int eng[5]; int Microsoft Windows 4 (ANSI C2 ) int kor[5] 20 # define #define SIZE 20 int a[10]; char c[10]; float

04_오픈지엘API.key

歯MW-1000AP_Manual_Kor_HJS.PDF

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

5장.key

Microsoft PowerPoint - java1-lab5-ImageProcessorTestOOP.pptx

제8장 자바 GUI 프로그래밍 II

Microsoft PowerPoint - chap02-C프로그램시작하기.pptx

Dialog Box 실행파일을 Web에 포함시키는 방법

2009년 상반기 사업계획

Microsoft PowerPoint - chap12-고급기능.pptx

Mobile Service > IAP > Android SDK [ ] IAP SDK TOAST SDK. IAP SDK. Android Studio IDE Android SDK Version (API Level 10). Name Reference V

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

슬라이드 1

본 강의에 들어가기 전

13주-14주proc.PDF

3주차_Core Audio_ key

09-interface.key

1. auto_ptr 다음프로그램의문제점은무엇인가? void func(void) int *p = new int; cout << " 양수입력 : "; cin >> *p; if (*p <= 0) cout << " 양수를입력해야합니다 " << endl; return; 동적할

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

The Pocket Guide to TCP/IP Sockets: C Version

Microsoft PowerPoint - Java7.pptx

untitled

BMP 파일 처리

Network Programming

비긴쿡-자바 00앞부속

untitled

이번장에서학습할내용 동적메모리란? malloc() 와 calloc() 연결리스트 파일을이용하면보다많은데이터를유용하고지속적으로사용및관리할수있습니다. 2

PowerPoint 프레젠테이션

1. 객체의생성과대입 int 형변수 : 선언과동시에초기화하는방법 (C++) int a = 3; int a(3); // 기본타입역시클래스와같이처리가능 객체의생성 ( 복습 ) class CPoint private : int x, y; public : CPoint(int a

Sena Technologies, Inc. HelloDevice Super 1.1.0

제목

chap8.PDF

Spring Boot/JDBC JdbcTemplate/CRUD 예제

Microsoft PowerPoint - ch07 - 포인터 pm0415

1 장 C 언어복습 표준입출력배열포인터배열과포인터함수 const와포인터구조체컴파일러사용방법 C++ 프로그래밍입문

Motor

PowerPoint Presentation

Transcription:

세모그래픽스 III. 게임프로그래밍에필요한 OpenGL Page 1

목차 1. 간단한 OBJ-C 2. IOS의 OGL VS Win32의 OGL 3. IOS개발환경설정 4. 뷰포트, 프로젝션, 모델뷰 ( 회전이먼저냐이동이먼저냐?) Page 2

세모그래픽스 간단한 OBJ-C 2011.07.16 김형석 Page 3

1. Obj-C (test2_cpp) #import <Foundation/Foundation.h> @interface Fraction : NSObject { @private int upnum; int downnum; -(void) print; -(int) upnum; -(int) downnum; -(void) setupnum : (int) val; -(void) setdownnum : (int) val; @property (nonatomic,assign) int numerator; @property (nonatomic,assign) int denumerator; @end Page 4

1. Obj-C (test2_cpp) @implementation Fraction -(void) print { printf("%d/%d = %f", upnum,downnum, upnum/(float)downnum); -(int) upnum { return upnum; -(int) downnum { return downnum; -(void) setupnum : (int) val { upnum = val; -(void) setdownnum : (int) val { downnum = val; @end @synthesize upnum; @synthesize downnum; Page 5

2. Obj-C (test1) #import <Foundation/Foundation.h> @interface Fraction : NSObject { @public int numerator; int denumerator; @property (nonatomic,assign) int numerator; @property (nonatomic,assign) int denumerator; -(void) print; @end @implementation Fraction @synthesize numerator; @synthesize denumerator; -(void) print { printf("%d/%d => %f\n", numerator, denumerator, numerator/(float)denumerator); @end Page 6

3. 소스컴파일옵션변경 - 소스컴파일옵션변경 (.m.mm.cpp.c) - 프레임웍추가 Page 7

세모그래픽스 IOS OpenGL vs Win OpenGL 2011.07.16 김형석 Page 8

1. OpenGL 렌더링순서 I. 렌더링콘텍스트생성 ( 프레임, 렌더링,Z, 스텐실버퍼 ) 1) 현재콘텍스트로설정 2) 뷰포트설정 콘텍스트변경 윈도크기변경 II. 사용자렌더링 3) 프로젝션 M 설정 4) 클리어버퍼 5) 모델뷰 M 설정 III. 렌더링콘텍스트삭제 6) GL 객체렌더링 ( 루프 ) 7) 스웹버퍼 ( 프레젠트 ) Page 9

I. 렌더링콘텍스트생성 ( 프레임, 렌더링,Z, 스텐실버퍼 ) m_context = [[EAGLContext alloc] initwithapi: keaglrenderingapiopengles1]; // Create & bind the color buffer so that the caller can allocate its space. glgenrenderbuffersoes(1, &m_renderbuffer); glbindrenderbufferoes(gl_renderbuffer_oes, m_renderbuffer); // Create the framebuffer object and attach the color buffer. glgenframebuffersoes(1, &m_framebuffer); glbindframebufferoes(gl_framebuffer_oes, m_framebuffer); glframebufferrenderbufferoes(gl_framebuffer_oes, GL_COLOR_ATTACHMENT0_OES, GL_RENDERBUFFER_OES, m_renderbuffer); hdc = GetDC(hWnd); hrc = wglcreatecontext(hdc); Page 10

II. 사용자렌더링 1) 현재콘텍스트로설정 2) 뷰포트설정 3) 프로젝션 M 설정 if (!m_context![eaglcontext setcurrentcontext:m_context]) { [self release]; return nil; glviewport(0, 0, width, height); glmatrixmode(gl_projection); // Initialize the projection matrix. const float maxx = 2; const float maxy = 3; glorthof(-maxx, +maxx, -maxy, +maxy, -1, 1); wglmakecurrent(hdc, hrc); case WM_SIZE: glviewport(0, 0, LOWORD(lParam), HIWORD(lParam)); break; glmatrixmode(gl_projection);// 기본매트릭스사용 Page 11

II. 사용자렌더링 5) 모델뷰 M 설정 6) GL 객체렌더링 ( 루프 ) 7) 스웹버퍼 ( 프레젠트 ) glclear(gl_color_buffer_bit); glpushmatrix(); glrotatef(m_currentangle, 0, 0, 1); glvertexpointer(2, GL_FLOAT, sizeof(vertex), &Vertices[0].Position[0]); glcolorpointer(4, GL_FLOAT, sizeof(vertex), &Vertices[0].Color[0]); GLsizei vertexcount = sizeof(vertices) / sizeof(vertex); gldrawarrays(gl_triangles, 0, vertexcount); glpopmatrix(); [m_context presentrenderbuffer:gl_renderbuffer]; glclear(gl_color_buffer_bit); 모델뷰, GL 객체렌더링은위와동일 SwapBuffers(hDC); /* nop if singlebuffered */ Page 12

III. 렌더링콘텍스트삭제 - (void)dealloc { [self deleteframebuffer]; [context release]; [super dealloc]; wglmakecurrent(null, NULL); ReleaseDC(hWnd, hdc); wgldeletecontext(hrc); Page 13

세모그래픽스 IOS 에서 MAC_XCode 개발환경설정 for OpenGL (HelloCone) 2011.07.16 김형석 Page 14

1. OpenGL 렌더링순서 I. 렌더링콘텍스트생성 ( 프레임, 렌더링,Z, 스텐실버퍼 ) 1) 현재콘텍스트로설정 2) 뷰포트설정 콘텍스트변경 윈도크기변경 II. 사용자렌더링 3) 프로젝션 M 설정 4) 클리어버퍼 5) 모델뷰 M 설정 III. 렌더링콘텍스트삭제 6) GL 객체렌더링 ( 루프 ) 7) 스웹버퍼 ( 프레젠트 ) Page 15

2. 뷰베이스앱으로개발 (Main.m) int main(int argc, char *argv[]) { NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; int retval = UIApplicationMain(argc, argv, nil, @"HelloConeAppDelegate"); [pool release]; return retval; Page 16

3. HelloConeAppDelegate.h/.cpp #include "GLView.h" @interface HelloConeAppDelegate : NSObject <UIApplicationDelegate> { @private UIWindow* m_window; GLView* m_view; @end #import "HelloConeAppDelegate.h" @implementation HelloConeAppDelegate - (void) applicationdidfinishlaunching: (UIApplication*) application { CGRect screenbounds = [[UIScreen mainscreen] bounds]; // 화면크기 m_window = [[UIWindow alloc] initwithframe: screenbounds]; m_view = [[GLView alloc] initwithframe: screenbounds]; [m_window addsubview: m_view]; // GLView를메인위도우의 sub윈도우로.. [m_window makekeyandvisible]; // show window @end Page 17

4. GLView.h/IRenderingEngine.hpp @interface GLView : UIView { @private EAGLContext* m_context; IRenderingEngine* m_renderingengine; float m_timestamp; - (void) drawview: (CADisplayLink*) displaylink; - (void) didrotate: (NSNotification*) notification; @end // Interface to the OpenGL ES renderer; consumed by Objective C. struct IRenderingEngine { virtual void Initialize(int width, int height) = 0; virtual void Render() const = 0; virtual void UpdateAnimation(float timestep) = 0; virtual void OnRotate(DeviceOrientation neworientation) = 0; virtual ~IRenderingEngine() { ; Page 18

5. GLView. hpp if (!m_context) { api = keaglrenderingapiopengles1; m_context = [[EAGLContext alloc] initwithapi:api]; I. 렌더링콘텍스트생성 ( 프레임, 렌더링,Z, 스텐실버퍼 ) if (!m_context![eaglcontext setcurrentcontext:m_context]) { [self release]; return nil; if (api == keaglrenderingapiopengles1) { NSLog(@"Using OpenGL ES 1.1"); m_renderingengine = CreateRenderer1(); else { NSLog(@"Using OpenGL ES 2.0"); m_renderingengine = CreateRenderer2(); [m_context renderbufferstorage:gl_renderbuffer fromdrawable: eagllayer]; m_renderingengine->initialize(cgrectgetwidth(frame), CGRectGetHeight(frame)); Page 19

6. GLView. hpp CADisplayLink* displaylink; displaylink = [CADisplayLink displaylinkwithtarget:self selector:@selector(drawview:)]; [displaylink addtorunloop:[nsrunloop currentrunloop] formode:nsdefaultrunloopmode]; [[UIDevice currentdevice] begingeneratingdeviceorientationnotifications]; [[NSNotificationCenter defaultcenter] addobserver:self selector:@selector(didrotate:) name:uideviceorientationdidchangenotification object:nil]; 반복함수및알람함수연결 Page 20

6. GLView. hpp - (void) didrotate: (NSNotification*) notification { UIDeviceOrientation orientation = [[UIDevice currentdevice] orientation]; m_renderingengine->onrotate((deviceorientation) orientation); [self drawview: nil]; - (void) drawview: (CADisplayLink*) displaylink { printf("."); if (displaylink!= nil) { float elapsedseconds = displaylink.timestamp - m_timestamp; m_timestamp = displaylink.timestamp; m_renderingengine->updateanimation(elapsedseconds); m_renderingengine->render(); [m_context presentrenderbuffer:gl_renderbuffer]; 7) 스웹버퍼 ( 프레젠트 ) Page 21

7. RenderingEngine1 (Z 버퍼설명하기 ) // Create & bind the color buffer so that the caller can allocate its space. glgenrenderbuffersoes(1, &m_colorrenderbuffer); glbindrenderbufferoes(gl_renderbuffer_oes, m_colorrenderbuffer); // Create the depth buffer. glgenrenderbuffersoes(1, &m_depthrenderbuffer); glbindrenderbufferoes(gl_renderbuffer_oes, m_depthrenderbuffer); glrenderbufferstorageoes(gl_renderbuffer_oes GL_DEPTH_COMPONENT16_OES,,width,height); // Create the framebuffer object; attach the depth and color buffers. glgenframebuffersoes(1, &m_framebuffer); glbindframebufferoes(gl_framebuffer_oes, m_framebuffer); glframebufferrenderbufferoes(gl_framebuffer_oes, GL_COLOR_ATTACHMENT0_OES, GL_RENDERBUFFER_OES, m_colorrenderbuffer); glframebufferrenderbufferoes(gl_framebuffer_oes, GL_DEPTH_ATTACHMENT_OES, GL_RENDERBUFFER_OES, m_depthrenderbuffer); // Bind the color buffer for rendering. glbindrenderbufferoes(gl_renderbuffer_oes, m_colorrenderbuffer); //khs Page 22

7. RenderingEngine1 glviewport(0, 0, width, height); glenable(gl_depth_test); glmatrixmode(gl_projection); // (0,0,0) -> LB(-1.6,-2.4,-5) RU(1.6,2.4,-10) glfrustumf(-1.6f, 1.6, -2.4, 2.4, 5, 10);//khs: left,right,bottom,top,near,far glmatrixmode(gl_modelview); gltranslatef(0, 0, -2); 뷰포트의미및변경 glfrustum vs glortho (ogl 예제실행 ) Page 23

8. 전체소스리뷰하기 전체소스리뷰하기 Page 24

세모그래픽스 간단한 CPP(abstract class) 2011.07.16 김형석 Page 25

1. CPP (simple_cpp) class IRenderingEngine { Public: virtual void Initialize(int width, int height) = 0; virtual void Render() const = 0; virtual void UpdateAnimation(float timestep) = 0; virtual void OnRotate(DeviceOrientation neworientation) = 0; ; virtual ~IRenderingEngine() { 표준화된인터페이스 Page 26

1. CPP (simple_cpp) class RenderingEngine1 : public IRenderingEngine { public: RenderingEngine1(); ~RenderingEngine1(); //khs void Initialize(int width, int height); void Render() const; void UpdateAnimation(float timestep); void OnRotate(DeviceOrientation neworientation); private: vector<vertex> m_cone; vector<vertex> m_disk; Animation m_animation; GLuint m_framebuffer; GLuint m_colorrenderbuffer; GLuint m_depthrenderbuffer; ; class RenderingEngine2 : public IRenderingEngine { public: RenderingEngine2(); void Initialize(int width, int height); void Render() const; void UpdateAnimation(float timestep); void OnRotate(DeviceOrientation neworientation); private: GLuint BuildShader(const char* source, GLenum shadertype) const; GLuint BuildProgram(const char* vshader, const char* fshader) const; vector<vertex> m_cone; vector<vertex> m_disk; Animation m_animation; GLuint m_simpleprogram; GLuint m_framebuffer; GLuint m_colorrenderbuffer; GLuint m_depthrenderbuffer; ; Page 27

1. CPP (simple_cpp) if (api == keaglrenderingapiopengles1) { NSLog(@"Using OpenGL ES 1.1"); m_renderingengine = new RenderingEngine1() else { NSLog(@"Using OpenGL ES 2.0"); m_renderingengine = new RenderingEngine2() m_renderingengine->initialize(cgrectgetwidth(frame), CGRectGetHeight(frame)); - (void) didrotate: (NSNotification*) notification { UIDeviceOrientation orientation = [[UIDevice currentdevice] orientation]; m_renderingengine->onrotate((deviceorientation) orientation); [self drawview: nil]; Page 28

2. Sound class ISoundEngine { public: ISoundEngine(); Virtual ~ISoundEngine(); void play(int name) = 0; void pause() const = 0; void stop(float timestep) = 0; ; 표준화된인터페이스 class FmodSoundEngine: public ISoundEngine { public: FmodSoundEngine(); ~ FmodSoundEngine(); //khs void play(int name); void pause() const; void stop(float timestep); ; class OALSoundEngine: public ISoundEngine { public: OALSoundEngine(); ~OALSoundEngine(); void play(int name); void pause() const; void stop(float timestep); ; Page 29

3. Idialog 이용실습 Simple_cpp Page 30