본문 바로가기

Cocos2d-x v3.17/고급 기능

[Cocos2d-x 고급기능]TextureCube

반응형

TextureCube

텍스처 큐브는 큐브형의 여섯개의 면에 대응되는 텍스처의 집합입니다.

텍스처 큐브는 주로 SkyBox와 같은 멀리있는 풍경을 그리고자 할때 사용됩니다.

텍스처 큐브는 아래와 같이 생겼습니다.

Cocos2d-x 아래와 같이 텍스처 큐브를 생성합니다.


C++

// create a textureCube object with six texture assets

auto textureCube = TextureCube::create("skybox/left.jpg",  "skybox/right.jpg""skybox/top.jpg""skybox/bottom.jpg""skybox/front.jpg""skybox/back.jpg");

// set cube map texture parameters

Texture2D::TexParams tRepeatParams;

tRepeatParams.magFilter = GL_NEAREST;

tRepeatParams.minFilter = GL_NEAREST;

tRepeatParams.wrapS = GL_MIRRORED_REPEAT;

tRepeatParams.wrapT = GL_MIRRORED_REPEAT;

textureCube->setTexParameters(tRepeatParams);

// create and set our custom shader

auto shader = GLProgram::createWithFilenames("cube_map.vert""cube_map.frag");

auto _state = GLProgramState::create(shader);

// bind cube map texture to uniform

state->setUniformTexture("u_cubeTex", textureCube);

 

출처: <http://cocos2d-x.org/docs/cocos2d-x/zh/3d/cubemap.html>

 



반응형