티스토리 뷰
RenderTexture란?
렌더링을 할 수 있는 텍스처로 Cocos2d-x 에서 필요한 크기만큼 생성하여 그 위에 그리고 싶은 오브젝트들을 그릴 수 있다.
만들어진 texture에 shader를 적용시켜서 광원 효과를 내거나 작은 renderTexture를 생성해서 미니맵 같은 요소를 만들 수 있다.
RenderTexture 생성
auto renderTexture = RenderTexture::create(100, 100, Texture2D::PixelFormat::RGBA8888); // width, height, pixelFormat
this->addChild(renderTexture);
RenderTexture에 sprite 추가
auto spr = Sprite::create("image.png");
renderTexture->addChild(spr);
RenderTexture 그리기
renderTexture->beginWithClear(0, 0, 0, 0); // clear to white
spr->visit(); // renderTexture의 자식으로 지정된 오브젝트들
renderTexture->end();
RenderTexture에 shader 적용
auto shader = ShaderCache::getInstance()->getGLProgram("Lighting"); // get GLProgram from ShaderCache
auto shaderState = GLProgramState::create(shader);
renderTexture->getSprite()->setGLProgram(shader); // getSprite()를 통해 sprite를 얻어와서 적용시킨다.
renderTexture->getSprite()->setGLProgramState(shaderState); // GLProgramState도 위와 같은 방식으로 적용시킨다.
'Programming > Cocos2d-x' 카테고리의 다른 글
cocos2d-x Reference : 스케줄(Schedule) (0) | 2015.09.29 |
---|---|
클래스 구성에 따른 삭제 문제 - SpriteBatchNode를 사용 (0) | 2015.08.27 |
cocos2d-x Reference : 파티클 블랜딩(Particle Blend) 종류 (0) | 2015.08.05 |
Shader : 모션 블러(Motion Blur) (0) | 2015.07.16 |
cocos2d-x Reference : 커스텀 셰이더(Custom Shader) (2) | 2015.07.06 |
- Total
- Today
- Yesterday
- Java
- C/C++
- 드라마
- SOCKET
- mongoDB
- SHADER
- machine learing
- 운영체제
- 국내여행
- JSP
- ios
- 알고리즘
- C++
- database
- Cocos2d-x
- game
- Git
- ue4
- 수학
- rxswift
- DesignPattern
- SwiftUI
- C
- 데이터베이스
- 자료구조
- OS
- winsock
- swift
- Spring
- scala
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
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 |