[0129 박민근] direct x2d

66
DirectX2D 초중급 게임 개발자 스터디 데브루키 (http://cafe.naver.com/devrookie ) 2011.01.29 박민근 (알콜코더)

description

초중급 게임개발자 스터디 (데브루키)2011.01.29 박민근"Direct2D" 발표 자료

Transcript of [0129 박민근] direct x2d

Page 1: [0129 박민근] direct x2d

DirectX2D

초중급 게임 개발자 스터디데브루키(http://cafe.naver.com/devrookie)

2011.01.29 박민근 (알콜코더)

Page 2: [0129 박민근] direct x2d

Direct2D란?

Windows7을 위한 새로운 2D 그래픽스 API

GDI,GDI+를 대체하는 차세대 그래픽스 API

Page 3: [0129 박민근] direct x2d

High Performance

하드웨어 가속 지원 (immedate-mode)

Page 4: [0129 박민근] direct x2d

High Quality

Per-Primitive Antialiasing

ClearType Text

Page 5: [0129 박민근] direct x2d
Page 6: [0129 박민근] direct x2d

GDI vs Direct2D

http://zoome.jp/pcuser/diary/14

Page 8: [0129 박민근] direct x2d

가능한 것들

2D 도형들 (Line, 도형, Curve등)

비트맵

텍스트 (텍스트 변형, 회전)

Page 9: [0129 박민근] direct x2d

기존 API와 상호 운영 가능

GDI, GDI+

Direct3D

Page 10: [0129 박민근] direct x2d

Direct2D 아키텍쳐 레이어

Page 11: [0129 박민근] direct x2d

C, C++에서 사용이 기본

Windows API Pack for .NET Framework를 이용하면

NET에서도 사용은 가능

Native Code 기반

Page 12: [0129 박민근] direct x2d

사용 대상

대규모 Native 어플리케이션 개발자

컨트롤 툴킷 및 라이브러리 개발자

Server-Side 2D 그래픽 렌더링이 필요한 개발자

Direct3D를 사용하면서, 간단하고 고성능의 2D 도형과

텍스트를 이용한 메뉴나 UI, HUD등을 개발하는 개발자

Page 13: [0129 박민근] direct x2d

요구 사항

Windows SDK에 포함되어 있음

윈도우 7, 윈도우 비스타 SP2 이상

DirectX 10.1 이상

Page 14: [0129 박민근] direct x2d
Page 15: [0129 박민근] direct x2d

게임 개발시

2D 그래픽 라이브러리의

필요성

Page 16: [0129 박민근] direct x2d

컷신 연출툴

마테리얼 개발툴

퀘스트 툴

각종 게임 개발툴

Page 17: [0129 박민근] direct x2d

게임 UI, HUD

Page 18: [0129 박민근] direct x2d

그럼 기존에는?

Page 19: [0129 박민근] direct x2d

구현이 간단함

2D 그래픽이 필요한 툴에서만 사용 가능하다

하드웨어 가속이 지원되지 않는다

게임에서는 사용 불가능하다 – Direct3D와 연동이 안됨

GDI, GDI+ 사용

Page 20: [0129 박민근] direct x2d

Direct3D 사용

그래픽 속도가 필요한 경우

배보다 배꼽이 더크다

Page 21: [0129 박민근] direct x2d

하드웨어 가속 지원

구현이 상당히 편하고, 간단하다

하지만, .NET 전용

게임에서는 당연히 사용 불가

WPF(Windows Presentation Foundation)

사용

Page 22: [0129 박민근] direct x2d

그래서… Direct2D는?

Page 23: [0129 박민근] direct x2d

AntiAliasing 지원 – 예쁘게 나온

Direct3D와 같이 사용 가능

게임내에서도 사용 가능

하드웨어 가속 지원

Page 24: [0129 박민근] direct x2d

- Direct3D 보다는 간결함

- GDI보다는 조금 복잡함

기능이 많지 않으며, 간단해서 쉽게 익힐 수 있음

사용하기 위한 코드가 간단하다

Page 25: [0129 박민근] direct x2d
Page 26: [0129 박민근] direct x2d

이미 IE9, Firefox, 크롬에서는 사용중

하드웨어 가속 웹 렌더링에서 사용 (HTML5)

Page 27: [0129 박민근] direct x2d

게임 UI 라이브러리로 사용하는 건 무리

요구 사항

Window7 이상

DirectX 10.1 이상

Page 28: [0129 박민근] direct x2d

게임 개발 툴에서 활용 가능성

2D 그래픽으로만 이루어진 개발툴이 의외로 많다

- 이걸 위해서 Direct3D를 사용하는 건 무리

2D 도형을 이용한 툴의 기능이 필요하다

Page 29: [0129 박민근] direct x2d

샘플 프로젝트에서 활용

스터디용 샘플 프로젝트

알고리즘 시각화 프로젝트

간단한 게임 만들기 - 해보리

Page 30: [0129 박민근] direct x2d

Direct2D 시작하기

Page 31: [0129 박민근] direct x2d

Illustration of two rectangles on a grid background

Page 32: [0129 박민근] direct x2d

1. 헤더 파일 추가

Page 33: [0129 박민근] direct x2d

2. 관련 객체 변수 선언

Page 34: [0129 박민근] direct x2d

2. Direct2D Factory 생성

Page 35: [0129 박민근] direct x2d

3. 렌더타겟 생성

Page 36: [0129 박민근] direct x2d

4. 컬러 브러쉬 생성

Page 37: [0129 박민근] direct x2d

4. 렌더 타겟 준비

Page 38: [0129 박민근] direct x2d

5. 배경 그리드 렌더링

Page 39: [0129 박민근] direct x2d

6. 사각형 렌더링

Page 40: [0129 박민근] direct x2d

7. 렌더타겟 완료

Page 41: [0129 박민근] direct x2d

Direct2D의 여러 기능들

Page 42: [0129 박민근] direct x2d

Advanced Path Geometries Example

http://msdn.microsoft.com/en-

us/library/ee461072(v=VS.85).aspx

Illustration of a river, mountains, and the sun

Page 43: [0129 박민근] direct x2d

Geometries Example

Illustration of several simple and path geometries

Illustration of several simple and path

geometries

http://msdn.microsoft.com/en-

us/library/ee329938(v=VS.85).aspx

Page 44: [0129 박민근] direct x2d

Brush Types Example

Illustration of solid color brush, linear gradient brush,

radial gradient brush, and bitmap brush

http://msdn.microsoft.com/en-

us/library/dd799414(v=VS.85).aspx

Page 45: [0129 박민근] direct x2d

Clip with Axis Aligned Rectangle Example

Illustration of a goldfish and a clipped region of the goldfish

http://msdn.microsoft.com/en-

us/library/dd756624(v=VS.85).aspx

Page 46: [0129 박민근] direct x2d

Clip with a Bitmap Mask Example

Illustration of a goldfish and a clipped region of the goldfish by using a

bitmap mask

http://msdn.microsoft.com/en-

us/library/dd756625(v=VS.85).aspx

Page 47: [0129 박민근] direct x2d

Clip with Layers Example

Illustration of a goldfish and a clipped region of the goldfish by using

layers

http://msdn.microsoft.com/en-

us/library/dd756626(v=VS.85).aspx

Page 48: [0129 박민근] direct x2d

Combine Geometries Example

Illustration of two geometries and the resulting geometry after various

combination operations

http://msdn.microsoft.com/en-

us/library/dd370923(v=VS.85).aspx

Page 49: [0129 박민근] direct x2d

Create Geometry Groups Example

Illustration of composite geometry groups with the two fill modes

http://msdn.microsoft.com/en-

us/library/dd756627(v=VS.85).aspx

Page 50: [0129 박민근] direct x2d

Draw Bitmap With Extend Mode Example

Illustration of various effects of extend mode

http://msdn.microsoft.com/en-

us/library/dd940315(v=VS.85).aspx

Page 51: [0129 박민근] direct x2d

Layers with Parameters Example

Illustrations of three bitmaps and the

resulting images after content bounds,

opacity masks, or geometric masks are

applied to them

http://msdn.microsoft.com/en-

us/library/ee329942(v=VS.85).aspx

Page 52: [0129 박민근] direct x2d

Multiple Transforms Example

Diagram of a square being rotated and then translated

http://msdn.microsoft.com/en-

us/library/dd799446(v=VS.85).aspx

Page 53: [0129 박민근] direct x2d

Opacity Masks Example

Illustration of three bitmaps with

different opacity masks applied to them

http://msdn.microsoft.com/en-

us/library/dd372307(v=VS.85).as

px

Page 54: [0129 박민근] direct x2d

Stroke Style Example

Illustration of line join styles (miter line join, round line join, bevel line join,

and miter or bevel line join)

http://msdn.microsoft.com/en-

us/library/dd317107(v=VS.85).aspx

Page 55: [0129 박민근] direct x2d

Direct2D & Direct3D같이 사용하기

Page 56: [0129 박민근] direct x2d
Page 57: [0129 박민근] direct x2d

Direct3D 10.1 버전 이상부터 Direct2D와 같이 사용이 가능하다

• 2D 화면을 3D 화면의 백그라운드 이미지로 사용하거나

• 2D 화면을 3D 오브젝트의 텍스쳐로 사용하거나

• 2D 텍스트를 3D 화면에 표시하거나

• 2D 오브젝트로 3D 게임의 UI로 사용하거나

Page 58: [0129 박민근] direct x2d

DXGI를 통해서 서로 사용이 가능하다

• IDXGISurface, ID2D1RenderTarget 을 이용하

여 Direct2D 컨텐츠를 Direct3D 서페이스에

Direct2D 컨텐츠를 렌더링할 수 있다.

• IDXGISurface에서 CreateShaderBitmap을 사

용하여 ID2D1Bitmap을 생성하여, Direct3D의

씬을 거기에 Direct2D로 렌더링 할 수 있다.

Page 59: [0129 박민근] direct x2d

자세한 내용은 DX10.1 이상의 아키텍쳐를 이해해고

있어야 하기 때문에, 생략….

MSDN에 자세한 설명과, 샘플 코드가 있습니다.

Direct2D and Direct3D Interoperability

Overview

Page 60: [0129 박민근] direct x2d
Page 61: [0129 박민근] direct x2d

GDI, GDI+를 대체하는

최신의 2D 그래픽스 라이브러리

Page 62: [0129 박민근] direct x2d

C++로 만들어야 하는 게임 개발툴에서 유용할 듯

- 셰이더 에디터, 마테리얼 에디터, 컷신 연출툴

Page 63: [0129 박민근] direct x2d

2D 프로토 타입 or

2D 게임 개발시 유용할 듯

Page 64: [0129 박민근] direct x2d

스터디의 샘플 프로젝트

제작시에도 유용할 듯

Page 65: [0129 박민근] direct x2d

상용 게임의 UI에 적용하는 것은 무리

- 요구 사항 제한